diff --git a/src/ifcgeom/IfcGeomObjects.cpp b/src/ifcgeom/IfcGeomObjects.cpp index d51331fc41..1c378ef056 100644 --- a/src/ifcgeom/IfcGeomObjects.cpp +++ b/src/ifcgeom/IfcGeomObjects.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "../ifcparse/IfcException.h" #include "../ifcgeom/IfcGeomObjects.h" @@ -68,10 +69,32 @@ int IfcGeomObjects::IfcMesh::addvert(const gp_XYZ& p) { } bool use_world_coords = false; +bool use_brep_data = false; IfcGeomObjects::IfcMesh::IfcMesh(int i, const IfcGeom::ShapeList& shapes) { id = i; + if ( use_brep_data ) { + TopoDS_Compound compound; + BRep_Builder builder; + builder.MakeCompound(compound); + for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) { + const TopoDS_Shape& s = *(*it).second; + const gp_GTrsf& trsf = *(*it).first; + bool trsf_valid = false; + gp_Trsf _trsf; + try { + _trsf = trsf.Trsf(); + trsf_valid = true; + } catch (...) {} + const TopoDS_Shape moved_shape = trsf_valid ? s.Moved(_trsf) : + BRepBuilderAPI_GTransform(s,trsf,true).Shape(); + builder.Add(compound,moved_shape); + } + std::stringstream sstream; + BRepTools::Write(compound,sstream); + brep_data = sstream.str(); + } else for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) { const TopoDS_Shape& s = *(*it).second; @@ -491,6 +514,9 @@ void IfcGeomObjects::Settings(int setting, bool value) { case CONVERT_BACK_UNITS: convert_back_units = value; break; + case USE_BREP_DATA: + use_brep_data = value; + break; } } int IfcGeomObjects::Progress() { diff --git a/src/ifcgeom/IfcGeomObjects.h b/src/ifcgeom/IfcGeomObjects.h index 15efe0d4a9..4cc690c440 100644 --- a/src/ifcgeom/IfcGeomObjects.h +++ b/src/ifcgeom/IfcGeomObjects.h @@ -72,6 +72,7 @@ namespace IfcGeomObjects { const int WELD_VERTICES = 1; const int USE_WORLD_COORDS = 2; const int CONVERT_BACK_UNITS = 3; + const int USE_BREP_DATA = 4; typedef std::vector::const_iterator IntIt; typedef std::vector::const_iterator FltIt; @@ -86,6 +87,7 @@ namespace IfcGeomObjects { std::vector faces; std::vector edges; std::vector normals; + std::string brep_data; VertKeyMap welds; IfcMesh(int i, const IfcGeom::ShapeList& s); diff --git a/src/ifcwrap/Interface.h b/src/ifcwrap/Interface.h index 1297a0bdce..57464ff3ca 100644 --- a/src/ifcwrap/Interface.h +++ b/src/ifcwrap/Interface.h @@ -21,6 +21,8 @@ namespace IfcGeomObjects { const int WELD_VERTICES = 1; const int USE_WORLD_COORDS = 2; + const int CONVERT_BACK_UNITS = 3; + const int USE_BREP_DATA = 4; class IfcMesh { public: @@ -29,6 +31,7 @@ namespace IfcGeomObjects { std::vector faces; std::vector edges; std::vector normals; + std::string brep_data; }; class IfcObject {