mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
Small conv result number tweaks
This commit is contained in:
@@ -95,7 +95,8 @@ namespace IfcGeom {
|
||||
virtual std::shared_ptr<const NumberConcept> divide(const NumberConcept& other) const = 0;
|
||||
virtual std::shared_ptr<const NumberConcept> negate() const = 0;
|
||||
virtual std::shared_ptr<const NumberConcept> from_double(double value) const = 0;
|
||||
virtual bool equals(const NumberConcept& other) const = 0;
|
||||
virtual std::shared_ptr<const NumberConcept> from_int(int value) const = 0;
|
||||
virtual bool equals(const NumberConcept& other) const = 0;
|
||||
virtual bool less_than(const NumberConcept& other) const = 0;
|
||||
virtual const std::type_info& type() const = 0;
|
||||
virtual const void* value_ptr() const = 0;
|
||||
@@ -165,6 +166,10 @@ namespace IfcGeom {
|
||||
return std::make_shared<NumberModel>(T(v));
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<const NumberConcept> from_int(int v) const {
|
||||
return std::make_shared<NumberModel>(T(v));
|
||||
}
|
||||
|
||||
virtual bool equals(const NumberConcept& other) const {
|
||||
return value == as_same(other).value;
|
||||
}
|
||||
@@ -255,10 +260,19 @@ namespace IfcGeom {
|
||||
return OpaqueNumber(data().negate());
|
||||
}
|
||||
|
||||
OpaqueNumber abs() const {
|
||||
auto zero = data().from_int(0);
|
||||
return OpaqueNumber(data().less_than(*zero) ? data().negate() : *this);
|
||||
}
|
||||
|
||||
OpaqueNumber same_type(double value) const {
|
||||
return OpaqueNumber(data().from_double(value));
|
||||
}
|
||||
|
||||
OpaqueNumber same_type(int value) const {
|
||||
return OpaqueNumber(data().from_int(value));
|
||||
}
|
||||
|
||||
bool equals(const OpaqueNumber& other) const {
|
||||
return data().equals(other.data());
|
||||
}
|
||||
@@ -336,7 +350,7 @@ namespace IfcGeom {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<double> to_doubles() const {
|
||||
std::vector<double> to_double() const {
|
||||
std::vector<double> result;
|
||||
result.reserve(N);
|
||||
for (const auto& value : values_) {
|
||||
@@ -436,6 +450,8 @@ namespace IfcGeom {
|
||||
|
||||
class IFC_GEOM_API ConversionResultShape {
|
||||
public:
|
||||
virtual std::string type() const = 0;
|
||||
|
||||
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const = 0;
|
||||
IfcGeom::Representation::Triangulation* Triangulate(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()) const;
|
||||
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const = 0;
|
||||
|
||||
@@ -146,6 +146,10 @@ namespace ifcopenshell { namespace geometry {
|
||||
return std::make_shared<Model>(CGAL::Epeck::FT(v));
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<const NumberConcept> from_int(int v) const {
|
||||
return std::make_shared<Model>(CGAL::Epeck::FT(v));
|
||||
}
|
||||
|
||||
virtual bool equals(const NumberConcept& other) const {
|
||||
return value == as_same(other).value;
|
||||
}
|
||||
@@ -182,7 +186,13 @@ namespace ifcopenshell { namespace geometry {
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
mutable boost::optional<CGAL::Nef_polyhedron_3<Kernel_>> nef_;
|
||||
#endif
|
||||
public:
|
||||
public:
|
||||
#ifdef IFOPSH_SIMPLE_KERNEL
|
||||
std::string type() const override { return "CgalSimpleShape"; }
|
||||
#else
|
||||
std::string type() const override { return "CgalShape"; }
|
||||
#endif
|
||||
|
||||
CgalShape(const cgal_shape_t& shape, bool convex = false, Logger& logger = Logger::Root());
|
||||
CgalShape(const cgal_point_t& point, bool convex = false);
|
||||
CgalShape(const cgal_wire_t& wire, bool convex = false);
|
||||
@@ -287,6 +297,8 @@ namespace ifcopenshell { namespace geometry {
|
||||
std::list<CGAL::Plane_3<Kernel_>> planes_;
|
||||
|
||||
public:
|
||||
std::string type() const override { return "CgalShapeHalfSpaceDecomposition"; }
|
||||
|
||||
CgalShapeHalfSpaceDecomposition(const CGAL::Nef_polyhedron_3<Kernel_>& shape, bool is_convex) {
|
||||
if (is_convex) {
|
||||
shape_ = std::move(build_halfspace_tree_is_decomposed(shape, planes_));
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace ifcopenshell {
|
||||
|
||||
class IFC_GEOMLIBRARY_API OpenCascadeShape : public IfcGeom::ConversionResultShape {
|
||||
public:
|
||||
std::string type() const override { return "OpenCascadeShape"; }
|
||||
|
||||
OpenCascadeShape(const TopoDS_Shape& shape)
|
||||
: shape_(shape) {}
|
||||
OpenCascadeShape(TopoDS_Shape&& shape)
|
||||
|
||||
@@ -1170,6 +1170,20 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type
|
||||
%template(svg_loop) std::vector<std::array<double, 2>>;
|
||||
%template(svg_loops) std::vector<std::vector<std::array<double, 2>>>;
|
||||
|
||||
%extend IfcGeom::OpaqueCoordinate {
|
||||
%pythoncode %{
|
||||
__len__ = size
|
||||
def __iter__(self):
|
||||
yield from (self.get(i) for i in range(len(self)))
|
||||
%}
|
||||
}
|
||||
|
||||
%extend IfcGeom::OpaqueNumber {
|
||||
%pythoncode %{
|
||||
__abs__ = abs
|
||||
%}
|
||||
}
|
||||
|
||||
%template(OpaqueCoordinate_3) IfcGeom::OpaqueCoordinate<3>;
|
||||
%template(OpaqueCoordinate_4) IfcGeom::OpaqueCoordinate<4>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user