Skip to content

Commit 6d3bf35

Browse files
authored
Merge pull request #942 from Geode-solutions/fix/missing_cmake_include_for_merge_mappings
fix(merge_mappings): Added missing cmake include and test.
2 parents 8a5a225 + bc394c5 commit 6d3bf35

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

src/geode/model/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ add_geode_library(
4141
"helpers/surface_radial_sort.cpp"
4242
"helpers/ray_tracing.cpp"
4343
"helpers/detail/build_model_boundaries.cpp"
44+
"helpers/detail/mappings_merger.cpp"
4445
"helpers/detail/split_along_surface_mesh_borders.cpp"
4546
"helpers/detail/split_along_block_mesh_borders.cpp"
4647
"mixin/builder/blocks_builder.cpp"
@@ -163,6 +164,7 @@ add_geode_library(
163164
"representation/io/geode/geode_section_output.h"
164165
ADVANCED_HEADERS
165166
"helpers/detail/build_model_boundaries.h"
167+
"helpers/detail/mappings_merger.h"
166168
"helpers/detail/split_along_surface_mesh_borders.h"
167169
"helpers/detail/split_along_block_mesh_borders.h"
168170
"mixin/core/detail/components_storage.h"

src/geode/model/helpers/detail/mappings_merger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ namespace geode
274274
result.mesh_vertices_mapping.surfaces =
275275
merge_vertex_mappings( mappings1.mesh_vertices_mapping.surfaces,
276276
mappings2.mesh_vertices_mapping.surfaces );
277+
return result;
277278
}
278279
} // namespace detail
279280
} // namespace geode

tests/model/test-model-mapping.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <geode/basic/assert.h>
2525
#include <geode/basic/logger.h>
2626

27+
#include <geode/model/helpers/detail/mappings_merger.h>
2728
#include <geode/model/mixin/core/corner.h>
2829
#include <geode/model/mixin/core/line.h>
2930
#include <geode/model/mixin/core/surface.h>
@@ -179,6 +180,59 @@ void test_components_mapping()
179180
}
180181
}
181182

183+
void test_merge_mappings()
184+
{
185+
std::vector< geode::uuid > uuids_in( 3 );
186+
std::vector< geode::uuid > uuids_mid( 3 );
187+
std::vector< geode::uuid > uuids_out( 3 );
188+
189+
geode::ModelGenericMapping generic_mapping;
190+
geode::GenericMapping< geode::uuid > first_mapping;
191+
for( const auto i : geode::LRange{ 3 } )
192+
{
193+
for( const auto j : geode::Range{ i, 3 } )
194+
{
195+
first_mapping.map( uuids_in[i], uuids_mid[j] );
196+
}
197+
}
198+
generic_mapping.emplace(
199+
geode::Corner3D::component_type_static(), std::move( first_mapping ) );
200+
201+
geode::ModelCopyMapping copy_mapping;
202+
geode::BijectiveMapping< geode::uuid > second_mapping;
203+
for( const auto i : geode::LRange{ 3 } )
204+
{
205+
second_mapping.map( uuids_mid[i], uuids_out[i] );
206+
}
207+
copy_mapping.emplace(
208+
geode::Corner3D::component_type_static(), std::move( second_mapping ) );
209+
210+
const auto merged_mapping =
211+
geode::detail::merge_mappings( generic_mapping, copy_mapping );
212+
OPENGEODE_EXCEPTION( !merged_mapping.has_mapping_type(
213+
geode::Surface3D::component_type_static() ),
214+
"[Test] Generic mappings should not exist for Surfaces" );
215+
OPENGEODE_EXCEPTION( generic_mapping.has_mapping_type(
216+
geode::Corner3D::component_type_static() ),
217+
"[Test] Generic mappings should exist for Corners" );
218+
const auto& corner_merged_mappings =
219+
merged_mapping.at( geode::Corner3D::component_type_static() );
220+
OPENGEODE_EXCEPTION( corner_merged_mappings.size_in() == 3,
221+
"[Test] Wrong size for CopyMapping Corners in" );
222+
OPENGEODE_EXCEPTION( corner_merged_mappings.size_out() == 3,
223+
"[Test] Wrong size for CopyMapping Corners out" );
224+
for( const auto i : geode::LRange{ 3 } )
225+
{
226+
OPENGEODE_EXCEPTION( corner_merged_mappings.in2out( uuids_in[i] ).size()
227+
== static_cast< geode::index_t >( 3 - i ),
228+
"[Test] Wrong mapping for CopyMapping Corners (in2out)" );
229+
OPENGEODE_EXCEPTION(
230+
corner_merged_mappings.out2in( uuids_out[i] ).size()
231+
== static_cast< geode::index_t >( i + 1 ),
232+
"[Test] Wrong mapping for CopyMapping Corners (out2in)" );
233+
}
234+
}
235+
182236
void test()
183237
{
184238
test_copy_mapping();

0 commit comments

Comments
 (0)