MeshLib
 
Loading...
Searching...
No Matches
MR::WatershedGraph Class Reference

graphs representing rain basins on the mesh More...

#include <MRWatershedGraph.h>

Classes

struct  BasinInfo
 associated with each vertex in graph More...
 
struct  BdInfo
 associated with each edge in graph More...
 
struct  OverflowPoint
 describes a point where a flow from one basin overflows into another basin More...
 

Public Member Functions

MRMESH_API WatershedGraph (const Mesh &mesh, const Vector< int, FaceId > &face2basin, int numBasins)
 constructs the graph from given mesh, heights in z-coordinate, and initial subdivision on basins
 
MRMESH_API float getHeightAt (VertId v) const
 returns height at given vertex or FLT_MAX if the vertex is invalid
 
const Graphgraph () const
 returns underlying graph where each basin is a vertex
 
float totalArea () const
 returns total precipitation area
 
int numBasins () const
 returns the current number of basins (excluding special "outside" basin)
 
const BasinInfobasinInfo (Graph::VertId v) const
 returns data associated with given basin
 
BasinInfobasinInfo (Graph::VertId v)
 
const BdInfobdInfo (Graph::EdgeId e) const
 returns data associated with given boundary between basins
 
BdInfobdInfo (Graph::EdgeId e)
 
Graph::VertId outsideId () const
 returns special "basin" representing outside areas of the mesh
 
MRMESH_API Graph::VertId getRootBasin (Graph::VertId v) const
 for valid basin returns self id; for invalid basin returns the id of basin it was merged in
 
MRMESH_API Graph::VertId flowsTo (Graph::VertId v) const
 returns the basin where the flow from this basin goes next (it can be self id if the basin is not full yet)
 
MRMESH_API Graph::VertId flowsFinallyTo (Graph::VertId v, bool exceptOutside=false) const
 
MRMESH_API void setParentsToRoots ()
 
MRMESH_API std::pair< Graph::EdgeId, float > findLowestBd () const
 
MRMESH_API Graph::VertId merge (Graph::VertId v0, Graph::VertId v1)
 merges basin v1 into basin v0, v1 is deleted after that, returns v0
 
MRMESH_API Graph::VertId mergeViaBd (Graph::EdgeId bd)
 merges two basins sharing given boundary, returns remaining basin
 
MRMESH_API FaceBitSet getBasinFaces (Graph::VertId basin) const
 returns the mesh faces of given basin
 
MRMESH_API Vector< FaceBitSet, Graph::VertIdgetAllBasinFaces (bool joinOverflowBasins=false) const
 
MRMESH_API FaceBitSet getBasinFacesBelowLevel (Graph::VertId basin, float waterLevel) const
 returns the mesh faces of given basin with at least one vertex below given level
 
MRMESH_API double computeBasinVolume (Graph::VertId basin, float waterLevel) const
 
MRMESH_API UndirectedEdgeBitSet getInterBasinEdges (bool joinOverflowBasins=false) const
 
MRMESH_API std::vector< OverflowPointgetOverflowPoints () const
 returns all overflow points in the graph
 
MRMESH_API Vector< Graph::VertId, Graph::VertIdiniBasin2Tgt (bool joinOverflowBasins=false) const
 

Detailed Description

graphs representing rain basins on the mesh

Constructor & Destructor Documentation

◆ WatershedGraph()

MRMESH_API MR::WatershedGraph::WatershedGraph ( const Mesh & mesh,
const Vector< int, FaceId > & face2basin,
int numBasins )

constructs the graph from given mesh, heights in z-coordinate, and initial subdivision on basins

Member Function Documentation

◆ basinInfo() [1/2]

BasinInfo & MR::WatershedGraph::basinInfo ( Graph::VertId v)
inlinenodiscard

◆ basinInfo() [2/2]

const BasinInfo & MR::WatershedGraph::basinInfo ( Graph::VertId v) const
inlinenodiscard

returns data associated with given basin

◆ bdInfo() [1/2]

BdInfo & MR::WatershedGraph::bdInfo ( Graph::EdgeId e)
inlinenodiscard

◆ bdInfo() [2/2]

const BdInfo & MR::WatershedGraph::bdInfo ( Graph::EdgeId e) const
inlinenodiscard

returns data associated with given boundary between basins

◆ computeBasinVolume()

MRMESH_API double MR::WatershedGraph::computeBasinVolume ( Graph::VertId basin,
float waterLevel ) const
nodiscard

returns water volume in basin when its surface reaches given level, which must be in between the lowest basin level and the lowest level on basin's boundary

◆ findLowestBd()

MRMESH_API std::pair< Graph::EdgeId, float > MR::WatershedGraph::findLowestBd ( ) const
nodiscard

finds the lowest boundary between basins and its height, which is defined as the minimal different between lowest boundary point and lowest point in a basin

◆ flowsFinallyTo()

MRMESH_API Graph::VertId MR::WatershedGraph::flowsFinallyTo ( Graph::VertId v,
bool exceptOutside = false ) const
nodiscard

returns the basin where the flow from this basin finally goes (it can be self id if the basin is not full yet);

Parameters
exceptOutsideif true then the method returns the basin that receives water flow from (v) just before outside

◆ flowsTo()

MRMESH_API Graph::VertId MR::WatershedGraph::flowsTo ( Graph::VertId v) const
nodiscard

returns the basin where the flow from this basin goes next (it can be self id if the basin is not full yet)

◆ getAllBasinFaces()

MRMESH_API Vector< FaceBitSet, Graph::VertId > MR::WatershedGraph::getAllBasinFaces ( bool joinOverflowBasins = false) const
nodiscard

returns the mesh faces of each valid basin;

Parameters
joinOverflowBasinsif true then overflowing basins will be merged in the target basins (except for overflow in outside)

◆ getBasinFaces()

MRMESH_API FaceBitSet MR::WatershedGraph::getBasinFaces ( Graph::VertId basin) const
nodiscard

returns the mesh faces of given basin

◆ getBasinFacesBelowLevel()

MRMESH_API FaceBitSet MR::WatershedGraph::getBasinFacesBelowLevel ( Graph::VertId basin,
float waterLevel ) const
nodiscard

returns the mesh faces of given basin with at least one vertex below given level

◆ getHeightAt()

MRMESH_API float MR::WatershedGraph::getHeightAt ( VertId v) const
nodiscard

returns height at given vertex or FLT_MAX if the vertex is invalid

◆ getInterBasinEdges()

MRMESH_API UndirectedEdgeBitSet MR::WatershedGraph::getInterBasinEdges ( bool joinOverflowBasins = false) const
nodiscard

returns the mesh edges between current basins

Parameters
joinOverflowBasinsif true then overflowing basins will be merged in the target basins (except for overflow in outside)

◆ getOverflowPoints()

MRMESH_API std::vector< OverflowPoint > MR::WatershedGraph::getOverflowPoints ( ) const
nodiscard

returns all overflow points in the graph

◆ getRootBasin()

MRMESH_API Graph::VertId MR::WatershedGraph::getRootBasin ( Graph::VertId v) const
nodiscard

for valid basin returns self id; for invalid basin returns the id of basin it was merged in

◆ graph()

const Graph & MR::WatershedGraph::graph ( ) const
inlinenodiscard

returns underlying graph where each basin is a vertex

◆ iniBasin2Tgt()

MRMESH_API Vector< Graph::VertId, Graph::VertId > MR::WatershedGraph::iniBasin2Tgt ( bool joinOverflowBasins = false) const
nodiscard

computes a map from initial basin id to a valid basin in which it was merged

Parameters
joinOverflowBasinsif true then overflowing basins will be merged in the target basins (except for overflow in outside)

◆ merge()

MRMESH_API Graph::VertId MR::WatershedGraph::merge ( Graph::VertId v0,
Graph::VertId v1 )

merges basin v1 into basin v0, v1 is deleted after that, returns v0

◆ mergeViaBd()

MRMESH_API Graph::VertId MR::WatershedGraph::mergeViaBd ( Graph::EdgeId bd)

merges two basins sharing given boundary, returns remaining basin

◆ numBasins()

int MR::WatershedGraph::numBasins ( ) const
inlinenodiscard

returns the current number of basins (excluding special "outside" basin)

◆ outsideId()

Graph::VertId MR::WatershedGraph::outsideId ( ) const
inlinenodiscard

returns special "basin" representing outside areas of the mesh

◆ setParentsToRoots()

MRMESH_API void MR::WatershedGraph::setParentsToRoots ( )

replaces parent of each basin with its computed root; this speeds up following calls to getRootBasin()

◆ totalArea()

float MR::WatershedGraph::totalArea ( ) const
inlinenodiscard

returns total precipitation area


The documentation for this class was generated from the following file: