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

#include <MRPolylineTopology.h>

Public Member Functions

template<typename T , typename F1 , typename F2 >
void buildFromContours (const std::vector< std::vector< T > > &contours, F1 &&reservePoints, F2 &&addPoint)
 
MRMESH_API void buildOpenLines (const std::vector< VertId > &comp2firstVert)
 
template<typename T , typename F >
std::vector< std::vector< T > > convertToContours (F &&getPoint, std::vector< std::vector< VertId > > *vertMap=nullptr) const
 converts this topology into contours of given type using the functor returning point by its Id
 
MRMESH_API EdgeId makeEdge ()
 creates an edge not associated with any vertex
 
MRMESH_API EdgeId makeEdge (VertId a, VertId b)
 
MRMESH_API bool isLoneEdge (EdgeId a) const
 checks whether the edge is disconnected from all other edges and disassociated from all vertices (as if after makeEdge)
 
MRMESH_API EdgeId lastNotLoneEdge () const
 returns last not lone edge id, or invalid id if no such edge exists
 
size_t edgeSize () const
 returns the number of half-edge records including lone ones
 
size_t undirectedEdgeSize () const
 returns the number of undirected edges (pairs of half-edges) including lone ones
 
MRMESH_API size_t computeNotLoneUndirectedEdges () const
 computes the number of not-lone (valid) undirected edges
 
void edgeReserve (size_t newCapacity)
 sets the capacity of half-edges vector
 
bool hasEdge (EdgeId e) const
 returns true if given edge is within valid range and not-lone
 
MRMESH_API void deleteEdge (UndirectedEdgeId ue)
 given edge becomes lone after the call, so it is un-spliced from connected edges, and if it was not connected at origin or destination, then that vertex is deleted as well
 
MRMESH_API void deleteEdges (const UndirectedEdgeBitSet &es)
 calls deleteEdge for every set bit
 
MRMESH_API size_t heapBytes () const
 returns the amount of memory this object occupies on heap
 
MRMESH_API void splice (EdgeId a, EdgeId b)
 
EdgeId next (EdgeId he) const
 next (counter clock wise) half-edge in the origin ring
 
VertId org (EdgeId he) const
 returns origin vertex of half-edge
 
VertId dest (EdgeId he) const
 returns destination vertex of half-edge
 
MRMESH_API void setOrg (EdgeId a, VertId v)
 
const Vector< EdgeId, VertId > & edgePerVertex () const
 for all valid vertices this vector contains an edge with the origin there
 
EdgeId edgeWithOrg (VertId a) const
 returns valid edge if given vertex is present in the mesh
 
bool hasVert (VertId a) const
 returns true if given vertex is present in the mesh
 
MRMESH_API int getVertDegree (VertId a) const
 returns 0 if given vertex does not exist, 1 if it has one incident edge, and 2 if it has two incident edges
 
int numValidVerts () const
 returns the number of valid vertices
 
MRMESH_API VertId lastValidVert () const
 returns last valid vertex id, or invalid id if no single valid vertex exists
 
VertId addVertId ()
 creates new vert-id not associated with any edge yet
 
MRMESH_API void vertResize (size_t newSize)
 explicitly increases the size of vertices vector
 
MRMESH_API void vertResizeWithReserve (size_t newSize)
 explicitly increases the size of vertices vector, doubling the current capacity if it was not enough
 
void vertReserve (size_t newCapacity)
 sets the capacity of vertices vector
 
size_t vertSize () const
 returns the number of vertex records including invalid ones
 
size_t vertCapacity () const
 returns the number of allocated vert records
 
const VertBitSetgetValidVerts () const
 returns cached set of all valid vertices
 
const VertBitSetgetVertIds (const VertBitSet *region) const
 if region pointer is not null then converts it in reference, otherwise returns all valid vertices in the mesh
 
MRMESH_API EdgeId findEdge (VertId o, VertId d) const
 finds and returns edge from o to d in the mesh; returns invalid edge otherwise
 
MRMESH_API VertBitSet getPathVertices (const EdgePath &path) const
 returns all vertices incident to path edges
 
MRMESH_API EdgeId splitEdge (EdgeId e)
 
MRMESH_API EdgeId makePolyline (const VertId *vs, size_t num)
 
MRMESH_API void addPart (const PolylineTopology &from, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr)
 
MRMESH_API void addPartByMask (const PolylineTopology &from, const UndirectedEdgeBitSet &mask, VertMap *outVmap=nullptr, EdgeMap *outEmap=nullptr)
 appends polyline topology (from) in addition to the current topology: creates new edges, verts;
 
MRMESH_API void pack (VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr)
 
MRMESH_API void write (std::ostream &s) const
 saves and loads in binary stream
 
MRMESH_API bool read (std::istream &s)
 
bool operator== (const PolylineTopology &b) const
 comparison via edges (all other members are considered as not important caches)
 
bool operator!= (const PolylineTopology &b) const
 
MRMESH_API bool isConsistentlyOriented () const
 returns true if for each edge e: e == e.next() || e.odd() == next( e ).sym().odd()
 
MRMESH_API void flip ()
 changes the orientation of all edges: every edge e is replaced with e.sym()
 
MRMESH_API bool checkValidity () const
 verifies that all internal data structures are valid
 
MRMESH_API void computeValidsFromEdges ()
 computes numValidVerts_ and validVerts_ from edgePerVertex_
 
MRMESH_API bool isClosed () const
 returns true if the polyline does not have any holes
 

Detailed Description

topology of one or several polylines (how line segments are connected in lines) common for 2D and 3D polylines

Member Function Documentation

◆ addPart()

MRMESH_API void MR::PolylineTopology::addPart ( const PolylineTopology & from,
VertMap * outVmap = nullptr,
WholeEdgeMap * outEmap = nullptr )

appends polyline topology (from) in addition to the current topology: creates new edges, verts;

Parameters
outVmap,outEmap(optionally) returns mappings: from.id -> this.id

◆ addPartByMask()

MRMESH_API void MR::PolylineTopology::addPartByMask ( const PolylineTopology & from,
const UndirectedEdgeBitSet & mask,
VertMap * outVmap = nullptr,
EdgeMap * outEmap = nullptr )

appends polyline topology (from) in addition to the current topology: creates new edges, verts;

◆ addVertId()

VertId MR::PolylineTopology::addVertId ( )
inlinenodiscard

creates new vert-id not associated with any edge yet

◆ buildFromContours()

template<typename T , typename F1 , typename F2 >
void MR::PolylineTopology::buildFromContours ( const std::vector< std::vector< T > > & contours,
F1 && reservePoints,
F2 && addPoint )

builds this topology from given contours

also builds the vector of referenced points using two functors: reserve and add
if all even edges are consistently oriented, then the output contours will be oriented the same

◆ buildOpenLines()

MRMESH_API void MR::PolylineTopology::buildOpenLines ( const std::vector< VertId > & comp2firstVert)

build topology of comp2firstVert.size()-1 not-closed polylines each pair (a,b) of indices in

Parameters
comp2firstVertdefines vertex range of a polyline [a,b)

◆ checkValidity()

MRMESH_API bool MR::PolylineTopology::checkValidity ( ) const

verifies that all internal data structures are valid

◆ computeNotLoneUndirectedEdges()

MRMESH_API size_t MR::PolylineTopology::computeNotLoneUndirectedEdges ( ) const
nodiscard

computes the number of not-lone (valid) undirected edges

◆ computeValidsFromEdges()

MRMESH_API void MR::PolylineTopology::computeValidsFromEdges ( )

computes numValidVerts_ and validVerts_ from edgePerVertex_

◆ convertToContours()

template<typename T , typename F >
std::vector< std::vector< T > > MR::PolylineTopology::convertToContours ( F && getPoint,
std::vector< std::vector< VertId > > * vertMap = nullptr ) const
nodiscard

converts this topology into contours of given type using the functor returning point by its Id

until contour start is reached

the contour is closed

◆ deleteEdge()

MRMESH_API void MR::PolylineTopology::deleteEdge ( UndirectedEdgeId ue)

given edge becomes lone after the call, so it is un-spliced from connected edges, and if it was not connected at origin or destination, then that vertex is deleted as well

◆ deleteEdges()

MRMESH_API void MR::PolylineTopology::deleteEdges ( const UndirectedEdgeBitSet & es)

calls deleteEdge for every set bit

◆ dest()

VertId MR::PolylineTopology::dest ( EdgeId he) const
inlinenodiscard

returns destination vertex of half-edge

◆ edgePerVertex()

const Vector< EdgeId, VertId > & MR::PolylineTopology::edgePerVertex ( ) const
inlinenodiscard

for all valid vertices this vector contains an edge with the origin there

◆ edgeReserve()

void MR::PolylineTopology::edgeReserve ( size_t newCapacity)
inline

sets the capacity of half-edges vector

◆ edgeSize()

size_t MR::PolylineTopology::edgeSize ( ) const
inlinenodiscard

returns the number of half-edge records including lone ones

◆ edgeWithOrg()

EdgeId MR::PolylineTopology::edgeWithOrg ( VertId a) const
inlinenodiscard

returns valid edge if given vertex is present in the mesh

◆ findEdge()

MRMESH_API EdgeId MR::PolylineTopology::findEdge ( VertId o,
VertId d ) const
nodiscard

finds and returns edge from o to d in the mesh; returns invalid edge otherwise

◆ flip()

MRMESH_API void MR::PolylineTopology::flip ( )

changes the orientation of all edges: every edge e is replaced with e.sym()

◆ getPathVertices()

MRMESH_API VertBitSet MR::PolylineTopology::getPathVertices ( const EdgePath & path) const
nodiscard

returns all vertices incident to path edges

◆ getValidVerts()

const VertBitSet & MR::PolylineTopology::getValidVerts ( ) const
inlinenodiscard

returns cached set of all valid vertices

◆ getVertDegree()

MRMESH_API int MR::PolylineTopology::getVertDegree ( VertId a) const
nodiscard

returns 0 if given vertex does not exist, 1 if it has one incident edge, and 2 if it has two incident edges

◆ getVertIds()

const VertBitSet & MR::PolylineTopology::getVertIds ( const VertBitSet * region) const
inlinenodiscard

if region pointer is not null then converts it in reference, otherwise returns all valid vertices in the mesh

◆ hasEdge()

bool MR::PolylineTopology::hasEdge ( EdgeId e) const
inlinenodiscard

returns true if given edge is within valid range and not-lone

◆ hasVert()

bool MR::PolylineTopology::hasVert ( VertId a) const
inlinenodiscard

returns true if given vertex is present in the mesh

◆ heapBytes()

MRMESH_API size_t MR::PolylineTopology::heapBytes ( ) const
nodiscard

returns the amount of memory this object occupies on heap

◆ isClosed()

MRMESH_API bool MR::PolylineTopology::isClosed ( ) const
nodiscard

returns true if the polyline does not have any holes

◆ isConsistentlyOriented()

MRMESH_API bool MR::PolylineTopology::isConsistentlyOriented ( ) const
nodiscard

returns true if for each edge e: e == e.next() || e.odd() == next( e ).sym().odd()

◆ isLoneEdge()

MRMESH_API bool MR::PolylineTopology::isLoneEdge ( EdgeId a) const
nodiscard

checks whether the edge is disconnected from all other edges and disassociated from all vertices (as if after makeEdge)

◆ lastNotLoneEdge()

MRMESH_API EdgeId MR::PolylineTopology::lastNotLoneEdge ( ) const
nodiscard

returns last not lone edge id, or invalid id if no such edge exists

◆ lastValidVert()

MRMESH_API VertId MR::PolylineTopology::lastValidVert ( ) const
nodiscard

returns last valid vertex id, or invalid id if no single valid vertex exists

◆ makeEdge() [1/2]

MRMESH_API EdgeId MR::PolylineTopology::makeEdge ( )
nodiscard

creates an edge not associated with any vertex

◆ makeEdge() [2/2]

MRMESH_API EdgeId MR::PolylineTopology::makeEdge ( VertId a,
VertId b )

makes an edge from vertex a to b (both must be within reserved capacity for vertices)

if either of the vertices already has 2 incident edges, then makeEdge(a,b) fails and returns invalid edge

◆ makePolyline()

MRMESH_API EdgeId MR::PolylineTopology::makePolyline ( const VertId * vs,
size_t num )

adds polyline in this topology passing progressively via vertices *[vs, vs+num); if vs[0] == vs[num-1] then a closed polyline is created; return the edge from first to second vertex

◆ next()

EdgeId MR::PolylineTopology::next ( EdgeId he) const
inlinenodiscard

next (counter clock wise) half-edge in the origin ring

◆ numValidVerts()

int MR::PolylineTopology::numValidVerts ( ) const
inlinenodiscard

returns the number of valid vertices

◆ operator!=()

bool MR::PolylineTopology::operator!= ( const PolylineTopology & b) const
inlinenodiscard

◆ operator==()

bool MR::PolylineTopology::operator== ( const PolylineTopology & b) const
inlinenodiscard

comparison via edges (all other members are considered as not important caches)

◆ org()

VertId MR::PolylineTopology::org ( EdgeId he) const
inlinenodiscard

returns origin vertex of half-edge

◆ pack()

MRMESH_API void MR::PolylineTopology::pack ( VertMap * outVmap = nullptr,
WholeEdgeMap * outEmap = nullptr )

tightly packs all arrays eliminating lone edges and invalid vertices

Parameters
outVmap,outEmapif given returns mappings: old.id -> new.id;

◆ read()

MRMESH_API bool MR::PolylineTopology::read ( std::istream & s)

◆ setOrg()

MRMESH_API void MR::PolylineTopology::setOrg ( EdgeId a,
VertId v )

sets new origin to the full origin ring including this edge

edgePerVertex_ table is updated accordingly

◆ splice()

MRMESH_API void MR::PolylineTopology::splice ( EdgeId a,
EdgeId b )

given two half edges do either of two:
1) if a and b were from distinct rings, puts them in one ring;
2) if a and b were from the same ring, puts them in separate rings;

the cut in rings in both cases is made after a and b

◆ splitEdge()

MRMESH_API EdgeId MR::PolylineTopology::splitEdge ( EdgeId e)

split given edge on two parts: dest(returned-edge) = org(e) - newly created vertex, org(returned-edge) = org(e-before-split), dest(e) = dest(e-before-split)

◆ undirectedEdgeSize()

size_t MR::PolylineTopology::undirectedEdgeSize ( ) const
inlinenodiscard

returns the number of undirected edges (pairs of half-edges) including lone ones

◆ vertCapacity()

size_t MR::PolylineTopology::vertCapacity ( ) const
inlinenodiscard

returns the number of allocated vert records

◆ vertReserve()

void MR::PolylineTopology::vertReserve ( size_t newCapacity)
inline

sets the capacity of vertices vector

◆ vertResize()

MRMESH_API void MR::PolylineTopology::vertResize ( size_t newSize)

explicitly increases the size of vertices vector

◆ vertResizeWithReserve()

MRMESH_API void MR::PolylineTopology::vertResizeWithReserve ( size_t newSize)

explicitly increases the size of vertices vector, doubling the current capacity if it was not enough

◆ vertSize()

size_t MR::PolylineTopology::vertSize ( ) const
inlinenodiscard

returns the number of vertex records including invalid ones

◆ write()

MRMESH_API void MR::PolylineTopology::write ( std::ostream & s) const

saves and loads in binary stream


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