Flatten the geometry representation namespace

Generated with the assistance of an AI coding tool.
This commit is contained in:
Thomas Krijnen
2026-08-08 15:56:41 +02:00
parent 616c7a00d5
commit 2ba55ba984
23 changed files with 77 additions and 82 deletions
+1 -1
View File
@@ -1405,7 +1405,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st
express::base quantity; express::base quantity;
std::vector<express::base> objects; std::vector<express::base> objects;
std::shared_ptr<ifcopenshell::geom::Representation::brep> previous_geometry_pointer; std::shared_ptr<ifcopenshell::geom::brep> previous_geometry_pointer;
for (;; ++num_created) { for (;; ++num_created) {
bool has_more = true; bool has_more = true;
+2 -2
View File
@@ -1,9 +1,9 @@
#include "conversion_result.h" #include "conversion_result.h"
#include "representation.h" #include "representation.h"
ifcopenshell::geom::Representation::triangulation* ifcopenshell::geom::conversion_result_shape::Triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger) const ifcopenshell::geom::triangulation* ifcopenshell::geom::conversion_result_shape::Triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger) const
{ {
auto t = ifcopenshell::geom::Representation::triangulation::empty(settings); auto t = ifcopenshell::geom::triangulation::empty(settings);
static ifcopenshell::geom::taxonomy::matrix4 iden; static ifcopenshell::geom::taxonomy::matrix4 iden;
Triangulate(settings, iden, t, -1, -1, logger); Triangulate(settings, iden, t, -1, -1, logger);
return t; return t;
+3 -5
View File
@@ -82,9 +82,7 @@ namespace std {
namespace ifcopenshell::geom { namespace ifcopenshell::geom {
namespace Representation { class IFC_GEOM_API triangulation;
class IFC_GEOM_API triangulation;
}
#ifndef SWIG #ifndef SWIG
template <typename T> template <typename T>
@@ -509,8 +507,8 @@ namespace ifcopenshell::geom {
#else #else
virtual std::string_view backend_id() const = 0; virtual std::string_view backend_id() const = 0;
#endif #endif
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const = 0; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const = 0;
ifcopenshell::geom::Representation::triangulation* Triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const; ifcopenshell::geom::triangulation* Triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const = 0; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const = 0;
virtual int surface_genus() const = 0; virtual int surface_genus() const = 0;
+3 -3
View File
@@ -44,7 +44,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
representation_id_builder << representation_node->instance.id(); representation_id_builder << representation_node->instance.id();
ifcopenshell::geom::Representation::brep* shape; ifcopenshell::geom::brep* shape;
std::vector<ifcopenshell::geom::conversion_result> shapes; std::vector<ifcopenshell::geom::conversion_result> shapes;
if (!kernel_->convert(representation_node, shapes)) { if (!kernel_->convert(representation_node, shapes)) {
@@ -254,7 +254,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
} }
} }
shape = new ifcopenshell::geom::Representation::brep(settings_, product_type, representation_id_builder.str(), shapes); shape = new ifcopenshell::geom::brep(settings_, product_type, representation_id_builder.str(), shapes);
std::string context_string = ""; std::string context_string = "";
@@ -280,7 +280,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
guid, guid,
context_string, context_string,
place, place,
std::shared_ptr<ifcopenshell::geom::Representation::brep>(shape), std::shared_ptr<ifcopenshell::geom::brep>(shape),
product product
); );
+1 -1
View File
@@ -16,7 +16,7 @@ namespace ifcopenshell { namespace geom {
class IFC_GEOM_API converter { class IFC_GEOM_API converter {
public: public:
typedef std::shared_ptr<ifcopenshell::geom::Representation::brep> brep_ptr; typedef std::shared_ptr<ifcopenshell::geom::brep> brep_ptr;
private: private:
ifcopenshell::geom::abstract_mapping* mapping_; ifcopenshell::geom::abstract_mapping* mapping_;
std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel> kernel_; std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel> kernel_;
+12 -12
View File
@@ -160,12 +160,12 @@ namespace ifcopenshell::geom {
class brep_element : public element { class brep_element : public element {
private: private:
std::shared_ptr<ifcopenshell::geom::Representation::brep> _geometry; std::shared_ptr<ifcopenshell::geom::brep> _geometry;
public: public:
const std::shared_ptr<ifcopenshell::geom::Representation::brep>& geometry_pointer() const { return _geometry; } const std::shared_ptr<ifcopenshell::geom::brep>& geometry_pointer() const { return _geometry; }
const ifcopenshell::geom::Representation::brep& geometry() const { return *_geometry; } const ifcopenshell::geom::brep& geometry() const { return *_geometry; }
brep_element(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid, brep_element(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid,
const std::string& context, const ifcopenshell::geom::taxonomy::matrix4::ptr& trsf, const std::shared_ptr<ifcopenshell::geom::Representation::brep>& geometry, const std::string& context, const ifcopenshell::geom::taxonomy::matrix4::ptr& trsf, const std::shared_ptr<ifcopenshell::geom::brep>& geometry,
const express::entity& product) const express::entity& product)
: element(geometry->settings(), id, parent_id, name, type, guid, context, trsf, product) : element(geometry->settings(), id, parent_id, name, type, guid, context, trsf, product)
, _geometry(geometry) , _geometry(geometry)
@@ -182,15 +182,15 @@ namespace ifcopenshell::geom {
class triangulation_element : public element { class triangulation_element : public element {
private: private:
std::shared_ptr< ifcopenshell::geom::Representation::triangulation > _geometry; std::shared_ptr< ifcopenshell::geom::triangulation > _geometry;
public: public:
const ifcopenshell::geom::Representation::triangulation& geometry() const { return *_geometry; } const ifcopenshell::geom::triangulation& geometry() const { return *_geometry; }
const std::shared_ptr< ifcopenshell::geom::Representation::triangulation>& geometry_pointer() const { return _geometry; } const std::shared_ptr< ifcopenshell::geom::triangulation>& geometry_pointer() const { return _geometry; }
triangulation_element(const ifcopenshell::geom::brep_element& shape_model) triangulation_element(const ifcopenshell::geom::brep_element& shape_model)
: element(shape_model) : element(shape_model)
, _geometry(std::make_shared<ifcopenshell::geom::Representation::triangulation>(shape_model.geometry())) , _geometry(std::make_shared<ifcopenshell::geom::triangulation>(shape_model.geometry()))
{} {}
triangulation_element(const ifcopenshell::geom::element& source, const std::shared_ptr<ifcopenshell::geom::Representation::triangulation>& geometry) triangulation_element(const ifcopenshell::geom::element& source, const std::shared_ptr<ifcopenshell::geom::triangulation>& geometry)
: element(source) : element(source)
, _geometry(geometry) , _geometry(geometry)
{} {}
@@ -202,12 +202,12 @@ namespace ifcopenshell::geom {
class serialized_element : public element { class serialized_element : public element {
private: private:
std::shared_ptr<ifcopenshell::geom::Representation::serialization> _geometry; std::shared_ptr<ifcopenshell::geom::serialization> _geometry;
public: public:
const ifcopenshell::geom::Representation::serialization& geometry() const { return *_geometry; } const ifcopenshell::geom::serialization& geometry() const { return *_geometry; }
serialized_element(const brep_element& shape_model) serialized_element(const brep_element& shape_model)
: element(shape_model) : element(shape_model)
, _geometry(std::make_shared<ifcopenshell::geom::Representation::serialization>(shape_model.geometry())) , _geometry(std::make_shared<ifcopenshell::geom::serialization>(shape_model.geometry()))
{} {}
serialized_element(const serialized_element& other) = default; serialized_element(const serialized_element& other) = default;
private: private:
+1 -1
View File
@@ -303,7 +303,7 @@ void ifcopenshell::geom::iterator::compute_bounds(bool with_geometry)
do { do {
auto geom_object = get(); auto geom_object = get();
const ifcopenshell::geom::triangulation_element* o = static_cast<const ifcopenshell::geom::triangulation_element*>(geom_object.get()); const ifcopenshell::geom::triangulation_element* o = static_cast<const ifcopenshell::geom::triangulation_element*>(geom_object.get());
const ifcopenshell::geom::Representation::triangulation& mesh = o->geometry(); const ifcopenshell::geom::triangulation& mesh = o->geometry();
auto mat = o->transformation().data()->ccomponents(); auto mat = o->transformation().data()->ccomponents();
Eigen::Vector4d vec, transformed; Eigen::Vector4d vec, transformed;
+1 -1
View File
@@ -22,7 +22,7 @@
* Geometrical data in an IFC file consists of shapes (IfcShapeRepresentation) * * Geometrical data in an IFC file consists of shapes (IfcShapeRepresentation) *
* and instances (SUBTYPE OF IfcBuildingElement e.g. IfcWindow). * * and instances (SUBTYPE OF IfcBuildingElement e.g. IfcWindow). *
* * * *
* ifcopenshell::geom::Representation::triangulation is a class that represents a * * ifcopenshell::geom::triangulation is a class that represents a *
* triangulated IfcShapeRepresentation. * * triangulated IfcShapeRepresentation. *
* Triangulation.verts is a 1 dimensional vector of float defining the * * Triangulation.verts is a 1 dimensional vector of float defining the *
* cartesian coordinates of the vertices of the triangulated shape in the * * cartesian coordinates of the vertices of the triangulated shape in the *
@@ -364,7 +364,7 @@ void ifcopenshell::geom::cgal_shape::to_nef() const {
} }
#endif #endif
void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const { void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
if (is_point() || is_wire()) { if (is_point() || is_wire()) {
return; return;
} }
@@ -1035,7 +1035,7 @@ bool ifcopenshell::geom::cgal_shape::surface_area_along_direction(double tol, co
#ifndef IFOPSH_SIMPLE_KERNEL #ifndef IFOPSH_SIMPLE_KERNEL
void ifcopenshell::geom::cgal_shape_half_space_decomposition::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const { void ifcopenshell::geom::cgal_shape_half_space_decomposition::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
throw std::runtime_error("Not implemented"); throw std::runtime_error("Not implemented");
} }
@@ -226,7 +226,7 @@ namespace ifcopenshell { namespace geom {
const cgal_point& point() const { return std::get<cgal_point>(*shape_); } const cgal_point& point() const { return std::get<cgal_point>(*shape_); }
const cgal_wire& wire() const { return std::get<cgal_wire>(*shape_); } const cgal_wire& wire() const { return std::get<cgal_wire>(*shape_); }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual ifcopenshell::geom::conversion_result_shape* clone() const { virtual ifcopenshell::geom::conversion_result_shape* clone() const {
@@ -319,7 +319,7 @@ namespace ifcopenshell { namespace geom {
#endif #endif
} }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const; virtual int surface_genus() const;
@@ -215,7 +215,7 @@ std::optional<manifold::Manifold> ifcopenshell::geom::manifold_shape::as_manifol
return manifold::Manifold::BatchBoolean(solids, manifold::OpType::Add); return manifold::Manifold::BatchBoolean(solids, manifold::OpType::Add);
} }
void ifcopenshell::geom::manifold_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const { void ifcopenshell::geom::manifold_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const {
for (const auto& part : parts_) { for (const auto& part : parts_) {
auto mesh = transform_mesh(part.mesh, place); auto mesh = transform_mesh(part.mesh, place);
std::vector<int> indices(mesh.NumVert()); std::vector<int> indices(mesh.NumVert());
@@ -40,7 +40,7 @@ public:
std::optional<manifold::Manifold> as_manifold() const; std::optional<manifold::Manifold> as_manifold() const;
virtual std::string_view backend_id() const { return "manifold"; } virtual std::string_view backend_id() const { return "manifold"; }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const; virtual int surface_genus() const;
@@ -68,7 +68,7 @@ ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::open_cascade_sh
return new open_cascade_shape(shape_); return new open_cascade_shape(shape_);
} }
void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const { void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
// @todo remove duplication with open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf); // @todo remove duplication with open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
// above can be static? // above can be static?
@@ -257,7 +257,7 @@ void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::set
} }
if (!t->normals().empty() && settings.get<settings::GenerateUvs>().get()) { if (!t->normals().empty() && settings.get<settings::GenerateUvs>().get()) {
t->uvs_ref() = ifcopenshell::geom::Representation::triangulation::box_project_uvs(t->verts(), t->normals()); t->uvs_ref() = ifcopenshell::geom::triangulation::box_project_uvs(t->verts(), t->normals());
} }
if (num_faces == 0) { if (num_faces == 0) {
@@ -49,7 +49,7 @@ namespace ifcopenshell {
operator const TopoDS_Shape& (); operator const TopoDS_Shape& ();
virtual std::string_view backend_id() const; virtual std::string_view backend_id() const;
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual ifcopenshell::geom::conversion_result_shape* clone() const; virtual ifcopenshell::geom::conversion_result_shape* clone() const;
@@ -374,7 +374,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// //
// representation_id_builder << representation->data().id(); // representation_id_builder << representation->data().id();
// //
// ifcopenshell::geom::Representation::brep* shape; // ifcopenshell::geom::brep* shape;
// std::vector<ifcopenshell::geom::conversion_result> shapes, shapes2; // std::vector<ifcopenshell::geom::conversion_result> shapes, shapes2;
// //
// if (!convert_shapes(representation, shapes)) { // if (!convert_shapes(representation, shapes)) {
@@ -524,16 +524,16 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// trsf = gp_Trsf(); // trsf = gp_Trsf();
// representation_id_builder << "-world-coords"; // representation_id_builder << "-world-coords";
// } // }
// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), opened_shapes); // shape = new ifcopenshell::geom::brep(element_settings, representation_id_builder.str(), opened_shapes);
// } else if (settings.get(IteratorSettings::USE_WORLD_COORDS)) { // } else if (settings.get(IteratorSettings::USE_WORLD_COORDS)) {
// for (std::vector<ifcopenshell::geom::conversion_result>::iterator it = shapes.begin(); it != shapes.end(); ++it) { // for (std::vector<ifcopenshell::geom::conversion_result>::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// it->prepend(trsf); // it->prepend(trsf);
// } // }
// trsf = gp_Trsf(); // trsf = gp_Trsf();
// representation_id_builder << "-world-coords"; // representation_id_builder << "-world-coords";
// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), shapes); // shape = new ifcopenshell::geom::brep(element_settings, representation_id_builder.str(), shapes);
// } else { // } else {
// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), shapes); // shape = new ifcopenshell::geom::brep(element_settings, representation_id_builder.str(), shapes);
// } // }
// //
// std::string context_string = ""; // std::string context_string = "";
@@ -551,7 +551,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// guid, // guid,
// context_string, // context_string,
// trsf, // trsf,
// std::shared_ptr<ifcopenshell::geom::Representation::brep>(shape), // std::shared_ptr<ifcopenshell::geom::brep>(shape),
// product // product
// ); // );
// //
@@ -286,7 +286,7 @@ ifcopenshell::geom::passthrough_shape::passthrough_shape(const std::vector<passt
ifcopenshell::geom::passthrough_shape::passthrough_shape(std::vector<passthrough_part>&& parts) ifcopenshell::geom::passthrough_shape::passthrough_shape(std::vector<passthrough_part>&& parts)
: parts_(normalize_parts(parts)) {} : parts_(normalize_parts(parts)) {}
void ifcopenshell::geom::passthrough_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const { void ifcopenshell::geom::passthrough_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const {
auto mesh = build_mesh(parts_, &place); auto mesh = build_mesh(parts_, &place);
std::vector<int> indices(mesh.vertices.size()); std::vector<int> indices(mesh.vertices.size());
for (size_t i = 0; i < mesh.vertices.size(); ++i) { for (size_t i = 0; i < mesh.vertices.size(); ++i) {
@@ -24,7 +24,7 @@ public:
const std::vector<passthrough_part>& parts() const { return parts_; } const std::vector<passthrough_part>& parts() const { return parts_; }
virtual std::string_view backend_id() const { return "passthrough"; } virtual std::string_view backend_id() const { return "passthrough"; }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const; virtual int surface_genus() const;
+11 -11
View File
@@ -19,7 +19,7 @@
#include "representation.h" #include "representation.h"
ifcopenshell::geom::Representation::serialization::serialization(const brep& brep) ifcopenshell::geom::serialization::serialization(const brep& brep)
: representation(brep.settings(), brep.entity(), brep.id()) : representation(brep.settings(), brep.entity(), brep.id())
{ {
for (auto it = brep.begin(); it != brep.end(); ++it) { for (auto it = brep.begin(); it != brep.end(); ++it) {
@@ -53,7 +53,7 @@ ifcopenshell::geom::Representation::serialization::serialization(const brep& bre
delete comp; delete comp;
} }
ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::Representation::brep::as_compound(bool force_meters) const { ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::as_compound(bool force_meters) const {
conversion_result_shape* accum = nullptr; conversion_result_shape* accum = nullptr;
for (auto it = begin(); it != end(); ++it) { for (auto it = begin(); it != end(); ++it) {
@@ -75,7 +75,7 @@ ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::Representation:
return accum; return accum;
} }
bool ifcopenshell::geom::Representation::brep::calculate_surface_area(double& area) const { bool ifcopenshell::geom::brep::calculate_surface_area(double& area) const {
std::unique_ptr<conversion_result_shape> s(as_compound()); std::unique_ptr<conversion_result_shape> s(as_compound());
if (!s) { if (!s) {
area = 0.; area = 0.;
@@ -85,7 +85,7 @@ bool ifcopenshell::geom::Representation::brep::calculate_surface_area(double& ar
return true; return true;
} }
bool ifcopenshell::geom::Representation::brep::calculate_volume(double& volume) const { bool ifcopenshell::geom::brep::calculate_volume(double& volume) const {
std::unique_ptr<conversion_result_shape> s(as_compound()); std::unique_ptr<conversion_result_shape> s(as_compound());
if (!s) { if (!s) {
volume = 0.; volume = 0.;
@@ -95,7 +95,7 @@ bool ifcopenshell::geom::Representation::brep::calculate_volume(double& volume)
return true; return true;
} }
bool ifcopenshell::geom::Representation::brep::calculate_projected_surface_area(const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { bool ifcopenshell::geom::brep::calculate_projected_surface_area(const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const {
along_x = along_y = along_z = 0.; along_x = along_y = along_z = 0.;
for (std::vector<ifcopenshell::geom::conversion_result>::const_iterator it = begin(); it != end(); ++it) { for (std::vector<ifcopenshell::geom::conversion_result>::const_iterator it = begin(); it != end(); ++it) {
@@ -116,7 +116,7 @@ bool ifcopenshell::geom::Representation::brep::calculate_projected_surface_area(
return true; return true;
} }
ifcopenshell::geom::Representation::triangulation::triangulation(const brep& shape_model) ifcopenshell::geom::triangulation::triangulation(const brep& shape_model)
: representation(shape_model.settings(), shape_model.entity(), shape_model.id()) : representation(shape_model.settings(), shape_model.entity(), shape_model.id())
, weld_offset_(0) , weld_offset_(0)
{ {
@@ -154,7 +154,7 @@ ifcopenshell::geom::Representation::triangulation::triangulation(const brep& sha
/// Generates UVs for a single mesh using box projection. /// Generates UVs for a single mesh using box projection.
/// @todo Very simple impl. Assumes that input vertices and normals match 1:1. /// @todo Very simple impl. Assumes that input vertices and normals match 1:1.
std::vector<double> ifcopenshell::geom::Representation::triangulation::box_project_uvs(const std::vector<double>& vertices, const std::vector<double>& normals) std::vector<double> ifcopenshell::geom::triangulation::box_project_uvs(const std::vector<double>& vertices, const std::vector<double>& normals)
{ {
std::vector<double> uvs; std::vector<double> uvs;
uvs.resize(vertices.size() / 3 * 2); uvs.resize(vertices.size() / 3 * 2);
@@ -182,7 +182,7 @@ std::vector<double> ifcopenshell::geom::Representation::triangulation::box_proje
return uvs; return uvs;
} }
int ifcopenshell::geom::Representation::triangulation::addVertex(int item_id, int material_index, double pX, double pY, double pZ) { int ifcopenshell::geom::triangulation::addVertex(int item_id, int material_index, double pX, double pY, double pZ) {
const bool convert = settings().get<ifcopenshell::geom::settings::ConvertBackUnits>().get(); const bool convert = settings().get<ifcopenshell::geom::settings::ConvertBackUnits>().get();
auto unit_magnitude = settings().get<ifcopenshell::geom::settings::LengthUnit>().get(); auto unit_magnitude = settings().get<ifcopenshell::geom::settings::LengthUnit>().get();
const double X = convert ? (pX /unit_magnitude) : pX; const double X = convert ? (pX /unit_magnitude) : pX;
@@ -205,12 +205,12 @@ int ifcopenshell::geom::Representation::triangulation::addVertex(int item_id, in
return i; return i;
} }
void ifcopenshell::geom::Representation::triangulation::registerEdgeCount(int n1, int n2, std::map<std::pair<int, int>, int>& edgecount) { void ifcopenshell::geom::triangulation::registerEdgeCount(int n1, int n2, std::map<std::pair<int, int>, int>& edgecount) {
const edge e = edge((std::min)(n1, n2), (std::max)(n1, n2)); const edge e = edge((std::min)(n1, n2), (std::max)(n1, n2));
edgecount[e] ++; edgecount[e] ++;
} }
const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::Representation::brep::item(int i) const { const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::item(int i) const {
if (i >= 0 && i < shapes_.size()) { if (i >= 0 && i < shapes_.size()) {
return shapes_[i].Shape()->moved(shapes_[i].Placement()); return shapes_[i].Shape()->moved(shapes_[i].Placement());
} else { } else {
@@ -218,7 +218,7 @@ const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::Represent
} }
} }
int ifcopenshell::geom::Representation::brep::item_id(int i) const { int ifcopenshell::geom::brep::item_id(int i) const {
if (i >= 0 && i < shapes_.size()) { if (i >= 0 && i < shapes_.size()) {
return shapes_[i].ItemId(); return shapes_[i].ItemId();
} else { } else {
-3
View File
@@ -27,8 +27,6 @@
namespace ifcopenshell::geom { namespace ifcopenshell::geom {
namespace Representation {
class IFC_GEOM_API representation { class IFC_GEOM_API representation {
representation(const representation&); //N/A representation(const representation&); //N/A
representation& operator =(const representation&); //N/A representation& operator =(const representation&); //N/A
@@ -235,7 +233,6 @@ namespace ifcopenshell::geom {
triangulation& operator=(const triangulation&); triangulation& operator=(const triangulation&);
}; };
}
} }
#endif #endif
+23 -23
View File
@@ -21,7 +21,7 @@
// Keep the established Python API names while the underlying C++ types use // Keep the established Python API names while the underlying C++ types use
// snake_case. // snake_case.
%rename("BRep") ifcopenshell::geom::Representation::brep; %rename("BRep") ifcopenshell::geom::brep;
%rename("BRepElement") ifcopenshell::geom::brep_element; %rename("BRepElement") ifcopenshell::geom::brep_element;
%rename("ConversionResult") ifcopenshell::geom::conversion_result; %rename("ConversionResult") ifcopenshell::geom::conversion_result;
%rename("ConversionResultShape") ifcopenshell::geom::conversion_result_shape; %rename("ConversionResultShape") ifcopenshell::geom::conversion_result_shape;
@@ -29,12 +29,12 @@
%rename("GeometrySerializer") ifcopenshell::geom::geometry_serializer; %rename("GeometrySerializer") ifcopenshell::geom::geometry_serializer;
%rename("Iterator") ifcopenshell::geom::iterator; %rename("Iterator") ifcopenshell::geom::iterator;
%rename("OpaqueNumber") ifcopenshell::geom::opaque_number; %rename("OpaqueNumber") ifcopenshell::geom::opaque_number;
%rename("Representation") ifcopenshell::geom::Representation::representation; %rename("Representation") ifcopenshell::geom::representation;
%rename("Serialization") ifcopenshell::geom::Representation::serialization; %rename("Serialization") ifcopenshell::geom::serialization;
%rename("SerializedElement") ifcopenshell::geom::serialized_element; %rename("SerializedElement") ifcopenshell::geom::serialized_element;
%rename("Settings") ifcopenshell::geom::settings; %rename("Settings") ifcopenshell::geom::settings;
%rename("Transformation") ifcopenshell::geom::transformation; %rename("Transformation") ifcopenshell::geom::transformation;
%rename("Triangulation") ifcopenshell::geom::Representation::triangulation; %rename("Triangulation") ifcopenshell::geom::triangulation;
%rename("TriangulationElement") ifcopenshell::geom::triangulation_element; %rename("TriangulationElement") ifcopenshell::geom::triangulation_element;
%rename("WriteOnlyGeometrySerializer") ifcopenshell::geom::write_only_geometry_serializer; %rename("WriteOnlyGeometrySerializer") ifcopenshell::geom::write_only_geometry_serializer;
@@ -125,8 +125,8 @@
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1.release()), SWIGTYPE_p_ifcopenshell__geom__brep_element, SWIG_POINTER_OWN); $result = SWIG_NewPointerObj(SWIG_as_voidptr($1.release()), SWIGTYPE_p_ifcopenshell__geom__brep_element, SWIG_POINTER_OWN);
} }
%newobject ifcopenshell::geom::Representation::brep::item; %newobject ifcopenshell::geom::brep::item;
%newobject ifcopenshell::geom::Representation::brep::as_compound; %newobject ifcopenshell::geom::brep::as_compound;
%newobject ifcopenshell::geom::conversion_result_shape::halfspaces; %newobject ifcopenshell::geom::conversion_result_shape::halfspaces;
%newobject ifcopenshell::geom::conversion_result_shape::box; %newobject ifcopenshell::geom::conversion_result_shape::box;
@@ -687,10 +687,10 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
return SWIG_Py_Void(); return SWIG_Py_Void();
} }
} }
PyObject* operator()(ifcopenshell::geom::Representation::representation* representation) const { PyObject* operator()(ifcopenshell::geom::representation* representation) const {
ifcopenshell::geom::Representation::serialization* serialized_representation = dynamic_cast<ifcopenshell::geom::Representation::serialization*>(representation); ifcopenshell::geom::serialization* serialized_representation = dynamic_cast<ifcopenshell::geom::serialization*>(representation);
ifcopenshell::geom::Representation::triangulation* triangulated_representation = dynamic_cast<ifcopenshell::geom::Representation::triangulation*>(representation); ifcopenshell::geom::triangulation* triangulated_representation = dynamic_cast<ifcopenshell::geom::triangulation*>(representation);
ifcopenshell::geom::Representation::brep* brep_representation = dynamic_cast<ifcopenshell::geom::Representation::brep*>(representation); ifcopenshell::geom::brep* brep_representation = dynamic_cast<ifcopenshell::geom::brep*>(representation);
if (serialized_representation) { if (serialized_representation) {
return SWIG_NewPointerObj(SWIG_as_voidptr(serialized_representation), SWIGTYPE_p_ifcopenshell__geom__Representation__serialization, SWIG_POINTER_OWN); return SWIG_NewPointerObj(SWIG_as_voidptr(serialized_representation), SWIGTYPE_p_ifcopenshell__geom__Representation__serialization, SWIG_POINTER_OWN);
} else if (triangulated_representation) { } else if (triangulated_representation) {
@@ -708,9 +708,9 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
%} %}
// Note that these elements ARE to be owned by SWIG/Python // Note that these elements ARE to be owned by SWIG/Python
%typemap(out) std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::Representation::representation*, ifcopenshell::geom::transformation*> { %typemap(out) std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::representation*, ifcopenshell::geom::transformation*> {
// See which type is set and return appropriate // See which type is set and return appropriate
$result = std::visit(shape_rtti(), (std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::Representation::representation*, ifcopenshell::geom::transformation*>) $1); $result = std::visit(shape_rtti(), (std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::representation*, ifcopenshell::geom::transformation*>) $1);
} }
%newobject construct_iterator; %newobject construct_iterator;
@@ -782,7 +782,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
} }
%} %}
%extend ifcopenshell::geom::Representation::triangulation { %extend ifcopenshell::geom::triangulation {
std::pair<const char*, size_t> faces_buffer() const { std::pair<const char*, size_t> faces_buffer() const {
return vector_to_buffer(self->faces()); return vector_to_buffer(self->faces());
@@ -869,14 +869,14 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
%} %}
}; };
%extend ifcopenshell::geom::Representation::representation { %extend ifcopenshell::geom::representation {
%pythoncode %{ %pythoncode %{
# Hide the getters with read-only property implementations # Hide the getters with read-only property implementations
id = property(id) id = property(id)
%} %}
}; };
%extend ifcopenshell::geom::Representation::serialization { %extend ifcopenshell::geom::serialization {
%pythoncode %{ %pythoncode %{
# Hide the getters with read-only property implementations # Hide the getters with read-only property implementations
brep_data = property(brep_data) brep_data = property(brep_data)
@@ -983,7 +983,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
return oss.str(); return oss.str();
} }
static std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::Representation::representation*, ifcopenshell::geom::transformation*> helper_fn_create_shape(logger& logger, const std::string& geometry_library, ifcopenshell::geom::settings& settings, const express::base& instance, const express::base& representation = express::base()) { static std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::representation*, ifcopenshell::geom::transformation*> helper_fn_create_shape(logger& logger, const std::string& geometry_library, ifcopenshell::geom::settings& settings, const express::base& instance, const express::base& representation = express::base()) {
ifcopenshell::file* file = instance.file(); ifcopenshell::file* file = instance.file();
ifcopenshell::geom::converter kernel(ifcopenshell::geom::kernels::construct(file, geometry_library, settings), file, settings, logger); ifcopenshell::geom::converter kernel(ifcopenshell::geom::kernels::construct(file, geometry_library, settings), file, settings, logger);
@@ -1045,12 +1045,12 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
throw ifcopenshell::exception("Failed to process shape. Instance: " + oss.str()); throw ifcopenshell::exception("Failed to process shape. Instance: " + oss.str());
} }
ifcopenshell::geom::Representation::brep brep(kernel.settings(), instance.declaration().name(), to_locale_invariant_string(instance.id()), shapes); ifcopenshell::geom::brep brep(kernel.settings(), instance.declaration().name(), to_locale_invariant_string(instance.id()), shapes);
try { try {
if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::SERIALIZED) { if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::SERIALIZED) {
return new ifcopenshell::geom::Representation::serialization(brep); return new ifcopenshell::geom::serialization(brep);
} else if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::TRIANGULATED) { } else if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::TRIANGULATED) {
return new ifcopenshell::geom::Representation::triangulation(brep); return new ifcopenshell::geom::triangulation(brep);
} }
} catch (...) { } catch (...) {
throw ifcopenshell::exception("error during shape serialization"); throw ifcopenshell::exception("error during shape serialization");
@@ -1060,7 +1060,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
throw ifcopenshell::exception("Invalid additional representation specified"); throw ifcopenshell::exception("Invalid additional representation specified");
} }
} }
return std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::Representation::representation*, ifcopenshell::geom::transformation*>(); return std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::representation*, ifcopenshell::geom::transformation*>();
} }
%} %}
@@ -1099,12 +1099,12 @@ ifcopenshell::geom::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type_inf
%} %}
%inline %{ %inline %{
static std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::Representation::representation*, ifcopenshell::geom::transformation*> create_shape(ifcopenshell::geom::settings& settings, const express::base& instance, const express::base& representation, const char* const geometry_library="opencascade", ifcopenshell::logger* logger = nullptr) { static std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::representation*, ifcopenshell::geom::transformation*> create_shape(ifcopenshell::geom::settings& settings, const express::base& instance, const express::base& representation, const char* const geometry_library="opencascade", ifcopenshell::logger* logger = nullptr) {
return helper_fn_create_shape(ifcopenshell::logger_or_root(logger), geometry_library, settings, instance, representation); return helper_fn_create_shape(ifcopenshell::logger_or_root(logger), geometry_library, settings, instance, representation);
} }
// Manual definition of overload without representation argument // Manual definition of overload without representation argument
static std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::Representation::representation*, ifcopenshell::geom::transformation*> create_shape(ifcopenshell::geom::settings& settings, const express::base& instance, const char* const geometry_library="opencascade", ifcopenshell::logger* logger = nullptr) { static std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::representation*, ifcopenshell::geom::transformation*> create_shape(ifcopenshell::geom::settings& settings, const express::base& instance, const char* const geometry_library="opencascade", ifcopenshell::logger* logger = nullptr) {
return create_shape(settings, instance, express::base(), geometry_library, logger); return create_shape(settings, instance, express::base(), geometry_library, logger);
} }
%} %}
@@ -1168,7 +1168,7 @@ ifcopenshell::geom::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type_inf
%extend ifcopenshell::geom::conversion_result_shape { %extend ifcopenshell::geom::conversion_result_shape {
std::string serialize_obj() { std::string serialize_obj() {
ifcopenshell::geom::settings settings; ifcopenshell::geom::settings settings;
std::unique_ptr<ifcopenshell::geom::Representation::triangulation> triangulation($self->Triangulate(settings)); std::unique_ptr<ifcopenshell::geom::triangulation> triangulation($self->Triangulate(settings));
std::ostringstream result; std::ostringstream result;
for (auto it = triangulation->verts().begin(); it != triangulation->verts().end();) { for (auto it = triangulation->verts().begin(); it != triangulation->verts().end();) {
+1 -1
View File
@@ -386,7 +386,7 @@ void collada_serializer::collada_exporter::startDocument(const std::string& unit
void collada_serializer::collada_exporter::write(const ifcopenshell::geom::triangulation_element* o) void collada_serializer::collada_exporter::write(const ifcopenshell::geom::triangulation_element* o)
{ {
const ifcopenshell::geom::Representation::triangulation& mesh = o->geometry(); const ifcopenshell::geom::triangulation& mesh = o->geometry();
BOOST_FOREACH(const ifcopenshell::geom::taxonomy::style::ptr& material, mesh.materials()) { BOOST_FOREACH(const ifcopenshell::geom::taxonomy::style::ptr& material, mesh.materials()) {
materials.add(material); materials.add(material);
} }
+1 -1
View File
@@ -203,7 +203,7 @@ void usd_serializer::write(const ifcopenshell::geom::triangulation_element* o) {
} }
pxr::UsdGeomXform usd_mesh_container = writeNode<pxr::UsdGeomXform>(o); // writeNode<pxr::UsdGeomMesh>(o); pxr::UsdGeomXform usd_mesh_container = writeNode<pxr::UsdGeomXform>(o); // writeNode<pxr::UsdGeomMesh>(o);
auto usd_mesh = pxr::UsdGeomMesh::Define(stage_, pxr::SdfPath(usd_mesh_container.GetPath().GetString() + "/" + o->context())); auto usd_mesh = pxr::UsdGeomMesh::Define(stage_, pxr::SdfPath(usd_mesh_container.GetPath().GetString() + "/" + o->context()));
const ifcopenshell::geom::Representation::triangulation& mesh = o->geometry(); const ifcopenshell::geom::triangulation& mesh = o->geometry();
const auto verts = mesh.verts(); const auto verts = mesh.verts();
const auto faces = mesh.faces(); const auto faces = mesh.faces();
const auto material_ids = mesh.material_ids(); const auto material_ids = mesh.material_ids();
+1 -1
View File
@@ -92,7 +92,7 @@ void wavefront_obj_serializer::write(const ifcopenshell::geom::triangulation_ele
obj_stream.stream << "s 1" << "\n"; obj_stream.stream << "s 1" << "\n";
const bool isyup = settings().get<ifcopenshell::geom::settings::UseYUp>().get(); const bool isyup = settings().get<ifcopenshell::geom::settings::UseYUp>().get();
const ifcopenshell::geom::Representation::triangulation& mesh = o->geometry(); const ifcopenshell::geom::triangulation& mesh = o->geometry();
size_t vcount = mesh.verts().size() / 3; size_t vcount = mesh.verts().size() / 3;
size_t ncount = mesh.normals().size() / 3; size_t ncount = mesh.normals().size() / 3;