Skip to content

Commit 64e1fac

Browse files
committed
change to the way we transfer model names
1 parent 0dc6ccf commit 64e1fac

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

src/geode/model/representation/core/detail/transfer_metadata.cpp

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include <geode/model/representation/core/detail/transfer_metadata.hpp>
2525

26+
#include <geode/basic/small_set.hpp>
27+
2628
#include <geode/mesh/core/edged_curve.hpp>
2729
#include <geode/mesh/core/point_set.hpp>
2830
#include <geode/mesh/core/solid_mesh.hpp>
@@ -50,23 +52,22 @@ namespace
5052
{
5153
return;
5254
}
53-
for( const auto& out2in_mapping : component_mapping
55+
for( const auto& [out_uuid, in_uuids] : component_mapping
5456
.at( geode::Corner< Model::dim >::component_type_static() )
5557
.out2in_map() )
5658
{
5759
std::string out_name{ "" };
58-
bool first{ true };
59-
for( const auto& in_uuid : out2in_mapping.second )
60+
geode::SmallSet< std::string_view > unique_names;
61+
for( const auto& in_uuid : in_uuids )
6062
{
61-
if( !first )
62-
{
63-
absl::StrAppend( &out_name, "+" );
64-
}
65-
first = false;
66-
absl::StrAppend(
67-
&out_name, old_model.corner( in_uuid ).name() );
63+
unique_names.insert( old_model.corner( in_uuid ).name() );
64+
}
65+
for( const auto& corner_name : unique_names )
66+
{
67+
absl::StrAppend( &out_name, corner_name, "+" );
6868
}
69-
builder.set_corner_name( out2in_mapping.first, out_name );
69+
out_name.pop_back();
70+
builder.set_corner_name( out_uuid, out_name );
7071
}
7172
}
7273

@@ -80,22 +81,22 @@ namespace
8081
{
8182
return;
8283
}
83-
for( const auto& out2in_mapping : component_mapping
84+
for( const auto& [out_uuid, in_uuids] : component_mapping
8485
.at( geode::Line< Model::dim >::component_type_static() )
8586
.out2in_map() )
8687
{
8788
std::string out_name{ "" };
88-
bool first{ true };
89-
for( const auto& in_uuid : out2in_mapping.second )
89+
geode::SmallSet< std::string_view > unique_names;
90+
for( const auto& in_uuid : in_uuids )
9091
{
91-
if( !first )
92-
{
93-
absl::StrAppend( &out_name, "+" );
94-
}
95-
first = false;
96-
absl::StrAppend( &out_name, old_model.line( in_uuid ).name() );
92+
unique_names.insert( old_model.line( in_uuid ).name() );
93+
}
94+
for( const auto& line_name : unique_names )
95+
{
96+
absl::StrAppend( &out_name, line_name, "+" );
9797
}
98-
builder.set_line_name( out2in_mapping.first, out_name );
98+
out_name.pop_back();
99+
builder.set_line_name( out_uuid, out_name );
99100
}
100101
}
101102

@@ -109,23 +110,22 @@ namespace
109110
{
110111
return;
111112
}
112-
for( const auto& out2in_mapping : component_mapping
113+
for( const auto& [out_uuid, in_uuids] : component_mapping
113114
.at( geode::Surface< Model::dim >::component_type_static() )
114115
.out2in_map() )
115116
{
116117
std::string out_name{ "" };
117-
bool first{ true };
118-
for( const auto& in_uuid : out2in_mapping.second )
118+
geode::SmallSet< std::string_view > unique_names;
119+
for( const auto& in_uuid : in_uuids )
119120
{
120-
if( !first )
121-
{
122-
absl::StrAppend( &out_name, "+" );
123-
}
124-
first = false;
125-
absl::StrAppend(
126-
&out_name, old_model.surface( in_uuid ).name() );
121+
unique_names.insert( old_model.surface( in_uuid ).name() );
122+
}
123+
for( const auto& surface_name : unique_names )
124+
{
125+
absl::StrAppend( &out_name, surface_name, "+" );
127126
}
128-
builder.set_surface_name( out2in_mapping.first, out_name );
127+
out_name.pop_back();
128+
builder.set_surface_name( out_uuid, out_name );
129129
}
130130
}
131131

@@ -138,22 +138,22 @@ namespace
138138
{
139139
return;
140140
}
141-
for( const auto& out2in_mapping :
141+
for( const auto& [out_uuid, in_uuids] :
142142
component_mapping.at( geode::Block3D::component_type_static() )
143143
.out2in_map() )
144144
{
145145
std::string out_name{ "" };
146-
bool first{ true };
147-
for( const auto& in_uuid : out2in_mapping.second )
146+
geode::SmallSet< std::string_view > unique_names;
147+
for( const auto& in_uuid : in_uuids )
148148
{
149-
if( !first )
150-
{
151-
absl::StrAppend( &out_name, "+" );
152-
}
153-
first = false;
154-
absl::StrAppend( &out_name, old_model.block( in_uuid ).name() );
149+
unique_names.insert( old_model.block( in_uuid ).name() );
150+
}
151+
for( const auto& surface_name : unique_names )
152+
{
153+
absl::StrAppend( &out_name, surface_name, "+" );
155154
}
156-
builder.set_block_name( out2in_mapping.first, out_name );
155+
out_name.pop_back();
156+
builder.set_block_name( out_uuid, out_name );
157157
}
158158
}
159159
} // namespace

0 commit comments

Comments
 (0)