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

Method buildOpenLines

source/MRMesh/MRPolylineTopology.cpp:12–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10{
11
12void PolylineTopology::buildOpenLines( const std::vector<VertId> & comp2firstVert )
13{
14 MR_TIMER;
15 if ( comp2firstVert.empty() )
16 {
17 assert( false );
18 return;
19 }
20 assert( comp2firstVert.front() == 0_v );
21 numValidVerts_ = comp2firstVert.back();
22 edges_.resizeNoInit( 2 * numValidVerts_ ); // the edges in between lines will be lone
23 edgePerVertex_.resizeNoInit( numValidVerts_ );
24 validVerts_.clear();
25 validVerts_.resize( numValidVerts_, true );
26 ParallelFor( edgePerVertex_, [&]( VertId v )
27 {
28 EdgeId e( 2 * (int)v );
29 if ( v + 1 >= numValidVerts_ )
30 return;
31 edgePerVertex_[v] = e;
32 edges_[e].next = v > 0 ? e - 1 : e;
33 edges_[e].org = v;
34 edges_[e + 1].next = e + 2;
35 edges_[e + 1].org = v + 1;
36 } );
37 for ( int j = 0; j + 1 < comp2firstVert.size(); ++j )
38 {
39 auto v0 = comp2firstVert[j];
40 auto v1 = comp2firstVert[j + 1];
41 if ( v0 == v1 )
42 continue;
43
44 EdgeId e0( 2 * (int)v0 );
45 assert( org( e0 ) == v0 );
46 edges_[e0].next = e0;
47
48 EdgeId e1( 2 * (int)(v1 - 1) );
49 assert( org( e1 - 1 ) == v1 - 1 );
50 if ( v1 < numValidVerts_ )
51 {
52 assert( org( e1 ) == v1 - 1 );
53 assert( edgePerVertex_[v1 - 1] == e1 );
54 }
55 edgePerVertex_[v1 - 1] = e1 - 1;
56 edges_[e1 - 1].next = e1 - 1;
57 edges_[e1].next = e1;
58 edges_[e1 + 1].next = e1 + 1;
59 edges_[e1].org = {};
60 edges_[e1 + 1].org = {};
61 assert( isLoneEdge( e1 ) );
62 }
63 assert( checkValidity() );
64}
65
66void PolylineTopology::vertResize( size_t newSize )
67{

Callers 2

computeFlowsPerBasinMethod · 0.80
PolylineMethod · 0.80

Calls 5

ParallelForFunction · 0.85
emptyMethod · 0.45
clearMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected