From ce495de74736213af716865365383610f40a01b8 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Thu, 13 Aug 2026 17:21:50 +0200 Subject: [PATCH 1/5] fix(ComponentID): change componentid class to struct --- .../src/model/mixin/core/component_type.cpp | 5 -- examples/layer_cake.ipynb | 4 +- .../model/helpers/model_component_filter.hpp | 2 +- .../mixin/core/component_mesh_element.hpp | 2 +- .../geode/model/mixin/core/component_type.hpp | 53 ++++++------------- .../representation/builder/detail/copy.hpp | 4 +- .../representation/builder/detail/filter.hpp | 4 +- .../representation/core/internal/helpers.hpp | 4 +- .../model/helpers/component_mesh_edges.cpp | 6 +-- .../model/helpers/component_mesh_polygons.cpp | 8 +-- .../helpers/component_mesh_polyhedra.cpp | 8 +-- .../model/helpers/component_mesh_vertices.cpp | 6 +-- .../model/helpers/compute_unique_vertices.cpp | 18 +++---- .../model/helpers/convert_brep_section.cpp | 4 +- .../helpers/detail/build_model_boundaries.cpp | 2 +- .../model/helpers/surface_radial_sort.cpp | 2 +- .../mixin/core/component_mesh_element.cpp | 2 +- src/geode/model/mixin/core/component_type.cpp | 4 +- .../mixin/core/detail/relationships_impl.cpp | 18 +++---- src/geode/model/mixin/core/relationships.cpp | 8 +-- .../model/mixin/core/vertex_identifier.cpp | 25 +++++---- .../representation/builder/brep_builder.cpp | 17 +++--- .../builder/section_builder.cpp | 14 +++-- src/geode/model/representation/core/brep.cpp | 34 ++++++------ .../model/representation/core/section.cpp | 22 ++++---- tests/model/test-model-creator.cpp | 2 +- tests/model/test-relationships.cpp | 4 +- 27 files changed, 124 insertions(+), 158 deletions(-) diff --git a/bindings/python/src/model/mixin/core/component_type.cpp b/bindings/python/src/model/mixin/core/component_type.cpp index ad74cab0c..2e0c4e0f9 100644 --- a/bindings/python/src/model/mixin/core/component_type.cpp +++ b/bindings/python/src/model/mixin/core/component_type.cpp @@ -38,11 +38,6 @@ namespace geode pybind11::class_< ComponentID >( module, "ComponentID" ) .def( pybind11::init<>() ) .def( pybind11::init< ComponentType, uuid >() ) - .def( "id", static_cast< const uuid& (ComponentID::*) () const& >( - &ComponentID::id ) ) - .def( "type", - static_cast< const ComponentType& (ComponentID::*) () const& >( - &ComponentID::type ) ) .def( "string", &ComponentID::string ) .def( pybind11::self == pybind11::self ) .def( pybind11::self != pybind11::self ); diff --git a/examples/layer_cake.ipynb b/examples/layer_cake.ipynb index 97c28e941..c964f716a 100644 --- a/examples/layer_cake.ipynb +++ b/examples/layer_cake.ipynb @@ -155,7 +155,7 @@ "def _corner_from_surface_vertex(brep, surface, vertex):\n", " vertex_id = brep.unique_vertex(opengeode.ComponentMeshVertex(surface.component_id(), vertex))\n", " unique_vertices = brep.filtered_component_mesh_vertices_by_type(vertex_id, opengeode.Corner3D.component_type_static())\n", - " return unique_vertices[0].component_id.id()\n", + " return unique_vertices[0].component_id.id\n", "\n", "def _brep_mapping(brep0, brep1):\n", " corner_mapping = _corner_mapping(brep0, brep1)\n", @@ -312,4 +312,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/include/geode/model/helpers/model_component_filter.hpp b/include/geode/model/helpers/model_component_filter.hpp index 517931a74..fe97ec774 100644 --- a/include/geode/model/helpers/model_component_filter.hpp +++ b/include/geode/model/helpers/model_component_filter.hpp @@ -29,7 +29,7 @@ namespace geode { class BRep; class Section; - class ComponentID; + struct ComponentID; } // namespace geode namespace geode diff --git a/include/geode/model/mixin/core/component_mesh_element.hpp b/include/geode/model/mixin/core/component_mesh_element.hpp index 30e6a3870..c48014e0d 100644 --- a/include/geode/model/mixin/core/component_mesh_element.hpp +++ b/include/geode/model/mixin/core/component_mesh_element.hpp @@ -46,7 +46,7 @@ namespace geode [[nodiscard]] MeshElement mesh_element() const { - return { component_id.id(), element_id }; + return { component_id.id, element_id }; } [[nodiscard]] bool operator==( const ComponentMeshElement& other ) const diff --git a/include/geode/model/mixin/core/component_type.hpp b/include/geode/model/mixin/core/component_type.hpp index 9c680e5a4..7805b57f7 100644 --- a/include/geode/model/mixin/core/component_type.hpp +++ b/include/geode/model/mixin/core/component_type.hpp @@ -44,35 +44,13 @@ namespace geode /*! * Identify a component by its type and a unique index */ - class ComponentID + struct ComponentID { - public: ComponentID() : ComponentID( ComponentType{ "undefined" }, uuid{} ) {} - ComponentID( ComponentType component_type, uuid id ) - : type_( std::move( component_type ) ), id_( std::move( id ) ) - { - } - - [[nodiscard]] const uuid& id() const& - { - return id_; - } - - [[nodiscard]] uuid&& id() && - { - return std::move( id_ ); - } - - [[nodiscard]] const ComponentType& type() const& - { - return type_; - } - - [[nodiscard]] ComponentType&& type() && - { - return std::move( type_ ); - } + ComponentID( ComponentType component_type, uuid input_id ) + : type{ std::move( component_type ) }, + id{ std::move( input_id ) } {}; [[nodiscard]] bool operator!=( const ComponentID& other ) const { @@ -81,29 +59,32 @@ namespace geode [[nodiscard]] bool operator==( const ComponentID& other ) const { - return type_.get() == other.type_.get() && id_ == other.id_; + return type.get() == other.type.get() && id == other.id; } [[nodiscard]] bool operator<( const ComponentID& other ) const { - if( type_.get() != other.type_.get() ) + if( type.get() != other.type.get() ) { - return type_.get() < other.type_.get(); + return type.get() < other.type.get(); } - return id_ < other.id_; + return id < other.id; } [[nodiscard]] std::string string() const { - return absl::StrCat( type_.get(), " ", id_.string() ); + return absl::StrCat( type.get(), " ", id.string() ); } template < typename H > friend H AbslHashValue( H h, const ComponentID& value ) { - return H::combine( std::move( h ), value.type_, value.id_ ); + return H::combine( std::move( h ), value.type, value.id ); } + ComponentType type; + uuid id; + private: friend class bitsery::Access; template < typename Archive > @@ -112,14 +93,10 @@ namespace geode serializer.ext( *this, Growable< Archive, ComponentID >{ { []( Archive& archive, ComponentID& component_id ) { - archive.object( component_id.type_ ); - archive.object( component_id.id_ ); + archive.object( component_id.type ); + archive.object( component_id.id ); } } } ); } - - private: - ComponentType type_; - uuid id_; }; } // namespace geode diff --git a/include/geode/model/representation/builder/detail/copy.hpp b/include/geode/model/representation/builder/detail/copy.hpp index 8d785e9f5..9c1c3d23f 100644 --- a/include/geode/model/representation/builder/detail/copy.hpp +++ b/include/geode/model/representation/builder/detail/copy.hpp @@ -433,10 +433,10 @@ namespace geode for( const auto& mesh_vertex : from.component_mesh_vertices( v ) ) { - const auto& type = mesh_vertex.component_id.type(); + const auto& type = mesh_vertex.component_id.type; builder_to.set_unique_vertex( { { type, mapping.at( type ).in2out( - mesh_vertex.component_id.id() ) }, + mesh_vertex.component_id.id ) }, mesh_vertex.vertex }, first_new_unique_vertex_id + v ); } diff --git a/include/geode/model/representation/builder/detail/filter.hpp b/include/geode/model/representation/builder/detail/filter.hpp index 7dc48cacb..46c0b021e 100644 --- a/include/geode/model/representation/builder/detail/filter.hpp +++ b/include/geode/model/representation/builder/detail/filter.hpp @@ -80,9 +80,9 @@ namespace geode { const auto& component_id = model.component_with_relation( vertex ); - if( !checker.apply( component_id.type() ) ) + if( !checker.apply( component_id.type ) ) { - components_to_remove.push_back( component_id.id() ); + components_to_remove.push_back( component_id.id ); } } for( const auto& component : components_to_remove ) diff --git a/include/geode/model/representation/core/internal/helpers.hpp b/include/geode/model/representation/core/internal/helpers.hpp index 19af5e763..2d37fcb7e 100644 --- a/include/geode/model/representation/core/internal/helpers.hpp +++ b/include/geode/model/representation/core/internal/helpers.hpp @@ -36,7 +36,7 @@ namespace geode { while( iterator.operator!=( iterator ) && iterator.Relationships::InternalRangeIterator::operator*() - .type() + .type != Filter::component_type_static() ) { iterator.Relationships::InternalRangeIterator::operator++(); @@ -49,7 +49,7 @@ namespace geode while( iterator.operator!=( iterator ) && iterator.Relationships::EmbeddingRangeIterator::operator*() - .type() + .type != Filter::component_type_static() ) { iterator.Relationships::EmbeddingRangeIterator::operator++(); diff --git a/src/geode/model/helpers/component_mesh_edges.cpp b/src/geode/model/helpers/component_mesh_edges.cpp index 205cc3365..d961f57cc 100644 --- a/src/geode/model/helpers/component_mesh_edges.cpp +++ b/src/geode/model/helpers/component_mesh_edges.cpp @@ -144,7 +144,7 @@ namespace geode edges.reserve( line_pairs.size() ); for( const auto& line_pair : line_pairs ) { - const auto& line = model.line( line_pair.first.id() ); + const auto& line = model.line( line_pair.first.id ); const auto& mesh = line.mesh(); for( const auto& pair : line_pair.second ) { @@ -221,7 +221,7 @@ namespace geode edges.reserve( surface_pairs.size() ); for( const auto& [surface_id, edge_pairs] : surface_pairs ) { - const auto& surface = model.surface( surface_id.id() ); + const auto& surface = model.surface( surface_id.id ); const auto& mesh = surface.mesh(); for( const auto& pair : edge_pairs ) { @@ -300,7 +300,7 @@ namespace geode edges.reserve( block_pairs.size() ); for( const auto& block_pair : block_pairs ) { - const auto& block = model.block( block_pair.first.id() ); + const auto& block = model.block( block_pair.first.id ); const auto& mesh = block.mesh(); for( const auto& pair : block_pair.second ) { diff --git a/src/geode/model/helpers/component_mesh_polygons.cpp b/src/geode/model/helpers/component_mesh_polygons.cpp index 1bd8d2fd1..e9417f0ad 100644 --- a/src/geode/model/helpers/component_mesh_polygons.cpp +++ b/src/geode/model/helpers/component_mesh_polygons.cpp @@ -69,7 +69,7 @@ namespace for( const auto& cmv : model.component_mesh_vertices( facet_unique_vertices[polygon_vertex_id] ) ) { - if( cmv.component_id.id() == block.id() ) + if( cmv.component_id.id == block.id() ) { block_facet_from_unique_vertices[polygon_vertex_id] .emplace_back( cmv.vertex ); @@ -311,7 +311,7 @@ namespace for( const auto& cmv : model.component_mesh_vertices( edge_unique_vertices[edge_vertex_id] ) ) { - if( cmv.component_id.id() == surface.id() ) + if( cmv.component_id.id == surface.id() ) { surface_edge_from_unique_vertices[edge_vertex_id] .emplace_back( cmv.vertex ); @@ -643,7 +643,7 @@ namespace geode polygons.reserve( surface_pairs.size() ); for( auto& surface_pair : surface_pairs ) { - const auto& surface = model.surface( surface_pair.first.id() ); + const auto& surface = model.surface( surface_pair.first.id ); const auto& mesh = surface.mesh(); for( auto& pair : surface_pair.second ) { @@ -680,7 +680,7 @@ namespace geode polygons.reserve( block_pairs.size() ); for( const auto& block_pair : block_pairs ) { - const auto& block = model.block( block_pair.first.id() ); + const auto& block = model.block( block_pair.first.id ); const auto& mesh = block.mesh(); for( const auto& pair : block_pair.second ) { diff --git a/src/geode/model/helpers/component_mesh_polyhedra.cpp b/src/geode/model/helpers/component_mesh_polyhedra.cpp index 3ec874cb6..608348c2f 100644 --- a/src/geode/model/helpers/component_mesh_polyhedra.cpp +++ b/src/geode/model/helpers/component_mesh_polyhedra.cpp @@ -69,7 +69,7 @@ namespace common_block_vertices_list_.clear(); for( const auto& first_cmv : unique_vertices_cmvs_[0].get() ) { - if( first_cmv.component_id.type() + if( first_cmv.component_id.type != geode::Block3D::component_type_static() ) { continue; @@ -80,7 +80,7 @@ namespace continue; } fill_polyhedron_vertices_possibilities( - first_cmv.component_id.id(), mesh_vertices, 1, + first_cmv.component_id.id, mesh_vertices, 1, { first_cmv.vertex } ); } return std::move( common_block_vertices_list_ ); @@ -90,7 +90,7 @@ namespace absl::FixedArray< std::vector< geode::index_t > > block_mesh_vertices( const geode::ComponentMeshVertex& first_cmv ) { - const auto& first_cmv_block_id = first_cmv.component_id.id(); + const auto& first_cmv_block_id = first_cmv.component_id.id; absl::FixedArray< std::vector< geode::index_t > > mesh_vertices( nb_unique_vertices_ ); mesh_vertices[0].push_back( first_cmv.vertex ); @@ -100,7 +100,7 @@ namespace for( const auto& other_cmv : unique_vertices_cmvs_[other_cmv_list_id].get() ) { - if( first_cmv_block_id == other_cmv.component_id.id() ) + if( first_cmv_block_id == other_cmv.component_id.id ) { mesh_vertices[other_cmv_list_id].push_back( other_cmv.vertex ); diff --git a/src/geode/model/helpers/component_mesh_vertices.cpp b/src/geode/model/helpers/component_mesh_vertices.cpp index c5dd1ee81..4a3c477f6 100644 --- a/src/geode/model/helpers/component_mesh_vertices.cpp +++ b/src/geode/model/helpers/component_mesh_vertices.cpp @@ -117,7 +117,7 @@ namespace geode unique_vertices0, unique_vertices1 ), [type]( const ComponentMeshVertex& cmv0, const ComponentMeshVertex& cmv1 ) { - return cmv0.component_id.type() == type + return cmv0.component_id.type == type && cmv0.component_id == cmv1.component_id; } ); } @@ -162,7 +162,7 @@ namespace geode unique_vertices0, unique_vertices1, unique_vertices2 ), [type]( const ComponentMeshVertex& cmv0, const ComponentMeshVertex& cmv1 ) { - return cmv0.component_id.type() == type + return cmv0.component_id.type == type && cmv0.component_id == cmv1.component_id; } ); } @@ -206,7 +206,7 @@ namespace geode return ::component_mesh_vertex_generic< dimension >( unique_vertices, [type]( const ComponentMeshVertex& cmv0, const ComponentMeshVertex& cmv1 ) { - return cmv0.component_id.type() == type + return cmv0.component_id.type == type && cmv0.component_id == cmv1.component_id; } ); } diff --git a/src/geode/model/helpers/compute_unique_vertices.cpp b/src/geode/model/helpers/compute_unique_vertices.cpp index 95c1eb50e..4bf5f2112 100644 --- a/src/geode/model/helpers/compute_unique_vertices.cpp +++ b/src/geode/model/helpers/compute_unique_vertices.cpp @@ -92,29 +92,29 @@ namespace const geode::Point< Model::dim >& get_point_base( const Model& model, const geode::ComponentMeshVertex& cmv ) { - if( cmv.component_id.type() + if( cmv.component_id.type == geode::Surface< Model::dim >::component_type_static() ) { - const auto& surface = model.surface( cmv.component_id.id() ); + const auto& surface = model.surface( cmv.component_id.id ); return surface.mesh().point( cmv.vertex ); } - if( cmv.component_id.type() + if( cmv.component_id.type == geode::Line< Model::dim >::component_type_static() ) { - const auto& line = model.line( cmv.component_id.id() ); + const auto& line = model.line( cmv.component_id.id ); return line.mesh().point( cmv.vertex ); } - if( cmv.component_id.type() + if( cmv.component_id.type == geode::Corner< Model::dim >::component_type_static() ) { - const auto& corner = model.corner( cmv.component_id.id() ); + const auto& corner = model.corner( cmv.component_id.id ); return corner.mesh().point( cmv.vertex ); } throw geode::OpenGeodeModelException{ nullptr, geode::OpenGeodeException::TYPE::data, "[compute_unique_vertices::get_point] Unknown component type: ", cmv.component_id.string() }; - const auto& corner = model.corner( cmv.component_id.id() ); + const auto& corner = model.corner( cmv.component_id.id ); return corner.mesh().point( cmv.vertex ); } @@ -127,10 +127,10 @@ namespace const geode::Point3D& get_point( const geode::BRep& model, const geode::ComponentMeshVertex& cmv ) { - if( cmv.component_id.type() + if( cmv.component_id.type == geode::Block< 3 >::component_type_static() ) { - const auto& block = model.block( cmv.component_id.id() ); + const auto& block = model.block( cmv.component_id.id ); return block.mesh().point( cmv.vertex ); } return get_point_base< geode::BRep >( model, cmv ); diff --git a/src/geode/model/helpers/convert_brep_section.cpp b/src/geode/model/helpers/convert_brep_section.cpp index a73a4e147..270de7eaa 100644 --- a/src/geode/model/helpers/convert_brep_section.cpp +++ b/src/geode/model/helpers/convert_brep_section.cpp @@ -266,7 +266,7 @@ namespace brep_.unique_vertex( { line.component_id(), line_pointid } ); for( const auto& cmv : brep_.component_mesh_vertices( uvertex_id ) ) { - if( cmv.component_id.id() == surface.id() ) + if( cmv.component_id.id == surface.id() ) { return cmv.vertex; } @@ -367,7 +367,7 @@ namespace brep_.unique_vertex( { surface.component_id(), surf_pointid } ); for( const auto& cmv : brep_.component_mesh_vertices( uvertex_id ) ) { - if( cmv.component_id.id() == block.id() ) + if( cmv.component_id.id == block.id() ) { return cmv.vertex; } diff --git a/src/geode/model/helpers/detail/build_model_boundaries.cpp b/src/geode/model/helpers/detail/build_model_boundaries.cpp index c8f1ad743..2f37e160f 100644 --- a/src/geode/model/helpers/detail/build_model_boundaries.cpp +++ b/src/geode/model/helpers/detail/build_model_boundaries.cpp @@ -39,7 +39,7 @@ namespace { for( const auto& collection : model.collections( component_id ) ) { - if( collection.type() + if( collection.type == geode::ModelBoundary< Model::dim >::component_type_static() ) { return true; diff --git a/src/geode/model/helpers/surface_radial_sort.cpp b/src/geode/model/helpers/surface_radial_sort.cpp index 2a9c95968..7f3e7ab6b 100644 --- a/src/geode/model/helpers/surface_radial_sort.cpp +++ b/src/geode/model/helpers/surface_radial_sort.cpp @@ -105,7 +105,7 @@ namespace geode::component_mesh_vertex_pairs( vertices0, vertices1, geode::Surface3D::component_type_static() ) ) { - const auto& surface_id = vertex_pairs.first.id(); + const auto& surface_id = vertex_pairs.first.id; const auto& surface = brep.surface( surface_id ); const auto& surface_mesh = surface.mesh(); for( const auto& pair : vertex_pairs.second ) diff --git a/src/geode/model/mixin/core/component_mesh_element.cpp b/src/geode/model/mixin/core/component_mesh_element.cpp index d6ecb996f..22f0e2e34 100644 --- a/src/geode/model/mixin/core/component_mesh_element.cpp +++ b/src/geode/model/mixin/core/component_mesh_element.cpp @@ -30,7 +30,7 @@ namespace std size_t hash< geode::ComponentMeshElement >::operator()( const geode::ComponentMeshElement& cme ) const { - return absl::Hash< geode::uuid >()( cme.component_id.id() ) + return absl::Hash< geode::uuid >()( cme.component_id.id ) ^ absl::Hash< geode::index_t >()( cme.element_id ); } } // namespace std \ No newline at end of file diff --git a/src/geode/model/mixin/core/component_type.cpp b/src/geode/model/mixin/core/component_type.cpp index eb0c1d822..8d48d69bc 100644 --- a/src/geode/model/mixin/core/component_type.cpp +++ b/src/geode/model/mixin/core/component_type.cpp @@ -34,8 +34,8 @@ namespace std } size_t hash< geode::ComponentID >::operator()( - const geode::ComponentID& id ) const + const geode::ComponentID& component_id ) const { - return absl::Hash< geode::uuid >()( id.id() ); + return absl::Hash< geode::uuid >()( component_id.id ); } } // namespace std \ No newline at end of file diff --git a/src/geode/model/mixin/core/detail/relationships_impl.cpp b/src/geode/model/mixin/core/detail/relationships_impl.cpp index 6deb59484..709b31fb1 100644 --- a/src/geode/model/mixin/core/detail/relationships_impl.cpp +++ b/src/geode/model/mixin/core/detail/relationships_impl.cpp @@ -122,7 +122,7 @@ namespace geode const ComponentID& from, const ComponentID& to ) { if( const auto component_id = - relation_edge_index( from.id(), to.id() ) ) + relation_edge_index( from.id, to.id ) ) { Logger::warning( "This relation already exists (", from.string(), " and ", to.string(), ")" ); @@ -196,14 +196,14 @@ namespace geode for( const auto vertex_id : Range{ graph_->nb_vertices() } ) { const auto& component_id = component_from_index( vertex_id ); - if( mapping.has_mapping_type( component_id.type() ) - && mapping.at( component_id.type() ) - .has_mapping_input( component_id.id() ) ) + if( mapping.has_mapping_type( component_id.type ) + && mapping.at( component_id.type ) + .has_mapping_input( component_id.id ) ) { - const auto& new_uuid = mapping.at( component_id.type() ) - .in2out( component_id.id() ); + const auto& new_uuid = mapping.at( component_id.type ) + .in2out( component_id.id ); ids_->set_value( - vertex_id, { component_id.type(), new_uuid } ); + vertex_id, { component_id.type, new_uuid } ); uuid2index_.set_new_mapping( new_uuid, vertex_id ); } else @@ -273,7 +273,7 @@ namespace geode const ComponentID& component_id ) { const auto index = GraphBuilder::create( *graph_ )->create_vertex(); - uuid2index_.set_new_mapping( component_id.id(), index ); + uuid2index_.set_new_mapping( component_id.id, index ); ids_->set_value( index, component_id ); return index; } @@ -281,7 +281,7 @@ namespace geode index_t RelationshipsImpl::find_or_create_vertex_id( const ComponentID& component_id ) { - if( const auto index = vertex_id( component_id.id() ) ) + if( const auto index = vertex_id( component_id.id ) ) { return index.value(); } diff --git a/src/geode/model/mixin/core/relationships.cpp b/src/geode/model/mixin/core/relationships.cpp index 4fae8f60f..8f522bb53 100644 --- a/src/geode/model/mixin/core/relationships.cpp +++ b/src/geode/model/mixin/core/relationships.cpp @@ -108,7 +108,7 @@ namespace geode } return graph_component_id( { edge_id.value(), BOUNDARY_EDGE_VERTEX } ) - .id() + .id == from; } @@ -122,7 +122,7 @@ namespace geode } return graph_component_id( { edge_id.value(), INTERNAL_EDGE_VERTEX } ) - .id() + .id == from; } @@ -135,7 +135,7 @@ namespace geode return false; } return graph_component_id( { edge_id.value(), ITEM_EDGE_VERTEX } ) - .id() + .id == from; } @@ -144,7 +144,7 @@ namespace geode const RelationType type ) { if( const auto component_id = - relation_edge_index( from.id(), to.id() ) ) + relation_edge_index( from.id, to.id ) ) { const auto relation_type = relation_type_->value( component_id.value() ); diff --git a/src/geode/model/mixin/core/vertex_identifier.cpp b/src/geode/model/mixin/core/vertex_identifier.cpp index d21f9f217..7f65a8c95 100644 --- a/src/geode/model/mixin/core/vertex_identifier.cpp +++ b/src/geode/model/mixin/core/vertex_identifier.cpp @@ -69,7 +69,7 @@ namespace geode MeshVertex ComponentMeshVertex::mesh_vertex() const { - return { component_id.id(), vertex }; + return { component_id.id, vertex }; } bool ComponentMeshVertex::operator==( @@ -164,7 +164,7 @@ namespace geode component_mesh_vertices( unique_vertex_id ); for( const auto& component_vertex : component_vertices ) { - if( component_vertex.component_id.type() == type ) + if( component_vertex.component_id.type == type ) { return true; } @@ -178,7 +178,7 @@ namespace geode for( const auto& component_vertex : component_mesh_vertices( unique_vertex_id ) ) { - if( component_vertex.component_id.id() == component_id ) + if( component_vertex.component_id.id == component_id ) { return true; } @@ -268,14 +268,13 @@ namespace geode unique_vertex_id, " does not exist (nb=", nb_unique_vertices(), ")" ); const auto& old_unique_id = - vertex2unique_vertex_ - .at( component_vertex_id.component_id.id() ) + vertex2unique_vertex_.at( component_vertex_id.component_id.id ) ->value( component_vertex_id.vertex ); if( old_unique_id != NO_ID ) { unset_unique_vertex( component_vertex_id, old_unique_id ); } - vertex2unique_vertex_.at( component_vertex_id.component_id.id() ) + vertex2unique_vertex_.at( component_vertex_id.component_id.id ) ->set_value( component_vertex_id.vertex, unique_vertex_id ); component_vertices_->modify_value( unique_vertex_id, [&component_vertex_id]( @@ -292,7 +291,7 @@ namespace geode const ComponentMeshVertex& component_vertex_id, const index_t unique_vertex_id ) { - vertex2unique_vertex_.at( component_vertex_id.component_id.id() ) + vertex2unique_vertex_.at( component_vertex_id.component_id.id ) ->set_value( component_vertex_id.vertex, NO_ID ); const auto& vertices = component_vertices_->value( unique_vertex_id ); @@ -315,7 +314,7 @@ namespace geode async::parallel_for( async::irange( index_t{ 0 }, nb_unique_vertices() ), [this, &component_id, &old2new]( index_t uv ) { - if( !has_component_mesh_vertices( uv, component_id.id() ) ) + if( !has_component_mesh_vertices( uv, component_id.id ) ) { return; } @@ -325,7 +324,7 @@ namespace geode for( const auto v : Indices{ all_vertices } ) { const auto& cmv = all_vertices[v]; - if( cmv.component_id.id() != component_id.id() ) + if( cmv.component_id.id != component_id.id ) { continue; } @@ -369,7 +368,7 @@ namespace geode } for( const auto& cmv : component_mesh_vertices( v ) ) { - components_vertices[cmv.component_id.id()].emplace_back( + components_vertices[cmv.component_id.id].emplace_back( cmv.vertex ); } } @@ -495,7 +494,7 @@ namespace geode bool update{ false }; for( const auto i : Indices{ component_mesh_vertices } ) { - if( component_mesh_vertices[i].component_id.id() + if( component_mesh_vertices[i].component_id.id == component_id ) { to_keep[i] = false; @@ -551,7 +550,7 @@ namespace geode index_t VertexIdentifier::unique_vertex( const ComponentMeshVertex& component_mesh_vertex ) const { - return impl_->unique_vertex( component_mesh_vertex.component_id.id(), + return impl_->unique_vertex( component_mesh_vertex.component_id.id, component_mesh_vertex.vertex ); } @@ -703,7 +702,7 @@ namespace std size_t hash< geode::ComponentMeshVertex >::operator()( const geode::ComponentMeshVertex& cmv ) const { - return absl::Hash< geode::uuid >()( cmv.component_id.id() ) + return absl::Hash< geode::uuid >()( cmv.component_id.id ) ^ absl::Hash< geode::index_t >()( cmv.vertex ); } } // namespace std diff --git a/src/geode/model/representation/builder/brep_builder.cpp b/src/geode/model/representation/builder/brep_builder.cpp index 1881d4cc2..ec3a2bb90 100644 --- a/src/geode/model/representation/builder/brep_builder.cpp +++ b/src/geode/model/representation/builder/brep_builder.cpp @@ -519,27 +519,26 @@ namespace geode { for( const auto& cmv : brep_.component_mesh_vertices( unique_vertex ) ) { - if( cmv.component_id.type() == Block3D::component_type_static() ) + if( cmv.component_id.type == Block3D::component_type_static() ) { - block_mesh_builder( brep_.block( cmv.component_id.id() ) ) + block_mesh_builder( brep_.block( cmv.component_id.id ) ) ->set_point( cmv.vertex, point ); } - else if( cmv.component_id.type() + else if( cmv.component_id.type == Surface3D::component_type_static() ) { - surface_mesh_builder( brep_.surface( cmv.component_id.id() ) ) + surface_mesh_builder( brep_.surface( cmv.component_id.id ) ) ->set_point( cmv.vertex, point ); } - else if( cmv.component_id.type() - == Line3D::component_type_static() ) + else if( cmv.component_id.type == Line3D::component_type_static() ) { - line_mesh_builder( brep_.line( cmv.component_id.id() ) ) + line_mesh_builder( brep_.line( cmv.component_id.id ) ) ->set_point( cmv.vertex, point ); } - else if( cmv.component_id.type() + else if( cmv.component_id.type == Corner3D::component_type_static() ) { - corner_mesh_builder( brep_.corner( cmv.component_id.id() ) ) + corner_mesh_builder( brep_.corner( cmv.component_id.id ) ) ->set_point( cmv.vertex, point ); } } diff --git a/src/geode/model/representation/builder/section_builder.cpp b/src/geode/model/representation/builder/section_builder.cpp index 9ef73bf91..0f35c1fc3 100644 --- a/src/geode/model/representation/builder/section_builder.cpp +++ b/src/geode/model/representation/builder/section_builder.cpp @@ -417,22 +417,20 @@ namespace geode for( const auto& cmv : section_.component_mesh_vertices( unique_vertex ) ) { - if( cmv.component_id.type() == Surface2D::component_type_static() ) + if( cmv.component_id.type == Surface2D::component_type_static() ) { - surface_mesh_builder( - section_.surface( cmv.component_id.id() ) ) + surface_mesh_builder( section_.surface( cmv.component_id.id ) ) ->set_point( cmv.vertex, point ); } - else if( cmv.component_id.type() - == Line2D::component_type_static() ) + else if( cmv.component_id.type == Line2D::component_type_static() ) { - line_mesh_builder( section_.line( cmv.component_id.id() ) ) + line_mesh_builder( section_.line( cmv.component_id.id ) ) ->set_point( cmv.vertex, point ); } - else if( cmv.component_id.type() + else if( cmv.component_id.type == Corner2D::component_type_static() ) { - corner_mesh_builder( section_.corner( cmv.component_id.id() ) ) + corner_mesh_builder( section_.corner( cmv.component_id.id ) ) ->set_point( cmv.vertex, point ); } } diff --git a/src/geode/model/representation/core/brep.cpp b/src/geode/model/representation/core/brep.cpp index e97f0b527..f6fd2129f 100644 --- a/src/geode/model/representation/core/brep.cpp +++ b/src/geode/model/representation/core/brep.cpp @@ -81,7 +81,7 @@ namespace geode const Corner3D& BRep::BoundaryCornerRange::operator*() const { return brep_.corner( - Relationships::BoundaryRangeIterator::operator*().id() ); + Relationships::BoundaryRangeIterator::operator*().id ); } BRep::BoundaryLineRange BRep::boundaries( const Surface3D& surface ) const @@ -116,7 +116,7 @@ namespace geode const Line3D& BRep::BoundaryLineRange::operator*() const { return brep_.line( - Relationships::BoundaryRangeIterator::operator*().id() ); + Relationships::BoundaryRangeIterator::operator*().id ); } BRep::BoundarySurfaceRange BRep::boundaries( const Block3D& block ) const @@ -153,7 +153,7 @@ namespace geode const Surface3D& BRep::BoundarySurfaceRange::operator*() const { return brep_.surface( - Relationships::BoundaryRangeIterator::operator*().id() ); + Relationships::BoundaryRangeIterator::operator*().id ); } BRep::IncidentLineRange BRep::incidences( const Corner3D& corner ) const @@ -188,7 +188,7 @@ namespace geode const Line3D& BRep::IncidentLineRange::operator*() const { return brep_.line( - Relationships::IncidenceRangeIterator::operator*().id() ); + Relationships::IncidenceRangeIterator::operator*().id ); } BRep::IncidentSurfaceRange BRep::incidences( const Line3D& line ) const @@ -225,7 +225,7 @@ namespace geode const Surface3D& BRep::IncidentSurfaceRange::operator*() const { return brep_.surface( - Relationships::IncidenceRangeIterator::operator*().id() ); + Relationships::IncidenceRangeIterator::operator*().id ); } BRep::IncidentBlockRange BRep::incidences( const Surface3D& surface ) const @@ -261,7 +261,7 @@ namespace geode const Block3D& BRep::IncidentBlockRange::operator*() const { return brep_.block( - Relationships::IncidenceRangeIterator::operator*().id() ); + Relationships::IncidenceRangeIterator::operator*().id ); } BRep::InternalLineRange BRep::internal_lines( @@ -317,7 +317,7 @@ namespace geode const Line3D& BRep::InternalLineRange::operator*() const { return brep_.line( - Relationships::InternalRangeIterator::operator*().id() ); + Relationships::InternalRangeIterator::operator*().id ); } BRep::InternalCornerRange BRep::internal_corners( const Line3D& line ) const @@ -387,7 +387,7 @@ namespace geode const Corner3D& BRep::InternalCornerRange::operator*() const { return brep_.corner( - Relationships::InternalRangeIterator::operator*().id() ); + Relationships::InternalRangeIterator::operator*().id ); } BRep::InternalSurfaceRange BRep::internal_surfaces( @@ -432,7 +432,7 @@ namespace geode const Surface3D& BRep::InternalSurfaceRange::operator*() const { return brep_.surface( - Relationships::InternalRangeIterator::operator*().id() ); + Relationships::InternalRangeIterator::operator*().id ); } BRep::EmbeddingLineRange BRep::embedding_lines( @@ -476,7 +476,7 @@ namespace geode const Line3D& BRep::EmbeddingLineRange::operator*() const { return brep_.line( - Relationships::EmbeddingRangeIterator::operator*().id() ); + Relationships::EmbeddingRangeIterator::operator*().id ); } BRep::EmbeddingSurfaceRange BRep::embedding_surfaces( @@ -536,7 +536,7 @@ namespace geode const Surface3D& BRep::EmbeddingSurfaceRange::operator*() const { return brep_.surface( - Relationships::EmbeddingRangeIterator::operator*().id() ); + Relationships::EmbeddingRangeIterator::operator*().id ); } BRep::EmbeddingBlockRange BRep::embedding_blocks( @@ -607,7 +607,7 @@ namespace geode const Block3D& BRep::EmbeddingBlockRange::operator*() const { return brep_.block( - Relationships::EmbeddingRangeIterator::operator*().id() ); + Relationships::EmbeddingRangeIterator::operator*().id ); } BRep::ItemCornerRange::ItemCornerRange( @@ -636,8 +636,7 @@ namespace geode const Corner3D& BRep::ItemCornerRange::operator*() const { - return brep_.corner( - Relationships::ItemRangeIterator::operator*().id() ); + return brep_.corner( Relationships::ItemRangeIterator::operator*().id ); } BRep::ItemLineRange::ItemLineRange( @@ -666,7 +665,7 @@ namespace geode const Line3D& BRep::ItemLineRange::operator*() const { - return brep_.line( Relationships::ItemRangeIterator::operator*().id() ); + return brep_.line( Relationships::ItemRangeIterator::operator*().id ); } BRep::ItemSurfaceRange::ItemSurfaceRange( @@ -702,7 +701,7 @@ namespace geode const Surface3D& BRep::ItemSurfaceRange::operator*() const { return brep_.surface( - Relationships::ItemRangeIterator::operator*().id() ); + Relationships::ItemRangeIterator::operator*().id ); } BRep::ItemBlockRange::ItemBlockRange( @@ -731,8 +730,7 @@ namespace geode const Block3D& BRep::ItemBlockRange::operator*() const { - return brep_.block( - Relationships::ItemRangeIterator::operator*().id() ); + return brep_.block( Relationships::ItemRangeIterator::operator*().id ); } BRep::BRep() = default; diff --git a/src/geode/model/representation/core/section.cpp b/src/geode/model/representation/core/section.cpp index ec6407708..5e49f03f2 100644 --- a/src/geode/model/representation/core/section.cpp +++ b/src/geode/model/representation/core/section.cpp @@ -81,7 +81,7 @@ namespace geode const Corner2D& Section::BoundaryCornerRange::operator*() const { return section_.corner( - Relationships::BoundaryRangeIterator::operator*().id() ); + Relationships::BoundaryRangeIterator::operator*().id ); } Section::BoundaryLineRange Section::boundaries( @@ -119,7 +119,7 @@ namespace geode const Line2D& Section::BoundaryLineRange::operator*() const { return section_.line( - Relationships::BoundaryRangeIterator::operator*().id() ); + Relationships::BoundaryRangeIterator::operator*().id ); } Section::IncidentLineRange Section::incidences( @@ -157,7 +157,7 @@ namespace geode const Line2D& Section::IncidentLineRange::operator*() const { return section_.line( - Relationships::IncidenceRangeIterator::operator*().id() ); + Relationships::IncidenceRangeIterator::operator*().id ); } Section::IncidentSurfaceRange Section::incidences( @@ -197,7 +197,7 @@ namespace geode const Surface2D& Section::IncidentSurfaceRange::operator*() const { return section_.surface( - Relationships::IncidenceRangeIterator::operator*().id() ); + Relationships::IncidenceRangeIterator::operator*().id ); } Section::InternalLineRange Section::internal_lines( @@ -242,7 +242,7 @@ namespace geode const Line2D& Section::InternalLineRange::operator*() const { return section_.line( - Relationships::InternalRangeIterator::operator*().id() ); + Relationships::InternalRangeIterator::operator*().id ); } Section::InternalCornerRange Section::internal_corners( @@ -302,7 +302,7 @@ namespace geode const Corner2D& Section::InternalCornerRange::operator*() const { return section_.corner( - Relationships::InternalRangeIterator::operator*().id() ); + Relationships::InternalRangeIterator::operator*().id ); } Section::EmbeddingLineRange Section::embedding_lines( @@ -347,7 +347,7 @@ namespace geode const Line2D& Section::EmbeddingLineRange::operator*() const { return section_.line( - Relationships::EmbeddingRangeIterator::operator*().id() ); + Relationships::EmbeddingRangeIterator::operator*().id ); } Section::EmbeddingSurfaceRange Section::embedding_surfaces( @@ -408,7 +408,7 @@ namespace geode const Surface2D& Section::EmbeddingSurfaceRange::operator*() const { return section_.surface( - Relationships::EmbeddingRangeIterator::operator*().id() ); + Relationships::EmbeddingRangeIterator::operator*().id ); } Section::ItemCornerRange::ItemCornerRange( @@ -438,7 +438,7 @@ namespace geode const Corner2D& Section::ItemCornerRange::operator*() const { return section_.corner( - Relationships::ItemRangeIterator::operator*().id() ); + Relationships::ItemRangeIterator::operator*().id ); } Section::ItemLineRange::ItemLineRange( @@ -475,7 +475,7 @@ namespace geode const Line2D& Section::ItemLineRange::operator*() const { return section_.line( - Relationships::ItemRangeIterator::operator*().id() ); + Relationships::ItemRangeIterator::operator*().id ); } Section::ItemSurfaceRange::ItemSurfaceRange( @@ -505,7 +505,7 @@ namespace geode const Surface2D& Section::ItemSurfaceRange::operator*() const { return section_.surface( - Relationships::ItemRangeIterator::operator*().id() ); + Relationships::ItemRangeIterator::operator*().id ); } Section::Section() = default; diff --git a/tests/model/test-model-creator.cpp b/tests/model/test-model-creator.cpp index 2417c2ba2..27985e80d 100644 --- a/tests/model/test-model-creator.cpp +++ b/tests/model/test-model-creator.cpp @@ -279,7 +279,7 @@ void test_section() bool found{ false }; for( const auto b2 : boundary_definitions[b].boundaries ) { - if( line.id() == lines[b2] ) + if( line.id == lines[b2] ) { found = true; break; diff --git a/tests/model/test-relationships.cpp b/tests/model/test-relationships.cpp index 48d0b3c47..cfe9a697a 100644 --- a/tests/model/test-relationships.cpp +++ b/tests/model/test-relationships.cpp @@ -162,10 +162,10 @@ void test_attributes( const geode::Relationships& relations, "Wrong relation index from uuids" ); const auto output = relations.relation_from_index( 0 ); geode::OpenGeodeModelException::test( - std::get< 0 >( output ).id() == uuids[1], + std::get< 0 >( output ).id == uuids[1], "Wrong relation uuids from index" ); geode::OpenGeodeModelException::test( - std::get< 1 >( output ).id() == uuids[0], + std::get< 1 >( output ).id == uuids[0], "Wrong relation uuids from index" ); geode::AttributeProperties attribute_properties; attribute_properties.assignable = false; From ac3545f833d981ea2d48aaa14955ebe18a64ce42 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Thu, 13 Aug 2026 17:47:20 +0200 Subject: [PATCH 2/5] fix python --- bindings/python/tests/model/test-py-brep.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/tests/model/test-py-brep.py b/bindings/python/tests/model/test-py-brep.py index 09ed3d2bf..bbb814446 100644 --- a/bindings/python/tests/model/test-py-brep.py +++ b/bindings/python/tests/model/test-py-brep.py @@ -346,7 +346,7 @@ def add_surfaces_in_model_boundaries(brep, builder, surface_uuids, boundary_uuid if brep.nb_collections(surface_id) != 1: raise ValueError("[Test] All Surfaces should be in 1 collection") for collection in brep.collections(surface_id): - if not collection.type().matches( + if not collection.type.matches( model.ModelBoundary3D.component_type_static() ): raise ValueError( From 658660ba787bd318864dc934bb46ad4a0df8b8ff Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 14 Aug 2026 09:29:06 +0200 Subject: [PATCH 3/5] fix python --- bindings/python/tests/model/test-py-brep.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bindings/python/tests/model/test-py-brep.py b/bindings/python/tests/model/test-py-brep.py index bbb814446..ae42c366f 100644 --- a/bindings/python/tests/model/test-py-brep.py +++ b/bindings/python/tests/model/test-py-brep.py @@ -368,7 +368,7 @@ def add_corners_in_corner_collections(brep, builder, corner_uuids, collection_uu if brep.nb_collections(corner_id) != 1: raise ValueError("[Test] All Corners should be in 1 collection") for collection in brep.collections(corner_id): - if not collection.type().matches( + if not collection.type.matches( model.CornerCollection3D.component_type_static() ): raise ValueError( @@ -390,7 +390,7 @@ def add_lines_in_line_collections(brep, builder, line_uuids, collection_uuids): if brep.nb_collections(line_id) != 1: raise ValueError("[Test] All Lines should be in 1 collection") for collection in brep.collections(line_id): - if not collection.type().matches( + if not collection.type.matches( model.LineCollection3D.component_type_static() ): raise ValueError( @@ -412,9 +412,9 @@ def add_surfaces_in_surface_collections(brep, builder, surface_uuids, collection if brep.nb_collections(surface_id) != 2: raise ValueError("[Test] All Surfaces should be in 2 collections") for collection in brep.collections(surface_id): - if not collection.type().matches( + if not collection.type.matches( model.SurfaceCollection3D.component_type_static() - ) and not collection.type().matches( + ) and not collection.type.matches( model.ModelBoundary3D.component_type_static() ): raise ValueError( @@ -430,7 +430,7 @@ def add_blocks_in_block_collections(brep, builder, block_uuid, collection_uuid): if brep.nb_collections(block_uuid) != 1: raise ValueError("[Test] All Blocks should be in 1 collection") for collection in brep.collections(block_uuid): - if not collection.type().matches( + if not collection.type.matches( model.BlockCollection3D.component_type_static() ): raise ValueError( From 31466dcc8c3fccdc59c9f1a3088cf0e3bca27424 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 14 Aug 2026 09:53:31 +0200 Subject: [PATCH 4/5] fix python --- bindings/python/src/model/mixin/core/component_type.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bindings/python/src/model/mixin/core/component_type.cpp b/bindings/python/src/model/mixin/core/component_type.cpp index 2e0c4e0f9..0523d3545 100644 --- a/bindings/python/src/model/mixin/core/component_type.cpp +++ b/bindings/python/src/model/mixin/core/component_type.cpp @@ -39,6 +39,8 @@ namespace geode .def( pybind11::init<>() ) .def( pybind11::init< ComponentType, uuid >() ) .def( "string", &ComponentID::string ) + .def_readwrite( "type", &ComponentID::type ) + .def_readwrite( "id", &ComponentID::id ) .def( pybind11::self == pybind11::self ) .def( pybind11::self != pybind11::self ); } From b4c4a549304adeae8f5424e3b35ac6ff5024b475 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 14 Aug 2026 10:13:10 +0200 Subject: [PATCH 5/5] fix python --- bindings/python/tests/model/test-py-section.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bindings/python/tests/model/test-py-section.py b/bindings/python/tests/model/test-py-section.py index 8cd0a36cf..7b99215be 100644 --- a/bindings/python/tests/model/test-py-section.py +++ b/bindings/python/tests/model/test-py-section.py @@ -218,7 +218,7 @@ def add_lines_in_model_boundaries(section, builder, line_uuids, boundary_uuids): if section.nb_collections(line_uuids[i]) != 1: raise ValueError("[Test] This Line should be in 1 collection") for collection in section.collections(line_uuids[i]): - if not collection.type().matches(model.ModelBoundary2D.component_type_static()): + if not collection.type.matches(model.ModelBoundary2D.component_type_static()): raise ValueError( "[Test] This Line should be in 1 collection of type Boundary") if section.nb_collections(line_uuids[4]) != 0: @@ -237,7 +237,7 @@ def add_corners_in_corner_collections(section, builder, corner_uuids, collection if section.nb_collections(corner_id) != 1: raise ValueError("[Test] All Corners should be in 1 collection") for collection in section.collections(corner_id): - if not collection.type().matches(model.CornerCollection2D.component_type_static()): + if not collection.type.matches(model.CornerCollection2D.component_type_static()): raise ValueError( "[Test] This corner should be in 1 collection of type CornerCollection") @@ -253,7 +253,7 @@ def add_lines_in_line_collections(section, builder, line_uuids, collection_uuids if section.nb_collections(line_uuids[i]) != 2: raise ValueError("[Test] This Line should be in 2 collections") for collection in section.collections(line_uuids[i]): - if not collection.type().matches(model.LineCollection2D.component_type_static()) and not collection.type().matches(model.ModelBoundary2D.component_type_static()): + if not collection.type.matches(model.LineCollection2D.component_type_static()) and not collection.type.matches(model.ModelBoundary2D.component_type_static()): raise ValueError( "[Test] This line should be in 2 collection of type LineCollection and ModelBoundary") for i in range(3,5): @@ -261,7 +261,7 @@ def add_lines_in_line_collections(section, builder, line_uuids, collection_uuids raise ValueError( "[Test] Last Lines should be in 1 collection (of type LineCollection)") for collection in section.collections(line_uuids[i]): - if not collection.type().matches(model.LineCollection2D.component_type_static()): + if not collection.type.matches(model.LineCollection2D.component_type_static()): raise ValueError( "[Test] This line should be in 1 collection of type LineCollection") @@ -274,7 +274,7 @@ def add_surfaces_in_surface_collections(section, builder, surface_uuids, collect if section.nb_collections(surface_id) != 1: raise ValueError("[Test] All Surfaces should be in 1 collections") for collection in section.collections(surface_id): - if not collection.type().matches(model.SurfaceCollection2D.component_type_static()): + if not collection.type.matches(model.SurfaceCollection2D.component_type_static()): raise ValueError( "[Test] This surface should be in 2 collections of type SurfaceCollection")