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

Method FlowAggregator

source/MRMesh/MRAggregateFlow.cpp:13–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11{
12
13FlowAggregator::FlowAggregator( const Mesh & mesh, const VertScalars & heights ) : mesh_( mesh ), heights_( heights )
14{
15 MR_TIMER;
16 downFlowVert_.resize( mesh.topology.vertSize() );
17 downPath_.resize( mesh.topology.vertSize() );
18 BitSetParallelFor( mesh.topology.getValidVerts(), [&]( VertId v )
19 {
20 if ( mesh.topology.isBdVertex( v ) )
21 return;
22 const EdgePoint p0( mesh.topology, v );
23 VertId nextVert;
24 EdgePoint bdPoint;
25 downPath_[v] = computeSteepestDescentPath( mesh, heights, p0, { .outVertexReached = &nextVert, .outBdReached = &bdPoint } );
26 if ( bdPoint )
27 downPath_[v].push_back( bdPoint );
28 downFlowVert_[v] = nextVert;
29 } );
30
31 rootVert_.resize( mesh.topology.vertSize() );
32 BitSetParallelFor( mesh.topology.getValidVerts(), [&]( VertId v )
33 {
34 auto root = v;
35 while ( auto n = downFlowVert_[root] )
36 root = n;
37 rootVert_[v] = root;
38 } );
39
40 using MinusHeightVert = std::pair<float, VertId>;
41 std::vector<MinusHeightVert> minusHeightVerts;
42 minusHeightVerts.reserve( mesh.topology.numValidVerts() );
43 for ( auto v : mesh.topology.getValidVerts() )
44 minusHeightVerts.push_back( { -heights[v], v } );
45 tbb::parallel_sort( minusHeightVerts.begin(), minusHeightVerts.end() );
46
47 vertsSortedDesc_.reserve( minusHeightVerts.size() );
48 for ( size_t i = 0; i < minusHeightVerts.size(); ++i )
49 vertsSortedDesc_.push_back( minusHeightVerts[i].second );
50}
51
52VertScalars FlowAggregator::computeFlow( const std::vector<FlowOrigin> & starts, const OutputFlows & out ) const
53{

Callers

nothing calls this directly

Calls 11

BitSetParallelForFunction · 0.85
isBdVertexMethod · 0.80
push_backMethod · 0.80
resizeMethod · 0.45
vertSizeMethod · 0.45
reserveMethod · 0.45
numValidVertsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected