diff --git a/src/exterior-shell-extractor/main.py b/src/exterior-shell-extractor/main.py index b9a914887e..d140535268 100644 --- a/src/exterior-shell-extractor/main.py +++ b/src/exterior-shell-extractor/main.py @@ -889,7 +889,7 @@ class context: def write_obj(ofn, *, elem=None, item=None): s = ifcopenshell.geom.settings(USE_WORLD_COORDS=True, WELD_VERTICES=False) if item: - geom = item.Triangulate(s) + geom = item.triangulate(s) else: geom = elem.geometry diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index adb50a2845..9eb639b184 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -1466,7 +1466,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st auto quantity_count = latebound_access::create(f, "IfcQuantityCount"); latebound_access::set(quantity_count, "Name", std::string("Surface Genus")); latebound_access::set(quantity_count, "Description", '#' + boost::lexical_cast(part.ItemId())); - latebound_access::set(quantity_count, "CountValue", (int64_t) part.Shape()->surface_genus()); + latebound_access::set(quantity_count, "CountValue", (int64_t) part.shape()->surface_genus()); quantities_2.push_back(quantity_count); } diff --git a/src/ifcconvert/validate_storey_containment.cpp b/src/ifcconvert/validate_storey_containment.cpp index b8ea68534c..66f3feb708 100644 --- a/src/ifcconvert/validate_storey_containment.cpp +++ b/src/ifcconvert/validate_storey_containment.cpp @@ -134,8 +134,8 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, std::vector intersection_volumes(nefs.size()); for (auto& g : geom_object->geometry()) { - auto s = std::static_pointer_cast(g.Shape())->poly(); - const auto& m = g.Placement()->ccomponents(); + auto s = std::static_pointer_cast(g.shape())->poly(); + const auto& m = g.placement()->ccomponents(); const auto& n = geom_object->transformation().data()->ccomponents(); const cgal_placement trsf( diff --git a/src/ifcconvert/validation_utils.h b/src/ifcconvert/validation_utils.h index e4cf8201be..40df1e4751 100644 --- a/src/ifcconvert/validation_utils.h +++ b/src/ifcconvert/validation_utils.h @@ -491,8 +491,8 @@ struct intersection_validator { std::wcout << sss.c_str() << std::endl; for (auto& g : geom_object->geometry()) { - cgal_polyhedron s = *std::static_pointer_cast(g.Shape()); - const auto& m = g.Placement()->ccomponents(); + cgal_polyhedron s = *std::static_pointer_cast(g.shape()); + const auto& m = g.placement()->ccomponents(); const auto& n = geom_object->transformation().data()->ccomponents(); const cgal_placement trsf( diff --git a/src/ifcgeom/conversion_result.cpp b/src/ifcgeom/conversion_result.cpp index b2cf5b2f6a..0ab7848e5e 100644 --- a/src/ifcgeom/conversion_result.cpp +++ b/src/ifcgeom/conversion_result.cpp @@ -1,11 +1,11 @@ #include "conversion_result.h" #include "representation.h" -ifcopenshell::geom::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::triangulation::empty(settings); static ifcopenshell::geom::taxonomy::matrix4 iden; - Triangulate(settings, iden, t, -1, -1, logger); + triangulate(settings, iden, t, -1, -1, logger); return t; } diff --git a/src/ifcgeom/conversion_result.h b/src/ifcgeom/conversion_result.h index c777959ceb..0c995eb796 100644 --- a/src/ifcgeom/conversion_result.h +++ b/src/ifcgeom/conversion_result.h @@ -507,9 +507,9 @@ namespace ifcopenshell::geom { #else virtual std::string_view backend_id() const = 0; #endif - 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::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 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::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 int surface_genus() const = 0; virtual bool is_manifold() const = 0; @@ -578,11 +578,11 @@ namespace ifcopenshell::geom { {} void append(ifcopenshell::geom::taxonomy::matrix4::ptr trsf); void prepend(ifcopenshell::geom::taxonomy::matrix4::ptr trsf); - std::shared_ptr Shape() const { return shape_; } - ifcopenshell::geom::taxonomy::matrix4::ptr Placement() const { return placement_; } + std::shared_ptr shape() const { return shape_; } + ifcopenshell::geom::taxonomy::matrix4::ptr placement() const { return placement_; } bool hasStyle() const { return !!style_; } - const ifcopenshell::geom::taxonomy::style& Style() const { return *style_; } - ifcopenshell::geom::taxonomy::style::ptr StylePtr() const { return style_; } + const ifcopenshell::geom::taxonomy::style& style() const { return *style_; } + ifcopenshell::geom::taxonomy::style::ptr style_ptr() const { return style_; } void setStyle(ifcopenshell::geom::taxonomy::style::ptr newStyle) { style_ = newStyle; } int ItemId() const { return id; } conversion_result_shape* apply_transform(double unit_scale = 1.) const { diff --git a/src/ifcgeom/converter.cpp b/src/ifcgeom/converter.cpp index 1fe74a9252..ecc4952700 100644 --- a/src/ifcgeom/converter.cpp +++ b/src/ifcgeom/converter.cpp @@ -23,12 +23,12 @@ namespace { void* box = nullptr; double volume = 0.; for (auto& i : items) { - nv += i.Shape()->num_vertices(); - volume = i.Shape()->bounding_box(box); + nv += i.shape()->num_vertices(); + volume = i.shape()->bounding_box(box); } density = nv / volume; if (density > 1e5) { - items[0].Shape()->set_box(box); + items[0].shape()->set_box(box); items.erase(items.begin() + 1, items.end()); logger.notice("GEO", 30, "Substituted element with " + boost::lexical_cast(density) + " vertices / m3 with a bounding box"); } @@ -135,7 +135,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for bool some_items_without_style = false; for (auto it = shapes.begin(); it != shapes.end(); ++it) { // @todo implement num_faces() - if (!it->hasStyle() /* && it->Shape()->num_faces() */) { + if (!it->hasStyle() /* && it->shape()->num_faces() */) { some_items_without_style = true; break; } @@ -153,7 +153,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for for (auto& s : shapes) { if (s.hasStyle()) { // @todo the uglyness - const_cast(&*s.StylePtr())->transparency = settings_.get().get(); + const_cast(&*s.style_ptr())->transparency = settings_.get().get(); } } } @@ -335,7 +335,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for int genus = (int)q2->as()->CountValue(); for (auto& part : elem->geometry()) { if (part.ItemId() == item_id) { - if (util::surface_genus(part.Shape()) != genus) { + if (util::surface_genus(part.shape()) != genus) { all_succeeded = false; } } diff --git a/src/ifcgeom/hybrid_kernel.h b/src/ifcgeom/hybrid_kernel.h index a6c19d5058..c6198484d2 100644 --- a/src/ifcgeom/hybrid_kernel.h +++ b/src/ifcgeom/hybrid_kernel.h @@ -109,7 +109,7 @@ namespace ifcopenshell { for (auto& k : kernels_) { bool is_valid = true; for (auto& s : entity_shapes) { - if (!k->accepts(*s.Shape())) { + if (!k->accepts(*s.shape())) { is_valid = false; break; } diff --git a/src/ifcgeom/kernels/cgal/cgal_conversion_result.cpp b/src/ifcgeom/kernels/cgal/cgal_conversion_result.cpp index 4e8616f653..1402ac0a6e 100644 --- a/src/ifcgeom/kernels/cgal/cgal_conversion_result.cpp +++ b/src/ifcgeom/kernels/cgal/cgal_conversion_result.cpp @@ -364,7 +364,7 @@ void ifcopenshell::geom::cgal_shape::to_nef() const { } #endif -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 { +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()) { return; } @@ -458,7 +458,7 @@ void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings se // std::map vertex_normals; // boost::associative_property_map> vertex_normals_map(vertex_normals); - // Triangulate the shape and compute the normals + // triangulate the shape and compute the normals std::map face_normals; boost::associative_property_map> face_normals_map(face_normals); @@ -586,7 +586,7 @@ void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings se } -void ifcopenshell::geom::cgal_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { +void ifcopenshell::geom::cgal_shape::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { std::stringstream sstream; if (is_point()) { auto p = point(); @@ -1035,11 +1035,11 @@ bool ifcopenshell::geom::cgal_shape::surface_area_along_direction(double tol, co #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::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"); } -void ifcopenshell::geom::cgal_shape_half_space_decomposition::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { +void ifcopenshell::geom::cgal_shape_half_space_decomposition::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { throw std::runtime_error("Not implemented"); } diff --git a/src/ifcgeom/kernels/cgal/cgal_conversion_result.h b/src/ifcgeom/kernels/cgal/cgal_conversion_result.h index 802f76c7b9..e8a7603cbe 100644 --- a/src/ifcgeom/kernels/cgal/cgal_conversion_result.h +++ b/src/ifcgeom/kernels/cgal/cgal_conversion_result.h @@ -226,8 +226,8 @@ namespace ifcopenshell { namespace geom { const cgal_point& point() const { return std::get(*shape_); } const cgal_wire& wire() const { return std::get(*shape_); } - 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 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 ifcopenshell::geom::conversion_result_shape* clone() const { if (shape_) { @@ -319,8 +319,8 @@ namespace ifcopenshell { namespace geom { #endif } - 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 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 int surface_genus() const; virtual bool is_manifold() const; diff --git a/src/ifcgeom/kernels/cgal/cgal_kernel.cpp b/src/ifcgeom/kernels/cgal/cgal_kernel.cpp index 2cec518dcf..96731d4637 100644 --- a/src/ifcgeom/kernels/cgal/cgal_kernel.cpp +++ b/src/ifcgeom/kernels/cgal/cgal_kernel.cpp @@ -912,8 +912,8 @@ bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::b std::list> first_operands_nef, second_operands_nef; for (auto& shp : entity_shapes) { - cgal_polyhedron entity_shape = *std::static_pointer_cast(shp.Shape()); - const auto& m = shp.Placement()->ccomponents(); + cgal_polyhedron entity_shape = *std::static_pointer_cast(shp.shape()); + const auto& m = shp.placement()->ccomponents(); if (!m.isIdentity()) { cgal_placement trsf; convert_placement(m, trsf); @@ -943,9 +943,9 @@ bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::b abstract_kernel::convert(op.first, opening_shapes); for (unsigned int i = 0; i < opening_shapes.size(); ++i) { - cgal_polyhedron entity_shape_unlocated = *std::static_pointer_cast(opening_shapes[i].Shape()); + cgal_polyhedron entity_shape_unlocated = *std::static_pointer_cast(opening_shapes[i].shape()); cgal_polyhedron entity_shape(entity_shape_unlocated); - auto gtrsf = opening_shapes[i].Placement(); + auto gtrsf = opening_shapes[i].placement(); // @todo check Eigen::Matrix4d m = opening_trsf.ccomponents() * gtrsf->ccomponents(); if (!m.isIdentity()) { @@ -1008,7 +1008,7 @@ bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::b return false; } - cut_shapes.push_back(ifcopenshell::geom::conversion_result(it->ItemId(), new cgal_shape(a_poly), it->StylePtr())); + cut_shapes.push_back(ifcopenshell::geom::conversion_result(it->ItemId(), new cgal_shape(a_poly), it->style_ptr())); it++; nit++; } @@ -2068,11 +2068,11 @@ bool cgal_kernel::convert_impl(const taxonomy::boolean_result::ptr br, std::vect } for (auto it = cr.begin(); it != cr.end(); ++it) { - cgal_polyhedron entity_shape_unlocated = *std::static_pointer_cast(it->Shape()); + cgal_polyhedron entity_shape_unlocated = *std::static_pointer_cast(it->shape()); cgal_polyhedron entity_shape(entity_shape_unlocated); - if (!it->Placement()->is_identity()) { + if (!it->placement()->is_identity()) { cgal_placement trsf; - convert_placement(it->Placement(), trsf); + convert_placement(it->placement(), trsf); for (auto &vertex : vertices(entity_shape)) { vertex->point() = vertex->point().transform(trsf); } diff --git a/src/ifcgeom/kernels/manifold/manifold_conversion_result.cpp b/src/ifcgeom/kernels/manifold/manifold_conversion_result.cpp index 90dfb6ca05..9fe7196263 100644 --- a/src/ifcgeom/kernels/manifold/manifold_conversion_result.cpp +++ b/src/ifcgeom/kernels/manifold/manifold_conversion_result.cpp @@ -215,7 +215,7 @@ std::optional ifcopenshell::geom::manifold_shape::as_manifol 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::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_) { auto mesh = transform_mesh(part.mesh, place); std::vector indices(mesh.NumVert()); @@ -250,7 +250,7 @@ void ifcopenshell::geom::manifold_shape::Triangulate(ifcopenshell::geom::setting } } -void ifcopenshell::geom::manifold_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const { +void ifcopenshell::geom::manifold_shape::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const { std::stringstream stream; stream << std::setprecision(17); size_t offset = 0; diff --git a/src/ifcgeom/kernels/manifold/manifold_conversion_result.h b/src/ifcgeom/kernels/manifold/manifold_conversion_result.h index 67ea711d2c..d2b774422b 100644 --- a/src/ifcgeom/kernels/manifold/manifold_conversion_result.h +++ b/src/ifcgeom/kernels/manifold/manifold_conversion_result.h @@ -40,8 +40,8 @@ public: std::optional as_manifold() const; virtual std::string_view backend_id() const { return "manifold"; } - 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 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 int surface_genus() const; virtual bool is_manifold() const; diff --git a/src/ifcgeom/kernels/manifold/manifold_kernel.cpp b/src/ifcgeom/kernels/manifold/manifold_kernel.cpp index 7dc26008f6..a102597280 100644 --- a/src/ifcgeom/kernels/manifold/manifold_kernel.cpp +++ b/src/ifcgeom/kernels/manifold/manifold_kernel.cpp @@ -1412,7 +1412,7 @@ namespace { } for (const auto& result : results) { if (result.hasStyle()) { - return result.StylePtr(); + return result.style_ptr(); } } return nullptr; @@ -1650,7 +1650,7 @@ bool manifold_kernel::convert_openings(const express::base&, const std::vector(result.Shape()->moved(taxonomy::make(relative->ccomponents() * result.Placement()->ccomponents()))); + auto moved = std::unique_ptr(result.shape()->moved(taxonomy::make(relative->ccomponents() * result.placement()->ccomponents()))); auto* shape = dynamic_cast(moved.get()); if (!shape) { ifcopenshell::logger::root().warning("Manifold kernel: opening result is not a manifold shape"); @@ -1679,7 +1679,7 @@ bool manifold_kernel::convert_openings(const express::base&, const std::vector::const_iterator it = shapes.begin(); it != shapes.end(); ++it) { TopoDS_Shape merged; - const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); + const TopoDS_Shape& s = std::static_pointer_cast(it->shape())->shape(); if (fuse || create_shell) { merged = util::ensure_fit_for_subtraction(s, tol); } else { @@ -820,7 +820,7 @@ bool ifcopenshell::geom::util::flatten_shape_list(const std::vectorPlacement()->ccomponents(); + const auto& m = it->placement()->ccomponents(); gp_Trsf trsf; trsf.SetValues( m(0, 0), m(0, 1), m(0, 2), m(0, 3), diff --git a/src/ifcgeom/kernels/opencascade/boolean_result.cpp b/src/ifcgeom/kernels/opencascade/boolean_result.cpp index 014fdbd859..663980d1d8 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_result.cpp +++ b/src/ifcgeom/kernels/opencascade/boolean_result.cpp @@ -122,13 +122,13 @@ bool open_cascade_kernel::convert_impl(const taxonomy::boolean_result::ptr br, s } else { for (auto& r : cr) { - auto S = std::static_pointer_cast(r.Shape())->shape(); + auto S = std::static_pointer_cast(r.shape())->shape(); if (S.IsNull()) { logger_.error("GEO", 120, "Null operand"); continue; } gp_GTrsf trsf; - convert(r.Placement(), trsf); + convert(r.placement(), trsf); // @todo it really confuses me why I cannot use Moved() here instead S.Location(S.Location() * trsf.Trsf()); diff --git a/src/ifcgeom/kernels/opencascade/layerset.cpp b/src/ifcgeom/kernels/opencascade/layerset.cpp index b4ba9fe6a8..eaa14f59db 100644 --- a/src/ifcgeom/kernels/opencascade/layerset.cpp +++ b/src/ifcgeom/kernels/opencascade/layerset.cpp @@ -251,9 +251,9 @@ bool ifcopenshell::geom::util::apply_folded_layerset(const std::vector::const_iterator it = items.begin(); it != items.end(); ++it) { TopoDS_Shape a, b; - if (split_solid_by_shell(std::static_pointer_cast(it->Shape())->shape(), shells.First(), a, b, tol)) { - result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->StylePtr()))); - result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->StylePtr()))); + if (split_solid_by_shell(std::static_pointer_cast(it->shape())->shape(), shells.First(), a, b, tol)) { + result.push_back(conversion_result(it->ItemId(), it->placement(), new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->style_ptr()))); + result.push_back(conversion_result(it->ItemId(), it->placement(), new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->style_ptr()))); } else { continue; } @@ -265,13 +265,13 @@ bool ifcopenshell::geom::util::apply_folded_layerset(const std::vector::const_iterator it = items.begin(); it != items.end(); ++it) { - const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); + const TopoDS_Shape& s = std::static_pointer_cast(it->shape())->shape(); TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol); std::vector slices; if (split(s, shells, tol, slices) && slices.size() == styles.size()) { for (size_t i = 0; i < slices.size(); ++i) { - result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr()))); + result.push_back(conversion_result(it->ItemId(), it->placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->style_ptr()))); } } else { return false; @@ -293,9 +293,9 @@ bool ifcopenshell::geom::util::apply_layerset(const std::vector::const_iterator it = items.begin(); it != items.end(); ++it) { TopoDS_Shape a, b; - if (split_solid_by_surface(std::static_pointer_cast(it->Shape())->shape(), surfaces[1], a, b, tol)) { - result.push_back(conversion_result(it->ItemId(), it->Placement(),new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->StylePtr()))); - result.push_back(conversion_result(it->ItemId(), it->Placement(),new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->StylePtr()))); + if (split_solid_by_surface(std::static_pointer_cast(it->shape())->shape(), surfaces[1], a, b, tol)) { + result.push_back(conversion_result(it->ItemId(), it->placement(),new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->style_ptr()))); + result.push_back(conversion_result(it->ItemId(), it->placement(),new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->style_ptr()))); } else { continue; } @@ -310,7 +310,7 @@ bool ifcopenshell::geom::util::apply_layerset(const std::vector::const_iterator it = items.begin(); it != items.end(); ++it) { - BRepBndLib::Add(it->Shape(), bb); + BRepBndLib::Add(it->shape(), bb); } double x1, y1, z1, x2, y2, z2; @@ -336,7 +336,7 @@ bool ifcopenshell::geom::util::apply_layerset(const std::vector::const_iterator it = items.begin(); it != items.end(); ++it) { - const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); + const TopoDS_Shape& s = std::static_pointer_cast(it->shape())->shape(); TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol); NCollection_List operands; @@ -354,14 +354,14 @@ bool ifcopenshell::geom::util::apply_layerset(const std::vectorItemId(), it->Placement(), x, nullptr)); + result.push_back(conversion_result(it->ItemId(), it->placement(), x, nullptr)); } */ std::vector slices; if (split(s, operands, tol, slices) && slices.size() == styles.size()) { for (size_t i = 0; i < slices.size(); ++i) { - result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr()))); + result.push_back(conversion_result(it->ItemId(), it->placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->style_ptr()))); } } else { return false; diff --git a/src/ifcgeom/kernels/opencascade/opencascade_conversion_result.cpp b/src/ifcgeom/kernels/opencascade/opencascade_conversion_result.cpp index 484af4648f..da27586dd6 100644 --- a/src/ifcgeom/kernels/opencascade/opencascade_conversion_result.cpp +++ b/src/ifcgeom/kernels/opencascade/opencascade_conversion_result.cpp @@ -68,7 +68,7 @@ ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::open_cascade_sh 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::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); // above can be static? @@ -104,7 +104,7 @@ void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::set } } if (!has_triangulation) { - // Triangulate the shape + // triangulate the shape try { BRepMesh_IncrementalMesh(shape_, settings.get().get(), false, settings.get().get()); } catch (...) { @@ -372,7 +372,7 @@ void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::set } } -void ifcopenshell::geom::open_cascade_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { +void ifcopenshell::geom::open_cascade_shape::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { auto s = ifcopenshell::geom::util::apply_transformation(shape_, place); std::stringstream sstream; #if OCC_VERSION_HEX >= 0x70600 diff --git a/src/ifcgeom/kernels/opencascade/opencascade_conversion_result.h b/src/ifcgeom/kernels/opencascade/opencascade_conversion_result.h index 64623891f1..3c73f20602 100644 --- a/src/ifcgeom/kernels/opencascade/opencascade_conversion_result.h +++ b/src/ifcgeom/kernels/opencascade/opencascade_conversion_result.h @@ -49,8 +49,8 @@ namespace ifcopenshell { operator const TopoDS_Shape& (); virtual std::string_view backend_id() 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 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 ifcopenshell::geom::conversion_result_shape* clone() const; diff --git a/src/ifcgeom/kernels/opencascade/opencascade_kernel.cpp b/src/ifcgeom/kernels/opencascade/opencascade_kernel.cpp index 1a58c23a40..b3bfeb3bd0 100644 --- a/src/ifcgeom/kernels/opencascade/opencascade_kernel.cpp +++ b/src/ifcgeom/kernels/opencascade/opencascade_kernel.cpp @@ -89,10 +89,10 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba abstract_kernel::convert(op.first, opening_shapes); for (unsigned int i = 0; i < opening_shapes.size(); ++i) { - auto opening_shape_i = std::static_pointer_cast(opening_shapes[i].Shape())->shape(); + auto opening_shape_i = std::static_pointer_cast(opening_shapes[i].shape())->shape(); const TopoDS_Shape& opening_shape_unlocated = util::ensure_fit_for_subtraction(opening_shape_i, settings_.get().get()); - auto gtrsf = opening_shapes[i].Placement(); + auto gtrsf = opening_shapes[i].placement(); // @todo check Eigen::Matrix4d m = relative * gtrsf->ccomponents(); gp_Trsf trsf; @@ -119,7 +119,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba std::list parts; - auto it3_shape = std::static_pointer_cast(it3->Shape())->shape(); + auto it3_shape = std::static_pointer_cast(it3->shape())->shape(); if (it3_shape.IsNull()) { logger_.error("GEO", 187, "Null operand"); continue; @@ -187,7 +187,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba } else { entity_shape_unlocated = util::ensure_fit_for_subtraction(entity_part, settings_.get().get()); } - const auto& m = it3->Placement()->ccomponents(); + const auto& m = it3->placement()->ccomponents(); // @todo // if (entity_shape_gtrsf.Form() == gp_Other) { // ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_WARNING, "Applying non uniform transformation to:", entity); @@ -262,19 +262,19 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba combined_result = C; } - cut_shapes.push_back(ifcopenshell::geom::conversion_result(it3->ItemId(), new open_cascade_shape(combined_result), it3->StylePtr())); + cut_shapes.push_back(ifcopenshell::geom::conversion_result(it3->ItemId(), new open_cascade_shape(combined_result), it3->style_ptr())); } return true; } bool ifcopenshell::geom::open_cascade_kernel::unify_shapes(const std::vector& input, std::vector& output) { std::transform(input.begin(), input.end(), std::back_inserter(output), [this](auto v) { - auto& s = std::static_pointer_cast(v.Shape())->shape(); + auto& s = std::static_pointer_cast(v.shape())->shape(); return ifcopenshell::geom::conversion_result( v.ItemId(), - v.Placement(), + v.placement(), new open_cascade_shape(util::unify(s, settings_.get().get())), - v.StylePtr()); + v.style_ptr()); }); return true; } @@ -439,7 +439,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol // } else { // bool some_items_without_style = false; // for (std::vector::iterator it = shapes.begin(); it != shapes.end(); ++it) { -// if (!it->hasStyle() && util::count(it->Shape(), TopAbs_FACE)) { +// if (!it->hasStyle() && util::count(it->shape(), TopAbs_FACE)) { // some_items_without_style = true; // break; // } @@ -457,7 +457,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol // for (auto& s : shapes) { // if (s.hasStyle()) { // for (auto& p : style_cache) { -// if (p.second == s.StylePtr()) { +// if (p.second == s.style_ptr()) { // std::const_pointer_cast(p.second)->Transparency() = settings.force_space_transparency(); // } // } @@ -604,7 +604,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol // int genus = (int)q2->as()->CountValue(); // for (auto& part : elem->geometry()) { // if (part.ItemId() == item_id) { -// if (util::surface_genus(part.Shape()) != genus) { +// if (util::surface_genus(part.shape()) != genus) { // all_succeeded = false; // } // } @@ -779,7 +779,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol // // TopoDS_Vertex a, b; // for (std::vector::const_iterator it = items.begin(); it != items.end(); ++it) { -// TopExp_Explorer exp(it->Shape(), TopAbs_VERTEX); +// TopExp_Explorer exp(it->shape(), TopAbs_VERTEX); // for (; exp.More(); exp.Next()) { // b = TopoDS::Vertex(exp.Current()); // if (a.IsNull()) { diff --git a/src/ifcgeom/kernels/opencascade/tree.h b/src/ifcgeom/kernels/opencascade/tree.h index 087090c4c1..30cb309365 100644 --- a/src/ifcgeom/kernels/opencascade/tree.h +++ b/src/ifcgeom/kernels/opencascade/tree.h @@ -1771,11 +1771,11 @@ namespace ifcopenshell::geom { TopoDS_Iterator it(compound); for (; it.More(); it.Next(), ++git) { // Assumption is that the number of styles is small, so the linear lookup time is not significant. - auto sit = std::find(styles_.begin(), styles_.end(), git->StylePtr()); + auto sit = std::find(styles_.begin(), styles_.end(), git->style_ptr()); size_t index; if (sit == styles_.end()) { index = styles_.size(); - styles_.push_back(git->StylePtr()); + styles_.push_back(git->style_ptr()); } else { index = std::distance(styles_.begin(), sit); } diff --git a/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.cpp b/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.cpp index afb2c53ef2..cb71607d3f 100644 --- a/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.cpp +++ b/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.cpp @@ -286,7 +286,7 @@ ifcopenshell::geom::passthrough_shape::passthrough_shape(const std::vector&& parts) : parts_(normalize_parts(parts)) {} -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 { +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); std::vector indices(mesh.vertices.size()); for (size_t i = 0; i < mesh.vertices.size(); ++i) { @@ -302,7 +302,7 @@ void ifcopenshell::geom::passthrough_shape::Triangulate(ifcopenshell::geom::sett } } -void ifcopenshell::geom::passthrough_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const { +void ifcopenshell::geom::passthrough_shape::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const { auto mesh = build_mesh(parts_, &place); std::stringstream stream; for (const auto& vertex : mesh.vertices) { diff --git a/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.h b/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.h index c2dd7d1360..d8a49a184d 100644 --- a/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.h +++ b/src/ifcgeom/kernels/passthrough/passthrough_conversion_result.h @@ -24,8 +24,8 @@ public: const std::vector& parts() const { return parts_; } virtual std::string_view backend_id() const { return "passthrough"; } - 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 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 int surface_genus() const; virtual bool is_manifold() const; diff --git a/src/ifcgeom/representation.cpp b/src/ifcgeom/representation.cpp index 265aa708b8..5e5fbca6f5 100644 --- a/src/ifcgeom/representation.cpp +++ b/src/ifcgeom/representation.cpp @@ -26,20 +26,20 @@ ifcopenshell::geom::serialization::serialization(const brep& brep) int sid = -1; if (it->hasStyle()) { - const auto& clr = it->Style().get_color().ccomponents(); + const auto& clr = it->style().get_color().ccomponents(); surface_styles_.push_back(clr(0)); surface_styles_.push_back(clr(1)); surface_styles_.push_back(clr(2)); - sid = it->Style().instance ? it->Style().instance.id() : -1; + sid = it->style().instance ? it->style().instance.id() : -1; } else { surface_styles_.push_back(-1.); surface_styles_.push_back(-1.); surface_styles_.push_back(-1.); } - if (it->hasStyle() && it->Style().has_transparency()) { - surface_styles_.push_back(1. - it->Style().transparency); + if (it->hasStyle() && it->style().has_transparency()) { + surface_styles_.push_back(1. - it->style().transparency); } else { surface_styles_.push_back(1.); } @@ -49,7 +49,7 @@ ifcopenshell::geom::serialization::serialization(const brep& brep) ifcopenshell::geom::taxonomy::matrix4 identity; auto* comp = brep.as_compound(); - comp->Serialize(identity, brep_data_); + comp->serialize(identity, brep_data_); delete comp; } @@ -100,9 +100,9 @@ bool ifcopenshell::geom::brep::calculate_projected_surface_area(const ifcopenshe for (std::vector::const_iterator it = begin(); it != end(); ++it) { double x, y, z; - it->Shape()->surface_area_along_direction(settings().get().get(), place, x, y, z); + it->shape()->surface_area_along_direction(settings().get().get(), place, x, y, z); - if (it->Shape()->is_manifold()) { + if (it->shape()->is_manifold()) { x /= 2.; y /= 2.; z /= 2.; @@ -127,10 +127,10 @@ ifcopenshell::geom::triangulation::triangulation(const brep& shape_model) int surface_style_id = -1; if (iit->hasStyle()) { - auto jt = std::find(materials_.begin(), materials_.end(), iit->StylePtr()); + auto jt = std::find(materials_.begin(), materials_.end(), iit->style_ptr()); if (jt == materials_.end()) { surface_style_id = (int)materials_.size(); - materials_.push_back(iit->StylePtr()); + materials_.push_back(iit->style_ptr()); } else { surface_style_id = (int)(jt - materials_.begin()); } @@ -147,7 +147,7 @@ ifcopenshell::geom::triangulation::triangulation(const brep& shape_model) } } - iit->Shape()->Triangulate(settings(), *iit->Placement(), this, iit->ItemId(), surface_style_id); + iit->shape()->triangulate(settings(), *iit->placement(), this, iit->ItemId(), surface_style_id); } } @@ -212,7 +212,7 @@ void ifcopenshell::geom::triangulation::registerEdgeCount(int n1, int n2, std::m const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::item(int i) const { if (i >= 0 && i < shapes_.size()) { - return shapes_[i].Shape()->moved(shapes_[i].Placement()); + return shapes_[i].shape()->moved(shapes_[i].placement()); } else { return nullptr; } diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index 4c5953547f..23706388fd 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -142,8 +142,8 @@ class ConversionResult: def setStyle(self, newStyle): ... class ConversionResultShape: - def Serialize(self, place, arg3): ... - def Triangulate(self, *args): ... + def serialize(self, place, arg3): ... + def triangulate(self, *args): ... def __init__(self, *args, **kwargs): ... def add(self, arg2): ... def area(self): ... diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 8cc9b81ff9..9c6cd5ed34 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -1168,7 +1168,7 @@ ifcopenshell::geom::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type_inf %extend ifcopenshell::geom::conversion_result_shape { std::string serialize_obj() { ifcopenshell::geom::settings settings; - std::unique_ptr triangulation($self->Triangulate(settings)); + std::unique_ptr triangulation($self->triangulate(settings)); std::ostringstream result; for (auto it = triangulation->verts().begin(); it != triangulation->verts().end();) { @@ -1204,7 +1204,7 @@ ifcopenshell::geom::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type_inf std::string serialize() { std::string result; ifcopenshell::geom::taxonomy::matrix4 iden; - $self->Serialize(iden, result); + $self->serialize(iden, result); return result; } @@ -1317,7 +1317,7 @@ ifcopenshell::geom::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type_inf std::string serialize() { std::string result; ifcopenshell::geom::taxonomy::matrix4 iden; - $self->Serialize(iden, result); + $self->serialize(iden, result); return result; }