From 50f874afd510040fa713432acb969a3736cb71e5 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Wed, 12 Aug 2026 09:24:09 +0200 Subject: [PATCH 1/2] feat(ModelBuilders): change parameters in model builder functions BREAKING CHANGE: take components instead of uuid in model builders such as set_surface_name --- .../builder/block_collections_builder.cpp | 1 + .../builder/corner_collections_builder.cpp | 1 + .../model/mixin/builder/corners_builder.cpp | 1 + .../builder/line_collections_builder.cpp | 1 + .../src/model/mixin/builder/lines_builder.cpp | 1 + .../builder/model_boundaries_builder.cpp | 1 + .../builder/surface_collections_builder.cpp | 1 + bindings/python/tests/model/test-py-brep.py | 18 +- .../python/tests/model/test-py-section.py | 8 +- .../internal/simplicial_model_creator.hpp | 7 +- .../builder/block_collections_builder.hpp | 7 +- .../model/mixin/builder/blocks_builder.hpp | 15 +- .../builder/corner_collections_builder.hpp | 7 +- .../model/mixin/builder/corners_builder.hpp | 12 +- .../builder/line_collections_builder.hpp | 7 +- .../model/mixin/builder/lines_builder.hpp | 11 +- .../builder/model_boundaries_builder.hpp | 6 +- .../builder/surface_collections_builder.hpp | 7 +- .../model/mixin/builder/surfaces_builder.hpp | 16 +- .../representation/builder/detail/copy.hpp | 134 +++++++----- .../core/detail/transfer_metadata.hpp | 24 ++- .../model/helpers/convert_brep_section.cpp | 31 +-- .../model/helpers/convert_model_meshes.cpp | 2 +- .../helpers/create_coordinate_system.cpp | 16 +- .../helpers/detail/build_model_boundaries.cpp | 3 +- .../detail/solid_mesh_validity_fix.cpp | 2 +- .../detail/split_along_block_mesh_borders.cpp | 9 +- .../split_along_surface_mesh_borders.cpp | 6 +- .../detail/surface_mesh_validity_fix.cpp | 3 +- .../model/helpers/simplicial_brep_creator.cpp | 3 +- .../builder/block_collections_builder.cpp | 17 +- .../model/mixin/builder/blocks_builder.cpp | 15 +- .../builder/corner_collections_builder.cpp | 17 +- .../model/mixin/builder/corners_builder.cpp | 26 +-- .../builder/line_collections_builder.cpp | 17 +- .../model/mixin/builder/lines_builder.cpp | 20 +- .../builder/model_boundaries_builder.cpp | 17 +- .../builder/surface_collections_builder.cpp | 17 +- .../model/mixin/builder/surfaces_builder.cpp | 21 +- .../representation/builder/brep_builder.cpp | 58 ++--- .../builder/section_builder.cpp | 49 ++--- .../core/detail/transfer_collections.cpp | 24 +-- .../core/detail/transfer_meshes.cpp | 16 +- .../core/detail/transfer_metadata.cpp | 117 +++++----- tests/model/test-brep.cpp | 200 +++++++++++------- tests/model/test-component-mesh-edges.cpp | 7 +- tests/model/test-model-component-filter.cpp | 2 +- tests/model/test-section.cpp | 87 +++++--- tests/model/test-surface-radial-sort.cpp | 8 +- tests/model/test-vertex-identifier.cpp | 11 +- 50 files changed, 631 insertions(+), 476 deletions(-) diff --git a/bindings/python/src/model/mixin/builder/block_collections_builder.cpp b/bindings/python/src/model/mixin/builder/block_collections_builder.cpp index f958047c2..73f52ce3a 100644 --- a/bindings/python/src/model/mixin/builder/block_collections_builder.cpp +++ b/bindings/python/src/model/mixin/builder/block_collections_builder.cpp @@ -26,6 +26,7 @@ #include #include +#include #define PYTHON_BLOCK_COLLECTIONS_BUILDER( dimension ) \ const auto name##dimension = \ diff --git a/bindings/python/src/model/mixin/builder/corner_collections_builder.cpp b/bindings/python/src/model/mixin/builder/corner_collections_builder.cpp index 38665f2c8..31bd43cbd 100644 --- a/bindings/python/src/model/mixin/builder/corner_collections_builder.cpp +++ b/bindings/python/src/model/mixin/builder/corner_collections_builder.cpp @@ -26,6 +26,7 @@ #include #include +#include #define PYTHON_CORNER_COLLECTIONS_BUILDER( dimension ) \ const auto name##dimension = \ diff --git a/bindings/python/src/model/mixin/builder/corners_builder.cpp b/bindings/python/src/model/mixin/builder/corners_builder.cpp index f1ee6df0a..e2837916b 100644 --- a/bindings/python/src/model/mixin/builder/corners_builder.cpp +++ b/bindings/python/src/model/mixin/builder/corners_builder.cpp @@ -28,6 +28,7 @@ #include #include +#include #define PYTHON_CORNERS_BUILDER( dimension ) \ const auto name##dimension = \ diff --git a/bindings/python/src/model/mixin/builder/line_collections_builder.cpp b/bindings/python/src/model/mixin/builder/line_collections_builder.cpp index aeebea4c6..8449e0b42 100644 --- a/bindings/python/src/model/mixin/builder/line_collections_builder.cpp +++ b/bindings/python/src/model/mixin/builder/line_collections_builder.cpp @@ -26,6 +26,7 @@ #include #include +#include #define PYTHON_LINE_COLLECTIONS_BUILDER( dimension ) \ const auto name##dimension = \ diff --git a/bindings/python/src/model/mixin/builder/lines_builder.cpp b/bindings/python/src/model/mixin/builder/lines_builder.cpp index 399257faf..c292541d7 100644 --- a/bindings/python/src/model/mixin/builder/lines_builder.cpp +++ b/bindings/python/src/model/mixin/builder/lines_builder.cpp @@ -28,6 +28,7 @@ #include #include +#include #define PYTHON_LINES_BUILDER( dimension ) \ const auto name##dimension = \ diff --git a/bindings/python/src/model/mixin/builder/model_boundaries_builder.cpp b/bindings/python/src/model/mixin/builder/model_boundaries_builder.cpp index c19788098..3d616645f 100644 --- a/bindings/python/src/model/mixin/builder/model_boundaries_builder.cpp +++ b/bindings/python/src/model/mixin/builder/model_boundaries_builder.cpp @@ -26,6 +26,7 @@ #include #include +#include #define PYTHON_MODEL_BOUNDARIES_BUILDER( dimension ) \ const auto name##dimension = \ diff --git a/bindings/python/src/model/mixin/builder/surface_collections_builder.cpp b/bindings/python/src/model/mixin/builder/surface_collections_builder.cpp index 91a101925..941e85657 100644 --- a/bindings/python/src/model/mixin/builder/surface_collections_builder.cpp +++ b/bindings/python/src/model/mixin/builder/surface_collections_builder.cpp @@ -26,6 +26,7 @@ #include #include +#include #define PYTHON_SURFACE_COLLECTIONS_BUILDER( dimension ) \ const auto name##dimension = \ diff --git a/bindings/python/tests/model/test-py-brep.py b/bindings/python/tests/model/test-py-brep.py index 7da7673bb..09ed3d2bf 100644 --- a/bindings/python/tests/model/test-py-brep.py +++ b/bindings/python/tests/model/test-py-brep.py @@ -43,7 +43,7 @@ def add_corners(brep, builder): uuids = [] for i in range(nb): uuids.append(builder.add_corner()) - builder.set_corner_name(uuids[-1], "corner" + str(len(uuids))) + builder.set_corner_name(brep.corner(uuids[-1]),"corner" + str(len(uuids))) temp_corner = brep.corner(builder.add_corner()) builder.remove_corner(temp_corner) @@ -59,7 +59,7 @@ def add_lines(brep, builder): uuids = [] for i in range(nb): uuids.append(builder.add_line()) - builder.set_line_name(uuids[-1], "line" + str(len(uuids))) + builder.set_line_name(brep.line(uuids[-1]), "line" + str(len(uuids))) temp_line = brep.line(builder.add_line()) builder.remove_line(temp_line) @@ -75,7 +75,7 @@ def add_surfaces(brep, builder): uuids = [] for i in range(nb): uuids.append(builder.add_surface()) - builder.set_surface_name(uuids[-1], "surface" + str(len(uuids))) + builder.set_surface_name(brep.surface(uuids[-1]), "surface" + str(len(uuids))) temp_surface = brep.surface(builder.add_surface()) builder.remove_surface(temp_surface) @@ -88,7 +88,7 @@ def add_surfaces(brep, builder): def add_block(brep, builder): uuid = builder.add_block() - builder.set_block_name(uuid, "block1") + builder.set_block_name(brep.block(uuid), "block1") temp_block = brep.block(builder.add_block()) builder.remove_block(temp_block) @@ -104,7 +104,7 @@ def add_model_boundaries(brep, builder): uuids = [] for i in range(nb): uuids.append(builder.add_model_boundary()) - builder.set_model_boundary_name(uuids[-1], "boundary" + str(len(uuids))) + builder.set_model_boundary_name(brep.model_boundary(uuids[-1]), "boundary" + str(len(uuids))) temp_boundary = brep.model_boundary(builder.add_model_boundary()) builder.remove_model_boundary(temp_boundary) @@ -120,7 +120,7 @@ def add_corner_collections(brep, builder): uuids = [] for i in range(nb): uuids.append(builder.add_corner_collection()) - builder.set_corner_collection_name(uuids[-1], "collection" + str(len(uuids))) + builder.set_corner_collection_name(brep.corner_collection(uuids[-1]), "collection" + str(len(uuids))) temp_collection = brep.corner_collection(builder.add_corner_collection()) builder.remove_corner_collection(temp_collection) @@ -136,7 +136,7 @@ def add_line_collections(brep, builder): uuids = [] for i in range(nb): uuids.append(builder.add_line_collection()) - builder.set_line_collection_name(uuids[-1], "collection" + str(len(uuids))) + builder.set_line_collection_name(brep.line_collection(uuids[-1]), "collection" + str(len(uuids))) temp_collection = brep.line_collection(builder.add_line_collection()) builder.remove_line_collection(temp_collection) @@ -152,7 +152,7 @@ def add_surface_collections(brep, builder): uuids = [] for i in range(nb): uuids.append(builder.add_surface_collection()) - builder.set_surface_collection_name(uuids[-1], "collection" + str(len(uuids))) + builder.set_surface_collection_name(brep.surface_collection(uuids[-1]), "collection" + str(len(uuids))) temp_collection = brep.surface_collection(builder.add_surface_collection()) builder.remove_surface_collection(temp_collection) @@ -165,7 +165,7 @@ def add_surface_collections(brep, builder): def add_block_collection(brep, builder): uuid = builder.add_block_collection() - builder.set_block_collection_name(uuid, "collection1") + builder.set_block_collection_name(brep.block_collection(uuid), "collection1") temp_collection = brep.block_collection(builder.add_block_collection()) builder.remove_block_collection(temp_collection) diff --git a/bindings/python/tests/model/test-py-section.py b/bindings/python/tests/model/test-py-section.py index 381e9fb54..8cd0a36cf 100644 --- a/bindings/python/tests/model/test-py-section.py +++ b/bindings/python/tests/model/test-py-section.py @@ -82,7 +82,7 @@ def add_model_boundaries(section, builder): for i in range(nb): uuids.append(builder.add_model_boundary()) builder.set_model_boundary_name( - uuids[-1], "boundary" + str(len(uuids))) + section.model_boundary(uuids[-1]), "boundary" + str(len(uuids))) temp_boundary = section.model_boundary(builder.add_model_boundary()) builder.remove_model_boundary(temp_boundary) @@ -98,7 +98,7 @@ def add_corner_collections(section, builder): for i in range(nb): uuids.append(builder.add_corner_collection()) builder.set_corner_collection_name( - uuids[-1], "collection" + str(len(uuids))) + section.corner_collection(uuids[-1]), "collection" + str(len(uuids))) temp_collection = section.corner_collection(builder.add_corner_collection()) builder.remove_corner_collection(temp_collection) @@ -114,7 +114,7 @@ def add_line_collections(section, builder): for i in range(nb): uuids.append(builder.add_line_collection()) builder.set_line_collection_name( - uuids[-1], "collection" + str(len(uuids))) + section.line_collection(uuids[-1]), "collection" + str(len(uuids))) temp_collection = section.line_collection(builder.add_line_collection()) builder.remove_line_collection(temp_collection) @@ -130,7 +130,7 @@ def add_surface_collections(section, builder): for i in range(nb): uuids.append(builder.add_surface_collection()) builder.set_surface_collection_name( - uuids[-1], "collection" + str(len(uuids))) + section.surface_collection(uuids[-1]), "collection" + str(len(uuids))) temp_collection = section.surface_collection(builder.add_surface_collection()) builder.remove_surface_collection(temp_collection) diff --git a/include/geode/model/helpers/internal/simplicial_model_creator.hpp b/include/geode/model/helpers/internal/simplicial_model_creator.hpp index f86584698..5e711c699 100644 --- a/include/geode/model/helpers/internal/simplicial_model_creator.hpp +++ b/include/geode/model/helpers/internal/simplicial_model_creator.hpp @@ -68,8 +68,7 @@ namespace geode { const auto& corner_id = builder_.add_corner(); const auto& corner = model_.corner( corner_id ); - auto mesh_builder = - builder_.corner_mesh_builder( corner_id ); + auto mesh_builder = builder_.corner_mesh_builder( corner ); create_point( *mesh_builder, corner, definition.vertex ); corners.push_back( corner_id ); } @@ -85,7 +84,7 @@ namespace geode { const auto& line_id = builder_.add_line(); const auto& line = model_.line( line_id ); - auto mesh_builder = builder_.line_mesh_builder( line_id ); + auto mesh_builder = builder_.line_mesh_builder( line ); const auto& vertices = definition.vertices; for( const auto vertex : vertices ) { @@ -119,7 +118,7 @@ namespace geode dimension >::type_name_static() ) ); const auto& surface = model_.surface( surface_id ); auto mesh_builder = - builder_.surface_mesh_builder( surface_id ); + builder_.surface_mesh_builder( surface ); for( const auto vertex : definition.vertices ) { create_point( *mesh_builder, surface, vertex ); diff --git a/include/geode/model/mixin/builder/block_collections_builder.hpp b/include/geode/model/mixin/builder/block_collections_builder.hpp index b887e4283..e91badfb5 100644 --- a/include/geode/model/mixin/builder/block_collections_builder.hpp +++ b/include/geode/model/mixin/builder/block_collections_builder.hpp @@ -43,9 +43,12 @@ namespace geode public: void load_block_collections( std::string_view directory ); - void set_block_collection_name( const uuid& id, std::string_view name ); + void set_block_collection_name( + const BlockCollection< dimension >& block_collection, + std::string_view name ); - void set_block_collection_active( const uuid& id, bool active ); + void set_block_collection_active( + const BlockCollection< dimension >& block_collection, bool active ); protected: explicit BlockCollectionsBuilder( diff --git a/include/geode/model/mixin/builder/blocks_builder.hpp b/include/geode/model/mixin/builder/blocks_builder.hpp index 7e9bbd5fb..da4c76a09 100644 --- a/include/geode/model/mixin/builder/blocks_builder.hpp +++ b/include/geode/model/mixin/builder/blocks_builder.hpp @@ -50,28 +50,29 @@ namespace geode /*! * Get a pointer to the builder of a Block mesh - * @param[in] id Unique index of the Block + * @param[in] Block Block component to get the builder of */ template < typename Mesh = SolidMesh< dimension > > [[nodiscard]] std::unique_ptr< typename Mesh::Builder > - block_mesh_builder( const uuid& id ) + block_mesh_builder( const Block< dimension >& block ) { auto& mesh = blocks_ - .modifiable_block( - id, typename Block< dimension >::BlocksBuilderKey{} ) + .modifiable_block( block.id(), + typename Block< dimension >::BlocksBuilderKey{} ) .modifiable_mesh( typename Block< dimension >::BlocksBuilderKey{} ); return MeshBuilderFactory::create_mesh_builder< typename Mesh::Builder >( dynamic_cast< Mesh& >( mesh ) ); } - void set_block_name( const uuid& id, std::string_view name ); + void set_block_name( + const Block< dimension >& block, std::string_view name ); - void set_block_active( const uuid& id, bool active ); + void set_block_active( const Block< dimension >& block, bool active ); [[nodiscard]] std::unique_ptr< SolidMesh< dimension > > - steal_block_mesh( const uuid& id ); + steal_block_mesh( const Block< dimension >& block ); protected: explicit BlocksBuilder( Blocks< dimension >& blocks ) diff --git a/include/geode/model/mixin/builder/corner_collections_builder.hpp b/include/geode/model/mixin/builder/corner_collections_builder.hpp index 827d947a1..d6970d356 100644 --- a/include/geode/model/mixin/builder/corner_collections_builder.hpp +++ b/include/geode/model/mixin/builder/corner_collections_builder.hpp @@ -44,9 +44,12 @@ namespace geode void load_corner_collections( std::string_view directory ); void set_corner_collection_name( - const uuid& id, std::string_view name ); + const CornerCollection< dimension >& corner_collection, + std::string_view name ); - void set_corner_collection_active( const uuid& id, bool active ); + void set_corner_collection_active( + const CornerCollection< dimension >& corner_collection, + bool active ); protected: explicit CornerCollectionsBuilder( diff --git a/include/geode/model/mixin/builder/corners_builder.hpp b/include/geode/model/mixin/builder/corners_builder.hpp index 71ffd489b..0784af470 100644 --- a/include/geode/model/mixin/builder/corners_builder.hpp +++ b/include/geode/model/mixin/builder/corners_builder.hpp @@ -49,17 +49,19 @@ namespace geode /*! * Get a pointer to the builder of a Corner mesh - * @param[in] id Unique index of the Corner + * @param[in] corner Corner in the model */ [[nodiscard]] std::unique_ptr< PointSetBuilder< dimension > > - corner_mesh_builder( const uuid& id ); + corner_mesh_builder( const Corner< dimension >& corner ); - void set_corner_name( const uuid& id, std::string_view name ); + void set_corner_name( + const Corner< dimension >& corner, std::string_view name ); - void set_corner_active( const uuid& id, bool active ); + void set_corner_active( + const Corner< dimension >& corner, bool active ); [[nodiscard]] std::unique_ptr< PointSet< dimension > > - steal_corner_mesh( const uuid& id ); + steal_corner_mesh( const Corner< dimension >& corner ); protected: explicit CornersBuilder( Corners< dimension >& corners ) diff --git a/include/geode/model/mixin/builder/line_collections_builder.hpp b/include/geode/model/mixin/builder/line_collections_builder.hpp index 905cade42..96faa9173 100644 --- a/include/geode/model/mixin/builder/line_collections_builder.hpp +++ b/include/geode/model/mixin/builder/line_collections_builder.hpp @@ -43,9 +43,12 @@ namespace geode public: void load_line_collections( std::string_view directory ); - void set_line_collection_name( const uuid& id, std::string_view name ); + void set_line_collection_name( + const LineCollection< dimension >& line_collection, + std::string_view name ); - void set_line_collection_active( const uuid& id, bool active ); + void set_line_collection_active( + const LineCollection< dimension >& line_collection, bool active ); protected: explicit LineCollectionsBuilder( diff --git a/include/geode/model/mixin/builder/lines_builder.hpp b/include/geode/model/mixin/builder/lines_builder.hpp index 9133e48eb..fd8e6bb92 100644 --- a/include/geode/model/mixin/builder/lines_builder.hpp +++ b/include/geode/model/mixin/builder/lines_builder.hpp @@ -49,17 +49,18 @@ namespace geode /*! * Get a pointer to the builder of a Line mesh - * @param[in] id Unique index of the Line + * @param[in] line Line component to get the builder of */ [[nodiscard]] std::unique_ptr< EdgedCurveBuilder< dimension > > - line_mesh_builder( const uuid& id ); + line_mesh_builder( const Line< dimension >& line ); - void set_line_name( const uuid& id, std::string_view name ); + void set_line_name( + const Line< dimension >& line, std::string_view name ); - void set_line_active( const uuid& id, bool active ); + void set_line_active( const Line< dimension >& line, bool active ); [[nodiscard]] std::unique_ptr< EdgedCurve< dimension > > - steal_line_mesh( const uuid& id ); + steal_line_mesh( const Line< dimension >& line ); protected: explicit LinesBuilder( Lines< dimension >& lines ) : lines_( lines ) {} diff --git a/include/geode/model/mixin/builder/model_boundaries_builder.hpp b/include/geode/model/mixin/builder/model_boundaries_builder.hpp index 77d19aa1a..00ef7d9d1 100644 --- a/include/geode/model/mixin/builder/model_boundaries_builder.hpp +++ b/include/geode/model/mixin/builder/model_boundaries_builder.hpp @@ -43,9 +43,11 @@ namespace geode public: void load_model_boundaries( std::string_view directory ); - void set_model_boundary_name( const uuid& id, std::string_view name ); + void set_model_boundary_name( + const ModelBoundary< dimension >& id, std::string_view name ); - void set_model_boundary_active( const uuid& id, bool active ); + void set_model_boundary_active( + const ModelBoundary< dimension >& id, bool active ); protected: explicit ModelBoundariesBuilder( diff --git a/include/geode/model/mixin/builder/surface_collections_builder.hpp b/include/geode/model/mixin/builder/surface_collections_builder.hpp index 2744d97e7..681fc6c6c 100644 --- a/include/geode/model/mixin/builder/surface_collections_builder.hpp +++ b/include/geode/model/mixin/builder/surface_collections_builder.hpp @@ -44,9 +44,12 @@ namespace geode void load_surface_collections( std::string_view directory ); void set_surface_collection_name( - const uuid& id, std::string_view name ); + const SurfaceCollection< dimension >& surface_collection, + std::string_view name ); - void set_surface_collection_active( const uuid& id, bool active ); + void set_surface_collection_active( + const SurfaceCollection< dimension >& surface_collection, + bool active ); protected: explicit SurfaceCollectionsBuilder( diff --git a/include/geode/model/mixin/builder/surfaces_builder.hpp b/include/geode/model/mixin/builder/surfaces_builder.hpp index 2f063fed1..f08529019 100644 --- a/include/geode/model/mixin/builder/surfaces_builder.hpp +++ b/include/geode/model/mixin/builder/surfaces_builder.hpp @@ -33,7 +33,9 @@ namespace geode { FORWARD_DECLARATION_DIMENSION_CLASS( Surface ); + ALIAS_2D_AND_3D( Surface ); FORWARD_DECLARATION_DIMENSION_CLASS( Surfaces ); + ALIAS_2D_AND_3D( Surfaces ); FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMesh ); FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMeshBuilder ); @@ -50,15 +52,15 @@ namespace geode /*! * Get a pointer to the builder of a Surface mesh - * @param[in] id Unique index of the Surface + * @param[in] surface Surface component to get the builder of */ template < typename Mesh = SurfaceMesh< dimension > > [[nodiscard]] std::unique_ptr< typename Mesh::Builder > - surface_mesh_builder( const uuid& id ) + surface_mesh_builder( const Surface< dimension >& surface ) { auto& mesh = surfaces_ - .modifiable_surface( id, + .modifiable_surface( surface.id(), typename Surface< dimension >::SurfacesBuilderKey{} ) .modifiable_mesh( typename Surface< dimension >::SurfacesBuilderKey{} ); @@ -66,12 +68,14 @@ namespace geode typename Mesh::Builder >( dynamic_cast< Mesh& >( mesh ) ); } - void set_surface_name( const uuid& id, std::string_view name ); + void set_surface_name( + const Surface< dimension >& surface, std::string_view name ); - void set_surface_active( const uuid& id, bool active ); + void set_surface_active( + const Surface< dimension >& surface, bool active ); [[nodiscard]] std::unique_ptr< SurfaceMesh< dimension > > - steal_surface_mesh( const uuid& id ); + steal_surface_mesh( const Surface< dimension >& surface ); protected: explicit SurfacesBuilder( Surfaces< dimension >& surfaces ) diff --git a/include/geode/model/representation/builder/detail/copy.hpp b/include/geode/model/representation/builder/detail/copy.hpp index 0e5f34276..40c297f19 100644 --- a/include/geode/model/representation/builder/detail/copy.hpp +++ b/include/geode/model/representation/builder/detail/copy.hpp @@ -51,23 +51,25 @@ namespace geode { using Mapping = ModelCopyMapping::Mapping; - template < typename ModelFrom, typename BuilderTo > - void copy_corner_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_corner_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& corner : from.corners() ) { if( mapping.has_mapping_input( corner.id() ) ) { const auto& id = mapping.in2out( corner.id() ); - ModelFrom::dim == BuilderTo::dim + ModelFrom::dim == ModelTo::dim ? builder_to.add_corner( id, corner.mesh().impl_name() ) : builder_to.add_corner( id ); } else { const auto& id = - ModelFrom::dim == BuilderTo::dim + ModelFrom::dim == ModelTo::dim ? builder_to.add_corner( corner.mesh().impl_name() ) : builder_to.add_corner(); mapping.map( corner.id(), id ); @@ -75,29 +77,32 @@ namespace geode const auto& id = mapping.in2out( corner.id() ); if( const auto name = corner.name() ) { - builder_to.set_corner_name( id, name.value() ); + builder_to.set_corner_name( to.corner( id ), name.value() ); } - builder_to.set_corner_active( id, corner.is_active() ); + builder_to.set_corner_active( + to.corner( id ), corner.is_active() ); } } - template < typename ModelFrom, typename BuilderTo > - void copy_line_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_line_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& line : from.lines() ) { if( mapping.has_mapping_input( line.id() ) ) { const auto& id = mapping.in2out( line.id() ); - ModelFrom::dim == BuilderTo::dim + ModelFrom::dim == ModelTo::dim ? builder_to.add_line( id, line.mesh().impl_name() ) : builder_to.add_line( id ); } else { const auto& id = - ModelFrom::dim == BuilderTo::dim + ModelFrom::dim == ModelTo::dim ? builder_to.add_line( line.mesh().impl_name() ) : builder_to.add_line(); mapping.map( line.id(), id ); @@ -105,29 +110,31 @@ namespace geode const auto& id = mapping.in2out( line.id() ); if( const auto name = line.name() ) { - builder_to.set_line_name( id, name.value() ); + builder_to.set_line_name( to.line( id ), name.value() ); } - builder_to.set_line_active( id, line.is_active() ); + builder_to.set_line_active( to.line( id ), line.is_active() ); } } - template < typename ModelFrom, typename BuilderTo > - void copy_surface_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_surface_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& surface : from.surfaces() ) { if( mapping.has_mapping_input( surface.id() ) ) { const auto& id = mapping.in2out( surface.id() ); - ModelFrom::dim == BuilderTo::dim + ModelFrom::dim == ModelTo::dim ? builder_to.add_surface( id, surface.mesh().impl_name() ) : builder_to.add_surface( id ); } else { - const auto& id = ModelFrom::dim == BuilderTo::dim + const auto& id = ModelFrom::dim == ModelTo::dim ? builder_to.add_surface( surface.mesh().impl_name() ) : builder_to.add_surface(); @@ -136,29 +143,33 @@ namespace geode const auto& id = mapping.in2out( surface.id() ); if( const auto name = surface.name() ) { - builder_to.set_surface_name( id, name.value() ); + builder_to.set_surface_name( + to.surface( id ), name.value() ); } - builder_to.set_surface_active( id, surface.is_active() ); + builder_to.set_surface_active( + to.surface( id ), surface.is_active() ); } } - template < typename ModelFrom, typename BuilderTo > - void copy_block_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_block_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& block : from.blocks() ) { if( mapping.has_mapping_input( block.id() ) ) { const auto& id = mapping.in2out( block.id() ); - ModelFrom::dim == BuilderTo::dim + ModelFrom::dim == ModelTo::dim ? builder_to.add_block( id, block.mesh().impl_name() ) : builder_to.add_block( id ); } else { const auto& id = - ModelFrom::dim == BuilderTo::dim + ModelFrom::dim == ModelTo::dim ? builder_to.add_block( block.mesh().impl_name() ) : builder_to.add_block(); mapping.map( block.id(), id ); @@ -166,15 +177,18 @@ namespace geode const auto& id = mapping.in2out( block.id() ); if( const auto name = block.name() ) { - builder_to.set_block_name( id, name.value() ); + builder_to.set_block_name( to.block( id ), name.value() ); } - builder_to.set_block_active( id, block.is_active() ); + builder_to.set_block_active( + to.block( id ), block.is_active() ); } } - template < typename ModelFrom, typename BuilderTo > - void copy_model_boundary_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_model_boundary_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& model_boundary : from.model_boundaries() ) { @@ -191,16 +205,19 @@ namespace geode const auto& id = mapping.in2out( model_boundary.id() ); if( const auto name = model_boundary.name() ) { - builder_to.set_model_boundary_name( id, name.value() ); + builder_to.set_model_boundary_name( + to.model_boundary( id ), name.value() ); } builder_to.set_model_boundary_active( - id, model_boundary.is_active() ); + to.model_boundary( id ), model_boundary.is_active() ); } } - template < typename ModelFrom, typename BuilderTo > - void copy_corner_collection_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_corner_collection_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& corner_collection : from.corner_collections() ) { @@ -217,16 +234,19 @@ namespace geode const auto& id = mapping.in2out( corner_collection.id() ); if( const auto name = corner_collection.name() ) { - builder_to.set_corner_collection_name( id, name.value() ); + builder_to.set_corner_collection_name( + to.corner_collection( id ), name.value() ); } builder_to.set_corner_collection_active( - id, corner_collection.is_active() ); + to.corner_collection( id ), corner_collection.is_active() ); } } - template < typename ModelFrom, typename BuilderTo > - void copy_line_collection_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_line_collection_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& line_collection : from.line_collections() ) { @@ -243,16 +263,19 @@ namespace geode const auto& id = mapping.in2out( line_collection.id() ); if( const auto name = line_collection.name() ) { - builder_to.set_line_collection_name( id, name.value() ); + builder_to.set_line_collection_name( + to.line_collection( id ), name.value() ); } builder_to.set_line_collection_active( - id, line_collection.is_active() ); + to.line_collection( id ), line_collection.is_active() ); } } - template < typename ModelFrom, typename BuilderTo > - void copy_surface_collection_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_surface_collection_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& surface_collection : from.surface_collections() ) { @@ -269,16 +292,20 @@ namespace geode const auto& id = mapping.in2out( surface_collection.id() ); if( const auto name = surface_collection.name() ) { - builder_to.set_surface_collection_name( id, name.value() ); + builder_to.set_surface_collection_name( + to.surface_collection( id ), name.value() ); } builder_to.set_surface_collection_active( - id, surface_collection.is_active() ); + to.surface_collection( id ), + surface_collection.is_active() ); } } - template < typename ModelFrom, typename BuilderTo > - void copy_block_collection_components( - const ModelFrom& from, BuilderTo& builder_to, Mapping& mapping ) + template < typename ModelFrom, typename ModelTo > + void copy_block_collection_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to, + Mapping& mapping ) { for( const auto& block_collection : from.block_collections() ) { @@ -295,10 +322,11 @@ namespace geode const auto& id = mapping.in2out( block_collection.id() ); if( const auto name = block_collection.name() ) { - builder_to.set_block_collection_name( id, name.value() ); + builder_to.set_block_collection_name( + to.block_collection( id ), name.value() ); } builder_to.set_block_collection_active( - id, block_collection.is_active() ); + to.block_collection( id ), block_collection.is_active() ); } } diff --git a/include/geode/model/representation/core/detail/transfer_metadata.hpp b/include/geode/model/representation/core/detail/transfer_metadata.hpp index 26919bf4a..39036154d 100644 --- a/include/geode/model/representation/core/detail/transfer_metadata.hpp +++ b/include/geode/model/representation/core/detail/transfer_metadata.hpp @@ -48,38 +48,44 @@ namespace geode namespace detail { void opengeode_model_api transfer_brep_metadata( const BRep& old_brep, + const BRep& new_brep, BRepBuilder& new_brep_builder, const ModelGenericMapping& component_mapping ); void opengeode_model_api transfer_section_metadata( const Section& old_section, + const Section& new_section, SectionBuilder& new_section_builder, const ModelGenericMapping& component_mapping ); - template < typename ModelBuilder > + template < typename Model > void transfer_pointsets_metadata( absl::Span< const std::reference_wrapper< - const PointSet< ModelBuilder::dim > > > pointsets, - ModelBuilder& model_builder, + const PointSet< Model::dim > > > pointsets, + const Model& model, + typename Model::Builder& builder, const ModelGenericMapping& component_mapping ); - template < typename ModelBuilder > + template < typename Model > void transfer_curves_metadata( absl::Span< const std::reference_wrapper< - const EdgedCurve< ModelBuilder::dim > > > curves, - ModelBuilder& model_builder, + const EdgedCurve< Model::dim > > > curves, + const Model& model, + typename Model::Builder& model_builder, const ModelGenericMapping& component_mapping ); - template < typename ModelBuilder > + template < typename Model > void transfer_surfaces_metadata( absl::Span< const std::reference_wrapper< - const SurfaceMesh< ModelBuilder::dim > > > surfaces, - ModelBuilder& model_builder, + const SurfaceMesh< Model::dim > > > surfaces, + const Model& model, + typename Model::Builder& model_builder, const ModelGenericMapping& component_mapping ); void opengeode_model_api transfer_solids_metadata( absl::Span< const std::reference_wrapper< const SolidMesh3D > > solids, + const BRep& model, BRepBuilder& model_builder, const ModelGenericMapping& component_mapping ); } // namespace detail diff --git a/src/geode/model/helpers/convert_brep_section.cpp b/src/geode/model/helpers/convert_brep_section.cpp index 973a902f3..a73a4e147 100644 --- a/src/geode/model/helpers/convert_brep_section.cpp +++ b/src/geode/model/helpers/convert_brep_section.cpp @@ -50,17 +50,18 @@ namespace { - template < typename ModelFrom, typename BuilderTo > - geode::ModelCopyMapping copy_components( - const ModelFrom& from, BuilderTo& builder_to ) + template < typename ModelFrom, typename ModelTo > + geode::ModelCopyMapping copy_components( const ModelFrom& from, + const ModelTo& to, + typename ModelTo::Builder& builder_to ) { geode::ModelCopyMapping mappings; - const auto dimension = BuilderTo::dim; - geode::detail::copy_corner_components( from, builder_to, + const auto dimension = ModelTo::dim; + geode::detail::copy_corner_components( from, to, builder_to, mappings[geode::Corner< dimension >::component_type_static()] ); - geode::detail::copy_line_components( from, builder_to, + geode::detail::copy_line_components( from, to, builder_to, mappings[geode::Line< dimension >::component_type_static()] ); - geode::detail::copy_surface_components( from, builder_to, + geode::detail::copy_surface_components( from, to, builder_to, mappings[geode::Surface< dimension >::component_type_static()] ); builder_to.copy_relationships( mappings, from ); return mappings; @@ -177,7 +178,7 @@ namespace corner_slice0, line ); brep_builder_.add_corner_line_boundary_relationship( corner_slice1, line ); - auto line_builder = brep_builder_.line_mesh_builder( line.id() ); + auto line_builder = brep_builder_.line_mesh_builder( line ); const auto corner_slice0_vid = line_builder->create_point( corner_slice0.mesh().point( 0 ) ); brep_builder_.set_unique_vertex( @@ -201,7 +202,7 @@ namespace if( const auto name = model_boundary.name() ) { brep_builder_.set_model_boundary_name( - new_id, name.value() ); + brep_.model_boundary( new_id ), name.value() ); } for( const auto& item : section_.model_boundary_items( model_boundary ) ) @@ -237,7 +238,7 @@ namespace section_line, surface ); auto surface_builder = - brep_builder_.surface_mesh_builder( surface.id() ); + brep_builder_.surface_mesh_builder( surface ); for( const auto edge_id : geode::Range{ line_slice0.mesh().nb_edges() } ) { @@ -271,7 +272,7 @@ namespace } } auto surface_builder = - brep_builder_.surface_mesh_builder( surface.id() ); + brep_builder_.surface_mesh_builder( surface ); auto pt_id = surface_builder->create_point( line.mesh().point( line_pointid ) ); brep_builder_.set_unique_vertex( @@ -339,7 +340,7 @@ namespace section_surface, block ); auto block_builder = brep_builder_.block_mesh_builder< geode::HybridSolid3D >( - block.id() ); + block ); for( const auto tgl_id : geode::Range{ surface_slice0.mesh().nb_polygons() } ) { @@ -371,7 +372,7 @@ namespace return cmv.vertex; } } - auto block_builder = brep_builder_.block_mesh_builder( block.id() ); + auto block_builder = brep_builder_.block_mesh_builder( block ); auto pt_id = block_builder->create_point( surface.mesh().point( surf_pointid ) ); brep_builder_.set_unique_vertex( @@ -482,7 +483,7 @@ namespace geode std::tuple< Section, ModelCopyMapping > result; auto& [section, mappings] = result; SectionBuilder builder{ section }; - mappings = copy_components< BRep, SectionBuilder >( brep, builder ); + mappings = copy_components< BRep, Section >( brep, section, builder ); for( const auto& corner : brep.corners() ) { builder.update_corner_mesh( @@ -519,7 +520,7 @@ namespace geode std::tuple< BRep, ModelCopyMapping > result; auto& [brep, mappings] = result; BRepBuilder builder{ brep }; - mappings = copy_components< Section, BRepBuilder >( section, builder ); + mappings = copy_components< Section, BRep >( section, brep, builder ); for( const auto& corner : section.corners() ) { builder.update_corner_mesh( diff --git a/src/geode/model/helpers/convert_model_meshes.cpp b/src/geode/model/helpers/convert_model_meshes.cpp index c672ad5c4..93113dae1 100644 --- a/src/geode/model/helpers/convert_model_meshes.cpp +++ b/src/geode/model/helpers/convert_model_meshes.cpp @@ -126,7 +126,7 @@ namespace { const auto& mesh = surface.mesh(); geode::triangulate_surface_mesh( - mesh, *builder.surface_mesh_builder( surface.id() ) ); + mesh, *builder.surface_mesh_builder( surface ) ); } } diff --git a/src/geode/model/helpers/create_coordinate_system.cpp b/src/geode/model/helpers/create_coordinate_system.cpp index 417a0e5f1..63494139e 100644 --- a/src/geode/model/helpers/create_coordinate_system.cpp +++ b/src/geode/model/helpers/create_coordinate_system.cpp @@ -62,19 +62,19 @@ namespace { for( const auto& corner : model.corners() ) { - auto mesh_builder = builder.corner_mesh_builder( corner.id() ); + auto mesh_builder = builder.corner_mesh_builder( corner ); set_generic_active_coordinate_system( *mesh_builder, coordinate_system_name ); } for( const auto& line : model.lines() ) { - auto mesh_builder = builder.line_mesh_builder( line.id() ); + auto mesh_builder = builder.line_mesh_builder( line ); set_generic_active_coordinate_system( *mesh_builder, coordinate_system_name ); } for( const auto& surface : model.surfaces() ) { - auto mesh_builder = builder.surface_mesh_builder( surface.id() ); + auto mesh_builder = builder.surface_mesh_builder( surface ); set_generic_active_coordinate_system( *mesh_builder, coordinate_system_name ); } @@ -90,21 +90,21 @@ namespace for( const auto& corner : model.corners() ) { const auto& mesh = corner.mesh(); - auto mesh_builder = builder.corner_mesh_builder( corner.id() ); + auto mesh_builder = builder.corner_mesh_builder( corner ); create_point_set_coordinate_system( mesh, *mesh_builder, new_coordinate_system_name, input, output ); } for( const auto& line : model.lines() ) { const auto& mesh = line.mesh(); - auto mesh_builder = builder.line_mesh_builder( line.id() ); + auto mesh_builder = builder.line_mesh_builder( line ); create_edged_curve_coordinate_system( mesh, *mesh_builder, new_coordinate_system_name, input, output ); } for( const auto& surface : model.surfaces() ) { const auto& mesh = surface.mesh(); - auto mesh_builder = builder.surface_mesh_builder( surface.id() ); + auto mesh_builder = builder.surface_mesh_builder( surface ); create_surface_mesh_coordinate_system( mesh, *mesh_builder, new_coordinate_system_name, input, output ); } @@ -124,7 +124,7 @@ namespace geode for( const auto& block : model.blocks() ) { const auto& mesh = block.mesh(); - auto mesh_builder = builder.block_mesh_builder( block.id() ); + auto mesh_builder = builder.block_mesh_builder( block ); create_solid_mesh_coordinate_system( mesh, *mesh_builder, new_coordinate_system_name, input, output ); } @@ -148,7 +148,7 @@ namespace geode model, builder, coordinate_system_name ); for( const auto& block : model.blocks() ) { - auto mesh_builder = builder.block_mesh_builder( block.id() ); + auto mesh_builder = builder.block_mesh_builder( block ); set_generic_active_coordinate_system( *mesh_builder, coordinate_system_name ); } diff --git a/src/geode/model/helpers/detail/build_model_boundaries.cpp b/src/geode/model/helpers/detail/build_model_boundaries.cpp index 7453717b9..c8f1ad743 100644 --- a/src/geode/model/helpers/detail/build_model_boundaries.cpp +++ b/src/geode/model/helpers/detail/build_model_boundaries.cpp @@ -64,7 +64,8 @@ namespace const auto& model_boundary_id = builder.add_model_boundary(); if( name ) { - builder.set_model_boundary_name( model_boundary_id, name.value() ); + builder.set_model_boundary_name( + model.model_boundary( model_boundary_id ), name.value() ); } const auto& boundary = model.model_boundary( model_boundary_id ); return boundary; diff --git a/src/geode/model/helpers/detail/solid_mesh_validity_fix.cpp b/src/geode/model/helpers/detail/solid_mesh_validity_fix.cpp index 960e67afb..12db61696 100644 --- a/src/geode/model/helpers/detail/solid_mesh_validity_fix.cpp +++ b/src/geode/model/helpers/detail/solid_mesh_validity_fix.cpp @@ -46,7 +46,7 @@ namespace geode const Block3D& block ) { const auto& mesh = block.mesh(); - auto mesh_builder = model_builder.block_mesh_builder( block.id() ); + auto mesh_builder = model_builder.block_mesh_builder( block ); const auto vertex_mappings = repair_non_manifold_vertices( mesh, *mesh_builder ); for( const auto& [old_vertex, new_vertices] : diff --git a/src/geode/model/helpers/detail/split_along_block_mesh_borders.cpp b/src/geode/model/helpers/detail/split_along_block_mesh_borders.cpp index 64ceaea2c..980500c9b 100644 --- a/src/geode/model/helpers/detail/split_along_block_mesh_borders.cpp +++ b/src/geode/model/helpers/detail/split_along_block_mesh_borders.cpp @@ -71,8 +71,7 @@ namespace geode adjacency_tasks[adjacency_count++] = async::spawn( [this, &block] { const auto& mesh = block.mesh(); - auto builder = - builder_.block_mesh_builder( block.id() ); + auto builder = builder_.block_mesh_builder( block ); const auto facets_list = mesh_border_facets( block ); SplitAlongSolidFacets block_splitter{ mesh, @@ -97,8 +96,8 @@ namespace geode duplicate_tasks[duplicate_count++] = async::spawn( [this, &block, solid_info] { const auto& mesh = block.mesh(); - auto builder = builder_.block_mesh_builder( - block.id() ); + auto builder = + builder_.block_mesh_builder( block ); const auto facets_list = mesh_border_facets( block ); SplitAlongSolidFacets block_splitter{ mesh, @@ -140,7 +139,7 @@ namespace geode CMVmappings split_block( const Block3D& block ) { const auto& mesh = block.mesh(); - auto builder = builder_.block_mesh_builder( block.id() ); + auto builder = builder_.block_mesh_builder( block ); const auto facets_list = mesh_border_facets( block ); SplitAlongSolidFacets block_splitter{ mesh, *builder }; auto mapping = diff --git a/src/geode/model/helpers/detail/split_along_surface_mesh_borders.cpp b/src/geode/model/helpers/detail/split_along_surface_mesh_borders.cpp index 6cdc5b69f..0e31db555 100644 --- a/src/geode/model/helpers/detail/split_along_surface_mesh_borders.cpp +++ b/src/geode/model/helpers/detail/split_along_surface_mesh_borders.cpp @@ -151,19 +151,19 @@ namespace geode void remove_adjacencies_along_internal_lines( const Surface< dimension >& surface ) { - auto builder = builder_.surface_mesh_builder( surface.id() ); + auto builder = builder_.surface_mesh_builder( surface ); remove_adjacencies_along_internal_lines( surface, *builder ); } CMVmappings duplicate_points( const Surface< dimension >& surface ) { - auto builder = builder_.surface_mesh_builder( surface.id() ); + auto builder = builder_.surface_mesh_builder( surface ); return duplicate_points( surface, *builder ); } CMVmappings split_points( const Surface< dimension >& surface ) { - auto builder = builder_.surface_mesh_builder( surface.id() ); + auto builder = builder_.surface_mesh_builder( surface ); remove_adjacencies_along_internal_lines( surface, *builder ); const auto result = duplicate_points( surface, *builder ); return result; diff --git a/src/geode/model/helpers/detail/surface_mesh_validity_fix.cpp b/src/geode/model/helpers/detail/surface_mesh_validity_fix.cpp index b5c3a7758..354216024 100644 --- a/src/geode/model/helpers/detail/surface_mesh_validity_fix.cpp +++ b/src/geode/model/helpers/detail/surface_mesh_validity_fix.cpp @@ -50,8 +50,7 @@ namespace geode const Surface< Model::dim >& surface ) { const auto& mesh = surface.mesh(); - auto mesh_builder = - model_builder.surface_mesh_builder( surface.id() ); + auto mesh_builder = model_builder.surface_mesh_builder( surface ); const auto vertex_mappings = repair_non_manifold_vertices( mesh, *mesh_builder ); for( const auto& [old_vertex, new_vertices] : diff --git a/src/geode/model/helpers/simplicial_brep_creator.cpp b/src/geode/model/helpers/simplicial_brep_creator.cpp index de2ee28f1..864ef3749 100644 --- a/src/geode/model/helpers/simplicial_brep_creator.cpp +++ b/src/geode/model/helpers/simplicial_brep_creator.cpp @@ -127,8 +127,7 @@ namespace geode TetrahedralSolid3D::type_name_static() ) ); const auto& block = model().block( block_id ); auto mesh_builder = - builder().block_mesh_builder< TetrahedralSolid3D >( - block_id ); + builder().block_mesh_builder< TetrahedralSolid3D >( block ); for( const auto vertex : definition.vertices ) { create_point( *mesh_builder, block, vertex ); diff --git a/src/geode/model/mixin/builder/block_collections_builder.cpp b/src/geode/model/mixin/builder/block_collections_builder.cpp index a76499383..7a75bc9ef 100644 --- a/src/geode/model/mixin/builder/block_collections_builder.cpp +++ b/src/geode/model/mixin/builder/block_collections_builder.cpp @@ -66,12 +66,13 @@ namespace geode template < index_t dimension > void BlockCollectionsBuilder< dimension >::set_block_collection_name( - const uuid& id, std::string_view name ) + const BlockCollection< dimension >& block_collection, + std::string_view name ) { block_collections_ - .modifiable_block_collection( - id, typename BlockCollections< - dimension >::BlockCollectionsBuilderKey{} ) + .modifiable_block_collection( block_collection.id(), + typename BlockCollections< + dimension >::BlockCollectionsBuilderKey{} ) .set_block_collection_name( name, typename BlockCollections< dimension >::BlockCollectionsBuilderKey{} ); @@ -79,12 +80,12 @@ namespace geode template < index_t dimension > void BlockCollectionsBuilder< dimension >::set_block_collection_active( - const uuid& id, bool active ) + const BlockCollection< dimension >& block_collection, bool active ) { block_collections_ - .modifiable_block_collection( - id, typename BlockCollections< - dimension >::BlockCollectionsBuilderKey{} ) + .modifiable_block_collection( block_collection.id(), + typename BlockCollections< + dimension >::BlockCollectionsBuilderKey{} ) .set_block_collection_active( active, typename BlockCollections< dimension >::BlockCollectionsBuilderKey{} ); diff --git a/src/geode/model/mixin/builder/blocks_builder.cpp b/src/geode/model/mixin/builder/blocks_builder.cpp index 02abcf4ca..0352ec56b 100644 --- a/src/geode/model/mixin/builder/blocks_builder.cpp +++ b/src/geode/model/mixin/builder/blocks_builder.cpp @@ -77,23 +77,23 @@ namespace geode template < index_t dimension > void BlocksBuilder< dimension >::set_block_name( - const uuid& id, std::string_view name ) + const Block< dimension >& block, std::string_view name ) { blocks_ .modifiable_block( - id, typename Blocks< dimension >::BlocksBuilderKey{} ) + block.id(), typename Blocks< dimension >::BlocksBuilderKey{} ) .set_block_name( name, typename Blocks< dimension >::BlocksBuilderKey{} ); - block_mesh_builder( id )->set_name( name ); + block_mesh_builder( block )->set_name( name ); } template < index_t dimension > void BlocksBuilder< dimension >::set_block_active( - const uuid& id, bool active ) + const Block< dimension >& block, bool active ) { blocks_ .modifiable_block( - id, typename Blocks< dimension >::BlocksBuilderKey{} ) + block.id(), typename Blocks< dimension >::BlocksBuilderKey{} ) .set_block_active( active, typename Blocks< dimension >::BlocksBuilderKey{} ); } @@ -121,11 +121,12 @@ namespace geode template < index_t dimension > std::unique_ptr< SolidMesh< dimension > > - BlocksBuilder< dimension >::steal_block_mesh( const uuid& id ) + BlocksBuilder< dimension >::steal_block_mesh( + const Block< dimension >& block ) { return blocks_ .modifiable_block( - id, typename Blocks< dimension >::BlocksBuilderKey{} ) + block.id(), typename Blocks< dimension >::BlocksBuilderKey{} ) .steal_mesh( typename Block< dimension >::BlocksBuilderKey{} ); } diff --git a/src/geode/model/mixin/builder/corner_collections_builder.cpp b/src/geode/model/mixin/builder/corner_collections_builder.cpp index 89b4d279d..b84a5a1bc 100644 --- a/src/geode/model/mixin/builder/corner_collections_builder.cpp +++ b/src/geode/model/mixin/builder/corner_collections_builder.cpp @@ -67,12 +67,13 @@ namespace geode template < index_t dimension > void CornerCollectionsBuilder< dimension >::set_corner_collection_name( - const uuid& id, std::string_view name ) + const CornerCollection< dimension >& corner_collection, + std::string_view name ) { corner_collections_ - .modifiable_corner_collection( - id, typename CornerCollections< - dimension >::CornerCollectionsBuilderKey{} ) + .modifiable_corner_collection( corner_collection.id(), + typename CornerCollections< + dimension >::CornerCollectionsBuilderKey{} ) .set_corner_collection_name( name, typename CornerCollections< dimension >::CornerCollectionsBuilderKey{} ); @@ -80,12 +81,12 @@ namespace geode template < index_t dimension > void CornerCollectionsBuilder< dimension >::set_corner_collection_active( - const uuid& id, bool active ) + const CornerCollection< dimension >& corner_collection, bool active ) { corner_collections_ - .modifiable_corner_collection( - id, typename CornerCollections< - dimension >::CornerCollectionsBuilderKey{} ) + .modifiable_corner_collection( corner_collection.id(), + typename CornerCollections< + dimension >::CornerCollectionsBuilderKey{} ) .set_corner_collection_active( active, typename CornerCollections< dimension >::CornerCollectionsBuilderKey{} ); diff --git a/src/geode/model/mixin/builder/corners_builder.cpp b/src/geode/model/mixin/builder/corners_builder.cpp index 03a629dd1..d86124264 100644 --- a/src/geode/model/mixin/builder/corners_builder.cpp +++ b/src/geode/model/mixin/builder/corners_builder.cpp @@ -78,34 +78,35 @@ namespace geode template < index_t dimension > std::unique_ptr< PointSetBuilder< dimension > > - CornersBuilder< dimension >::corner_mesh_builder( const uuid& id ) + CornersBuilder< dimension >::corner_mesh_builder( + const Corner< dimension >& corner ) { return PointSetBuilder< dimension >::create( corners_ - .modifiable_corner( - id, typename Corners< dimension >::CornersBuilderKey{} ) + .modifiable_corner( corner.id(), + typename Corners< dimension >::CornersBuilderKey{} ) .modifiable_mesh( typename Corner< dimension >::CornersBuilderKey{} ) ); } template < index_t dimension > void CornersBuilder< dimension >::set_corner_name( - const uuid& id, std::string_view name ) + const Corner< dimension >& corner, std::string_view name ) { corners_ - .modifiable_corner( - id, typename Corners< dimension >::CornersBuilderKey{} ) + .modifiable_corner( corner.id(), + typename Corners< dimension >::CornersBuilderKey{} ) .set_corner_name( name, typename Corners< dimension >::CornersBuilderKey{} ); - corner_mesh_builder( id )->set_name( name ); + corner_mesh_builder( corner )->set_name( name ); } template < index_t dimension > void CornersBuilder< dimension >::set_corner_active( - const uuid& id, bool active ) + const Corner< dimension >& corner, bool active ) { corners_ - .modifiable_corner( - id, typename Corners< dimension >::CornersBuilderKey{} ) + .modifiable_corner( corner.id(), + typename Corners< dimension >::CornersBuilderKey{} ) .set_corner_active( active, typename Corners< dimension >::CornersBuilderKey{} ); } @@ -134,11 +135,12 @@ namespace geode template < index_t dimension > std::unique_ptr< PointSet< dimension > > - CornersBuilder< dimension >::steal_corner_mesh( const uuid& id ) + CornersBuilder< dimension >::steal_corner_mesh( + const Corner< dimension >& corner ) { return corners_ .modifiable_corner( - id, typename Corner< dimension >::CornersBuilderKey{} ) + corner.id(), typename Corner< dimension >::CornersBuilderKey{} ) .steal_mesh( typename Corner< dimension >::CornersBuilderKey{} ); } diff --git a/src/geode/model/mixin/builder/line_collections_builder.cpp b/src/geode/model/mixin/builder/line_collections_builder.cpp index c50a12fd8..21d33106c 100644 --- a/src/geode/model/mixin/builder/line_collections_builder.cpp +++ b/src/geode/model/mixin/builder/line_collections_builder.cpp @@ -66,12 +66,13 @@ namespace geode template < index_t dimension > void LineCollectionsBuilder< dimension >::set_line_collection_name( - const uuid& id, std::string_view name ) + const LineCollection< dimension >& line_collection, + std::string_view name ) { line_collections_ - .modifiable_line_collection( - id, typename LineCollections< - dimension >::LineCollectionsBuilderKey{} ) + .modifiable_line_collection( line_collection.id(), + typename LineCollections< + dimension >::LineCollectionsBuilderKey{} ) .set_line_collection_name( name, typename LineCollections< dimension >::LineCollectionsBuilderKey{} ); @@ -79,12 +80,12 @@ namespace geode template < index_t dimension > void LineCollectionsBuilder< dimension >::set_line_collection_active( - const uuid& id, bool active ) + const LineCollection< dimension >& line_collection, bool active ) { line_collections_ - .modifiable_line_collection( - id, typename LineCollections< - dimension >::LineCollectionsBuilderKey{} ) + .modifiable_line_collection( line_collection.id(), + typename LineCollections< + dimension >::LineCollectionsBuilderKey{} ) .set_line_collection_active( active, typename LineCollections< dimension >::LineCollectionsBuilderKey{} ); diff --git a/src/geode/model/mixin/builder/lines_builder.cpp b/src/geode/model/mixin/builder/lines_builder.cpp index 899c85600..6fac0ff4a 100644 --- a/src/geode/model/mixin/builder/lines_builder.cpp +++ b/src/geode/model/mixin/builder/lines_builder.cpp @@ -76,34 +76,35 @@ namespace geode template < index_t dimension > std::unique_ptr< EdgedCurveBuilder< dimension > > - LinesBuilder< dimension >::line_mesh_builder( const uuid& id ) + LinesBuilder< dimension >::line_mesh_builder( + const Line< dimension >& line ) { return EdgedCurveBuilder< dimension >::create( lines_ .modifiable_line( - id, typename Lines< dimension >::LinesBuilderKey{} ) + line.id(), typename Lines< dimension >::LinesBuilderKey{} ) .modifiable_mesh( typename Line< dimension >::LinesBuilderKey{} ) ); } template < index_t dimension > void LinesBuilder< dimension >::set_line_name( - const uuid& id, std::string_view name ) + const Line< dimension >& line, std::string_view name ) { lines_ .modifiable_line( - id, typename Lines< dimension >::LinesBuilderKey{} ) + line.id(), typename Lines< dimension >::LinesBuilderKey{} ) .set_line_name( name, typename Lines< dimension >::LinesBuilderKey{} ); - line_mesh_builder( id )->set_name( name ); + line_mesh_builder( line )->set_name( name ); } template < index_t dimension > void LinesBuilder< dimension >::set_line_active( - const uuid& id, bool active ) + const Line< dimension >& line, bool active ) { lines_ .modifiable_line( - id, typename Lines< dimension >::LinesBuilderKey{} ) + line.id(), typename Lines< dimension >::LinesBuilderKey{} ) .set_line_active( active, typename Lines< dimension >::LinesBuilderKey{} ); } @@ -131,11 +132,12 @@ namespace geode template < index_t dimension > std::unique_ptr< EdgedCurve< dimension > > - LinesBuilder< dimension >::steal_line_mesh( const uuid& id ) + LinesBuilder< dimension >::steal_line_mesh( + const Line< dimension >& line ) { return lines_ .modifiable_line( - id, typename Lines< dimension >::LinesBuilderKey{} ) + line.id(), typename Lines< dimension >::LinesBuilderKey{} ) .steal_mesh( typename Line< dimension >::LinesBuilderKey{} ); } diff --git a/src/geode/model/mixin/builder/model_boundaries_builder.cpp b/src/geode/model/mixin/builder/model_boundaries_builder.cpp index de4742764..fe74b903f 100644 --- a/src/geode/model/mixin/builder/model_boundaries_builder.cpp +++ b/src/geode/model/mixin/builder/model_boundaries_builder.cpp @@ -65,12 +65,13 @@ namespace geode template < index_t dimension > void ModelBoundariesBuilder< dimension >::set_model_boundary_name( - const uuid& id, std::string_view name ) + const ModelBoundary< dimension >& model_boundary, + std::string_view name ) { model_boundaries_ - .modifiable_model_boundary( - id, typename ModelBoundaries< - dimension >::ModelBoundariesBuilderKey{} ) + .modifiable_model_boundary( model_boundary.id(), + typename ModelBoundaries< + dimension >::ModelBoundariesBuilderKey{} ) .set_model_boundary_name( name, typename ModelBoundaries< dimension >::ModelBoundariesBuilderKey{} ); @@ -78,12 +79,12 @@ namespace geode template < index_t dimension > void ModelBoundariesBuilder< dimension >::set_model_boundary_active( - const uuid& id, bool active ) + const ModelBoundary< dimension >& model_boundary, bool active ) { model_boundaries_ - .modifiable_model_boundary( - id, typename ModelBoundaries< - dimension >::ModelBoundariesBuilderKey{} ) + .modifiable_model_boundary( model_boundary.id(), + typename ModelBoundaries< + dimension >::ModelBoundariesBuilderKey{} ) .set_model_boundary_active( active, typename ModelBoundaries< dimension >::ModelBoundariesBuilderKey{} ); diff --git a/src/geode/model/mixin/builder/surface_collections_builder.cpp b/src/geode/model/mixin/builder/surface_collections_builder.cpp index 10f7d8ce9..40d1c13bf 100644 --- a/src/geode/model/mixin/builder/surface_collections_builder.cpp +++ b/src/geode/model/mixin/builder/surface_collections_builder.cpp @@ -67,12 +67,13 @@ namespace geode template < index_t dimension > void SurfaceCollectionsBuilder< dimension >::set_surface_collection_name( - const uuid& id, std::string_view name ) + const SurfaceCollection< dimension >& surface_collection, + std::string_view name ) { surface_collections_ - .modifiable_surface_collection( - id, typename SurfaceCollections< - dimension >::SurfaceCollectionsBuilderKey{} ) + .modifiable_surface_collection( surface_collection.id(), + typename SurfaceCollections< + dimension >::SurfaceCollectionsBuilderKey{} ) .set_surface_collection_name( name, typename SurfaceCollections< dimension >::SurfaceCollectionsBuilderKey{} ); @@ -80,12 +81,12 @@ namespace geode template < index_t dimension > void SurfaceCollectionsBuilder< dimension >::set_surface_collection_active( - const uuid& id, bool active ) + const SurfaceCollection< dimension >& surface_collection, bool active ) { surface_collections_ - .modifiable_surface_collection( - id, typename SurfaceCollections< - dimension >::SurfaceCollectionsBuilderKey{} ) + .modifiable_surface_collection( surface_collection.id(), + typename SurfaceCollections< + dimension >::SurfaceCollectionsBuilderKey{} ) .set_surface_collection_active( active, typename SurfaceCollections< dimension >::SurfaceCollectionsBuilderKey{} ); diff --git a/src/geode/model/mixin/builder/surfaces_builder.cpp b/src/geode/model/mixin/builder/surfaces_builder.cpp index ac85dd79e..889570330 100644 --- a/src/geode/model/mixin/builder/surfaces_builder.cpp +++ b/src/geode/model/mixin/builder/surfaces_builder.cpp @@ -79,23 +79,23 @@ namespace geode template < index_t dimension > void SurfacesBuilder< dimension >::set_surface_name( - const uuid& id, std::string_view name ) + const Surface< dimension >& surface, std::string_view name ) { surfaces_ - .modifiable_surface( - id, typename Surface< dimension >::SurfacesBuilderKey{} ) + .modifiable_surface( surface.id(), + typename Surface< dimension >::SurfacesBuilderKey{} ) .set_surface_name( name, typename Surface< dimension >::SurfacesBuilderKey{} ); - surface_mesh_builder( id )->set_name( name ); + surface_mesh_builder( surface )->set_name( name ); } template < index_t dimension > void SurfacesBuilder< dimension >::set_surface_active( - const uuid& id, bool active ) + const Surface< dimension >& surface, bool active ) { surfaces_ - .modifiable_surface( - id, typename Surface< dimension >::SurfacesBuilderKey{} ) + .modifiable_surface( surface.id(), + typename Surface< dimension >::SurfacesBuilderKey{} ) .set_surface_active( active, typename Surface< dimension >::SurfacesBuilderKey{} ); } @@ -124,11 +124,12 @@ namespace geode template < index_t dimension > std::unique_ptr< SurfaceMesh< dimension > > - SurfacesBuilder< dimension >::steal_surface_mesh( const uuid& id ) + SurfacesBuilder< dimension >::steal_surface_mesh( + const Surface< dimension >& surface ) { return surfaces_ - .modifiable_surface( - id, typename Surface< dimension >::SurfacesBuilderKey{} ) + .modifiable_surface( surface.id(), + typename Surface< dimension >::SurfacesBuilderKey{} ) .steal_mesh( typename Surface< dimension >::SurfacesBuilderKey{} ); } diff --git a/src/geode/model/representation/builder/brep_builder.cpp b/src/geode/model/representation/builder/brep_builder.cpp index f48ed5833..1881d4cc2 100644 --- a/src/geode/model/representation/builder/brep_builder.cpp +++ b/src/geode/model/representation/builder/brep_builder.cpp @@ -98,23 +98,23 @@ namespace geode { ModelCopyMapping mappings; detail::copy_corner_components( - brep, *this, mappings[Corner3D::component_type_static()] ); + brep, brep_, *this, mappings[Corner3D::component_type_static()] ); detail::copy_line_components( - brep, *this, mappings[Line3D::component_type_static()] ); + brep, brep_, *this, mappings[Line3D::component_type_static()] ); detail::copy_surface_components( - brep, *this, mappings[Surface3D::component_type_static()] ); + brep, brep_, *this, mappings[Surface3D::component_type_static()] ); detail::copy_block_components( - brep, *this, mappings[Block3D::component_type_static()] ); - detail::copy_model_boundary_components( - brep, *this, mappings[ModelBoundary3D::component_type_static()] ); - detail::copy_corner_collection_components( brep, *this, + brep, brep_, *this, mappings[Block3D::component_type_static()] ); + detail::copy_model_boundary_components( brep, brep_, *this, + mappings[ModelBoundary3D::component_type_static()] ); + detail::copy_corner_collection_components( brep, brep_, *this, mappings[CornerCollection3D::component_type_static()] ); - detail::copy_line_collection_components( - brep, *this, mappings[LineCollection3D::component_type_static()] ); - detail::copy_surface_collection_components( brep, *this, + detail::copy_line_collection_components( brep, brep_, *this, + mappings[LineCollection3D::component_type_static()] ); + detail::copy_surface_collection_components( brep, brep_, *this, mappings[SurfaceCollection3D::component_type_static()] ); - detail::copy_block_collection_components( - brep, *this, mappings[BlockCollection3D::component_type_static()] ); + detail::copy_block_collection_components( brep, brep_, *this, + mappings[BlockCollection3D::component_type_static()] ); return mappings; } @@ -122,23 +122,23 @@ namespace geode ModelCopyMapping& mapping, const BRep& brep ) { detail::copy_corner_components( - brep, *this, mapping[Corner3D::component_type_static()] ); + brep, brep_, *this, mapping[Corner3D::component_type_static()] ); detail::copy_line_components( - brep, *this, mapping[Line3D::component_type_static()] ); + brep, brep_, *this, mapping[Line3D::component_type_static()] ); detail::copy_surface_components( - brep, *this, mapping[Surface3D::component_type_static()] ); + brep, brep_, *this, mapping[Surface3D::component_type_static()] ); detail::copy_block_components( - brep, *this, mapping[Block3D::component_type_static()] ); - detail::copy_model_boundary_components( - brep, *this, mapping[ModelBoundary3D::component_type_static()] ); - detail::copy_corner_collection_components( - brep, *this, mapping[CornerCollection3D::component_type_static()] ); - detail::copy_line_collection_components( - brep, *this, mapping[LineCollection3D::component_type_static()] ); - detail::copy_surface_collection_components( brep, *this, + brep, brep_, *this, mapping[Block3D::component_type_static()] ); + detail::copy_model_boundary_components( brep, brep_, *this, + mapping[ModelBoundary3D::component_type_static()] ); + detail::copy_corner_collection_components( brep, brep_, *this, + mapping[CornerCollection3D::component_type_static()] ); + detail::copy_line_collection_components( brep, brep_, *this, + mapping[LineCollection3D::component_type_static()] ); + detail::copy_surface_collection_components( brep, brep_, *this, mapping[SurfaceCollection3D::component_type_static()] ); - detail::copy_block_collection_components( - brep, *this, mapping[BlockCollection3D::component_type_static()] ); + detail::copy_block_collection_components( brep, brep_, *this, + mapping[BlockCollection3D::component_type_static()] ); } void BRepBuilder::copy_component_geometry( @@ -521,25 +521,25 @@ namespace geode { if( cmv.component_id.type() == Block3D::component_type_static() ) { - block_mesh_builder( cmv.component_id.id() ) + block_mesh_builder( brep_.block( cmv.component_id.id() ) ) ->set_point( cmv.vertex, point ); } else if( cmv.component_id.type() == Surface3D::component_type_static() ) { - surface_mesh_builder( 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() ) { - line_mesh_builder( cmv.component_id.id() ) + line_mesh_builder( brep_.line( cmv.component_id.id() ) ) ->set_point( cmv.vertex, point ); } else if( cmv.component_id.type() == Corner3D::component_type_static() ) { - corner_mesh_builder( 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 0bba84560..9ef73bf91 100644 --- a/src/geode/model/representation/builder/section_builder.cpp +++ b/src/geode/model/representation/builder/section_builder.cpp @@ -91,19 +91,19 @@ namespace geode ModelCopyMapping SectionBuilder::copy_components( const Section& section ) { ModelCopyMapping mappings; - detail::copy_corner_components( - section, *this, mappings[Corner2D::component_type_static()] ); - detail::copy_line_components( - section, *this, mappings[Line2D::component_type_static()] ); - detail::copy_surface_components( - section, *this, mappings[Surface2D::component_type_static()] ); - detail::copy_model_boundary_components( section, *this, + detail::copy_corner_components( section, section_, *this, + mappings[Corner2D::component_type_static()] ); + detail::copy_line_components( section, section_, *this, + mappings[Line2D::component_type_static()] ); + detail::copy_surface_components( section, section_, *this, + mappings[Surface2D::component_type_static()] ); + detail::copy_model_boundary_components( section, section_, *this, mappings[ModelBoundary2D::component_type_static()] ); - detail::copy_corner_collection_components( section, *this, + detail::copy_corner_collection_components( section, section_, *this, mappings[CornerCollection2D::component_type_static()] ); - detail::copy_line_collection_components( section, *this, + detail::copy_line_collection_components( section, section_, *this, mappings[LineCollection2D::component_type_static()] ); - detail::copy_surface_collection_components( section, *this, + detail::copy_surface_collection_components( section, section_, *this, mappings[SurfaceCollection2D::component_type_static()] ); return mappings; } @@ -111,19 +111,19 @@ namespace geode void SectionBuilder::copy_components( ModelCopyMapping& mapping, const Section& section ) { - detail::copy_corner_components( - section, *this, mapping[Corner2D::component_type_static()] ); - detail::copy_line_components( - section, *this, mapping[Line2D::component_type_static()] ); - detail::copy_surface_components( - section, *this, mapping[Surface2D::component_type_static()] ); - detail::copy_model_boundary_components( - section, *this, mapping[ModelBoundary2D::component_type_static()] ); - detail::copy_corner_collection_components( section, *this, + detail::copy_corner_components( section, section_, *this, + mapping[Corner2D::component_type_static()] ); + detail::copy_line_components( section, section_, *this, + mapping[Line2D::component_type_static()] ); + detail::copy_surface_components( section, section_, *this, + mapping[Surface2D::component_type_static()] ); + detail::copy_model_boundary_components( section, section_, *this, + mapping[ModelBoundary2D::component_type_static()] ); + detail::copy_corner_collection_components( section, section_, *this, mapping[CornerCollection2D::component_type_static()] ); - detail::copy_line_collection_components( section, *this, + detail::copy_line_collection_components( section, section_, *this, mapping[LineCollection2D::component_type_static()] ); - detail::copy_surface_collection_components( section, *this, + detail::copy_surface_collection_components( section, section_, *this, mapping[SurfaceCollection2D::component_type_static()] ); } @@ -419,19 +419,20 @@ namespace geode { if( cmv.component_id.type() == Surface2D::component_type_static() ) { - surface_mesh_builder( 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() ) { - line_mesh_builder( cmv.component_id.id() ) + line_mesh_builder( section_.line( cmv.component_id.id() ) ) ->set_point( cmv.vertex, point ); } else if( cmv.component_id.type() == Corner2D::component_type_static() ) { - corner_mesh_builder( 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/detail/transfer_collections.cpp b/src/geode/model/representation/core/detail/transfer_collections.cpp index e13c7ea9b..9aa33b3e2 100644 --- a/src/geode/model/representation/core/detail/transfer_collections.cpp +++ b/src/geode/model/representation/core/detail/transfer_collections.cpp @@ -75,7 +75,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_corner_collection_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -138,7 +138,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_corner_collection_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -186,7 +186,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_line_collection_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -247,7 +247,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_line_collection_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -296,7 +296,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_surface_collection_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -360,7 +360,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_surface_collection_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -408,7 +408,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_block_collection_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -469,7 +469,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_block_collection_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -517,7 +517,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_model_boundary_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -580,7 +580,7 @@ namespace if( const auto name = model_bdry.name() ) { new_model_builder.set_model_boundary_name( - model_bdry.id(), name.value() ); + model_bdry, name.value() ); } } const auto& new_model_bdry = @@ -628,7 +628,7 @@ namespace if( const auto name = collection_in.name() ) { new_model_builder.set_model_boundary_name( - collection_in.id(), name.value() ); + collection_in, name.value() ); } } const auto& new_collection = @@ -688,7 +688,7 @@ namespace if( const auto name = model_bdry.name() ) { new_model_builder.set_model_boundary_name( - model_bdry.id(), name.value() ); + model_bdry, name.value() ); } } const auto& new_model_bdry = diff --git a/src/geode/model/representation/core/detail/transfer_meshes.cpp b/src/geode/model/representation/core/detail/transfer_meshes.cpp index e180d601b..22ced25d9 100644 --- a/src/geode/model/representation/core/detail/transfer_meshes.cpp +++ b/src/geode/model/representation/core/detail/transfer_meshes.cpp @@ -148,8 +148,8 @@ namespace const auto& corner = model.corner( corner_id ); other_builder.unregister_mesh_component( other_corner ); builder.update_corner_mesh( - corner, other_builder.steal_corner_mesh( other_corner_id ) ); - auto mesh_builder = builder.corner_mesh_builder( corner_id ); + corner, other_builder.steal_corner_mesh( other_corner ) ); + auto mesh_builder = builder.corner_mesh_builder( corner ); mesh_builder->set_id( corner.id() ); if( const auto name = corner.name() ) { @@ -178,8 +178,8 @@ namespace const auto& line = model.line( line_id ); other_builder.unregister_mesh_component( other_line ); builder.update_line_mesh( - line, other_builder.steal_line_mesh( other_line_id ) ); - auto mesh_builder = builder.line_mesh_builder( line_id ); + line, other_builder.steal_line_mesh( other_line ) ); + auto mesh_builder = builder.line_mesh_builder( line ); mesh_builder->set_id( line.id() ); if( const auto name = line.name() ) { @@ -209,8 +209,8 @@ namespace const auto& surface = model.surface( surface_id ); other_builder.unregister_mesh_component( other_surface ); builder.update_surface_mesh( - surface, other_builder.steal_surface_mesh( other_surface_id ) ); - auto mesh_builder = builder.surface_mesh_builder( surface_id ); + surface, other_builder.steal_surface_mesh( other_surface ) ); + auto mesh_builder = builder.surface_mesh_builder( surface ); mesh_builder->set_id( surface.id() ); if( const auto name = surface.name() ) { @@ -239,8 +239,8 @@ namespace const auto& block = model.block( block_id ); other_builder.unregister_mesh_component( other_block ); builder.update_block_mesh( - block, other_builder.steal_block_mesh( other_block_id ) ); - auto mesh_builder = builder.block_mesh_builder( block_id ); + block, other_builder.steal_block_mesh( other_block ) ); + auto mesh_builder = builder.block_mesh_builder( block ); mesh_builder->set_id( block.id() ); if( const auto name = block.name() ) { diff --git a/src/geode/model/representation/core/detail/transfer_metadata.cpp b/src/geode/model/representation/core/detail/transfer_metadata.cpp index 21f0f8427..cc03dc14e 100644 --- a/src/geode/model/representation/core/detail/transfer_metadata.cpp +++ b/src/geode/model/representation/core/detail/transfer_metadata.cpp @@ -44,6 +44,7 @@ namespace { template < typename Model > void transfer_model_corner_metadata( const Model& old_model, + const Model& new_model, typename Model::Builder& builder, const geode::ModelGenericMapping& component_mapping ) { @@ -74,12 +75,13 @@ namespace absl::StrAppend( &out_name, corner_name, "+" ); } out_name.pop_back(); - builder.set_corner_name( out_uuid, out_name ); + builder.set_corner_name( new_model.corner( out_uuid ), out_name ); } } template < typename Model > void transfer_model_line_metadata( const Model& old_model, + const Model& new_model, typename Model::Builder& builder, const geode::ModelGenericMapping& component_mapping ) { @@ -110,12 +112,13 @@ namespace absl::StrAppend( &out_name, line_name, "+" ); } out_name.pop_back(); - builder.set_line_name( out_uuid, out_name ); + builder.set_line_name( new_model.line( out_uuid ), out_name ); } } template < typename Model > void transfer_model_surface_metadata( const Model& old_model, + const Model& new_model, typename Model::Builder& builder, const geode::ModelGenericMapping& component_mapping ) { @@ -146,11 +149,12 @@ namespace absl::StrAppend( &out_name, surface_name, "+" ); } out_name.pop_back(); - builder.set_surface_name( out_uuid, out_name ); + builder.set_surface_name( new_model.surface( out_uuid ), out_name ); } } void transfer_model_block_metadata( const geode::BRep& old_model, + const geode::BRep& new_model, typename geode::BRepBuilder& builder, const geode::ModelGenericMapping& component_mapping ) { @@ -181,7 +185,7 @@ namespace absl::StrAppend( &out_name, surface_name, "+" ); } out_name.pop_back(); - builder.set_block_name( out_uuid, out_name ); + builder.set_block_name( new_model.block( out_uuid ), out_name ); } } } // namespace @@ -191,47 +195,49 @@ namespace geode namespace detail { void opengeode_model_api transfer_brep_metadata( const BRep& old_brep, + const BRep& new_brep, BRepBuilder& new_brep_builder, const ModelGenericMapping& component_mapping ) { transfer_model_corner_metadata( - old_brep, new_brep_builder, component_mapping ); + old_brep, new_brep, new_brep_builder, component_mapping ); transfer_model_line_metadata( - old_brep, new_brep_builder, component_mapping ); + old_brep, new_brep, new_brep_builder, component_mapping ); transfer_model_surface_metadata( - old_brep, new_brep_builder, component_mapping ); + old_brep, new_brep, new_brep_builder, component_mapping ); transfer_model_block_metadata( - old_brep, new_brep_builder, component_mapping ); + old_brep, new_brep, new_brep_builder, component_mapping ); } void opengeode_model_api transfer_section_metadata( const Section& old_section, + const Section& new_section, SectionBuilder& new_section_builder, const ModelGenericMapping& component_mapping ) { - transfer_model_corner_metadata( - old_section, new_section_builder, component_mapping ); - transfer_model_line_metadata( - old_section, new_section_builder, component_mapping ); - transfer_model_surface_metadata( - old_section, new_section_builder, component_mapping ); + transfer_model_corner_metadata( old_section, new_section, + new_section_builder, component_mapping ); + transfer_model_line_metadata( old_section, new_section, + new_section_builder, component_mapping ); + transfer_model_surface_metadata( old_section, new_section, + new_section_builder, component_mapping ); } - template < typename ModelBuilder > + template < typename Model > void transfer_pointsets_metadata( absl::Span< const std::reference_wrapper< - const PointSet< ModelBuilder::dim > > > pointsets, - ModelBuilder& model_builder, + const PointSet< Model::dim > > > pointsets, + const Model& model, + typename Model::Builder& model_builder, const ModelGenericMapping& component_mapping ) { - if( !component_mapping.has_mapping_type( geode::Corner< - ModelBuilder::dim >::component_type_static() ) ) + if( !component_mapping.has_mapping_type( + geode::Corner< Model::dim >::component_type_static() ) ) { return; } for( const auto& out2in_mapping : component_mapping - .at( geode::Corner< - ModelBuilder::dim >::component_type_static() ) + .at( geode::Corner< Model::dim >::component_type_static() ) .out2in_map() ) { std::string out_name{ "" }; @@ -241,10 +247,9 @@ namespace geode { absl::StrAppend( &out_name, "+" ); } - const auto in_pointset = absl::c_find_if( - pointsets, [&in_uuid]( const std::reference_wrapper< - const PointSet< ModelBuilder::dim > >& - pointset_ref ) { + const auto in_pointset = absl::c_find_if( pointsets, + [&in_uuid]( const std::reference_wrapper< + const PointSet< Model::dim > >& pointset_ref ) { return pointset_ref.get().id() == in_uuid; } ); OpenGeodeModelException::check_exception( @@ -260,26 +265,26 @@ namespace geode if( !out_name.empty() ) { model_builder.set_corner_name( - out2in_mapping.first, out_name ); + model.corner( out2in_mapping.first ), out_name ); } } } - template < typename ModelBuilder > + template < typename Model > void transfer_curves_metadata( absl::Span< const std::reference_wrapper< - const EdgedCurve< ModelBuilder::dim > > > curves, - ModelBuilder& model_builder, + const EdgedCurve< Model::dim > > > curves, + const Model& model, + typename Model::Builder& model_builder, const ModelGenericMapping& component_mapping ) { - if( !component_mapping.has_mapping_type( geode::Line< - ModelBuilder::dim >::component_type_static() ) ) + if( !component_mapping.has_mapping_type( + geode::Line< Model::dim >::component_type_static() ) ) { return; } for( const auto& out2in_mapping : component_mapping - .at( geode::Line< - ModelBuilder::dim >::component_type_static() ) + .at( geode::Line< Model::dim >::component_type_static() ) .out2in_map() ) { std::string out_name{ "" }; @@ -289,10 +294,9 @@ namespace geode { absl::StrAppend( &out_name, "+" ); } - const auto in_curve = absl::c_find_if( - curves, [&in_uuid]( const std::reference_wrapper< - const EdgedCurve< ModelBuilder::dim > >& - curve_ref ) { + const auto in_curve = absl::c_find_if( curves, + [&in_uuid]( const std::reference_wrapper< + const EdgedCurve< Model::dim > >& curve_ref ) { return curve_ref.get().id() == in_uuid; } ); OpenGeodeModelException::check_exception( @@ -308,27 +312,28 @@ namespace geode if( !out_name.empty() ) { model_builder.set_line_name( - out2in_mapping.first, out_name ); + model.line( out2in_mapping.first ), out_name ); } } } - template < typename ModelBuilder > + template < typename Model > void transfer_surfaces_metadata( absl::Span< const std::reference_wrapper< - const SurfaceMesh< ModelBuilder::dim > > > surfaces, - ModelBuilder& model_builder, + const SurfaceMesh< Model::dim > > > surfaces, + const Model& model, + typename Model::Builder& model_builder, const ModelGenericMapping& component_mapping ) { - if( !component_mapping.has_mapping_type( geode::Surface< - ModelBuilder::dim >::component_type_static() ) ) + if( !component_mapping.has_mapping_type( + geode::Surface< Model::dim >::component_type_static() ) ) { return; } - for( const auto& out2in_mapping : component_mapping - .at( geode::Surface< - ModelBuilder::dim >::component_type_static() ) - .out2in_map() ) + for( const auto& out2in_mapping : + component_mapping + .at( geode::Surface< Model::dim >::component_type_static() ) + .out2in_map() ) { std::string out_name{ "" }; for( const auto& in_uuid : out2in_mapping.second ) @@ -337,10 +342,9 @@ namespace geode { absl::StrAppend( &out_name, "+" ); } - const auto in_surface = absl::c_find_if( - surfaces, [&in_uuid]( const std::reference_wrapper< - const SurfaceMesh< ModelBuilder::dim > >& - surface_ref ) { + const auto in_surface = absl::c_find_if( surfaces, + [&in_uuid]( const std::reference_wrapper< + const SurfaceMesh< Model::dim > >& surface_ref ) { return surface_ref.get().id() == in_uuid; } ); OpenGeodeModelException::check_exception( @@ -356,7 +360,7 @@ namespace geode if( !out_name.empty() ) { model_builder.set_surface_name( - out2in_mapping.first, out_name ); + model.surface( out2in_mapping.first ), out_name ); } } } @@ -364,6 +368,7 @@ namespace geode void transfer_solids_metadata( absl::Span< const std::reference_wrapper< const SolidMesh3D > > solids, + const BRep& model, BRepBuilder& model_builder, const ModelGenericMapping& component_mapping ) { @@ -402,40 +407,46 @@ namespace geode if( !out_name.empty() ) { model_builder.set_block_name( - out2in_mapping.first, out_name ); + model.block( out2in_mapping.first ), out_name ); } } } template void opengeode_model_api transfer_pointsets_metadata( absl::Span< const std::reference_wrapper< const PointSet2D > >, + const Section& model, SectionBuilder&, const ModelGenericMapping& ); template void opengeode_model_api transfer_pointsets_metadata( absl::Span< const std::reference_wrapper< const PointSet3D > >, + const BRep&, BRepBuilder&, const ModelGenericMapping& ); template void opengeode_model_api transfer_curves_metadata( absl::Span< const std::reference_wrapper< const EdgedCurve2D > > curves, + const Section& model, SectionBuilder& model_builder, const ModelGenericMapping& component_mapping ); template void opengeode_model_api transfer_curves_metadata( absl::Span< const std::reference_wrapper< const EdgedCurve3D > > curves, + const BRep& model, BRepBuilder& model_builder, const ModelGenericMapping& component_mapping ); template void opengeode_model_api transfer_surfaces_metadata( absl::Span< const std::reference_wrapper< const SurfaceMesh2D > >, + const Section&, SectionBuilder&, const ModelGenericMapping& ); template void opengeode_model_api transfer_surfaces_metadata( absl::Span< const std::reference_wrapper< const SurfaceMesh3D > >, + const BRep&, BRepBuilder&, const ModelGenericMapping& ); } // namespace detail diff --git a/tests/model/test-brep.cpp b/tests/model/test-brep.cpp index 80d6a9a9a..967eb670c 100644 --- a/tests/model/test-brep.cpp +++ b/tests/model/test-brep.cpp @@ -65,7 +65,8 @@ std::array< geode::uuid, 6 > add_corners( for( const auto c : geode::Range{ 6 } ) { uuids[c] = builder.add_corner(); - builder.set_corner_name( uuids[c], absl::StrCat( "corner", c + 1 ) ); + builder.set_corner_name( + model.corner( uuids[c] ), absl::StrCat( "corner", c + 1 ) ); } const auto& temp_corner = model.corner( builder.add_corner( geode::OpenGeodePointSet3D::impl_name_static() ) ); @@ -78,8 +79,8 @@ std::array< geode::uuid, 6 > add_corners( model.corner( uuids[3] ).name() == "corner4", "Wrong Corner name" ); geode::OpenGeodeModelException::test( model.nb_active_corners() == 6, message ); - builder.set_corner_active( uuids[1], false ); - builder.set_corner_active( uuids[4], false ); + builder.set_corner_active( model.corner( uuids[1] ), false ); + builder.set_corner_active( model.corner( uuids[4] ), false ); geode::OpenGeodeModelException::test( model.nb_active_corners() == 4, "BRep should have 4 active corners" ); geode::OpenGeodeModelException::test( @@ -94,7 +95,8 @@ std::array< geode::uuid, 9 > add_lines( for( const auto l : geode::Range{ 9 } ) { uuids[l] = builder.add_line(); - builder.set_line_name( uuids[l], absl::StrCat( "line", l + 1 ) ); + builder.set_line_name( + model.line( uuids[l] ), absl::StrCat( "line", l + 1 ) ); } const auto& temp_line = model.line( builder.add_line( geode::OpenGeodeEdgedCurve3D::impl_name_static() ) ); @@ -107,8 +109,8 @@ std::array< geode::uuid, 9 > add_lines( model.line( uuids[3] ).name() == "line4", "Wrong Line name" ); geode::OpenGeodeModelException::test( model.nb_active_lines() == 9, message ); - builder.set_line_active( uuids[1], false ); - builder.set_line_active( uuids[4], false ); + builder.set_line_active( model.line( uuids[1] ), false ); + builder.set_line_active( model.line( uuids[4] ), false ); geode::OpenGeodeModelException::test( model.nb_active_lines() == 7, "BRep should have 7 active lines" ); geode::OpenGeodeModelException::test( @@ -124,7 +126,8 @@ std::array< geode::uuid, 5 > add_surfaces( { uuids[s] = builder.add_surface( geode::OpenGeodeTriangulatedSurface3D::impl_name_static() ); - builder.set_surface_name( uuids[s], absl::StrCat( "surface", s + 1 ) ); + builder.set_surface_name( + model.surface( uuids[s] ), absl::StrCat( "surface", s + 1 ) ); } for( const auto s : geode::Range{ 2, 5 } ) { @@ -141,8 +144,8 @@ std::array< geode::uuid, 5 > add_surfaces( model.surface( uuids[1] ).name() == "surface2", "Wrong Surface name" ); geode::OpenGeodeModelException::test( model.nb_active_surfaces() == 5, message ); - builder.set_surface_active( uuids[1], false ); - builder.set_surface_active( uuids[4], false ); + builder.set_surface_active( model.surface( uuids[1] ), false ); + builder.set_surface_active( model.surface( uuids[4] ), false ); geode::OpenGeodeModelException::test( model.nb_active_surfaces() == 3, "BRep should have 3 active surfaces" ); geode::OpenGeodeModelException::test( @@ -153,7 +156,7 @@ std::array< geode::uuid, 5 > add_surfaces( geode::uuid add_block( const geode::BRep& model, geode::BRepBuilder& builder ) { geode::uuid block_uuid = builder.add_block(); - builder.set_block_name( block_uuid, "block1" ); + builder.set_block_name( model.block( block_uuid ), "block1" ); const auto& temp_block = model.block( builder.add_block( geode::OpenGeodePolyhedralSolid3D::impl_name_static() ) ); builder.remove_block( temp_block ); @@ -165,7 +168,7 @@ geode::uuid add_block( const geode::BRep& model, geode::BRepBuilder& builder ) model.block( block_uuid ).name() == "block1", "Wrong Block name" ); geode::OpenGeodeModelException::test( model.nb_active_blocks() == 1, message ); - builder.set_block_active( block_uuid, false ); + builder.set_block_active( model.block( block_uuid ), false ); geode::OpenGeodeModelException::test( model.nb_active_blocks() == 0, "BRep should have 0 active block" ); geode::OpenGeodeModelException::test( @@ -180,8 +183,8 @@ std::array< geode::uuid, 3 > add_model_boundaries( for( const auto mb : geode::Range{ 3 } ) { uuids[mb] = builder.add_model_boundary(); - builder.set_model_boundary_name( - uuids[mb], absl::StrCat( "boundary", mb + 1 ) ); + builder.set_model_boundary_name( model.model_boundary( uuids[mb] ), + absl::StrCat( "boundary", mb + 1 ) ); } const auto& temp_boundary = model.model_boundary( builder.add_model_boundary() ); @@ -198,8 +201,10 @@ std::array< geode::uuid, 3 > add_model_boundaries( "Wrong ModelBoundary name" ); geode::OpenGeodeModelException::test( model.nb_active_model_boundaries() == 3, message ); - builder.set_model_boundary_active( uuids[1], false ); - builder.set_model_boundary_active( uuids[2], false ); + builder.set_model_boundary_active( + model.model_boundary( uuids[1] ), false ); + builder.set_model_boundary_active( + model.model_boundary( uuids[2] ), false ); geode::OpenGeodeModelException::test( model.nb_active_model_boundaries() == 1, "BRep should have 1 active model boundary" ); @@ -216,7 +221,8 @@ std::array< geode::uuid, 2 > add_corner_collections( { uuids[mb] = builder.add_corner_collection(); builder.set_corner_collection_name( - uuids[mb], absl::StrCat( "corner_collection", mb + 1 ) ); + model.corner_collection( uuids[mb] ), + absl::StrCat( "corner_collection", mb + 1 ) ); } const auto& temp_collection = model.corner_collection( builder.add_corner_collection() ); @@ -234,7 +240,8 @@ std::array< geode::uuid, 2 > add_corner_collections( "Wrong CornerCollection name" ); geode::OpenGeodeModelException::test( model.nb_active_corner_collections() == 2, message ); - builder.set_corner_collection_active( uuids[1], false ); + builder.set_corner_collection_active( + model.corner_collection( uuids[1] ), false ); geode::OpenGeodeModelException::test( model.nb_active_corner_collections() == 1, "BRep should have 1 active corner collection" ); @@ -251,8 +258,8 @@ std::array< geode::uuid, 2 > add_line_collections( for( const auto mb : geode::Indices{ uuids } ) { uuids[mb] = builder.add_line_collection(); - builder.set_line_collection_name( - uuids[mb], absl::StrCat( "line_collection", mb + 1 ) ); + builder.set_line_collection_name( model.line_collection( uuids[mb] ), + absl::StrCat( "line_collection", mb + 1 ) ); } const auto& temp_collection = model.line_collection( builder.add_line_collection() ); @@ -270,7 +277,8 @@ std::array< geode::uuid, 2 > add_line_collections( "Wrong LineCollection name" ); geode::OpenGeodeModelException::test( model.nb_active_line_collections() == 2, message ); - builder.set_line_collection_active( uuids[1], false ); + builder.set_line_collection_active( + model.line_collection( uuids[1] ), false ); geode::OpenGeodeModelException::test( model.nb_active_line_collections() == 1, "BRep should have 1 active line collection" ); @@ -287,7 +295,8 @@ std::array< geode::uuid, 2 > add_surface_collections( { uuids[mb] = builder.add_surface_collection(); builder.set_surface_collection_name( - uuids[mb], absl::StrCat( "surface_collection", mb + 1 ) ); + model.surface_collection( uuids[mb] ), + absl::StrCat( "surface_collection", mb + 1 ) ); } const auto& temp_collection = model.surface_collection( builder.add_surface_collection() ); @@ -305,7 +314,8 @@ std::array< geode::uuid, 2 > add_surface_collections( "Wrong SurfaceCollection name" ); geode::OpenGeodeModelException::test( model.nb_active_surface_collections() == 2, message ); - builder.set_surface_collection_active( uuids[1], false ); + builder.set_surface_collection_active( + model.surface_collection( uuids[1] ), false ); geode::OpenGeodeModelException::test( model.nb_active_surface_collections() == 1, "BRep should have 1 active surface collection" ); @@ -319,7 +329,8 @@ geode::uuid add_block_collection( { geode::uuid block_uuid; block_uuid = builder.add_block_collection(); - builder.set_block_collection_name( block_uuid, "block_collection1" ); + builder.set_block_collection_name( + model.block_collection( block_uuid ), "block_collection1" ); const auto& temp_collection = model.block_collection( builder.add_block_collection() ); builder.remove_block_collection( temp_collection ); @@ -334,7 +345,8 @@ geode::uuid add_block_collection( "Wrong BlockCollection name" ); geode::OpenGeodeModelException::test( model.nb_active_block_collections() == 1, message ); - builder.set_block_collection_active( block_uuid, false ); + builder.set_block_collection_active( + model.block_collection( block_uuid ), false ); geode::OpenGeodeModelException::test( model.nb_active_block_collections() == 0, "BRep should have 0 active block collection" ); @@ -798,7 +810,8 @@ void add_internal_surface_block_relations( const geode::BRep& model, } } -void set_geometry( geode::BRepBuilder& builder, +void set_geometry( const geode::BRep& model, + geode::BRepBuilder& builder, absl::Span< const geode::uuid > corner_uuids, absl::Span< const geode::uuid > line_uuids, absl::Span< const geode::uuid > surface_uuids ) @@ -812,80 +825,114 @@ void set_geometry( geode::BRepBuilder& builder, points[5] = geode::Point3D{ { 2., 2., 2. } }; for( const auto i : geode::Range{ 6 } ) { - builder.corner_mesh_builder( corner_uuids[i] ) + builder.corner_mesh_builder( model.corner( corner_uuids[i] ) ) ->create_point( points[i] ); } - builder.line_mesh_builder( line_uuids[0] )->create_point( points[0] ); - builder.line_mesh_builder( line_uuids[0] )->create_point( points[1] ); - builder.line_mesh_builder( line_uuids[1] )->create_point( points[1] ); - builder.line_mesh_builder( line_uuids[1] )->create_point( points[2] ); - builder.line_mesh_builder( line_uuids[2] )->create_point( points[0] ); - builder.line_mesh_builder( line_uuids[2] )->create_point( points[2] ); - builder.line_mesh_builder( line_uuids[3] )->create_point( points[1] ); - builder.line_mesh_builder( line_uuids[3] )->create_point( points[4] ); - builder.line_mesh_builder( line_uuids[4] )->create_point( points[2] ); - builder.line_mesh_builder( line_uuids[4] )->create_point( points[5] ); - builder.line_mesh_builder( line_uuids[5] )->create_point( points[0] ); - builder.line_mesh_builder( line_uuids[5] )->create_point( points[3] ); - builder.line_mesh_builder( line_uuids[6] )->create_point( points[3] ); - builder.line_mesh_builder( line_uuids[6] )->create_point( points[4] ); - builder.line_mesh_builder( line_uuids[7] )->create_point( points[4] ); - builder.line_mesh_builder( line_uuids[7] )->create_point( points[5] ); - builder.line_mesh_builder( line_uuids[8] )->create_point( points[3] ); - builder.line_mesh_builder( line_uuids[8] )->create_point( points[5] ); + builder.line_mesh_builder( model.line( line_uuids[0] ) ) + ->create_point( points[0] ); + builder.line_mesh_builder( model.line( line_uuids[0] ) ) + ->create_point( points[1] ); + builder.line_mesh_builder( model.line( line_uuids[1] ) ) + ->create_point( points[1] ); + builder.line_mesh_builder( model.line( line_uuids[1] ) ) + ->create_point( points[2] ); + builder.line_mesh_builder( model.line( line_uuids[2] ) ) + ->create_point( points[0] ); + builder.line_mesh_builder( model.line( line_uuids[2] ) ) + ->create_point( points[2] ); + builder.line_mesh_builder( model.line( line_uuids[3] ) ) + ->create_point( points[1] ); + builder.line_mesh_builder( model.line( line_uuids[3] ) ) + ->create_point( points[4] ); + builder.line_mesh_builder( model.line( line_uuids[4] ) ) + ->create_point( points[2] ); + builder.line_mesh_builder( model.line( line_uuids[4] ) ) + ->create_point( points[5] ); + builder.line_mesh_builder( model.line( line_uuids[5] ) ) + ->create_point( points[0] ); + builder.line_mesh_builder( model.line( line_uuids[5] ) ) + ->create_point( points[3] ); + builder.line_mesh_builder( model.line( line_uuids[6] ) ) + ->create_point( points[3] ); + builder.line_mesh_builder( model.line( line_uuids[6] ) ) + ->create_point( points[4] ); + builder.line_mesh_builder( model.line( line_uuids[7] ) ) + ->create_point( points[4] ); + builder.line_mesh_builder( model.line( line_uuids[7] ) ) + ->create_point( points[5] ); + builder.line_mesh_builder( model.line( line_uuids[8] ) ) + ->create_point( points[3] ); + builder.line_mesh_builder( model.line( line_uuids[8] ) ) + ->create_point( points[5] ); for( const auto i : geode::Range{ 9 } ) { - builder.line_mesh_builder( line_uuids[i] )->create_edge( 0, 1 ); + builder.line_mesh_builder( model.line( line_uuids[i] ) ) + ->create_edge( 0, 1 ); } builder .surface_mesh_builder< geode::TriangulatedSurface3D >( - surface_uuids[0] ) + model.surface( surface_uuids[0] ) ) ->create_point( points[0] ); builder .surface_mesh_builder< geode::TriangulatedSurface3D >( - surface_uuids[0] ) + model.surface( surface_uuids[0] ) ) ->create_point( points[1] ); builder .surface_mesh_builder< geode::TriangulatedSurface3D >( - surface_uuids[0] ) + model.surface( surface_uuids[0] ) ) ->create_point( points[2] ); builder .surface_mesh_builder< geode::TriangulatedSurface3D >( - surface_uuids[0] ) + model.surface( surface_uuids[0] ) ) ->create_polygon( { 0, 1, 2 } ); - builder.surface_mesh_builder( surface_uuids[1] )->create_point( points[0] ); - builder.surface_mesh_builder( surface_uuids[1] )->create_point( points[1] ); - builder.surface_mesh_builder( surface_uuids[1] )->create_point( points[4] ); - builder.surface_mesh_builder( surface_uuids[1] )->create_point( points[3] ); - builder.surface_mesh_builder( surface_uuids[1] ) + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) + ->create_point( points[0] ); + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) + ->create_point( points[1] ); + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) + ->create_point( points[4] ); + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) + ->create_point( points[3] ); + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) ->create_polygon( { 0, 1, 2 } ); - builder.surface_mesh_builder( surface_uuids[1] ) + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) ->create_polygon( { 0, 2, 3 } ); - builder.surface_mesh_builder( surface_uuids[2] )->create_point( points[4] ); - builder.surface_mesh_builder( surface_uuids[2] )->create_point( points[1] ); - builder.surface_mesh_builder( surface_uuids[2] )->create_point( points[2] ); - builder.surface_mesh_builder( surface_uuids[2] )->create_point( points[5] ); - builder.surface_mesh_builder( surface_uuids[2] ) + builder.surface_mesh_builder( model.surface( surface_uuids[2] ) ) + ->create_point( points[4] ); + builder.surface_mesh_builder( model.surface( surface_uuids[2] ) ) + ->create_point( points[1] ); + builder.surface_mesh_builder( model.surface( surface_uuids[2] ) ) + ->create_point( points[2] ); + builder.surface_mesh_builder( model.surface( surface_uuids[2] ) ) + ->create_point( points[5] ); + builder.surface_mesh_builder( model.surface( surface_uuids[2] ) ) ->create_polygon( { 0, 1, 2 } ); - builder.surface_mesh_builder( surface_uuids[2] ) + builder.surface_mesh_builder( model.surface( surface_uuids[2] ) ) ->create_polygon( { 0, 2, 3 } ); - builder.surface_mesh_builder( surface_uuids[3] )->create_point( points[3] ); - builder.surface_mesh_builder( surface_uuids[3] )->create_point( points[0] ); - builder.surface_mesh_builder( surface_uuids[3] )->create_point( points[2] ); - builder.surface_mesh_builder( surface_uuids[3] )->create_point( points[5] ); - builder.surface_mesh_builder( surface_uuids[3] ) + builder.surface_mesh_builder( model.surface( surface_uuids[3] ) ) + ->create_point( points[3] ); + builder.surface_mesh_builder( model.surface( surface_uuids[3] ) ) + ->create_point( points[0] ); + builder.surface_mesh_builder( model.surface( surface_uuids[3] ) ) + ->create_point( points[2] ); + builder.surface_mesh_builder( model.surface( surface_uuids[3] ) ) + ->create_point( points[5] ); + builder.surface_mesh_builder( model.surface( surface_uuids[3] ) ) ->create_polygon( { 0, 1, 2 } ); - builder.surface_mesh_builder( surface_uuids[3] ) + builder.surface_mesh_builder( model.surface( surface_uuids[3] ) ) ->create_polygon( { 0, 2, 3 } ); - builder.surface_mesh_builder( surface_uuids[4] )->create_point( points[3] ); - builder.surface_mesh_builder( surface_uuids[4] )->create_point( points[4] ); - builder.surface_mesh_builder( surface_uuids[4] )->create_point( points[5] ); - builder.surface_mesh_builder( surface_uuids[4] ) + builder.surface_mesh_builder( model.surface( surface_uuids[4] ) ) + ->create_point( points[3] ); + builder.surface_mesh_builder( model.surface( surface_uuids[4] ) ) + ->create_point( points[4] ); + builder.surface_mesh_builder( model.surface( surface_uuids[4] ) ) + ->create_point( points[5] ); + builder.surface_mesh_builder( model.surface( surface_uuids[4] ) ) ->create_polygon( { 0, 1, 2 } ); } @@ -1532,7 +1579,7 @@ void test_backward_io() for( const auto& surface : brep.surfaces() ) { auto vertex_index = - brep_builder.surface_mesh_builder( surface.id() )->create_vertex(); + brep_builder.surface_mesh_builder( surface )->create_vertex(); DEBUG( vertex_index ); DEBUG( brep.unique_vertex( { surface.component_id(), vertex_index } ) ); geode::OpenGeodeModelException::test( @@ -1570,8 +1617,7 @@ void test_backward_io() for( const auto& surface : brep_v17.surfaces() ) { auto vertex_index = - brep_builder_v17.surface_mesh_builder( surface.id() ) - ->create_vertex(); + brep_builder_v17.surface_mesh_builder( surface )->create_vertex(); geode::OpenGeodeModelException::test( brep_v17.unique_vertex( { surface.component_id(), vertex_index } ) == geode::NO_ID, @@ -1628,7 +1674,7 @@ void test() test_registry( model, 4, 6, 9, 5, 1, 5, 2, 2, 2, 1, 3 ); - set_geometry( builder, corner_uuids, line_uuids, surface_uuids ); + set_geometry( model, builder, corner_uuids, line_uuids, surface_uuids ); add_corner_line_boundary_relation( model, builder, corner_uuids, line_uuids ); @@ -1679,8 +1725,8 @@ void test() geode::BRepBuilder model2_builder{ model2 }; for( const auto& surface : model2.surfaces() ) { - auto vertex_index = model2_builder.surface_mesh_builder( surface.id() ) - ->create_vertex(); + auto vertex_index = + model2_builder.surface_mesh_builder( surface )->create_vertex(); DEBUG( vertex_index ); DEBUG( model2.unique_vertex( { surface.component_id(), vertex_index } ) ); diff --git a/tests/model/test-component-mesh-edges.cpp b/tests/model/test-component-mesh-edges.cpp index c3afa5950..34e34b626 100644 --- a/tests/model/test-component-mesh-edges.cpp +++ b/tests/model/test-component-mesh-edges.cpp @@ -53,7 +53,8 @@ geode::Section build_section() { const auto& line_id = builder.add_line(); - auto line_builder = builder.line_mesh_builder( line_id ); + auto line_builder = + builder.line_mesh_builder( section.line( line_id ) ); line_builder->create_point( points[0] ); line_builder->create_point( points[1] ); line_builder->create_point( points[2] ); @@ -81,7 +82,7 @@ geode::Section build_section() geode::TriangulatedSurface2D::type_name_static() ) ); auto surface_builder = builder.surface_mesh_builder< geode::TriangulatedSurface2D >( - surface_id ); + section.surface( surface_id ) ); surface_builder->create_point( points[0] ); surface_builder->create_point( points[1] ); surface_builder->create_point( points[2] ); @@ -108,7 +109,7 @@ geode::Section build_section() geode::TriangulatedSurface2D::type_name_static() ) ); auto surface_builder = builder.surface_mesh_builder< geode::TriangulatedSurface2D >( - surface_id ); + section.surface( surface_id ) ); surface_builder->create_point( points[0] ); surface_builder->create_point( points[1] ); surface_builder->create_point( points[2] ); diff --git a/tests/model/test-model-component-filter.cpp b/tests/model/test-model-component-filter.cpp index 7987d0940..ba1596a65 100644 --- a/tests/model/test-model-component-filter.cpp +++ b/tests/model/test-model-component-filter.cpp @@ -86,7 +86,7 @@ void add_inactive_surface( geode::BRep& brep ) { geode::BRepBuilder builder{ brep }; const auto new_surface_id = builder.add_surface(); - builder.set_surface_active( new_surface_id, false ); + builder.set_surface_active( brep.surface( new_surface_id ), false ); } void test() diff --git a/tests/model/test-section.cpp b/tests/model/test-section.cpp index 37b8e0bd0..a9e4e1f3b 100644 --- a/tests/model/test-section.cpp +++ b/tests/model/test-section.cpp @@ -113,8 +113,8 @@ std::array< geode::uuid, 2 > add_model_boundaries( for( auto mb : geode::Range{ 2 } ) { uuids[mb] = builder.add_model_boundary(); - builder.set_model_boundary_name( - uuids[mb], absl::StrCat( "boundary", mb + 1 ) ); + builder.set_model_boundary_name( section.model_boundary( uuids[mb] ), + absl::StrCat( "boundary", mb + 1 ) ); } const auto& temp_boundary = section.model_boundary( builder.add_model_boundary() ); @@ -140,7 +140,8 @@ std::array< geode::uuid, 2 > add_corner_collections( { uuids[mb] = builder.add_corner_collection(); builder.set_corner_collection_name( - uuids[mb], absl::StrCat( "collection", mb + 1 ) ); + section.corner_collection( uuids[mb] ), + absl::StrCat( "collection", mb + 1 ) ); } const auto& temp_collection = section.corner_collection( builder.add_corner_collection() ); @@ -166,8 +167,8 @@ std::array< geode::uuid, 2 > add_line_collections( for( auto mb : geode::Range{ 2 } ) { uuids[mb] = builder.add_line_collection(); - builder.set_line_collection_name( - uuids[mb], absl::StrCat( "collection", mb + 1 ) ); + builder.set_line_collection_name( section.line_collection( uuids[mb] ), + absl::StrCat( "collection", mb + 1 ) ); } const auto& temp_collection = section.line_collection( builder.add_line_collection() ); @@ -193,7 +194,8 @@ std::array< geode::uuid, 2 > add_surface_collections( { uuids[mb] = builder.add_surface_collection(); builder.set_surface_collection_name( - uuids[mb], absl::StrCat( "collection", mb + 1 ) ); + section.surface_collection( uuids[mb] ), + absl::StrCat( "collection", mb + 1 ) ); } const auto& temp_collection = section.surface_collection( builder.add_surface_collection() ); @@ -303,7 +305,8 @@ void add_line_surface_boundary_relation( const geode::Section& model, "Surface 1 should have 4 Lines as boundaries" ); } -void set_geometry( geode::SectionBuilder& builder, +void set_geometry( const geode::Section& model, + geode::SectionBuilder& builder, absl::Span< const geode::uuid > corner_uuids, absl::Span< const geode::uuid > line_uuids, absl::Span< const geode::uuid > surface_uuids ) @@ -316,39 +319,59 @@ void set_geometry( geode::SectionBuilder& builder, points[4] = geode::Point2D{ { 2., 2. } }; for( const auto i : geode::Range{ 5 } ) { - builder.corner_mesh_builder( corner_uuids[i] ) + builder.corner_mesh_builder( model.corner( corner_uuids[i] ) ) ->create_point( points[i] ); } - builder.line_mesh_builder( line_uuids[0] )->create_point( points[0] ); - builder.line_mesh_builder( line_uuids[0] )->create_point( points[1] ); - builder.line_mesh_builder( line_uuids[1] )->create_point( points[0] ); - builder.line_mesh_builder( line_uuids[1] )->create_point( points[2] ); - builder.line_mesh_builder( line_uuids[2] )->create_point( points[1] ); - builder.line_mesh_builder( line_uuids[2] )->create_point( points[2] ); - builder.line_mesh_builder( line_uuids[3] )->create_point( points[1] ); - builder.line_mesh_builder( line_uuids[3] )->create_point( points[3] ); - builder.line_mesh_builder( line_uuids[4] )->create_point( points[2] ); - builder.line_mesh_builder( line_uuids[4] )->create_point( points[4] ); - builder.line_mesh_builder( line_uuids[5] )->create_point( points[3] ); - builder.line_mesh_builder( line_uuids[5] )->create_point( points[4] ); + builder.line_mesh_builder( model.line( line_uuids[0] ) ) + ->create_point( points[0] ); + builder.line_mesh_builder( model.line( line_uuids[0] ) ) + ->create_point( points[1] ); + builder.line_mesh_builder( model.line( line_uuids[1] ) ) + ->create_point( points[0] ); + builder.line_mesh_builder( model.line( line_uuids[1] ) ) + ->create_point( points[2] ); + builder.line_mesh_builder( model.line( line_uuids[2] ) ) + ->create_point( points[1] ); + builder.line_mesh_builder( model.line( line_uuids[2] ) ) + ->create_point( points[2] ); + builder.line_mesh_builder( model.line( line_uuids[3] ) ) + ->create_point( points[1] ); + builder.line_mesh_builder( model.line( line_uuids[3] ) ) + ->create_point( points[3] ); + builder.line_mesh_builder( model.line( line_uuids[4] ) ) + ->create_point( points[2] ); + builder.line_mesh_builder( model.line( line_uuids[4] ) ) + ->create_point( points[4] ); + builder.line_mesh_builder( model.line( line_uuids[5] ) ) + ->create_point( points[3] ); + builder.line_mesh_builder( model.line( line_uuids[5] ) ) + ->create_point( points[4] ); for( const auto i : geode::Range{ 6 } ) { - builder.line_mesh_builder( line_uuids[i] )->create_edge( 0, 1 ); + builder.line_mesh_builder( model.line( line_uuids[i] ) ) + ->create_edge( 0, 1 ); } - builder.surface_mesh_builder( surface_uuids[0] )->create_point( points[0] ); - builder.surface_mesh_builder( surface_uuids[0] )->create_point( points[1] ); - builder.surface_mesh_builder( surface_uuids[0] )->create_point( points[2] ); - builder.surface_mesh_builder( surface_uuids[0] ) + builder.surface_mesh_builder( model.surface( surface_uuids[0] ) ) + ->create_point( points[0] ); + builder.surface_mesh_builder( model.surface( surface_uuids[0] ) ) + ->create_point( points[1] ); + builder.surface_mesh_builder( model.surface( surface_uuids[0] ) ) + ->create_point( points[2] ); + builder.surface_mesh_builder( model.surface( surface_uuids[0] ) ) ->create_polygon( { 0, 1, 2 } ); - builder.surface_mesh_builder( surface_uuids[1] )->create_point( points[1] ); - builder.surface_mesh_builder( surface_uuids[1] )->create_point( points[2] ); - builder.surface_mesh_builder( surface_uuids[1] )->create_point( points[4] ); - builder.surface_mesh_builder( surface_uuids[1] )->create_point( points[3] ); - builder.surface_mesh_builder( surface_uuids[1] ) + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) + ->create_point( points[1] ); + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) + ->create_point( points[2] ); + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) + ->create_point( points[4] ); + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) + ->create_point( points[3] ); + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) ->create_polygon( { 0, 1, 2 } ); - builder.surface_mesh_builder( surface_uuids[1] ) + builder.surface_mesh_builder( model.surface( surface_uuids[1] ) ) ->create_polygon( { 0, 2, 3 } ); } @@ -985,7 +1008,7 @@ void test() test_registry( model ); - set_geometry( builder, corner_uuids, line_uuids, surface_uuids ); + set_geometry( model, builder, corner_uuids, line_uuids, surface_uuids ); add_corner_line_boundary_relation( model, builder, corner_uuids, line_uuids ); diff --git a/tests/model/test-surface-radial-sort.cpp b/tests/model/test-surface-radial-sort.cpp index 193386ec5..9502f0475 100644 --- a/tests/model/test-surface-radial-sort.cpp +++ b/tests/model/test-surface-radial-sort.cpp @@ -52,7 +52,7 @@ void test() const auto line_id = builder.add_line(); const auto& line = brep.line( line_id ); - auto line_builder = builder.line_mesh_builder( line_id ); + auto line_builder = builder.line_mesh_builder( line ); line_builder->create_point( points[0] ); builder.set_unique_vertex( { line.component_id(), 0 }, 0 ); line_builder->create_point( points[1] ); @@ -61,7 +61,7 @@ void test() const auto surface0_id = builder.add_surface(); const auto& surface0 = brep.surface( surface0_id ); - auto surface0_builder = builder.surface_mesh_builder( surface0_id ); + auto surface0_builder = builder.surface_mesh_builder( surface0 ); surface0_builder->create_point( points[0] ); builder.set_unique_vertex( { surface0.component_id(), 0 }, 0 ); surface0_builder->create_point( points[1] ); @@ -72,7 +72,7 @@ void test() const auto surface1_id = builder.add_surface(); const auto& surface1 = brep.surface( surface1_id ); - auto surface1_builder = builder.surface_mesh_builder( surface1_id ); + auto surface1_builder = builder.surface_mesh_builder( surface1 ); surface1_builder->create_point( points[0] ); builder.set_unique_vertex( { surface1.component_id(), 0 }, 0 ); surface1_builder->create_point( points[1] ); @@ -83,7 +83,7 @@ void test() const auto surface2_id = builder.add_surface(); const auto& surface2 = brep.surface( surface2_id ); - auto surface2_builder = builder.surface_mesh_builder( surface2_id ); + auto surface2_builder = builder.surface_mesh_builder( surface2 ); surface2_builder->create_point( points[1] ); builder.set_unique_vertex( { surface2.component_id(), 0 }, 1 ); surface2_builder->create_point( points[0] ); diff --git a/tests/model/test-vertex-identifier.cpp b/tests/model/test-vertex-identifier.cpp index 84ab63ca4..0534bae92 100644 --- a/tests/model/test-vertex-identifier.cpp +++ b/tests/model/test-vertex-identifier.cpp @@ -199,7 +199,8 @@ void test_update_unique_vertices() SurfaceProviderBuilder builder( provider ); const auto& surface_id = builder.add_surface(); - auto surf_builder = builder.surface_mesh_builder( surface_id ); + auto surf_builder = + builder.surface_mesh_builder( provider.surface( surface_id ) ); const auto surface_cid = provider.surface( surface_id ).component_id(); builder.create_unique_vertices( 5 ); for( const auto i : geode::Range{ 10 } ) @@ -252,13 +253,13 @@ void test() const auto& corner1_id = builder.add_corner(); const auto& corner2_id = builder.add_corner(); const auto& corner3_id = builder.add_corner(); - builder.corner_mesh_builder( corner0_id ) + builder.corner_mesh_builder( provider.corner( corner0_id ) ) ->create_point( geode::Point2D{ { 0.1, 2.3 } } ); - builder.corner_mesh_builder( corner1_id ) + builder.corner_mesh_builder( provider.corner( corner1_id ) ) ->create_point( geode::Point2D{ { 1.1, 4.3 } } ); - builder.corner_mesh_builder( corner2_id ) + builder.corner_mesh_builder( provider.corner( corner2_id ) ) ->create_point( geode::Point2D{ { 0.9, -3.7 } } ); - builder.corner_mesh_builder( corner3_id ) + builder.corner_mesh_builder( provider.corner( corner3_id ) ) ->create_point( geode::Point2D{ { 0.1, 2.3 } } ); geode::VertexIdentifierBuilder vertex_id_builder{ vertex_identifier }; From 5e89a6cf705bde485f9044fc63390bc45e6ecb3d Mon Sep 17 00:00:00 2001 From: BenPinet Date: Wed, 12 Aug 2026 10:05:54 +0200 Subject: [PATCH 2/2] pierre's comments --- .../model/mixin/builder/surfaces_builder.hpp | 2 - .../representation/builder/detail/copy.hpp | 77 ++++++++++--------- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/include/geode/model/mixin/builder/surfaces_builder.hpp b/include/geode/model/mixin/builder/surfaces_builder.hpp index f08529019..8a3a968c3 100644 --- a/include/geode/model/mixin/builder/surfaces_builder.hpp +++ b/include/geode/model/mixin/builder/surfaces_builder.hpp @@ -33,9 +33,7 @@ namespace geode { FORWARD_DECLARATION_DIMENSION_CLASS( Surface ); - ALIAS_2D_AND_3D( Surface ); FORWARD_DECLARATION_DIMENSION_CLASS( Surfaces ); - ALIAS_2D_AND_3D( Surfaces ); FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMesh ); FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMeshBuilder ); diff --git a/include/geode/model/representation/builder/detail/copy.hpp b/include/geode/model/representation/builder/detail/copy.hpp index 40c297f19..8d785e9f5 100644 --- a/include/geode/model/representation/builder/detail/copy.hpp +++ b/include/geode/model/representation/builder/detail/copy.hpp @@ -53,7 +53,7 @@ namespace geode template < typename ModelFrom, typename ModelTo > void copy_corner_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -77,16 +77,17 @@ namespace geode const auto& id = mapping.in2out( corner.id() ); if( const auto name = corner.name() ) { - builder_to.set_corner_name( to.corner( id ), name.value() ); + builder_to.set_corner_name( + model_to.corner( id ), name.value() ); } builder_to.set_corner_active( - to.corner( id ), corner.is_active() ); + model_to.corner( id ), corner.is_active() ); } } template < typename ModelFrom, typename ModelTo > void copy_line_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -110,15 +111,17 @@ namespace geode const auto& id = mapping.in2out( line.id() ); if( const auto name = line.name() ) { - builder_to.set_line_name( to.line( id ), name.value() ); + builder_to.set_line_name( + model_to.line( id ), name.value() ); } - builder_to.set_line_active( to.line( id ), line.is_active() ); + builder_to.set_line_active( + model_to.line( id ), line.is_active() ); } } template < typename ModelFrom, typename ModelTo > void copy_surface_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -144,16 +147,16 @@ namespace geode if( const auto name = surface.name() ) { builder_to.set_surface_name( - to.surface( id ), name.value() ); + model_to.surface( id ), name.value() ); } builder_to.set_surface_active( - to.surface( id ), surface.is_active() ); + model_to.surface( id ), surface.is_active() ); } } template < typename ModelFrom, typename ModelTo > void copy_block_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -177,16 +180,17 @@ namespace geode const auto& id = mapping.in2out( block.id() ); if( const auto name = block.name() ) { - builder_to.set_block_name( to.block( id ), name.value() ); + builder_to.set_block_name( + model_to.block( id ), name.value() ); } builder_to.set_block_active( - to.block( id ), block.is_active() ); + model_to.block( id ), block.is_active() ); } } template < typename ModelFrom, typename ModelTo > void copy_model_boundary_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -206,16 +210,16 @@ namespace geode if( const auto name = model_boundary.name() ) { builder_to.set_model_boundary_name( - to.model_boundary( id ), name.value() ); + model_to.model_boundary( id ), name.value() ); } builder_to.set_model_boundary_active( - to.model_boundary( id ), model_boundary.is_active() ); + model_to.model_boundary( id ), model_boundary.is_active() ); } } template < typename ModelFrom, typename ModelTo > void copy_corner_collection_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -235,16 +239,17 @@ namespace geode if( const auto name = corner_collection.name() ) { builder_to.set_corner_collection_name( - to.corner_collection( id ), name.value() ); + model_to.corner_collection( id ), name.value() ); } builder_to.set_corner_collection_active( - to.corner_collection( id ), corner_collection.is_active() ); + model_to.corner_collection( id ), + corner_collection.is_active() ); } } template < typename ModelFrom, typename ModelTo > void copy_line_collection_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -264,16 +269,17 @@ namespace geode if( const auto name = line_collection.name() ) { builder_to.set_line_collection_name( - to.line_collection( id ), name.value() ); + model_to.line_collection( id ), name.value() ); } builder_to.set_line_collection_active( - to.line_collection( id ), line_collection.is_active() ); + model_to.line_collection( id ), + line_collection.is_active() ); } } template < typename ModelFrom, typename ModelTo > void copy_surface_collection_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -293,17 +299,17 @@ namespace geode if( const auto name = surface_collection.name() ) { builder_to.set_surface_collection_name( - to.surface_collection( id ), name.value() ); + model_to.surface_collection( id ), name.value() ); } builder_to.set_surface_collection_active( - to.surface_collection( id ), + model_to.surface_collection( id ), surface_collection.is_active() ); } } template < typename ModelFrom, typename ModelTo > void copy_block_collection_components( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, Mapping& mapping ) { @@ -323,10 +329,11 @@ namespace geode if( const auto name = block_collection.name() ) { builder_to.set_block_collection_name( - to.block_collection( id ), name.value() ); + model_to.block_collection( id ), name.value() ); } builder_to.set_block_collection_active( - to.block_collection( id ), block_collection.is_active() ); + model_to.block_collection( id ), + block_collection.is_active() ); } } @@ -355,7 +362,7 @@ namespace geode template < typename ModelFrom, typename ModelTo > void copy_corner_geometry( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, const Mapping& corners ) { @@ -363,14 +370,14 @@ namespace geode from.corners(), from.nb_corners() ) ) { builder_to.update_corner_mesh( - to.corner( corners.in2out( corner.first ) ), + model_to.corner( corners.in2out( corner.first ) ), std::move( corner.second ) ); } } template < typename ModelFrom, typename ModelTo > void copy_line_geometry( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, const Mapping& lines ) { @@ -378,14 +385,14 @@ namespace geode from.lines(), from.nb_lines() ) ) { builder_to.update_line_mesh( - to.line( lines.in2out( line.first ) ), + model_to.line( lines.in2out( line.first ) ), std::move( line.second ) ); } } template < typename ModelFrom, typename ModelTo > void copy_surface_geometry( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, const Mapping& surfaces ) { @@ -393,14 +400,14 @@ namespace geode from.surfaces(), from.nb_surfaces() ) ) { builder_to.update_surface_mesh( - to.surface( surfaces.in2out( surface.first ) ), + model_to.surface( surfaces.in2out( surface.first ) ), std::move( surface.second ) ); } } template < typename ModelFrom, typename ModelTo > void copy_block_geometry( const ModelFrom& from, - const ModelTo& to, + const ModelTo& model_to, typename ModelTo::Builder& builder_to, const Mapping& blocks ) { @@ -408,7 +415,7 @@ namespace geode from.blocks(), from.nb_blocks() ) ) { builder_to.update_block_mesh( - to.block( blocks.in2out( block.first ) ), + model_to.block( blocks.in2out( block.first ) ), std::move( block.second ) ); } }