Skip to content

Commit 58ef891

Browse files
committed
updated_version
1 parent 118015f commit 58ef891

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

src/geode/mesh/helpers/convert_surface_mesh.cpp

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,39 @@ namespace
271271
*surface, *builder, grid, cells_to_densify );
272272
return surface;
273273
}
274+
275+
template < geode::index_t dimension >
276+
void transfer_adjacents(
277+
geode::TriangulatedSurfaceBuilder< dimension >& builder,
278+
absl::Span< const std::optional< geode::PolygonEdge > > adjacents,
279+
absl::Span< const geode::index_t > new_polygons )
280+
{
281+
if( adjacents.front() )
282+
{
283+
builder.set_polygon_adjacent(
284+
{ new_polygons.front(), 0 }, adjacents.front()->polygon_id );
285+
builder.set_polygon_adjacent(
286+
adjacents.front().value(), new_polygons.front() );
287+
}
288+
for( const auto v : LRange{ 1, nb_vertices - 1 } )
289+
{
290+
if( adjacents[v] )
291+
{
292+
builder.set_polygon_adjacent(
293+
{ new_polygons[v - 1], 1 }, adjacents[v]->polygon_id );
294+
builder.set_polygon_adjacent(
295+
adjacents[v].value(), new_polygons[v - 1] );
296+
}
297+
}
298+
if( adjacents.back() )
299+
{
300+
builder.set_polygon_adjacent(
301+
{ new_polygons.back(), 2 }, adjacents.back()->polygon_id );
302+
builder.set_polygon_adjacent(
303+
adjacents.back().value(), new_polygons.back() );
304+
}
305+
builder.compute_polygon_adjacencies( new_polygons );
306+
}
274307
} // namespace
275308

276309
namespace geode
@@ -352,8 +385,6 @@ namespace geode
352385
to_delete[p] = nb_vertices != 3;
353386
if( nb_vertices > 3 )
354387
{
355-
DEBUG( "====== " );
356-
DEBUG( p );
357388
absl::FixedArray< std::optional< PolygonEdge > > adjacents(
358389
nb_vertices, std::nullopt );
359390
for( const auto e : LRange{ nb_vertices } )
@@ -367,34 +398,8 @@ namespace geode
367398
{
368399
new_polygons.emplace_back( builder.create_polygon(
369400
{ vertices[0], vertices[v - 1], vertices[v] } ) );
370-
DEBUG( new_polygons.back() );
371-
}
372-
if( adjacents.front() )
373-
{
374-
builder.set_polygon_adjacent( { new_polygons.front(), 0 },
375-
adjacents.front()->polygon_id );
376-
builder.set_polygon_adjacent(
377-
adjacents.front().value(), new_polygons.front() );
378-
}
379-
for( const auto v : LRange{ 1, nb_vertices - 1 } )
380-
{
381-
if( adjacents[v] )
382-
{
383-
builder.set_polygon_adjacent(
384-
{ new_polygons[v - 1], 1 },
385-
adjacents[v]->polygon_id );
386-
builder.set_polygon_adjacent(
387-
adjacents[v].value(), new_polygons[v - 1] );
388-
}
389-
}
390-
if( adjacents.back() )
391-
{
392-
builder.set_polygon_adjacent( { new_polygons.back(), 2 },
393-
adjacents.back()->polygon_id );
394-
builder.set_polygon_adjacent(
395-
adjacents.back().value(), new_polygons.back() );
396401
}
397-
builder.compute_polygon_adjacencies( new_polygons );
402+
::transfer_adjacents( builder, adjacents, new_polygons );
398403
}
399404
}
400405
to_delete.resize( surface.nb_polygons(), false );

0 commit comments

Comments
 (0)