Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions include/Src/AtlasCharts.inl
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,26 @@ const
atlasCharts[ ChartIndex(i) ].maxCorner = Point2D< GeometryReal >(0,0);
}

// The map taking a vertex index in the atlas and giving the index of the corresponding vertex within the chart
// The map taking a vertex index in the atlas and giving the index of the corresponding vertex within the chart.
// Also track which chart the vertex was assigned to, so that vertices shared between charts (pinch points)
// are correctly added to each chart independently.
std::vector< unsigned int > chartVertexID( SimpleTriangleMesh< GeometryReal , 2 >::vertices.size() , static_cast< unsigned int >(-1) );
std::vector< unsigned int > chartVertexChart( SimpleTriangleMesh< GeometryReal , 2 >::vertices.size() , static_cast< unsigned int >(-1) );

for( unsigned int t=0 ; t<SimpleTriangleMesh< GeometryReal , 2 >::triangles.size() ; t++ )
{
AtlasChart< GeometryReal > &atlasChart = atlasCharts[ triangleToChart( AtlasMeshTriangleIndex( t ) ) ];
unsigned int chartIdx = static_cast< unsigned int >( triangleToChart( AtlasMeshTriangleIndex( t ) ) );
AtlasChart< GeometryReal > &atlasChart = atlasCharts[ ChartIndex( chartIdx ) ];

SimplexIndex< 2 > tri;
for( unsigned int k=0 ; k<3 ; k++ )
{
atlasChart._chartHalfEdgeToAtlasEdge.push_back( halfEdgeToEdge( AtlasMeshHalfEdgeIndex( 3*t+k ) ) );
unsigned int v = SimpleTriangleMesh< GeometryReal , 2 >::triangles[t][k];
if( chartVertexID[v]==-1 )
if( chartVertexID[v]==static_cast< unsigned int >(-1) || chartVertexChart[v]!=chartIdx )
{
chartVertexID[v] = (unsigned int)atlasChart.vertices.size();
chartVertexChart[v] = chartIdx;
Point2D< GeometryReal > vertexPos = SimpleTriangleMesh< GeometryReal , 2 >::vertices[v];
for( unsigned int c=0 ; c<2 ; c++ )
{
Expand Down