MeshLib Documentation
Loading...
Searching...
No Matches
MR::Polyline< V > Struct Template Reference

#include <MRPolyline.h>

Public Member Functions

 Polyline ()=default
 
MRMESH_API Polyline (const Contours2f &contours)
 creates polyline from 2D contours, 3D polyline will get zero z-component
 
MRMESH_API Polyline (const Contours3f &contours)
 creates polyline from 3D contours, 2D polyline will lose z-component
 
MRMESH_API Polyline (const std::vector< VertId > &comp2firstVert, Vector< V, VertId > ps)
 
MRMESH_API EdgeId addFromPoints (const V *vs, size_t num, bool closed)
 
MRMESH_API EdgeId addFromPoints (const V *vs, size_t num)
 
MRMESH_API void addPart (const Polyline< V > &from, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr)
 
MRMESH_API 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
 
MRMESH_API 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
 
MRMESH_API 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)
 
MRMESH_API Vector3f loopDirArea (EdgeId e) const
 
MRMESH_API float totalLength () const
 returns total length of the polyline
 
MRMESH_API 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
 
MRMESH_API Box< V > getBoundingBox () const
 returns the minimal bounding box containing all valid vertices (implemented via getAABBTree())
 
MRMESH_API Box< V > computeBoundingBox (const AffineXf< V > *toWorld=nullptr) const
 
MRMESH_APIfindCenterFromPoints () const
 
MRMESH_API void transform (const AffineXf< V > &xf)
 applies given transformation to all valid polyline vertices
 
MRMESH_API EdgeId splitEdge (EdgeId e, const V &newVertPos)
 
EdgeId splitEdge (EdgeId e)
 
void invalidateCaches ()
 Invalidates caches (e.g. aabb-tree) after a change in polyline.
 
MRMESH_API Contours< V > contours (std::vector< std::vector< VertId > > *vertMap=nullptr) const
 
MRMESH_API Contours2f contours2 (std::vector< std::vector< VertId > > *vertMap=nullptr) const
 
template<typename U >
Polyline< U > toPolyline () const
 convert Polyline3 to Polyline2 or vice versa
 
MRMESH_API EdgeId addFromEdgePath (const Mesh &mesh, const EdgePath &path)
 
EdgeId addFromSurfacePath (const Mesh &mesh, const SurfacePath &path)
 
MRMESH_API EdgeId addFromGeneralSurfacePath (const Mesh &mesh, const MeshTriPoint &start, const SurfacePath &path, const MeshTriPoint &end)
 
MRMESH_API 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 >
MRMESH_API MR::Polyline< V >::Polyline ( const Contours2f & contours)

creates polyline from 2D contours, 3D polyline will get zero z-component

◆ Polyline() [3/4]

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

creates polyline from 3D contours, 2D polyline will lose z-component

◆ Polyline() [4/4]

template<typename V >
MRMESH_API 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 >
MRMESH_API 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 >
MRMESH_API 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 >
MRMESH_API EdgeId MR::Polyline< V >::addFromPoints ( const V * vs,
size_t num )

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

if 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 >
MRMESH_API 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 >
MRMESH_API 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 >
MRMESH_API 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

◆ computeBoundingBox()

template<typename V >
MRMESH_API 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 >
MRMESH_API 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

◆ contours2()

template<typename V >
MRMESH_API Contours2f MR::Polyline< V >::contours2 ( std::vector< std::vector< VertId > > * vertMap = nullptr) const
nodiscard

convert Polyline to simple 2D 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 >
MRMESH_API V MR::Polyline< V >::findCenterFromPoints ( ) const
nodiscard

◆ getAABBTree()

template<typename V >
MRMESH_API 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 >
MRMESH_API Box< V > MR::Polyline< V >::getBoundingBox ( ) const
nodiscard

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

◆ heapBytes()

template<typename V >
MRMESH_API 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 >
MRMESH_API 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 >
MRMESH_API 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

◆ splitEdge() [2/2]

template<typename V >
MRMESH_API 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 >
MRMESH_API 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 >
MRMESH_API float MR::Polyline< V >::totalLength ( ) const
nodiscard

returns total length of the polyline

◆ transform()

template<typename V >
MRMESH_API 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: