Filter by context id, not using curves or solids. See #1674.

This commit is contained in:
Dion Moult
2021-09-22 10:56:49 +10:00
committed by Thomas Krijnen
parent 37bddc25ca
commit 514c5eb790
4 changed files with 20 additions and 15 deletions
@@ -342,6 +342,11 @@ namespace IfcGeom {
// WR31: The parent context shall not be another geometric representation sub context.
}
for (auto context_id : settings.context_ids()) {
IfcSchema::IfcGeometricRepresentationContext* context = ifc_file->instance_by_id(context_id)->as<IfcSchema::IfcGeometricRepresentationContext>();
representations->push(context->RepresentationsInContext());
}
if (any_precision_encountered) {
// Some arbitrary factor that has proven to work better for the models in the set of test files.
lowest_precision_encountered *= kernel.getValue(IfcGeom::Kernel::GV_PRECISION_FACTOR);
+7 -1
View File
@@ -112,6 +112,7 @@ namespace IfcGeom
double deflection_tolerance() const { return deflection_tolerance_; }
double angular_tolerance() const { return angular_tolerance_; }
double force_space_transparency() const { return force_space_transparency_; }
std::set<int> context_ids() const { return context_ids_; }
void set_deflection_tolerance(double value)
{
@@ -130,7 +131,11 @@ namespace IfcGeom
void force_space_transparency(double value) {
force_space_transparency_ = value;
}
}
void set_context_ids(std::vector<int> value) {
context_ids_ = std::set<int>(value.begin(), value.end());
}
/// Get boolean value for a single settings or for a combination of settings.
bool get(unsigned setting) const
@@ -158,6 +163,7 @@ namespace IfcGeom
protected:
unsigned settings_;
double deflection_tolerance_, angular_tolerance_, force_space_transparency_;
std::set<int> context_ids_;
};
class IFC_GEOM_API ElementSettings : public IteratorSettings
+2 -4
View File
@@ -887,8 +887,6 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
// @nb the selection is partly duplicated from convert_curves() but it's needed as a
// geometric set by it's static class definition does not inform us of the type of elements.
// @todo handle this better so that this doesn't log an error.
const bool include_curves = getValue(GV_DIMENSIONALITY) != +1;
const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1;
aggregate_of_instance::ptr elements = l->Elements();
if ( !elements->size() ) return false;
@@ -902,11 +900,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
if (!(convert_shapes(element, items) && flatten_shape_list(items, s, false))) {
continue;
}
} else if (shape_type(element) == ST_SHAPE && include_solids_and_surfaces) {
} else if (shape_type(element) == ST_SHAPE) {
if (!convert_shape(element, s)) {
continue;
}
} else if (shape_type(element) == ST_WIRE && include_curves) {
} else if (shape_type(element) == ST_WIRE) {
TopoDS_Wire w;
if (!convert_wire(element, w)) {
continue;
+6 -10
View File
@@ -54,34 +54,30 @@ bool IfcGeom::Kernel::convert_shape(const IfcBaseInterface* l, TopoDS_Shape& r)
const unsigned int id = l->data().id();
bool success = false;
bool processed = false;
bool ignored = false;
#ifndef NO_CACHE
std::map<int,TopoDS_Shape>::const_iterator it = cache.Shape.find(id);
if ( it != cache.Shape.end() ) { r = it->second; return true; }
#endif
const bool include_curves = getValue(GV_DIMENSIONALITY) != +1;
const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1;
IfcGeom::ShapeType st = shape_type(l);
ignored = (!include_solids_and_surfaces && (st == ST_SHAPE || st == ST_FACE)) || (!include_curves && (st == ST_WIRE || st == ST_CURVE));
if (st == ST_SHAPELIST) {
processed = true;
IfcRepresentationShapeItems items;
success = convert_shapes(l, items) && flatten_shape_list(items, r, false);
} else if (st == ST_SHAPE && include_solids_and_surfaces) {
} else if (st == ST_SHAPE) {
#include "IfcRegisterConvertShape.h"
} else if (st == ST_FACE && include_solids_and_surfaces) {
} else if (st == ST_FACE) {
processed = true;
success = convert_face(l, r);
} else if (st == ST_WIRE && include_curves) {
} else if (st == ST_WIRE) {
processed = true;
TopoDS_Wire w;
success = convert_wire(l, w);
if (success) {
r = w;
}
} else if (st == ST_CURVE && include_curves) {
} else if (st == ST_CURVE) {
processed = true;
Handle(Geom_Curve) crv;
TopoDS_Wire w;
@@ -102,7 +98,7 @@ bool IfcGeom::Kernel::convert_shape(const IfcBaseInterface* l, TopoDS_Shape& r)
BRepCheck_Analyzer ana(r);
Logger::Notice("Valid: " + std::to_string(ana.IsValid()), l);
}
} else if (!ignored) {
} else {
const char* const msg = processed
? "Failed to convert:"
: "No operation defined for:";
@@ -131,4 +127,4 @@ bool IfcGeom::Kernel::convert_curve(const IfcBaseInterface* l, Handle(Geom_Curve
#include "IfcRegisterConvertCurve.h"
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l);
return false;
}
}