DISABLE_OPENING_SUBTRACTIONS and DISABLE_OBJECT_PLACEMENT settings for create_shape() / create_brep_data()

This commit is contained in:
Thomas Krijnen
2014-04-17 10:50:42 +02:00
parent a4c3fdfd18
commit d91e5d31f6
3 changed files with 17 additions and 11 deletions
+4 -1
View File
@@ -79,6 +79,9 @@ namespace IfcGeom {
GV_PRECISION GV_PRECISION
}; };
const int DISABLE_OPENING_SUBTRACTIONS = 1 << 0;
const int DISABLE_OBJECT_PLACEMENT = 1 << 1;
bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face); bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face);
bool convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoDS_Wire& wire); bool convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoDS_Wire& wire);
bool convert_shapes(const IfcUtil::IfcBaseClass* L, IfcRepresentationShapeItems& result); bool convert_shapes(const IfcUtil::IfcBaseClass* L, IfcRepresentationShapeItems& result);
@@ -103,7 +106,7 @@ namespace IfcGeom {
void apply_tolerance(TopoDS_Shape& s, double t); void apply_tolerance(TopoDS_Shape& s, double t);
void SetValue(GeomValue var, double value); void SetValue(GeomValue var, double value);
double GetValue(GeomValue var); double GetValue(GeomValue var);
std::string create_brep_data(Ifc2x3::IfcProduct* s); std::string create_brep_data(Ifc2x3::IfcProduct* s, unsigned int settings);
bool fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape); bool fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape);
IfcSchema::IfcProductDefinitionShape* tesselate(TopoDS_Shape& shape, double deflection, IfcEntities es); IfcSchema::IfcProductDefinitionShape* tesselate(TopoDS_Shape& shape, double deflection, IfcEntities es);
+8 -8
View File
@@ -689,7 +689,10 @@ bool IfcGeom::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape) {
return true; return true;
} }
std::string IfcGeom::create_brep_data(Ifc2x3::IfcProduct* ifc_product) { std::string IfcGeom::create_brep_data(Ifc2x3::IfcProduct* ifc_product, unsigned int settings) {
const bool no_openings = !!(settings & DISABLE_OPENING_SUBTRACTIONS);
const bool no_placement = !!(settings & DISABLE_OBJECT_PLACEMENT);
if (!ifc_product->hasRepresentation()) return ""; if (!ifc_product->hasRepresentation()) return "";
Ifc2x3::IfcProductRepresentation* prod_rep = ifc_product->Representation(); Ifc2x3::IfcProductRepresentation* prod_rep = ifc_product->Representation();
@@ -740,23 +743,20 @@ std::string IfcGeom::create_brep_data(Ifc2x3::IfcProduct* ifc_product) {
} }
} }
if ( openings && openings->Size() ) { if (openings && openings->Size() && !no_openings) {
IfcGeom::IfcRepresentationShapeItems opened_shapes; IfcGeom::IfcRepresentationShapeItems opened_shapes;
try { try {
IfcGeom::convert_openings(ifc_product,openings,shapes,trsf,opened_shapes); IfcGeom::convert_openings(ifc_product,openings,shapes,trsf,opened_shapes);
} catch(...) { } catch(...) {
Logger::Message(Logger::LOG_ERROR,"Error processing openings for:",ifc_product->entity); Logger::Message(Logger::LOG_ERROR,"Error processing openings for:",ifc_product->entity);
} }
for ( IfcGeom::IfcRepresentationShapeItems::iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++ it ) {
it->prepend(trsf);
}
trsf = gp_Trsf();
shapes = opened_shapes; shapes = opened_shapes;
} else { }
if (!no_placement) {
for ( IfcGeom::IfcRepresentationShapeItems::iterator it = shapes.begin(); it != shapes.end(); ++ it ) { for ( IfcGeom::IfcRepresentationShapeItems::iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
it->prepend(trsf); it->prepend(trsf);
} }
trsf = gp_Trsf();
} }
TopoDS_Compound compound; TopoDS_Compound compound;
+5 -2
View File
@@ -91,15 +91,18 @@ namespace IfcParse {
return f; return f;
} }
std::string create_shape(IfcParse::IfcUntypedEntity* e) { std::string create_shape(IfcParse::IfcUntypedEntity* e, unsigned int settings = 0) {
if (!e->is(IfcSchema::Type::IfcProduct)) throw IfcException("Entity is not an IfcProduct"); if (!e->is(IfcSchema::Type::IfcProduct)) throw IfcException("Entity is not an IfcProduct");
IfcSchema::IfcProduct* ifc_product = (IfcSchema::IfcProduct*) e; IfcSchema::IfcProduct* ifc_product = (IfcSchema::IfcProduct*) e;
return IfcGeom::create_brep_data(ifc_product); return IfcGeom::create_brep_data(ifc_product, settings);
} }
void clean() { void clean() {
IfcGeom::Cache::Purge(); IfcGeom::Cache::Purge();
} }
const int DISABLE_OPENING_SUBTRACTIONS = 1 << 0;
const int DISABLE_OBJECT_PLACEMENT = 1 << 1;
} }
std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f); std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f);