Provide access to IfcGeomObject geometry as Open Cascade BRep data

This commit is contained in:
Thomas Krijnen
2012-01-31 08:56:10 +00:00
parent 5ebc23656a
commit b719e12417
3 changed files with 31 additions and 0 deletions
+26
View File
@@ -40,6 +40,7 @@
#include <Poly_Array1OfTriangle.hxx>
#include <StdFail_NotDone.hxx>
#include <BRepGProp_Face.hxx>
#include <BRepBuilderAPI_GTransform.hxx>
#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() {
+2
View File
@@ -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<int>::const_iterator IntIt;
typedef std::vector<float>::const_iterator FltIt;
@@ -86,6 +87,7 @@ namespace IfcGeomObjects {
std::vector<int> faces;
std::vector<int> edges;
std::vector<float> normals;
std::string brep_data;
VertKeyMap welds;
IfcMesh(int i, const IfcGeom::ShapeList& s);
+3
View File
@@ -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<int> faces;
std::vector<int> edges;
std::vector<float> normals;
std::string brep_data;
};
class IfcObject {