|
40 | 40 | #include <Poly_Array1OfTriangle.hxx> |
41 | 41 | #include <StdFail_NotDone.hxx> |
42 | 42 | #include <BRepGProp_Face.hxx> |
| 43 | +#include <BRepBuilderAPI_GTransform.hxx> |
43 | 44 |
|
44 | 45 | #include "../ifcparse/IfcException.h" |
45 | 46 | #include "../ifcgeom/IfcGeomObjects.h" |
@@ -68,10 +69,32 @@ int IfcGeomObjects::IfcMesh::addvert(const gp_XYZ& p) { |
68 | 69 | } |
69 | 70 |
|
70 | 71 | bool use_world_coords = false; |
| 72 | +bool use_brep_data = false; |
71 | 73 |
|
72 | 74 | IfcGeomObjects::IfcMesh::IfcMesh(int i, const IfcGeom::ShapeList& shapes) { |
73 | 75 | id = i; |
74 | 76 |
|
| 77 | + if ( use_brep_data ) { |
| 78 | + TopoDS_Compound compound; |
| 79 | + BRep_Builder builder; |
| 80 | + builder.MakeCompound(compound); |
| 81 | + for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) { |
| 82 | + const TopoDS_Shape& s = *(*it).second; |
| 83 | + const gp_GTrsf& trsf = *(*it).first; |
| 84 | + bool trsf_valid = false; |
| 85 | + gp_Trsf _trsf; |
| 86 | + try { |
| 87 | + _trsf = trsf.Trsf(); |
| 88 | + trsf_valid = true; |
| 89 | + } catch (...) {} |
| 90 | + const TopoDS_Shape moved_shape = trsf_valid ? s.Moved(_trsf) : |
| 91 | + BRepBuilderAPI_GTransform(s,trsf,true).Shape(); |
| 92 | + builder.Add(compound,moved_shape); |
| 93 | + } |
| 94 | + std::stringstream sstream; |
| 95 | + BRepTools::Write(compound,sstream); |
| 96 | + brep_data = sstream.str(); |
| 97 | + } else |
75 | 98 | for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) { |
76 | 99 |
|
77 | 100 | const TopoDS_Shape& s = *(*it).second; |
@@ -491,6 +514,9 @@ void IfcGeomObjects::Settings(int setting, bool value) { |
491 | 514 | case CONVERT_BACK_UNITS: |
492 | 515 | convert_back_units = value; |
493 | 516 | break; |
| 517 | + case USE_BREP_DATA: |
| 518 | + use_brep_data = value; |
| 519 | + break; |
494 | 520 | } |
495 | 521 | } |
496 | 522 | int IfcGeomObjects::Progress() { |
|
0 commit comments