Skip to content

Commit d91e5d3

Browse files
committed
DISABLE_OPENING_SUBTRACTIONS and DISABLE_OBJECT_PLACEMENT settings for create_shape() / create_brep_data()
1 parent a4c3fdf commit d91e5d3

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/ifcgeom/IfcGeom.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ namespace IfcGeom {
7979
GV_PRECISION
8080
};
8181

82+
const int DISABLE_OPENING_SUBTRACTIONS = 1 << 0;
83+
const int DISABLE_OBJECT_PLACEMENT = 1 << 1;
84+
8285
bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face);
8386
bool convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoDS_Wire& wire);
8487
bool convert_shapes(const IfcUtil::IfcBaseClass* L, IfcRepresentationShapeItems& result);
@@ -103,7 +106,7 @@ namespace IfcGeom {
103106
void apply_tolerance(TopoDS_Shape& s, double t);
104107
void SetValue(GeomValue var, double value);
105108
double GetValue(GeomValue var);
106-
std::string create_brep_data(Ifc2x3::IfcProduct* s);
109+
std::string create_brep_data(Ifc2x3::IfcProduct* s, unsigned int settings);
107110
bool fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape);
108111
IfcSchema::IfcProductDefinitionShape* tesselate(TopoDS_Shape& shape, double deflection, IfcEntities es);
109112

src/ifcgeom/IfcGeomFunctions.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,10 @@ bool IfcGeom::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape) {
689689
return true;
690690
}
691691

692-
std::string IfcGeom::create_brep_data(Ifc2x3::IfcProduct* ifc_product) {
692+
std::string IfcGeom::create_brep_data(Ifc2x3::IfcProduct* ifc_product, unsigned int settings) {
693+
const bool no_openings = !!(settings & DISABLE_OPENING_SUBTRACTIONS);
694+
const bool no_placement = !!(settings & DISABLE_OBJECT_PLACEMENT);
695+
693696
if (!ifc_product->hasRepresentation()) return "";
694697

695698
Ifc2x3::IfcProductRepresentation* prod_rep = ifc_product->Representation();
@@ -740,23 +743,20 @@ std::string IfcGeom::create_brep_data(Ifc2x3::IfcProduct* ifc_product) {
740743
}
741744
}
742745

743-
if ( openings && openings->Size() ) {
746+
if (openings && openings->Size() && !no_openings) {
744747
IfcGeom::IfcRepresentationShapeItems opened_shapes;
745748
try {
746749
IfcGeom::convert_openings(ifc_product,openings,shapes,trsf,opened_shapes);
747750
} catch(...) {
748751
Logger::Message(Logger::LOG_ERROR,"Error processing openings for:",ifc_product->entity);
749752
}
750-
for ( IfcGeom::IfcRepresentationShapeItems::iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++ it ) {
751-
it->prepend(trsf);
752-
}
753-
trsf = gp_Trsf();
754753
shapes = opened_shapes;
755-
} else {
754+
}
755+
756+
if (!no_placement) {
756757
for ( IfcGeom::IfcRepresentationShapeItems::iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
757758
it->prepend(trsf);
758759
}
759-
trsf = gp_Trsf();
760760
}
761761

762762
TopoDS_Compound compound;

src/ifcwrap/Interface.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ namespace IfcParse {
9191
return f;
9292
}
9393

94-
std::string create_shape(IfcParse::IfcUntypedEntity* e) {
94+
std::string create_shape(IfcParse::IfcUntypedEntity* e, unsigned int settings = 0) {
9595
if (!e->is(IfcSchema::Type::IfcProduct)) throw IfcException("Entity is not an IfcProduct");
9696
IfcSchema::IfcProduct* ifc_product = (IfcSchema::IfcProduct*) e;
97-
return IfcGeom::create_brep_data(ifc_product);
97+
return IfcGeom::create_brep_data(ifc_product, settings);
9898
}
9999

100100
void clean() {
101101
IfcGeom::Cache::Purge();
102102
}
103+
104+
const int DISABLE_OPENING_SUBTRACTIONS = 1 << 0;
105+
const int DISABLE_OBJECT_PLACEMENT = 1 << 1;
103106
}
104107

105108
std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f);

0 commit comments

Comments
 (0)