MeshLib C++ Docs
Loading...
Searching...
No Matches
MRAggregateFlow.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshTriPoint.h"
4#include "MRVector.h"
5#include "MRPolyline.h"
6#include <functional>
7
8namespace MR
9{
10
11struct FlowOrigin
12{
14 MeshTriPoint point;
16 float amount = 1;
17};
18
19struct OutputFlows
20{
22 Polyline3* pPolyline = nullptr;
24 UndirectedEdgeScalars* pFlowPerEdge = nullptr;
26 float amountGreaterThan = 0;
27};
28
30class FlowAggregator
31{
32public:
34 MRMESH_API FlowAggregator( const Mesh & mesh, const VertScalars & heights );
35
39 MRMESH_API VertScalars computeFlow( const std::vector<FlowOrigin> & starts, const OutputFlows & out = {} ) const;
40 // same with all amounts equal to 1
41 MRMESH_API VertScalars computeFlow( const std::vector<MeshTriPoint> & starts, const OutputFlows & out = {} ) const;
42 // general version that supplies starts in a functional way
43 MRMESH_API VertScalars computeFlow( size_t numStarts,
44 const std::function<MeshTriPoint(size_t)> & startById,
45 const std::function<float(size_t)> & amountById,
46 const std::function<const FaceBitSet*(size_t)> & regionById,
47 const OutputFlows & out = {} ) const;
48
54
58 MRMESH_API HashMap<VertId, Flows> computeFlowsPerBasin( const std::vector<FlowOrigin> & starts ) const;
59 // same with all amounts equal to 1
60 MRMESH_API HashMap<VertId, Flows> computeFlowsPerBasin( const std::vector<MeshTriPoint> & starts ) const;
61 // general version that supplies starts in a functional way
62 MRMESH_API HashMap<VertId, Flows> computeFlowsPerBasin( size_t numStarts,
63 const std::function<MeshTriPoint(size_t)> & startById,
64 const std::function<float(size_t)> & amountById ) const;
65
68 [[nodiscard]] MRMESH_API UndirectedEdgeBitSet computeCatchmentDelineation() const;
69
70private:
71 const Mesh & mesh_;
72 const VertScalars & heights_;
73 VertMap downFlowVert_; // for each vertex stores what next vertex is on flow path (invalid vertex for local minima)
74 VertMap rootVert_; // for each vertex stores the final vertex is on flow path (self-vertex for local minima)
75 Vector<SurfacePath, VertId> downPath_; // till next vertex
76 std::vector<VertId> vertsSortedDesc_; // all vertices sorted in descending heights order
77};
78
79} //namespace MR
#define MRMESH_API
Definition MRMeshFwd.h:80
unsafe FlowAggregator(MR._ByValue_FlowAggregator _other)
new unsafe ref float amount
new unsafe MR.MeshTriPoint point
Definition MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:23
new unsafe ref float amountGreaterThan
new unsafe MR.? Polyline3 pPolyline
new unsafe MR.? UndirectedEdgeScalars pFlowPerEdge
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:19
Definition MRCameraOrientationPlugin.h:8
Definition MRAggregateFlow.h:50
UndirectedEdgeScalars flowPerEdge
Definition MRAggregateFlow.h:52
Polyline3 polyline
Definition MRAggregateFlow.h:51