MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::Polyline< V > Struct Template Reference

#include <MRMesh/MRPolyline.h>

Public Member Functions

 Polyline ()=default
 Polyline (const Contour< V > &contour)
 creates polyline from one contour (open or closed)
 Polyline (const Contours< V > &contours)
 creates polyline from several contours (each can be open or closed)
 Polyline (const std::vector< VertId > &comp2firstVert, Vector< V, VertId > ps)
EdgeId addFromPoints (const V *vs, size_t num, bool closed)
EdgeId addFromPoints (const V *vs, size_t num)
void addPart (const Polyline< V > &from, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr)
void addPartByMask (const Polyline< V > &from, const UndirectedEdgeBitSet &mask, VertMap *outVmap=nullptr, EdgeMap *outEmap=nullptr)
 appends polyline (from) in addition to this polyline: creates new edges, verts and points
void pack (VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr)
orgPnt (EdgeId e) const
 returns coordinates of the edge origin
destPnt (EdgeId e) const
 returns coordinates of the edge destination
edgePoint (EdgeId e, float f) const
 returns a point on the edge: origin point for f=0 and destination point for f=1
edgePoint (const EdgePoint &ep) const
 computes coordinates of point given as edge and relative position on it
edgeCenter (EdgeId e) const
 returns edge's centroid
edgeVector (EdgeId e) const
 returns vector equal to edge destination point minus edge origin point
LineSegm< V > edgeSegment (EdgeId e) const
 returns line segment of given edge
EdgePoint toEdgePoint (VertId v) const
 converts vertex into edge-point representation
EdgePoint toEdgePoint (EdgeId e, const V &p) const
 converts edge and point's coordinates into edge-point representation
float edgeLength (EdgeId e) const
 returns Euclidean length of the edge
float edgeLengthSq (EdgeId e) const
 returns squared Euclidean length of the edge (faster to compute than length)
Vector3f loopDirArea (EdgeId e) const
float totalLength () const
 returns total length of the polyline
float averageEdgeLength () const
 returns average edge length in the polyline
const AABBTreePolyline< V > & getAABBTree () const
 returns cached aabb-tree for this polyline, creating it if it did not exist in a thread-safe manner
const AABBTreePolyline< V > * getAABBTreeNotCreate () const
 returns cached aabb-tree for this polyline, but does not create it if it did not exist
Box< V > getBoundingBox () const
 returns the minimal bounding box containing all valid vertices (implemented via getAABBTree())
Box< V > computeBoundingBox (const AffineXf< V > *toWorld=nullptr) const
findCenterFromPoints () const
 computes average position of all valid polyline vertices
void transform (const AffineXf< V > &xf)
 applies given transformation to all valid polyline vertices
EdgeId splitEdge (EdgeId e, const V &newVertPos)
EdgeId splitEdge (EdgeId e)
 same, but split given edge on two equal parts
void invalidateCaches ()
 Invalidates caches (e.g. aabb-tree) after a change in polyline.
Contours< V > contours (std::vector< std::vector< VertId > > *vertMap=nullptr) const
template<typename U>
Polyline< U > toPolyline () const
 convert Polyline3 to Polyline2 or vice versa
EdgeId addFromEdgePath (const Mesh &mesh, const EdgePath &path)
EdgeId addFromSurfacePath (const Mesh &mesh, const SurfacePath &path)
EdgeId addFromGeneralSurfacePath (const Mesh &mesh, const MeshTriPoint &start, const SurfacePath &path, const MeshTriPoint &end)
size_t heapBytes () const
 returns the amount of memory this object occupies on heap
template<class Q = V>
std::enable_if_t< std::is_same_v< Q, Vector3f > > mirror (const Plane3f &plane)
 reflects the polyline from a given plane. Enabled only for Polyline3f

Public Attributes

PolylineTopology topology
Vector< V, VertId > points

Detailed Description

template<typename V>
struct MR::Polyline< V >

polyline that stores points of type V

Constructor & Destructor Documentation

◆ Polyline() [1/4]

template<typename V>
MR::Polyline< V >::Polyline ( )
default

◆ Polyline() [2/4]

template<typename V>
MR::Polyline< V >::Polyline ( const Contour< V > & contour)

creates polyline from one contour (open or closed)

◆ Polyline() [3/4]

template<typename V>
MR::Polyline< V >::Polyline ( const Contours< V > & contours)

creates polyline from several contours (each can be open or closed)

◆ Polyline() [4/4]

template<typename V>
MR::Polyline< V >::Polyline ( const std::vector< VertId > & comp2firstVert,
Vector< V, VertId > ps )

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

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

Member Function Documentation

◆ addFromEdgePath()

template<typename V>
EdgeId MR::Polyline< V >::addFromEdgePath ( const Mesh & mesh,
const EdgePath & path )

adds path to this polyline

Returns
the edge from first new to second new vertex

◆ addFromGeneralSurfacePath()

template<typename V>
EdgeId MR::Polyline< V >::addFromGeneralSurfacePath ( const Mesh & mesh,
const MeshTriPoint & start,
const SurfacePath & path,
const MeshTriPoint & end )

adds general path = start-path-end (where both start and end are optional) to this polyline

Returns
the edge from first new to second new vertex

◆ addFromPoints() [1/2]

template<typename V>
EdgeId MR::Polyline< V >::addFromPoints ( const V * vs,
size_t num )

adds connected line in this, passing progressively via points *[vs, vs+num)

if num > 2 && vs[0] == vs[num-1] then a closed line is created

Returns
the edge from first new to second new vertex

◆ addFromPoints() [2/2]

template<typename V>
EdgeId MR::Polyline< V >::addFromPoints ( const V * vs,
size_t num,
bool closed )

adds connected line in this, passing progressively via points *[vs, vs+num)

if closed argument is true then the last and the first points will be additionally connected

Returns
the edge from first new to second new vertex

◆ addFromSurfacePath()

template<typename V>
EdgeId MR::Polyline< V >::addFromSurfacePath ( const Mesh & mesh,
const SurfacePath & path )
inline

adds path to this polyline

Returns
the edge from first new to second new vertex

◆ addPart()

template<typename V>
void MR::Polyline< V >::addPart ( const Polyline< V > & from,
VertMap * outVmap = nullptr,
WholeEdgeMap * outEmap = nullptr )

appends polyline (from) in addition to this polyline: creates new edges, verts and points;

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

◆ addPartByMask()

template<typename V>
void MR::Polyline< V >::addPartByMask ( const Polyline< V > & from,
const UndirectedEdgeBitSet & mask,
VertMap * outVmap = nullptr,
EdgeMap * outEmap = nullptr )

appends polyline (from) in addition to this polyline: creates new edges, verts and points

◆ averageEdgeLength()

template<typename V>
float MR::Polyline< V >::averageEdgeLength ( ) const
inlinenodiscard

returns average edge length in the polyline

◆ computeBoundingBox()

template<typename V>
Box< V > MR::Polyline< V >::computeBoundingBox ( const AffineXf< V > * toWorld = nullptr) const
nodiscard

passes through all valid points and finds the minimal bounding box containing all of them

if toWorld transformation is given then returns minimal bounding box in world space

◆ contours()

template<typename V>
Contours< V > MR::Polyline< V >::contours ( std::vector< std::vector< VertId > > * vertMap = nullptr) const
nodiscard

convert Polyline to simple contour structures with vector of points inside

if all even edges are consistently oriented, then the output contours will be oriented the same

Parameters
vertMapoptional output map for for each contour point to corresponding VertId

◆ destPnt()

template<typename V>
V MR::Polyline< V >::destPnt ( EdgeId e) const
inlinenodiscard

returns coordinates of the edge destination

◆ edgeCenter()

template<typename V>
V MR::Polyline< V >::edgeCenter ( EdgeId e) const
inlinenodiscard

returns edge's centroid

◆ edgeLength()

template<typename V>
float MR::Polyline< V >::edgeLength ( EdgeId e) const
inlinenodiscard

returns Euclidean length of the edge

◆ edgeLengthSq()

template<typename V>
float MR::Polyline< V >::edgeLengthSq ( EdgeId e) const
inlinenodiscard

returns squared Euclidean length of the edge (faster to compute than length)

◆ edgePoint() [1/2]

template<typename V>
V MR::Polyline< V >::edgePoint ( const EdgePoint & ep) const
inlinenodiscard

computes coordinates of point given as edge and relative position on it

◆ edgePoint() [2/2]

template<typename V>
V MR::Polyline< V >::edgePoint ( EdgeId e,
float f ) const
inlinenodiscard

returns a point on the edge: origin point for f=0 and destination point for f=1

◆ edgeSegment()

template<typename V>
LineSegm< V > MR::Polyline< V >::edgeSegment ( EdgeId e) const
inlinenodiscard

returns line segment of given edge

◆ edgeVector()

template<typename V>
V MR::Polyline< V >::edgeVector ( EdgeId e) const
inlinenodiscard

returns vector equal to edge destination point minus edge origin point

◆ findCenterFromPoints()

template<typename V>
V MR::Polyline< V >::findCenterFromPoints ( ) const
nodiscard

computes average position of all valid polyline vertices

◆ getAABBTree()

template<typename V>
const AABBTreePolyline< V > & MR::Polyline< V >::getAABBTree ( ) const

returns cached aabb-tree for this polyline, creating it if it did not exist in a thread-safe manner

◆ getAABBTreeNotCreate()

template<typename V>
const AABBTreePolyline< V > * MR::Polyline< V >::getAABBTreeNotCreate ( ) const
inlinenodiscard

returns cached aabb-tree for this polyline, but does not create it if it did not exist

◆ getBoundingBox()

template<typename V>
Box< V > MR::Polyline< V >::getBoundingBox ( ) const
nodiscard

returns the minimal bounding box containing all valid vertices (implemented via getAABBTree())

◆ heapBytes()

template<typename V>
size_t MR::Polyline< V >::heapBytes ( ) const
nodiscard

returns the amount of memory this object occupies on heap

◆ invalidateCaches()

template<typename V>
void MR::Polyline< V >::invalidateCaches ( )
inline

Invalidates caches (e.g. aabb-tree) after a change in polyline.

◆ loopDirArea()

template<typename V>
Vector3f MR::Polyline< V >::loopDirArea ( EdgeId e) const
nodiscard

calculates directed loop area if iterating in e direction .z = FLT_MAX if e does not represent a loop

◆ mirror()

template<typename V>
template<class Q = V>
std::enable_if_t< std::is_same_v< Q, Vector3f > > MR::Polyline< V >::mirror ( const Plane3f & plane)
inlinenodiscard

reflects the polyline from a given plane. Enabled only for Polyline3f

◆ orgPnt()

template<typename V>
V MR::Polyline< V >::orgPnt ( EdgeId e) const
inlinenodiscard

returns coordinates of the edge origin

◆ pack()

template<typename V>
void MR::Polyline< V >::pack ( VertMap * outVmap = nullptr,
WholeEdgeMap * outEmap = nullptr )

tightly packs all arrays eliminating lone edges and invalid verts and points, optionally returns mappings: old.id -> new.id

◆ splitEdge() [1/2]

template<typename V>
EdgeId MR::Polyline< V >::splitEdge ( EdgeId e)
inline

same, but split given edge on two equal parts

◆ splitEdge() [2/2]

template<typename V>
EdgeId MR::Polyline< V >::splitEdge ( EdgeId e,
const V & newVertPos )

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)

◆ toEdgePoint() [1/2]

template<typename V>
EdgePoint MR::Polyline< V >::toEdgePoint ( EdgeId e,
const V & p ) const
nodiscard

converts edge and point's coordinates into edge-point representation

◆ toEdgePoint() [2/2]

template<typename V>
EdgePoint MR::Polyline< V >::toEdgePoint ( VertId v) const
inlinenodiscard

converts vertex into edge-point representation

◆ toPolyline()

template<typename V>
template<typename U>
Polyline< U > MR::Polyline< V >::toPolyline ( ) const
nodiscard

convert Polyline3 to Polyline2 or vice versa

◆ totalLength()

template<typename V>
float MR::Polyline< V >::totalLength ( ) const
nodiscard

returns total length of the polyline

◆ transform()

template<typename V>
void MR::Polyline< V >::transform ( const AffineXf< V > & xf)

applies given transformation to all valid polyline vertices

Member Data Documentation

◆ points

template<typename V>
Vector<V, VertId> MR::Polyline< V >::points

◆ topology

template<typename V>
PolylineTopology MR::Polyline< V >::topology

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