| 11 | { |
| 12 | |
| 13 | FlowAggregator::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 | |
| 52 | VertScalars FlowAggregator::computeFlow( const std::vector<FlowOrigin> & starts, const OutputFlows & out ) const |
| 53 | { |
nothing calls this directly
no test coverage detected