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{
12
13
15{
19 float amount = 1;
20};
21
23{
25 Polyline3* pPolyline = nullptr;
27 UndirectedEdgeScalars* pFlowPerEdge = nullptr;
30};
31
34{
35public:
37 MRMESH_API FlowAggregator( const Mesh & mesh, const VertScalars & heights );
38
42 MRMESH_API VertScalars computeFlow( const std::vector<FlowOrigin> & starts, const OutputFlows & out = {} ) const;
44 MRMESH_API VertScalars computeFlow( const std::vector<MeshTriPoint> & starts, const OutputFlows & out = {} ) const;
46 MRMESH_API VertScalars computeFlow( size_t numStarts,
47 const std::function<MeshTriPoint(size_t)> & startById,
48 const std::function<float(size_t)> & amountById,
49 const std::function<const FaceBitSet*(size_t)> & regionById,
50 const OutputFlows & out = {} ) const;
51
52 struct Flows
53 {
54 Polyline3 polyline;
55 UndirectedEdgeScalars flowPerEdge;
56 };
57
61 MRMESH_API HashMap<VertId, Flows> computeFlowsPerBasin( const std::vector<FlowOrigin> & starts ) const;
63 MRMESH_API HashMap<VertId, Flows> computeFlowsPerBasin( const std::vector<MeshTriPoint> & starts ) const;
65 MRMESH_API HashMap<VertId, Flows> computeFlowsPerBasin( size_t numStarts,
66 const std::function<MeshTriPoint(size_t)> & startById,
67 const std::function<float(size_t)> & amountById ) const;
68
71 [[nodiscard]] MRMESH_API UndirectedEdgeBitSet computeCatchmentDelineation() const;
72
73private:
74 const Mesh & mesh_;
75 const VertScalars & heights_;
76 VertMap downFlowVert_;
77 VertMap rootVert_;
79 std::vector<VertId> vertsSortedDesc_;
80};
81
82}
this class can track multiple flows and find in each mesh vertex the amount of water reached it
Definition MRAggregateFlow.h:34
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:23
UndirectedEdgeScalars flowPerEdge
Definition MRAggregateFlow.h:55
MRMESH_API UndirectedEdgeBitSet computeCatchmentDelineation() const
float amountGreaterThan
output in outPolyline only the flows with the amount greater than
Definition MRAggregateFlow.h:29
MeshTriPoint point
point on the mesh, where this flow starts
Definition MRAggregateFlow.h:17
MRMESH_API VertScalars computeFlow(size_t numStarts, const std::function< MeshTriPoint(size_t)> &startById, const std::function< float(size_t)> &amountById, const std::function< const FaceBitSet *(size_t)> &regionById, const OutputFlows &out={}) const
general version that supplies starts in a functional way
float amount
amount of flow, e.g. can be proportional to the horizontal area associated with the start point
Definition MRAggregateFlow.h:19
MRMESH_API HashMap< VertId, Flows > computeFlowsPerBasin(const std::vector< FlowOrigin > &starts) const
UndirectedEdgeScalars * pFlowPerEdge
optional output: flow in each line of outPolyline
Definition MRAggregateFlow.h:27
MRMESH_API HashMap< VertId, Flows > computeFlowsPerBasin(size_t numStarts, const std::function< MeshTriPoint(size_t)> &startById, const std::function< float(size_t)> &amountById) const
general version that supplies starts in a functional way
MRMESH_API VertScalars computeFlow(const std::vector< MeshTriPoint > &starts, const OutputFlows &out={}) const
same with all amounts equal to 1
Polyline3 * pPolyline
optional output: lines of all flows
Definition MRAggregateFlow.h:25
Polyline3 polyline
Definition MRAggregateFlow.h:54
MRMESH_API HashMap< VertId, Flows > computeFlowsPerBasin(const std::vector< MeshTriPoint > &starts) const
same with all amounts equal to 1
MRMESH_API FlowAggregator(const Mesh &mesh, const VertScalars &heights)
prepares the processing of given mesh with given height in each vertex
MRMESH_API VertScalars computeFlow(const std::vector< FlowOrigin > &starts, const OutputFlows &out={}) const
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRAggregateFlow.h:53
Definition MRAggregateFlow.h:15
Definition MRMeshTriPoint.h:26
Definition MRMesh.h:23
Definition MRAggregateFlow.h:23