diff --git a/src/ifcgeom/ConversionResult.cpp b/src/ifcgeom/ConversionResult.cpp index 30bed11214..6be2736742 100644 --- a/src/ifcgeom/ConversionResult.cpp +++ b/src/ifcgeom/ConversionResult.cpp @@ -1,6 +1,8 @@ #include "ConversionResult.h" #include "IfcGeomRepresentation.h" +#include + IfcGeom::Representation::Triangulation * IfcGeom::ConversionResultShape::Triangulate(const ifcopenshell::geometry::Settings& settings) const { auto t = IfcGeom::Representation::Triangulation::empty(settings); @@ -18,3 +20,9 @@ void IfcGeom::ConversionResult::append(ifcopenshell::geometry::taxonomy::matrix4 void IfcGeom::ConversionResult::prepend(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) { placement_ = make(trsf->ccomponents() * placement_->ccomponents()); } + +std::string IfcGeom::NumberNativeDouble::to_string() const { + std::stringstream ss; + ss << std::setprecision(std::numeric_limits::digits10 + 1) << value_; + return ss.str(); +} diff --git a/src/ifcgeom/ConversionResult.h b/src/ifcgeom/ConversionResult.h index d9f172e2de..aa945bee82 100644 --- a/src/ifcgeom/ConversionResult.h +++ b/src/ifcgeom/ConversionResult.h @@ -71,6 +71,8 @@ namespace IfcGeom { class IFC_GEOM_API OpaqueNumber { public: virtual double to_double() const = 0; + virtual std::string to_string() const = 0; + virtual ~OpaqueNumber() {} virtual OpaqueNumber* operator+(OpaqueNumber* other) const = 0; @@ -80,6 +82,7 @@ namespace IfcGeom { virtual bool operator==(OpaqueNumber* other) const = 0; virtual bool operator<(OpaqueNumber* other) const = 0; virtual OpaqueNumber* operator-() const = 0; + virtual OpaqueNumber* clone() const = 0; }; // @todo this can simply be a template class, to remove the need for the NumberEpeck in CGAL kernel. @@ -119,10 +122,11 @@ namespace IfcGeom { return value_; } + virtual std::string to_string() const; + virtual OpaqueNumber* operator+(OpaqueNumber* other) const { return binary_op>(other); } - virtual OpaqueNumber* operator-(OpaqueNumber* other) const { return binary_op>(other); } @@ -141,11 +145,14 @@ namespace IfcGeom { virtual OpaqueNumber* operator-() const { return unary_op>(); } + virtual OpaqueNumber* clone() const { + return new NumberNativeDouble(value_); + } }; template struct IFC_GEOM_API OpaqueCoordinate { - std::array, N> values; + std::array values; template OpaqueCoordinate(Args... args) { @@ -159,21 +166,21 @@ namespace IfcGeom { } } - std::shared_ptr get(size_t i) { + OpaqueNumber* get(size_t i) { if (i >= N) { return nullptr; } return values[i]; } - void set(size_t i, std::shared_ptr n) { + void set(size_t i, OpaqueNumber* n) { if (i < N) { - values[i] = n; + values[i] = n->clone(); } } private: template - void init_(std::shared_ptr value, Args... args) { + void init_(OpaqueNumber* value, Args... args) { values[Index] = value; if constexpr (Index + 1 < N) { init_(args...); @@ -200,9 +207,9 @@ namespace IfcGeom { virtual std::pair, OpaqueCoordinate<3>> bounding_box() const = 0; virtual void set_box(void* b) = 0; - virtual std::shared_ptr length() = 0; - virtual std::shared_ptr area() = 0; - virtual std::shared_ptr volume() = 0; + virtual OpaqueNumber* length() = 0; + virtual OpaqueNumber* area() = 0; + virtual OpaqueNumber* volume() = 0; virtual OpaqueCoordinate<3> position() = 0; virtual OpaqueCoordinate<3> axis() = 0; @@ -212,6 +219,8 @@ namespace IfcGeom { virtual ConversionResultShape* halfspaces() = 0; virtual ConversionResultShape* box() = 0; virtual ConversionResultShape* solid() = 0; + + virtual std::vector vertices() = 0; virtual std::vector edges() = 0; virtual std::vector facets() = 0; diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp index 2819cff6d7..4947dea3d8 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp @@ -21,8 +21,12 @@ using ifcopenshell::geometry::NumberEpeck; ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t & shape) { shape_ = shape; - CGAL::Polygon_mesh_processing::triangulate_faces(*shape_); - CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_); + if (shape.size_of_facets() != 1) { + // this is for handling the specical case of storing a single point in a polyhedron, + // @todo come up with a proper variant for storing lower dimensional entities + CGAL::Polygon_mesh_processing::triangulate_faces(*shape_); + CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_); + } } #ifndef IFOPSH_SIMPLE_KERNEL @@ -63,7 +67,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett m(2, 0), m(2, 1), m(2, 2), m(2, 3)); // Apply transformation - for (auto &vertex : vertices(s)) { + for (auto &vertex : s.vertex_handles()) { vertex->point() = vertex->point().transform(trsf); } } @@ -185,7 +189,7 @@ void ifcopenshell::geometry::CgalShape::Serialize(const ifcopenshell::geometry:: m(2, 0), m(2, 1), m(2, 2), m(2, 3)); // Apply transformation - for (auto &vertex : vertices(s)) { + for (auto &vertex : s.vertex_handles()) { vertex->point() = vertex->point().transform(trsf); } } @@ -255,7 +259,7 @@ int ifcopenshell::geometry::CgalShape::num_faces() const } } -std::shared_ptr ifcopenshell::geometry::CgalShape::CgalShape::length() +OpaqueNumber* ifcopenshell::geometry::CgalShape::CgalShape::length() { to_poly(); Kernel_::FT len = 0; @@ -265,19 +269,19 @@ std::shared_ptr ifcopenshell::geometry::CgalShape::CgalShape::leng it->next()->vertex()->point() ).squared_length()); } - return std::make_shared(len); + return new NumberType(len); } -std::shared_ptr ifcopenshell::geometry::CgalShape::area() +OpaqueNumber* ifcopenshell::geometry::CgalShape::area() { to_poly(); - return std::make_shared(CGAL::Polygon_mesh_processing::area(*shape_)); + return new NumberType(CGAL::Polygon_mesh_processing::area(*shape_)); } -std::shared_ptr ifcopenshell::geometry::CgalShape::volume() +OpaqueNumber* ifcopenshell::geometry::CgalShape::volume() { to_poly(); - return std::make_shared(CGAL::Polygon_mesh_processing::volume(*shape_)); + return new NumberType(CGAL::Polygon_mesh_processing::volume(*shape_)); } OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::position() @@ -297,9 +301,9 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::position() p[i] /= N; } return OpaqueCoordinate<3>( - std::make_shared(p[0]), - std::make_shared(p[1]), - std::make_shared(p[2]) + new NumberType(p[0]), + new NumberType(p[1]), + new NumberType(p[2]) ); } else { throw std::runtime_error("Invalid shape type"); @@ -307,15 +311,25 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::position() } namespace { + template + CGAL::Direction_3 newell(Facet& face) { + typename Kernel_::FT a(0), b(0), c(0); + CGAL::Polyhedron_3::Halfedge_around_facet_const_circulator current_halfedge = face.facet_begin(); + do { + auto& curr = current_halfedge->vertex()->point(); + auto& next = current_halfedge->next()->vertex()->point(); + a += (curr.y() - next.y()) * (curr.z() + next.z()); + b += (curr.z() - next.z()) * (curr.x() + next.x()); + c += (curr.x() - next.x()) * (curr.y() + next.y()); + } while (++current_halfedge != face.facet_begin()); + return CGAL::Direction_3(a, b, c); + } + struct Plane_equation { - template - typename Facet::Plane_3 operator()(Facet& f) { - // @todo from the docs, but better use Newell's method - typename Facet::Halfedge_handle h = f.halfedge(); - typedef typename Facet::Plane_3 Plane; - return Plane(h->vertex()->point(), - h->next()->vertex()->point(), - h->next()->next()->vertex()->point()); + template + typename Facet::Plane_3 operator()(Facet& face) { + typename Facet::Halfedge_handle h = face.halfedge(); + return typename Facet::Plane_3(h->vertex()->point(), newell(face)); } }; } @@ -331,9 +345,9 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::axis() auto maxval = ((-*minel) > *maxel) ? (-*minel) : *maxel; return OpaqueCoordinate<3>( - std::make_shared(pl.a() / maxval), - std::make_shared(pl.b() / maxval), - std::make_shared(pl.c() / maxval) + new NumberType(pl.a() / maxval), + new NumberType(pl.b() / maxval), + new NumberType(pl.c() / maxval) ); } else { throw std::runtime_error("Invalid shape type"); @@ -390,9 +404,52 @@ ConversionResultShape * ifcopenshell::geometry::CgalShape::box() throw std::runtime_error("Not implemented"); } +std::vector ifcopenshell::geometry::CgalShape::vertices() +{ + // @todo this is ridiculous + to_poly(); + std::vector result; + for (auto& p : shape_->points()) { + std::vector ps = { + p, p, p + }; + + std::vector> ids(1); + ids.front().push_back(0); + ids.front().push_back(1); + ids.front().push_back(2); + + cgal_shape_t poly; + CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(ps, ids, poly); + + result.push_back(new CgalShape(poly)); + } + return result; +} + std::vector ifcopenshell::geometry::CgalShape::edges() { - throw std::runtime_error("Not implemented"); + // @todo this is ridiculous + to_poly(); + std::vector result; + for (auto& ed : shape_->edges()) { + std::vector ps = { + ed.vertex()->point(), + ed.vertex()->point(), + ed.next()->vertex()->point() + }; + + std::vector> ids(1); + ids.front().push_back(0); + ids.front().push_back(1); + ids.front().push_back(2); + + cgal_shape_t poly; + CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(ps, ids, poly); + + result.push_back(new CgalShape(poly)); + } + return result; } std::vector ifcopenshell::geometry::CgalShape::facets() @@ -463,7 +520,7 @@ ConversionResultShape* ifcopenshell::geometry::CgalShape::moved(ifcopenshell::ge m(2, 0), m(2, 1), m(2, 2), m(2, 3)); // Apply transformation - for (auto &vertex : vertices(s)) { + for (auto &vertex : s.vertex_handles()) { vertex->point() = vertex->point().transform(trsf); } } @@ -515,17 +572,17 @@ int ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::num_faces() const throw std::runtime_error("Not implemented"); } -std::shared_ptr ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::CgalShapeHalfSpaceDecomposition::length() +OpaqueNumber* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::CgalShapeHalfSpaceDecomposition::length() { throw std::runtime_error("Not implemented"); } -std::shared_ptr ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::area() +OpaqueNumber* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::area() { throw std::runtime_error("Not implemented"); } -std::shared_ptr ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::volume() +OpaqueNumber* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::volume() { throw std::runtime_error("Not implemented"); } @@ -535,9 +592,9 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::pos if (planes_.size() == 1) { auto xyz = CGAL::ORIGIN + planes_.front().d() * CGAL::Vector_3(planes_.front().a(), planes_.front().b(), planes_.front().c()); return OpaqueCoordinate<3>( - std::make_shared(xyz.cartesian(0)), - std::make_shared(xyz.cartesian(1)), - std::make_shared(xyz.cartesian(2)) + new NumberType(xyz.cartesian(0)), + new NumberType(xyz.cartesian(1)), + new NumberType(xyz.cartesian(2)) ); } else { throw std::runtime_error("Invalid shape type"); @@ -552,9 +609,9 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::axi auto maxel = std::max_element(abc.begin(), abc.end()); auto maxval = ((-*minel) > *maxel) ? (-*minel) : *maxel; return OpaqueCoordinate<3>( - std::make_shared(planes_.front().a() / maxval), - std::make_shared(planes_.front().b() / maxval), - std::make_shared(planes_.front().c() / maxval) + new NumberType(planes_.front().a() / maxval), + new NumberType(planes_.front().b() / maxval), + new NumberType(planes_.front().c() / maxval) ); } else { throw std::runtime_error("Invalid shape type"); @@ -569,10 +626,10 @@ OpaqueCoordinate<4> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::pla auto maxel = std::max_element(abc.begin(), abc.end()); auto maxval = ((-*minel) > *maxel) ? (-*minel) : *maxel; return OpaqueCoordinate<4>( - std::make_shared(planes_.front().a() / maxval), - std::make_shared(planes_.front().b() / maxval), - std::make_shared(planes_.front().c() / maxval), - std::make_shared(planes_.front().d() / maxval) + new NumberType(planes_.front().a() / maxval), + new NumberType(planes_.front().b() / maxval), + new NumberType(planes_.front().c() / maxval), + new NumberType(planes_.front().d() / maxval) ); } else { throw std::runtime_error("Invalid shape type"); @@ -599,6 +656,11 @@ ConversionResultShape * ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition: throw std::runtime_error("Not implemented"); } +std::vector ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::vertices() +{ + throw std::runtime_error("Not implemented"); +} + std::vector ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::edges() { throw std::runtime_error("Not implemented"); @@ -646,16 +708,16 @@ void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::map(OpaqueCoordina plane_map mp; mp.insert({ CGAL::Plane_3( - std::static_pointer_cast(from.values[0])->value(), - std::static_pointer_cast(from.values[1])->value(), - std::static_pointer_cast(from.values[2])->value(), - std::static_pointer_cast(from.values[3])->value() + static_cast(from.values[0])->value(), + static_cast(from.values[1])->value(), + static_cast(from.values[2])->value(), + static_cast(from.values[3])->value() ), CGAL::Plane_3( - std::static_pointer_cast(to.values[0])->value(), - std::static_pointer_cast(to.values[1])->value(), - std::static_pointer_cast(to.values[2])->value(), - std::static_pointer_cast(to.values[3])->value() + static_cast(to.values[0])->value(), + static_cast(to.values[1])->value(), + static_cast(to.values[2])->value(), + static_cast(to.values[3])->value() ) }); auto nw = shape_->map(mp); @@ -674,16 +736,16 @@ void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::map(const std::vec auto& to = *jt; mp.insert({ CGAL::Plane_3( - std::static_pointer_cast(from.values[0])->value(), - std::static_pointer_cast(from.values[1])->value(), - std::static_pointer_cast(from.values[2])->value(), - std::static_pointer_cast(from.values[3])->value() + static_cast(from.values[0])->value(), + static_cast(from.values[1])->value(), + static_cast(from.values[2])->value(), + static_cast(from.values[3])->value() ), CGAL::Plane_3( - std::static_pointer_cast(to.values[0])->value(), - std::static_pointer_cast(to.values[1])->value(), - std::static_pointer_cast(to.values[2])->value(), - std::static_pointer_cast(to.values[3])->value() + static_cast(to.values[0])->value(), + static_cast(to.values[1])->value(), + static_cast(to.values[2])->value(), + static_cast(to.values[3])->value() ) }); } diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.h b/src/ifcgeom/kernels/cgal/CgalConversionResult.h index 2764ba5230..d6c1148175 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.h +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.h @@ -132,10 +132,18 @@ namespace ifcopenshell { namespace geometry { NumberEpeck(const CGAL::Epeck::FT& v) : value_(v) {} + virtual ~NumberEpeck() { } + virtual double to_double() const { return CGAL::to_double(value_); } + virtual std::string to_string() const { + std::stringstream ss; + ss << value_.exact(); + return ss.str(); + } + const CGAL::Epeck::FT& value() const { return value_; } @@ -161,6 +169,9 @@ namespace ifcopenshell { namespace geometry { virtual OpaqueNumber* operator-() const { return unary_op>(); } + virtual OpaqueNumber* clone() const { + return new NumberEpeck(value_); + } }; #endif @@ -217,9 +228,9 @@ namespace ifcopenshell { namespace geometry { // @todo this must be something with a virtual dtor so that we can delete it. virtual std::pair, OpaqueCoordinate<3>> bounding_box() const; - virtual std::shared_ptr length(); - virtual std::shared_ptr area(); - virtual std::shared_ptr volume(); + virtual OpaqueNumber* length(); + virtual OpaqueNumber* area(); + virtual OpaqueNumber* volume(); virtual OpaqueCoordinate<3> position(); virtual OpaqueCoordinate<3> axis(); @@ -229,6 +240,8 @@ namespace ifcopenshell { namespace geometry { virtual ConversionResultShape* halfspaces(); virtual ConversionResultShape* solid(); virtual ConversionResultShape* box(); + + virtual std::vector vertices(); virtual std::vector edges(); virtual std::vector facets(); @@ -274,9 +287,9 @@ namespace ifcopenshell { namespace geometry { virtual std::pair, OpaqueCoordinate<3>> bounding_box() const; virtual void set_box(void* b); - virtual std::shared_ptr length(); - virtual std::shared_ptr area(); - virtual std::shared_ptr volume(); + virtual OpaqueNumber* length(); + virtual OpaqueNumber* area(); + virtual OpaqueNumber* volume(); virtual OpaqueCoordinate<3> position(); virtual OpaqueCoordinate<3> axis(); @@ -286,6 +299,8 @@ namespace ifcopenshell { namespace geometry { virtual ConversionResultShape* halfspaces(); virtual ConversionResultShape* solid(); virtual ConversionResultShape* box(); + + virtual std::vector vertices(); virtual std::vector edges(); virtual std::vector facets(); diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp index 02edc17a4f..0bedee7355 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp @@ -257,28 +257,28 @@ int ifcopenshell::geometry::OpenCascadeShape::num_faces() const return IfcGeom::util::count(shape_, TopAbs_FACE); } -std::shared_ptr ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape::length() +OpaqueNumber* ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape::length() { GProp_GProps prop; BRepGProp::LinearProperties(shape_, prop); double l = prop.Mass(); - return std::make_shared(l); + return new NumberNativeDouble(l); } -std::shared_ptr ifcopenshell::geometry::OpenCascadeShape::area() +OpaqueNumber* ifcopenshell::geometry::OpenCascadeShape::area() { GProp_GProps prop; BRepGProp::SurfaceProperties(shape_, prop); double l = prop.Mass(); - return std::make_shared(l); + return new NumberNativeDouble(l); } -std::shared_ptr ifcopenshell::geometry::OpenCascadeShape::volume() +OpaqueNumber* ifcopenshell::geometry::OpenCascadeShape::volume() { GProp_GProps prop; BRepGProp::VolumeProperties(shape_, prop); double l = prop.Mass(); - return std::make_shared(l); + return new NumberNativeDouble(l); } #include @@ -291,9 +291,9 @@ OpaqueCoordinate<3> ifcopenshell::geometry::OpenCascadeShape::position() if (plane) { auto loc = plane->Location(); return OpaqueCoordinate<3>( - std::make_shared(loc.X()), - std::make_shared(loc.Y()), - std::make_shared(loc.Z()) + new NumberNativeDouble(loc.X()), + new NumberNativeDouble(loc.Y()), + new NumberNativeDouble(loc.Z()) ); } } @@ -308,9 +308,9 @@ OpaqueCoordinate<3> ifcopenshell::geometry::OpenCascadeShape::axis() if (plane) { auto dir = plane->Axis().Direction(); return OpaqueCoordinate<3>( - std::make_shared(dir.X()), - std::make_shared(dir.Y()), - std::make_shared(dir.Z()) + new NumberNativeDouble(dir.X()), + new NumberNativeDouble(dir.Y()), + new NumberNativeDouble(dir.Z()) ); } } @@ -326,10 +326,10 @@ OpaqueCoordinate<4> ifcopenshell::geometry::OpenCascadeShape::plane_equation() double a, b, c, d; plane->Pln().Coefficients(a, b, c, d); return OpaqueCoordinate<4>( - std::make_shared(a), - std::make_shared(b), - std::make_shared(c), - std::make_shared(d) + new NumberNativeDouble(a), + new NumberNativeDouble(b), + new NumberNativeDouble(c), + new NumberNativeDouble(d) ); } } @@ -356,6 +356,17 @@ ConversionResultShape * ifcopenshell::geometry::OpenCascadeShape::box() throw std::runtime_error("Not implemented"); } +std::vector ifcopenshell::geometry::OpenCascadeShape::vertices() +{ + TopTools_IndexedMapOfShape map; + TopExp::MapShapes(shape_, TopAbs_VERTEX, map); + std::vector vec; + for (int i = 1; i <= map.Extent(); ++i) { + vec.push_back(new OpenCascadeShape(map.FindKey(i))); + } + return vec; +} + std::vector ifcopenshell::geometry::OpenCascadeShape::edges() { TopTools_IndexedMapOfShape map; diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h index a113573599..4b4e224a3b 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h @@ -75,9 +75,9 @@ namespace ifcopenshell { // @todo this must be something with a virtual dtor so that we can delete it. virtual std::pair, OpaqueCoordinate<3>> bounding_box() const; - virtual std::shared_ptr length(); - virtual std::shared_ptr area(); - virtual std::shared_ptr volume(); + virtual OpaqueNumber* length(); + virtual OpaqueNumber* area(); + virtual OpaqueNumber* volume(); virtual OpaqueCoordinate<3> position(); virtual OpaqueCoordinate<3> axis(); @@ -87,6 +87,8 @@ namespace ifcopenshell { virtual ConversionResultShape* halfspaces(); virtual ConversionResultShape* solid(); virtual ConversionResultShape* box(); + + virtual std::vector vertices(); virtual std::vector edges(); virtual std::vector facets(); diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 08e62609e6..90e066851b 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -58,6 +58,8 @@ } } +%newobject IfcGeom::Representation::BRep::item; + %newobject IfcGeom::ConversionResultShape::halfspaces; %newobject IfcGeom::ConversionResultShape::box; %newobject IfcGeom::ConversionResultShape::solid; @@ -65,8 +67,18 @@ %newobject IfcGeom::ConversionResultShape::subtract; %newobject IfcGeom::ConversionResultShape::intersect; %newobject IfcGeom::ConversionResultShape::moved; + +%newobject IfcGeom::ConversionResultShape::area; +%newobject IfcGeom::ConversionResultShape::volume; +%newobject IfcGeom::ConversionResultShape::length; + %newobject nary_union; +%newobject IfcGeom::OpaqueNumber::operator+; +%newobject IfcGeom::OpaqueNumber::operator-; +%newobject IfcGeom::OpaqueNumber::operator*; +%newobject IfcGeom::OpaqueNumber::operator/; + %include "../ifcgeom/ifc_geom_api.h" %include "../ifcgeom/Converter.h" %include "../ifcgeom/ConversionResult.h" @@ -640,15 +652,23 @@ struct ShapeRTTI : public boost::static_visitor %template(OpaqueCoordinate_3) IfcGeom::OpaqueCoordinate<3>; %template(OpaqueCoordinate_4) IfcGeom::OpaqueCoordinate<4>; +%newobject create_epeck; + %inline %{ - std::shared_ptr create_epeck(int i) { - return std::make_shared(i); + IfcGeom::OpaqueNumber* create_epeck(int i) { + return new ifcopenshell::geometry::NumberEpeck(i); + } + IfcGeom::OpaqueNumber* create_epeck(double d) { + return new ifcopenshell::geometry::NumberEpeck(d); + } + IfcGeom::OpaqueNumber* create_epeck(const std::string& s) { + return new ifcopenshell::geometry::NumberEpeck(typename CGAL::Epeck::FT::ET(s)); } %} %inline %{ IfcGeom::ConversionResultShape* nary_union(PyObject* sequence) { - CGAL::Nef_nary_union_3< CGAL::Nef_polyhedron_3 > accum; + CGAL::Nef_nary_union_3< CGAL::Nef_polyhedron_3 > accum; for(Py_ssize_t i = 0; i < PySequence_Size(sequence); ++i) { PyObject* element = PySequence_GetItem(sequence, i); void* argp1 = nullptr; diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index a35b97c4d3..5ed90d6456 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -52,9 +52,7 @@ %include "std_vector.i" %include "std_string.i" %include "exception.i" -%include "std_shared_ptr.i" -%shared_ptr(IfcGeom::OpaqueNumber); %ignore IfcGeom::NumberNativeDouble; %ignore ifcopenshell::geometry::Converter;