#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 VertBitSet & | getValidVerts () const |
returns cached set of all valid vertices | |
const VertBitSet & | getVertIds (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 | |
topology of one or several polylines (how line segments are connected in lines) common for 2D and 3D polylines
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;
outVmap,outEmap | (optionally) returns mappings: from.id -> this.id |
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;
|
inlinenodiscard |
creates new vert-id not associated with any edge yet
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
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
comp2firstVert | defines vertex range of a polyline [a,b) |
MRMESH_API bool MR::PolylineTopology::checkValidity | ( | ) | const |
verifies that all internal data structures are valid
|
nodiscard |
computes the number of not-lone (valid) undirected edges
MRMESH_API void MR::PolylineTopology::computeValidsFromEdges | ( | ) |
computes numValidVerts_ and validVerts_ from edgePerVertex_
|
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
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
MRMESH_API void MR::PolylineTopology::deleteEdges | ( | const UndirectedEdgeBitSet & | es | ) |
calls deleteEdge for every set bit
|
inlinenodiscard |
returns destination vertex of half-edge
|
inlinenodiscard |
for all valid vertices this vector contains an edge with the origin there
|
inline |
sets the capacity of half-edges vector
|
inlinenodiscard |
returns the number of half-edge records including lone ones
|
inlinenodiscard |
returns valid edge if given vertex is present in the mesh
|
nodiscard |
finds and returns edge from o to d in the mesh; returns invalid edge otherwise
MRMESH_API void MR::PolylineTopology::flip | ( | ) |
changes the orientation of all edges: every edge e is replaced with e.sym()
|
nodiscard |
returns all vertices incident to path edges
|
inlinenodiscard |
returns cached set of all valid vertices
|
nodiscard |
returns 0 if given vertex does not exist, 1 if it has one incident edge, and 2 if it has two incident edges
|
inlinenodiscard |
if region pointer is not null then converts it in reference, otherwise returns all valid vertices in the mesh
|
inlinenodiscard |
returns true if given edge is within valid range and not-lone
|
inlinenodiscard |
returns true if given vertex is present in the mesh
|
nodiscard |
returns the amount of memory this object occupies on heap
|
nodiscard |
returns true if the polyline does not have any holes
|
nodiscard |
returns true if for each edge e: e == e.next() || e.odd() == next( e ).sym().odd()
|
nodiscard |
checks whether the edge is disconnected from all other edges and disassociated from all vertices (as if after makeEdge)
|
nodiscard |
returns last not lone edge id, or invalid id if no such edge exists
|
nodiscard |
returns last valid vertex id, or invalid id if no single valid vertex exists
|
nodiscard |
creates an edge not associated with any vertex
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
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
|
inlinenodiscard |
next (counter clock wise) half-edge in the origin ring
|
inlinenodiscard |
returns the number of valid vertices
|
inlinenodiscard |
|
inlinenodiscard |
comparison via edges (all other members are considered as not important caches)
|
inlinenodiscard |
returns origin vertex of half-edge
MRMESH_API void MR::PolylineTopology::pack | ( | VertMap * | outVmap = nullptr, |
WholeEdgeMap * | outEmap = nullptr ) |
tightly packs all arrays eliminating lone edges and invalid vertices
outVmap,outEmap | if given returns mappings: old.id -> new.id; |
MRMESH_API bool MR::PolylineTopology::read | ( | std::istream & | s | ) |
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
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
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)
|
inlinenodiscard |
returns the number of undirected edges (pairs of half-edges) including lone ones
|
inlinenodiscard |
returns the number of allocated vert records
|
inline |
sets the capacity of vertices vector
MRMESH_API void MR::PolylineTopology::vertResize | ( | size_t | newSize | ) |
explicitly increases the size of vertices vector
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
|
inlinenodiscard |
returns the number of vertex records including invalid ones
MRMESH_API void MR::PolylineTopology::write | ( | std::ostream & | s | ) | const |
saves and loads in binary stream