mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Provide access to IfcGeomObject geometry as Open Cascade BRep data
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
#include <Poly_Array1OfTriangle.hxx>
|
#include <Poly_Array1OfTriangle.hxx>
|
||||||
#include <StdFail_NotDone.hxx>
|
#include <StdFail_NotDone.hxx>
|
||||||
#include <BRepGProp_Face.hxx>
|
#include <BRepGProp_Face.hxx>
|
||||||
|
#include <BRepBuilderAPI_GTransform.hxx>
|
||||||
|
|
||||||
#include "../ifcparse/IfcException.h"
|
#include "../ifcparse/IfcException.h"
|
||||||
#include "../ifcgeom/IfcGeomObjects.h"
|
#include "../ifcgeom/IfcGeomObjects.h"
|
||||||
@@ -68,10 +69,32 @@ int IfcGeomObjects::IfcMesh::addvert(const gp_XYZ& p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool use_world_coords = false;
|
bool use_world_coords = false;
|
||||||
|
bool use_brep_data = false;
|
||||||
|
|
||||||
IfcGeomObjects::IfcMesh::IfcMesh(int i, const IfcGeom::ShapeList& shapes) {
|
IfcGeomObjects::IfcMesh::IfcMesh(int i, const IfcGeom::ShapeList& shapes) {
|
||||||
id = i;
|
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 ) {
|
for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
|
||||||
|
|
||||||
const TopoDS_Shape& s = *(*it).second;
|
const TopoDS_Shape& s = *(*it).second;
|
||||||
@@ -491,6 +514,9 @@ void IfcGeomObjects::Settings(int setting, bool value) {
|
|||||||
case CONVERT_BACK_UNITS:
|
case CONVERT_BACK_UNITS:
|
||||||
convert_back_units = value;
|
convert_back_units = value;
|
||||||
break;
|
break;
|
||||||
|
case USE_BREP_DATA:
|
||||||
|
use_brep_data = value;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int IfcGeomObjects::Progress() {
|
int IfcGeomObjects::Progress() {
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ namespace IfcGeomObjects {
|
|||||||
const int WELD_VERTICES = 1;
|
const int WELD_VERTICES = 1;
|
||||||
const int USE_WORLD_COORDS = 2;
|
const int USE_WORLD_COORDS = 2;
|
||||||
const int CONVERT_BACK_UNITS = 3;
|
const int CONVERT_BACK_UNITS = 3;
|
||||||
|
const int USE_BREP_DATA = 4;
|
||||||
|
|
||||||
typedef std::vector<int>::const_iterator IntIt;
|
typedef std::vector<int>::const_iterator IntIt;
|
||||||
typedef std::vector<float>::const_iterator FltIt;
|
typedef std::vector<float>::const_iterator FltIt;
|
||||||
@@ -86,6 +87,7 @@ namespace IfcGeomObjects {
|
|||||||
std::vector<int> faces;
|
std::vector<int> faces;
|
||||||
std::vector<int> edges;
|
std::vector<int> edges;
|
||||||
std::vector<float> normals;
|
std::vector<float> normals;
|
||||||
|
std::string brep_data;
|
||||||
VertKeyMap welds;
|
VertKeyMap welds;
|
||||||
|
|
||||||
IfcMesh(int i, const IfcGeom::ShapeList& s);
|
IfcMesh(int i, const IfcGeom::ShapeList& s);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace IfcGeomObjects {
|
|||||||
|
|
||||||
const int WELD_VERTICES = 1;
|
const int WELD_VERTICES = 1;
|
||||||
const int USE_WORLD_COORDS = 2;
|
const int USE_WORLD_COORDS = 2;
|
||||||
|
const int CONVERT_BACK_UNITS = 3;
|
||||||
|
const int USE_BREP_DATA = 4;
|
||||||
|
|
||||||
class IfcMesh {
|
class IfcMesh {
|
||||||
public:
|
public:
|
||||||
@@ -29,6 +31,7 @@ namespace IfcGeomObjects {
|
|||||||
std::vector<int> faces;
|
std::vector<int> faces;
|
||||||
std::vector<int> edges;
|
std::vector<int> edges;
|
||||||
std::vector<float> normals;
|
std::vector<float> normals;
|
||||||
|
std::string brep_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IfcObject {
|
class IfcObject {
|
||||||
|
|||||||
Reference in New Issue
Block a user