Skip to content

Commit 9d71a4e

Browse files
committed
feat(replace_components_meshes_by_others): Added function to replace component meshes of a BRep by another BRep's.
1 parent 724c3f7 commit 9d71a4e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

include/geode/model/representation/builder/brep_builder.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ namespace geode
110110

111111
ModelCopyMapping copy( const BRep& brep );
112112

113+
void replace_components_meshes_by_others(
114+
BRep&& other, const ModelCopyMapping& mapping );
115+
113116
ModelCopyMapping copy_components( const BRep& brep );
114117

115118
void copy_components( ModelCopyMapping& mapping, const BRep& brep );

src/geode/model/representation/builder/brep_builder.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,48 @@ namespace geode
8181
return mapping;
8282
}
8383

84+
void BRepBuilder::replace_components_meshes_by_others(
85+
BRep&& other, const ModelCopyMapping& mapping )
86+
{
87+
for( const auto& in2out :
88+
mapping.at( Corner3D::component_type_static() ).in2out_map() )
89+
{
90+
this->unregister_mesh_component( brep_.corner( in2out.first ) );
91+
this->set_corner_mesh(
92+
in2out.first, other.corner( in2out.second ).mesh().clone() );
93+
this->corner_mesh_builder( in2out.first )->set_id( in2out.first );
94+
}
95+
for( const auto& in2out :
96+
mapping.at( Line3D::component_type_static() ).in2out_map() )
97+
{
98+
this->unregister_mesh_component( brep_.line( in2out.first ) );
99+
this->set_line_mesh(
100+
in2out.first, other.line( in2out.second ).mesh().clone() );
101+
this->line_mesh_builder( in2out.first )->set_id( in2out.first );
102+
}
103+
for( const auto& in2out :
104+
mapping.at( Surface3D::component_type_static() ).in2out_map() )
105+
{
106+
this->unregister_mesh_component( brep_.surface( in2out.first ) );
107+
this->set_surface_mesh(
108+
in2out.first, other.surface( in2out.second ).mesh().clone() );
109+
this->surface_mesh_builder( in2out.first )->set_id( in2out.first );
110+
}
111+
for( const auto& in2out :
112+
mapping.at( Block3D::component_type_static() ).in2out_map() )
113+
{
114+
this->unregister_mesh_component( brep_.block( in2out.first ) );
115+
this->set_block_mesh(
116+
in2out.first, other.block( in2out.second ).mesh().clone() );
117+
this->block_mesh_builder( in2out.first )->set_id( in2out.first );
118+
}
119+
this->delete_isolated_vertices();
120+
const auto first_new_unique_vertex_id =
121+
create_unique_vertices( other.nb_unique_vertices() );
122+
detail::copy_vertex_identifier_components(
123+
other, *this, first_new_unique_vertex_id, mapping );
124+
}
125+
84126
ModelCopyMapping BRepBuilder::copy_components( const BRep& brep )
85127
{
86128
ModelCopyMapping mappings;

0 commit comments

Comments
 (0)