mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
Work on serialization
This commit is contained in:
@@ -322,8 +322,8 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IFC_GEOM_API IfcSchema::IfcProductDefinitionShape* tesselate(const TopoDS_Shape& shape, double deflection);
|
IfcUtil::IfcBaseClass* MAKE_TYPE_NAME(tesselate_)(const TopoDS_Shape& shape, double deflection);
|
||||||
IFC_GEOM_API IfcSchema::IfcProductDefinitionShape* serialise(const TopoDS_Shape& shape, bool advanced);
|
IfcUtil::IfcBaseClass* MAKE_TYPE_NAME(serialise_)(const TopoDS_Shape& shape, bool advanced);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ int convert_to_ifc(const TopoDS_Shape& s, U*& item, bool advanced) {
|
|||||||
return faces->size();
|
return faces->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSchema::IfcProductDefinitionShape* IfcGeom::serialise(const TopoDS_Shape& shape, bool advanced) {
|
IfcUtil::IfcBaseClass* IfcGeom::serialise(const TopoDS_Shape& shape, bool advanced) {
|
||||||
#ifndef USE_IFC4
|
#ifndef USE_IFC4
|
||||||
advanced = false;
|
advanced = false;
|
||||||
#endif
|
#endif
|
||||||
@@ -604,7 +604,7 @@ IfcSchema::IfcProductDefinitionShape* IfcGeom::serialise(const TopoDS_Shape& sha
|
|||||||
return new IfcSchema::IfcProductDefinitionShape(boost::none, boost::none, reps);
|
return new IfcSchema::IfcProductDefinitionShape(boost::none, boost::none, reps);
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSchema::IfcProductDefinitionShape* IfcGeom::tesselate(const TopoDS_Shape& shape, double deflection) {
|
IfcUtil::IfcBaseClass* IfcGeom::tesselate(const TopoDS_Shape& shape, double deflection) {
|
||||||
BRepMesh_IncrementalMesh(shape, deflection);
|
BRepMesh_IncrementalMesh(shape, deflection);
|
||||||
|
|
||||||
IfcSchema::IfcFace::list::ptr faces(new IfcSchema::IfcFace::list);
|
IfcSchema::IfcFace::list::ptr faces(new IfcSchema::IfcFace::list);
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include "Serialization.h"
|
||||||
|
|
||||||
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
|
|
||||||
|
namespace IfcGeom {
|
||||||
|
extern IfcUtil::IfcBaseClass* tesselate_Ifc2x3(const TopoDS_Shape& shape, double deflection);
|
||||||
|
extern IfcUtil::IfcBaseClass* tesselate_Ifc4(const TopoDS_Shape& shape, double deflection);
|
||||||
|
extern IfcUtil::IfcBaseClass* serialise_Ifc2x3(const TopoDS_Shape& shape, bool advanced);
|
||||||
|
extern IfcUtil::IfcBaseClass* serialise_Ifc4(const TopoDS_Shape& shape, bool advanced);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Fn, typename T>
|
||||||
|
IfcUtil::IfcBaseClass* execute_based_on_schema(Fn fn1, Fn fn2, const std::string& schema_name, const TopoDS_Shape& shape, T t) {
|
||||||
|
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
||||||
|
if (schema_name == "ifc2x3") {
|
||||||
|
return fn1(shape, t);
|
||||||
|
} else if (schema_name == "ifc4") {
|
||||||
|
return fn2(shape, t);
|
||||||
|
} else {
|
||||||
|
throw IfcParse::IfcException("No geometry serialization available for " + schema_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IfcUtil::IfcBaseClass* IfcGeom::tesselate(const std::string& schema_name, const TopoDS_Shape& shape, double deflection) {
|
||||||
|
return execute_based_on_schema(IfcGeom::tesselate_Ifc2x3, IfcGeom::tesselate_Ifc4, schema_name, shape, deflection);
|
||||||
|
}
|
||||||
|
|
||||||
|
IfcUtil::IfcBaseClass* IfcGeom::serialise(const std::string& schema_name, const TopoDS_Shape& shape, bool advanced) {
|
||||||
|
return execute_based_on_schema(IfcGeom::serialise_Ifc2x3, IfcGeom::serialise_Ifc4, schema_name, shape, advanced);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#include "../ifcgeom/ifc_geom_api.h"
|
||||||
|
#include "../ifcparse/IfcBaseClass.h"
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace IfcGeom {
|
||||||
|
IFC_GEOM_API IfcUtil::IfcBaseClass* tesselate(const std::string& schema_name, const TopoDS_Shape& shape, double deflection);
|
||||||
|
IFC_GEOM_API IfcUtil::IfcBaseClass* serialise(const std::string& schema_name, const TopoDS_Shape& shape, bool advanced);
|
||||||
|
}
|
||||||
@@ -439,27 +439,25 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/*
|
|
||||||
%inline %{
|
%inline %{
|
||||||
IfcUtil::IfcBaseClass* serialise(const std::string& s, bool advanced=true) {
|
IfcUtil::IfcBaseClass* serialise(const std::string& schema_name, const std::string& shape_str, bool advanced=true) {
|
||||||
std::stringstream stream(s);
|
std::stringstream stream(shape_str);
|
||||||
BRepTools_ShapeSet shapes;
|
BRepTools_ShapeSet shapes;
|
||||||
shapes.Read(stream);
|
shapes.Read(stream);
|
||||||
const TopoDS_Shape& shp = shapes.Shape(shapes.NbShapes());
|
const TopoDS_Shape& shp = shapes.Shape(shapes.NbShapes());
|
||||||
|
|
||||||
return IfcGeom::serialise(shp, advanced);
|
return IfcGeom::serialise(schema_name, shp, advanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcUtil::IfcBaseClass* tesselate(const std::string& s, double d) {
|
IfcUtil::IfcBaseClass* tesselate(const std::string& schema_name, const std::string& shape_str, double d) {
|
||||||
std::stringstream stream(s);
|
std::stringstream stream(shape_str);
|
||||||
BRepTools_ShapeSet shapes;
|
BRepTools_ShapeSet shapes;
|
||||||
shapes.Read(stream);
|
shapes.Read(stream);
|
||||||
const TopoDS_Shape& shp = shapes.Shape(shapes.NbShapes());
|
const TopoDS_Shape& shp = shapes.Shape(shapes.NbShapes());
|
||||||
|
|
||||||
return IfcGeom::tesselate(shp, d);
|
return IfcGeom::tesselate(schema_name, shp, d);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
*/
|
|
||||||
|
|
||||||
namespace IfcGeom {
|
namespace IfcGeom {
|
||||||
%template(iterator_single_precision) Iterator<float>;
|
%template(iterator_single_precision) Iterator<float>;
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
|
|
||||||
%module ifcopenshell_wrapper %{
|
%module ifcopenshell_wrapper %{
|
||||||
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
|
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
|
||||||
|
#include "../ifcgeom_schema_agnostic/Serialization.h"
|
||||||
#include "../ifcgeom/IfcGeomTree.h"
|
#include "../ifcgeom/IfcGeomTree.h"
|
||||||
|
|
||||||
#include "../ifcparse/Ifc2x3.h"
|
#include "../ifcparse/Ifc2x3.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user