Skip to content

Commit 3be1b93

Browse files
Merge pull request #1030 from Geode-solutions/fix/cut_along_internal_lines_wrong_adjacencies
fix(SplitAlongSurfaceMeshBorders): Fixed issue with wrong adjacencies…
2 parents 71363b3 + 7f6791e commit 3be1b93

File tree

5 files changed

+21
-32
lines changed

5 files changed

+21
-32
lines changed

bindings/python/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# This file is autogenerated by pip-compile with Python 3.10
33
# by the following command:
44
#
5-
# pip-compile bindings/python/requirements.in
5+
# pip-compile --pre bindings/python/requirements.in
66
#

include/geode/mesh/core/solid_edges.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace geode
7171

7272
/*!
7373
* Get the index of edge corresponding to given vertices
74-
* @param[in] vertices Ordered vertex indices
74+
* @param[in] vertices Unordered vertex indices
7575
*/
7676
[[nodiscard]] std::optional< index_t > edge_from_vertices(
7777
const std::array< index_t, 2 >& vertices ) const;

src/geode/mesh/core/surface_mesh.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -676,14 +676,15 @@ namespace geode
676676
const auto adj_vertices = polygon_vertices( polygon_adj_id );
677677
const auto nb_edges = adj_vertices.size();
678678
std::vector< PolygonEdge > failed_edges;
679-
for( const auto e : LRange{ nb_edges } )
679+
for( const auto edge_id : LRange{ nb_edges } )
680680
{
681-
const PolygonEdge polygon_adj_edge{ polygon_adj_id, e };
682-
if( v0 == adj_vertices[e] )
681+
const PolygonEdge polygon_adj_edge{ polygon_adj_id, edge_id };
682+
if( v0 == adj_vertices[edge_id] )
683683
{
684-
const auto enext = e == nb_edges - 1
685-
? 0u
686-
: static_cast< local_index_t >( e + 1 );
684+
const auto enext =
685+
edge_id == nb_edges - 1
686+
? 0u
687+
: static_cast< local_index_t >( edge_id + 1 );
687688
if( v1 == adj_vertices[enext] )
688689
{
689690
if( polygon_adjacent( polygon_adj_edge )
@@ -694,11 +695,12 @@ namespace geode
694695
failed_edges.emplace_back( polygon_adj_edge );
695696
}
696697
}
697-
else if( v1 == adj_vertices[e] )
698+
else if( v1 == adj_vertices[edge_id] )
698699
{
699-
const auto enext = e == nb_edges - 1
700-
? 0u
701-
: static_cast< local_index_t >( e + 1 );
700+
const auto enext =
701+
edge_id == nb_edges - 1
702+
? 0u
703+
: static_cast< local_index_t >( edge_id + 1 );
702704
if( v0 == adj_vertices[enext] )
703705
{
704706
if( polygon_adjacent( polygon_adj_edge )

src/geode/model/helpers/component_mesh_edges.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ namespace geode
163163
{
164164
if( auto edge = mesh.polygon_edge_from_vertices(
165165
pair[0], pair[1] ) )
166-
167166
{
168167
edges[surface.id()].emplace_back(
169168
std::move( edge.value() ) );

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ namespace geode
207207
for( const auto& line : model_.internal_lines( surface ) )
208208
{
209209
const auto& mesh = line.mesh();
210-
for( const auto e : Range{ mesh.nb_edges() } )
210+
for( const auto edge_id : Range{ mesh.nb_edges() } )
211211
{
212212
const auto model_edges =
213-
component_mesh_edges( model_, line, e );
213+
component_mesh_edges( model_, line, edge_id );
214214
const auto& surface_edges = model_edges.surface_edges;
215215
const auto it = surface_edges.find( surface.id() );
216216
if( it == surface_edges.end() )
@@ -219,24 +219,12 @@ namespace geode
219219
}
220220
for( auto& edge : it->second )
221221
{
222-
const auto& surface_mesh = surface.mesh();
223-
const auto& edge_vertices =
224-
surface_mesh.polygon_edge_vertices( edge );
225-
edges.emplace_back(
226-
surface_mesh
227-
.polygon_edge_from_vertices(
228-
edge_vertices[0], edge_vertices[1] )
229-
.value() );
230-
if( surface_mesh
231-
.polygon_edge_from_vertices(
232-
edge_vertices[1], edge_vertices[0] )
233-
.has_value() )
222+
edges.push_back( edge );
223+
if( const auto adj_edge =
224+
surface.mesh().polygon_adjacent_edge(
225+
edge ) )
234226
{
235-
edges.emplace_back(
236-
surface_mesh
237-
.polygon_edge_from_vertices(
238-
edge_vertices[1], edge_vertices[0] )
239-
.value() );
227+
edges.push_back( adj_edge.value() );
240228
}
241229
}
242230
}

0 commit comments

Comments
 (0)