From 92f7d2683569c4497703d71560cb9c9f3f0d596a Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 3 Aug 2019 15:09:50 +0200 Subject: [PATCH] Work on Python wrapper --- src/ifcgeom/kernels/opencascade/IfcGeomTree.h | 1 + src/ifcgeom/schema_agnostic/IfcGeomElement.h | 10 +++++----- .../schema_agnostic/IfcGeomRepresentation.h | 4 ++-- src/ifcwrap/IfcGeomWrapper.i | 19 ++++++++++--------- src/ifcwrap/IfcPython.i | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomTree.h b/src/ifcgeom/kernels/opencascade/IfcGeomTree.h index dbc723ac29..c5c657a370 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomTree.h +++ b/src/ifcgeom/kernels/opencascade/IfcGeomTree.h @@ -24,6 +24,7 @@ #include "../../../ifcgeom/schema_agnostic/IfcGeomElement.h" #include "../../../ifcgeom/schema_agnostic/IfcGeomIterator.h" #include "../../../ifcgeom/schema_agnostic/Kernel.h" +#include "../../../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include #include diff --git a/src/ifcgeom/schema_agnostic/IfcGeomElement.h b/src/ifcgeom/schema_agnostic/IfcGeomElement.h index f01a397563..0cefed19de 100644 --- a/src/ifcgeom/schema_agnostic/IfcGeomElement.h +++ b/src/ifcgeom/schema_agnostic/IfcGeomElement.h @@ -38,7 +38,7 @@ namespace IfcGeom { private: std::vector

_data; public: - Matrix(const ElementSettings& settings, const ConversionResultPlacement* trsf) { + Matrix(const ElementSettings& settings, const IfcGeom::ConversionResultPlacement* trsf) { // Convert the gp_Trsf into a 4x3 Matrix // Note that in case the CONVERT_BACK_UNITS setting is enabled // the translation component of the matrix needs to be divided @@ -66,12 +66,12 @@ namespace IfcGeom { ConversionResultPlacement* trsf_; Matrix

matrix_; public: - Transformation(const ElementSettings& settings, const ConversionResultPlacement* trsf) + Transformation(const ElementSettings& settings, const IfcGeom::ConversionResultPlacement* trsf) : settings_(settings) , trsf_(trsf ? trsf->clone() : nullptr) , matrix_(settings, trsf) {} - const ConversionResultPlacement* data() const { return trsf_; } + const IfcGeom::ConversionResultPlacement* data() const { return trsf_; } const Matrix

& matrix() const { return matrix_; } Transformation inverted() const { @@ -133,7 +133,7 @@ namespace IfcGeom { void SetParents(std::vector*> newparents) { _parents = newparents; } Element(const ElementSettings& settings, int id, int parent_id, const std::string& name, const std::string& type, - const std::string& guid, const std::string& context, const ConversionResultPlacement* trsf, IfcUtil::IfcBaseEntity* product) + const std::string& guid, const std::string& context, const IfcGeom::ConversionResultPlacement* trsf, IfcUtil::IfcBaseEntity* product) : _id(id), _parent_id(parent_id), _name(name), _type(type), _guid(guid), _context(context), _transformation(settings, trsf) , product_(product) { @@ -170,7 +170,7 @@ namespace IfcGeom { const boost::shared_ptr& geometry_pointer() const { return _geometry; } const Representation::BRep& geometry() const { return *_geometry; } NativeElement(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid, - const std::string& context, const ConversionResultPlacement* trsf, const boost::shared_ptr& geometry, + const std::string& context, const IfcGeom::ConversionResultPlacement* trsf, const boost::shared_ptr& geometry, IfcUtil::IfcBaseEntity* product) : Element(geometry->settings() ,id, parent_id, name, type, guid, context, trsf, product) , _geometry(geometry) diff --git a/src/ifcgeom/schema_agnostic/IfcGeomRepresentation.h b/src/ifcgeom/schema_agnostic/IfcGeomRepresentation.h index e04f0f9d48..a2886803fc 100644 --- a/src/ifcgeom/schema_agnostic/IfcGeomRepresentation.h +++ b/src/ifcgeom/schema_agnostic/IfcGeomRepresentation.h @@ -60,11 +60,11 @@ namespace IfcGeom { IfcGeom::ConversionResults::const_iterator end() const { return shapes_.end(); } const IfcGeom::ConversionResults& shapes() const { return shapes_; } const std::string& id() const { return id_; } - ConversionResultShape* as_compound(bool force_meters = false) const; + IfcGeom::ConversionResultShape* as_compound(bool force_meters = false) const; bool calculate_volume(double&) const; bool calculate_surface_area(double&) const; - bool calculate_projected_surface_area(const ConversionResultPlacement* ax, double& along_x, double& along_y, double& along_z) const; + bool calculate_projected_surface_area(const IfcGeom::ConversionResultPlacement* ax, double& along_x, double& along_y, double& along_z) const; }; class IFC_GEOM_API Serialization : public Representation { diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index fe6687936d..5af6ceac67 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -38,16 +38,16 @@ %ignore IfcGeom::impl::tree::selector; -%include "../ifcgeom/ifc_geom_api.h" -%include "../ifcgeom/IfcGeomIteratorSettings.h" -%include "../ifcgeom/IfcGeomElement.h" -%include "../ifcgeom_schema_agnostic/IfcGeomMaterial.h" -%include "../ifcgeom/IfcGeomRepresentation.h" -%include "../ifcgeom_schema_agnostic/IfcGeomIterator.h" +%include "../ifcgeom/schema_agnostic/ifc_geom_api.h" +%include "../ifcgeom/schema_agnostic/IfcGeomIteratorSettings.h" +%include "../ifcgeom/schema_agnostic/IfcGeomElement.h" +%include "../ifcgeom/schema_agnostic/IfcGeomMaterial.h" +%include "../ifcgeom/schema_agnostic/IfcGeomRepresentation.h" +%include "../ifcgeom/schema_agnostic/IfcGeomIterator.h" // A Template instantantation should be defined before it is used as a base class. // But frankly I don't care as most methods are subtlely different anyway. -%include "../ifcgeom/IfcGeomTree.h" +%include "../ifcgeom/kernels/opencascade/IfcGeomTree.h" %extend IfcGeom::tree { @@ -277,8 +277,9 @@ struct ShapeRTTI : public boost::static_visitor template static boost::variant*, IfcGeom::Representation::Representation*> helper_fn_create_shape(IfcGeom::IteratorSettings& settings, IfcUtil::IfcBaseClass* instance, IfcUtil::IfcBaseClass* representation = 0) { IfcParse::IfcFile* file = instance->data().file; - - IfcGeom::Kernel kernel(file); + + // @todo Default to opencascade for now. + IfcGeom::Kernel kernel("opencascade", file); kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_ORIENT, settings.get(IfcGeom::IteratorSettings::SEW_SHELLS) ? std::numeric_limits::infinity() : -1); kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get(IfcGeom::IteratorSettings::INCLUDE_CURVES) ? (settings.get(IfcGeom::IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES) ? -1. : 0.) : +1.)); diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index 7b54ac2e94..84c0320d20 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -72,7 +72,7 @@ %module ifcopenshell_wrapper %{ #include "../ifcgeom/schema_agnostic/IfcGeomIterator.h" #include "../ifcgeom/schema_agnostic/Serialization.h" - #include "../ifcgeom/IfcGeomTree.h" + #include "../ifcgeom/kernels/opencascade/IfcGeomTree.h" #include "../ifcparse/Ifc2x3.h" #include "../ifcparse/Ifc4.h"