mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Geometry serialization (#71)
Serialize geometry to IFC instances directly from a TopoDS_Shape
This commit is contained in:
@@ -389,6 +389,34 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
||||
}
|
||||
return boost::variant<IfcGeom::Element<double>*, IfcGeom::Representation::Representation*>();
|
||||
}
|
||||
|
||||
IfcParse::IfcLateBoundEntity* serialise(const std::string& s, bool advanced=true) {
|
||||
std::stringstream stream(s);
|
||||
BRepTools_ShapeSet shapes;
|
||||
shapes.Read(stream);
|
||||
const TopoDS_Shape& shp = shapes.Shape(shapes.NbShapes());
|
||||
|
||||
const IfcUtil::IfcBaseClass* e = IfcGeom::serialise(shp, advanced);
|
||||
if (e) {
|
||||
return new IfcParse::IfcLateBoundEntity(e->entity);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
IfcParse::IfcLateBoundEntity* tesselate(const std::string& s, double d) {
|
||||
std::stringstream stream(s);
|
||||
BRepTools_ShapeSet shapes;
|
||||
shapes.Read(stream);
|
||||
const TopoDS_Shape& shp = shapes.Shape(shapes.NbShapes());
|
||||
|
||||
const IfcUtil::IfcBaseClass* e = IfcGeom::tesselate(shp, d);
|
||||
if (e) {
|
||||
return new IfcParse::IfcLateBoundEntity(e->entity);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
namespace IfcGeom {
|
||||
|
||||
@@ -76,6 +76,8 @@
|
||||
#else
|
||||
#include "../ifcparse/Ifc2x3-latebound.h"
|
||||
#endif
|
||||
|
||||
#include <BRepTools_ShapeSet.hxx>
|
||||
%}
|
||||
|
||||
%include "utils/type_conversion.i"
|
||||
|
||||
Reference in New Issue
Block a user