MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / constructGraph_

Method constructGraph_

source/MRMesh/MRSegmentMesh.cpp:89–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void MeshSegmenter::constructGraph_()
90{
91 MR_TIMER;
92
93 // initially:
94 // Graph::VertId = Mesh::FaceId
95 // Graph::EdgeId = Mesh::UndirectedEdgeId
96
97 graphEdgeData_.resize( mesh_.topology.undirectedEdgeSize() );
98 Graph::EndsPerEdge ends( mesh_.topology.undirectedEdgeSize() );
99 Graph::EdgeBitSet validGraphEdges;
100 static_cast<BitSet&>( validGraphEdges ) = mesh_.topology.findNotLoneUndirectedEdges();
101 BitSetParallelFor( validGraphEdges, [&]( Graph::EdgeId ge )
102 {
103 UndirectedEdgeId ue( (int)ge );
104
105 Graph::EndVertices vv;
106 vv.v0 = Graph::VertId( (int)mesh_.topology.left( ue ) );
107 vv.v1 = Graph::VertId( (int)mesh_.topology.right( ue ) );
108 if ( !vv.v0 || !vv.v1 )
109 {
110 validGraphEdges.reset( ge );
111 return;
112 }
113
114 assert( vv.v0 != vv.v1 );
115 if ( vv.v1 < vv.v0 )
116 std::swap( vv.v0, vv.v1 );
117 ends[ge] = vv;
118
119 const auto len = mesh_.edgeLength( ue );
120 graphEdgeData_[ge] =
121 {
122 .length = len,
123 .lengthCurv = len * curvMetric_( ue )
124 };
125 } );
126
127 graphVertData_.resize( mesh_.topology.faceSize() );
128 Graph::NeighboursPerVertex neis( mesh_.topology.faceSize() );
129 Graph::VertBitSet validGraphVerts;
130 static_cast<BitSet&>( validGraphVerts ) = mesh_.topology.getValidFaces();
131 BitSetParallelFor( validGraphVerts, [&]( Graph::VertId gv )
132 {
133 FaceId f( (int)gv );
134 Graph::Neighbours n;
135 n.reserve( mesh_.topology.getFaceDegree( f ) );
136 for ( auto e : leftRing( mesh_.topology, f ) )
137 {
138 Graph::EdgeId ge( int( e.undirected() ) );
139 assert( mesh_.topology.left( e ) = f );
140 if ( mesh_.topology.right( e ) )
141 n.push_back( ge );
142 }
143 graphVertData_[gv].area = mesh_.area( f );
144 std::sort( n.begin(), n.end() );
145 neis[gv] = std::move( n );
146 } );

Callers 1

runMethod · 0.80

Calls 15

BitSetParallelForFunction · 0.85
leftRingFunction · 0.85
leftMethod · 0.80
rightMethod · 0.80
faceSizeMethod · 0.80
getFaceDegreeMethod · 0.80
undirectedMethod · 0.80
push_backMethod · 0.80
areaMethod · 0.80
swapFunction · 0.70
resizeMethod · 0.45

Tested by

no test coverage detected