#include <MRMeshTopology.h>
Public Member Functions | |
MRMESH_API EdgeId | makeEdge () |
creates an edge not associated with any vertex or face | |
MRMESH_API bool | isLoneEdge (EdgeId a) const |
checks whether the edge is disconnected from all other edges and disassociated from all vertices and faces (as if after makeEdge) | |
MRMESH_API EdgeId | lastNotLoneEdge () const |
returns last not lone edge id, or invalid id if no such edge exists | |
MRMESH_API void | excludeLoneEdges (UndirectedEdgeBitSet &edges) const |
remove all lone edges from given set | |
size_t | edgeSize () const |
returns the number of half-edge records including lone ones | |
size_t | edgeCapacity () const |
returns the number of allocated edge records | |
size_t | undirectedEdgeSize () const |
returns the number of undirected edges (pairs of half-edges) including lone ones | |
size_t | undirectedEdgeCapacity () const |
returns the number of allocated undirected edges (pairs of half-edges) | |
MRMESH_API size_t | computeNotLoneUndirectedEdges () const |
computes the number of not-lone (valid) undirected edges | |
MRMESH_API UndirectedEdgeBitSet | findNotLoneUndirectedEdges () const |
finds and returns all 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 size_t | heapBytes () const |
returns the amount of memory this object occupies on heap | |
MRMESH_API void | shrinkToFit () |
requests the removal of unused capacity | |
MRMESH_API void | splice (EdgeId a, EdgeId b) |
MRMESH_API EdgeId | collapseEdge (EdgeId e, const std::function< void(EdgeId del, EdgeId rem)> &onEdgeDel) |
EdgeId | next (EdgeId he) const |
next (counter clock wise) half-edge in the origin ring | |
EdgeId | prev (EdgeId he) const |
previous (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 | |
FaceId | left (EdgeId he) const |
returns left face of half-edge | |
FaceId | right (EdgeId he) const |
returns right face of half-edge | |
MRMESH_API void | setOrg (EdgeId a, VertId v) |
MRMESH_API void | setLeft (EdgeId a, FaceId f) |
MRMESH_API bool | fromSameOriginRing (EdgeId a, EdgeId b) const |
returns true if a and b are both from the same origin ring | |
MRMESH_API bool | fromSameLeftRing (EdgeId a, EdgeId b) const |
returns true if a and b are both from the same left face ring | |
MRMESH_API int | getOrgDegree (EdgeId a) const |
returns the number of edges around the origin vertex, returns 1 for lone edges | |
int | getVertDegree (VertId v) const |
returns the number of edges around the given vertex | |
MRMESH_API int | getLeftDegree (EdgeId a) const |
returns the number of edges around the left face: 3 for triangular faces, ... | |
int | getFaceDegree (FaceId f) const |
returns the number of edges around the given face: 3 for triangular faces, ... | |
MRMESH_API bool | isLeftTri (EdgeId a) const |
returns true if the cell to the left of a is triangular | |
void | getTriVerts (FaceId f, VertId &v0, VertId &v1, VertId &v2) const |
void | getTriVerts (FaceId f, VertId(&v)[3]) const |
void | getTriVerts (FaceId f, ThreeVertIds &v) const |
ThreeVertIds | getTriVerts (FaceId f) const |
MRMESH_API std::vector< ThreeVertIds > | getAllTriVerts () const |
returns three vertex ids for valid triangles, invalid triangles are skipped | |
MRMESH_API Triangulation | getTriangulation () const |
MRMESH_API void | getLeftTriVerts (EdgeId a, VertId &v0, VertId &v1, VertId &v2) const |
void | getLeftTriVerts (EdgeId a, VertId(&v)[3]) const |
void | getLeftTriVerts (EdgeId a, ThreeVertIds &v) const |
ThreeVertIds | getLeftTriVerts (EdgeId a) const |
template<typename T > | |
void | forEachVertex (const MeshTriPoint &p, T &&callback) const |
MRMESH_API void | getTriEdges (FaceId f, EdgeId &e0, EdgeId &e1, EdgeId &e2) const |
void | getTriEdges (FaceId f, EdgeId(&e)[3]) const |
MRMESH_API bool | isLeftQuad (EdgeId a) const |
returns true if the cell to the left of a is quadrangular | |
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 | |
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 | |
void | flip (VertBitSet &vs) const |
sets in (vs) all valid vertices that were not selected before the call, and resets other bits | |
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 | |
const Vector< EdgeId, FaceId > & | edgePerFace () const |
for all valid faces this vector contains an edge with that face at left | |
EdgeId | edgeWithLeft (FaceId a) const |
returns valid edge if given vertex is present in the mesh | |
bool | hasFace (FaceId a) const |
returns true if given face is present in the mesh | |
MRMESH_API EdgeId | sharedEdge (FaceId l, FaceId r) const |
if two valid faces share the same edge then it is found and returned | |
MRMESH_API EdgeId | sharedVertInOrg (EdgeId a, EdgeId b) const |
if two valid edges share the same vertex then it is found and returned as Edge with this vertex in origin | |
MRMESH_API EdgeId | sharedVertInOrg (FaceId l, FaceId r) const |
if two valid faces share the same vertex then it is found and returned as Edge with this vertex in origin | |
MRMESH_API FaceId | sharedFace (EdgeId a, EdgeId b) const |
if two valid edges belong to same valid face then it is found and returned | |
int | numValidFaces () const |
returns the number of valid faces | |
MRMESH_API FaceId | lastValidFace () const |
returns last valid face id, or invalid id if no single valid face exists | |
FaceId | addFaceId () |
creates new face-id not associated with any edge yet | |
MRMESH_API void | deleteFace (FaceId f, const UndirectedEdgeBitSet *keepEdges=nullptr) |
deletes the face, also deletes its edges and vertices if they were not shared by other faces ant not in | |
MRMESH_API void | deleteFaces (const FaceBitSet &fs, const UndirectedEdgeBitSet *keepEdges=nullptr) |
deletes multiple given faces by calling deleteFace for each | |
MRMESH_API void | faceResize (size_t newSize) |
explicitly increases the size of faces vector | |
MRMESH_API void | faceResizeWithReserve (size_t newSize) |
explicitly increases the size of faces vector, doubling the current capacity if it was not enough | |
void | faceReserve (size_t newCapacity) |
sets the capacity of faces vector | |
size_t | faceSize () const |
returns the number of face records including invalid ones | |
size_t | faceCapacity () const |
returns the number of allocated face records | |
const FaceBitSet & | getValidFaces () const |
returns cached set of all valid faces | |
void | flip (FaceBitSet &fs) const |
sets in (fs) all valid faces that were not selected before the call, and resets other bits | |
const FaceBitSet & | getFaceIds (const FaceBitSet *region) const |
if region pointer is not null then converts it in reference, otherwise returns all valid faces in the mesh | |
MRMESH_API EdgeId | bdEdgeSameLeft (EdgeId e, const FaceBitSet *region=nullptr) const |
bool | isBdVertexInLeft (EdgeId e, const FaceBitSet *region=nullptr) const |
returns true if edge's left is on (region) boundary | |
EdgeId | bdEdgeWithLeft (FaceId f, const FaceBitSet *region=nullptr) const |
bool | isBdFace (FaceId f, const FaceBitSet *region=nullptr) const |
returns true if given face is on (region) boundary | |
bool | isLeftInRegion (EdgeId e, const FaceBitSet *region=nullptr) const |
return true if left face of given edge belongs to region (or just have valid id if region is nullptr) | |
bool | isInnerEdge (EdgeId e, const FaceBitSet *region=nullptr) const |
return true if given edge is inner for given region (or for whole mesh if region is nullptr) | |
bool | isBdEdge (EdgeId e, const FaceBitSet *region=nullptr) const |
return true if given edge is boundary for given region (or for whole mesh if region is nullptr) | |
MRMESH_API EdgeId | bdEdgeSameOrigin (EdgeId e, const FaceBitSet *region=nullptr) const |
bool | isBdVertexInOrg (EdgeId e, const FaceBitSet *region=nullptr) const |
returns true if edge's origin is on (region) boundary | |
EdgeId | bdEdgeWithOrigin (VertId v, const FaceBitSet *region=nullptr) const |
bool | isBdVertex (VertId v, const FaceBitSet *region=nullptr) const |
returns true if given vertex is on (region) boundary | |
MRMESH_API bool | isInnerOrBdVertex (VertId v, const FaceBitSet *region=nullptr) const |
returns true if one of incident faces of given vertex pertain to given region (or any such face exists if region is nullptr) | |
bool | isLeftBdEdge (EdgeId e, const FaceBitSet *region=nullptr) const |
returns true if left face of given edge belongs to given region (if provided) and right face either does not exist or does not belong | |
bool | isInnerOrBdEdge (EdgeId e, const FaceBitSet *region=nullptr) const |
return true if given edge is inner or boundary for given region (or for whole mesh if region is nullptr), returns false for lone edges | |
MRMESH_API EdgeId | nextLeftBd (EdgeId e, const FaceBitSet *region=nullptr) const |
given a (region) boundary edge with no right face in given region, returns next boundary edge for the same region: dest(e)==org(res) | |
MRMESH_API EdgeId | prevLeftBd (EdgeId e, const FaceBitSet *region=nullptr) const |
given a (region) boundary edge with no right face in given region, returns previous boundary edge for the same region; dest(res)==org(e) | |
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 bool | isClosed (const FaceBitSet *region=nullptr) const |
returns true if the mesh (region) does not have any neighboring holes | |
MRMESH_API std::vector< EdgeId > | findHoleRepresentiveEdges () const |
returns one edge with no valid left face for every boundary in the mesh | |
MRMESH_API int | findNumHoles (EdgeBitSet *holeRepresentativeEdges=nullptr) const |
MRMESH_API EdgeLoop | getLeftRing (EdgeId e) const |
returns full edge-loop of left face from (e) starting from (e) itself | |
MRMESH_API std::vector< EdgeLoop > | getLeftRings (const std::vector< EdgeId > &es) const |
MRMESH_API EdgeBitSet | findBoundaryEdges () const |
returns all boundary edges, where each edge does not have valid left face | |
MRMESH_API FaceBitSet | findBoundaryFaces (const FaceBitSet *region=nullptr) const |
MRMESH_API VertBitSet | findBoundaryVerts (const VertBitSet *region=nullptr) const |
MRMESH_API VertBitSet | getPathVertices (const EdgePath &path) const |
returns all vertices incident to path edges | |
MRMESH_API FaceBitSet | getPathLeftFaces (const EdgePath &path) const |
returns all valid left faces of path edges | |
MRMESH_API FaceBitSet | getPathRightFaces (const EdgePath &path) const |
returns all valid right faces of path edges | |
MRMESH_API void | flipEdge (EdgeId e) |
template<typename T > | |
void | flipEdgesIn (EdgeId e0, T &&flipNeeded) |
template<typename T > | |
void | flipEdgesIn (VertId v, T &&flipNeeded) |
template<typename T > | |
void | flipEdgesOut (EdgeId e0, T &&flipNeeded) |
template<typename T > | |
void | flipEdgesOut (VertId v, T &&flipNeeded) |
MRMESH_API EdgeId | splitEdge (EdgeId e, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr) |
MRMESH_API VertId | splitFace (FaceId f, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr) |
MRMESH_API void | flipOrientation (const UndirectedEdgeBitSet *fullComponents=nullptr) |
MRMESH_API void | addPart (const MeshTopology &from, FaceMap *outFmap=nullptr, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false) |
MRMESH_API void | addPartByMask (const MeshTopology &from, const FaceBitSet &fromFaces, const PartMapping &map) |
the same but copies only portion of (from) specified by fromFaces, | |
MRMESH_API void | addPartByMask (const MeshTopology &from, const FaceBitSet &fromFaces, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, const PartMapping &map={}) |
MRMESH_API void | addPartByFaceMap (const MeshTopology &from, const FaceMap &fromFaces, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, const PartMapping &map={}) |
fromFaces contains mapping from this-topology (considering it is empty) to from-topology | |
template<typename I > | |
MRMESH_API void | addPartBy (const MeshTopology &from, I fbegin, I fend, size_t fcount, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, const PartMapping &map={}) |
both addPartByMask and addPartByFaceMap call this general implementation | |
MRMESH_API void | rotateTriangles () |
for each triangle selects edgeWithLeft with minimal origin vertex | |
MRMESH_API void | pack (FaceMap *outFmap=nullptr, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false) |
MRMESH_API void | pack (const PackMapping &map) |
MRMESH_API void | packMinMem (const PackMapping &map) |
MRMESH_API void | write (std::ostream &s) const |
saves in binary stream | |
MRMESH_API Expected< void > | read (std::istream &s, ProgressCallback callback={}) |
MRMESH_API bool | operator== (const MeshTopology &b) const |
compare that two topologies are exactly the same | |
MRMESH_API void | resizeBeforeParallelAdd (size_t edgeSize, size_t vertSize, size_t faceSize) |
MRMESH_API void | addPackedPart (const MeshTopology &from, EdgeId toEdgeId, const FaceMap &fmap, const VertMap &vmap) |
MRMESH_API bool | computeValidsFromEdges (ProgressCallback cb={}) |
MRMESH_API void | stopUpdatingValids () |
stops updating validVerts(), validFaces(), numValidVerts(), numValidFaces() for parallel processing of mesh parts | |
bool | updatingValids () const |
returns whether the methods validVerts(), validFaces(), numValidVerts(), numValidFaces() can be called | |
MRMESH_API void | preferEdges (const UndirectedEdgeBitSet &stableEdges) |
MRMESH_API bool | buildGridMesh (const GridSettings &settings, ProgressCallback cb={}) |
MRMESH_API bool | checkValidity (ProgressCallback cb={}, bool allVerts=true) const |
Friends | |
class | MeshDiff |
Mesh Topology
|
inlinenodiscard |
creates new face-id not associated with any edge yet
MRMESH_API void MR::MeshTopology::addPackedPart | ( | const MeshTopology & | from, |
EdgeId | toEdgeId, | ||
const FaceMap & | fmap, | ||
const VertMap & | vmap ) |
copies topology (from) into this;
from | edges must be tightly packes without any lone edges, and they are mapped [0, from.edges.size()) -> [toEdgeId, toEdgeId + from.edges.size()); |
fmap,vmap | mapping of vertices and faces if it is given ( from.id -> this.id ) |
MRMESH_API void MR::MeshTopology::addPart | ( | const MeshTopology & | from, |
FaceMap * | outFmap = nullptr, | ||
VertMap * | outVmap = nullptr, | ||
WholeEdgeMap * | outEmap = nullptr, | ||
bool | rearrangeTriangles = false ) |
appends mesh topology (from) in addition to the current topology: creates new edges, faces, verts;
rearrangeTriangles | if true then the order of triangles is selected according to the order of their vertices, please call rotateTriangles() first |
outFmap,outVmap,outEmap | (optionally) returns mappings: from.id -> this.id |
MRMESH_API void MR::MeshTopology::addPartBy | ( | const MeshTopology & | from, |
I | fbegin, | ||
I | fend, | ||
size_t | fcount, | ||
bool | flipOrientation = false, | ||
const std::vector< EdgePath > & | thisContours = {}, | ||
const std::vector< EdgePath > & | fromContours = {}, | ||
const PartMapping & | map = {} ) |
both addPartByMask and addPartByFaceMap call this general implementation
MRMESH_API void MR::MeshTopology::addPartByFaceMap | ( | const MeshTopology & | from, |
const FaceMap & | fromFaces, | ||
bool | flipOrientation = false, | ||
const std::vector< EdgePath > & | thisContours = {}, | ||
const std::vector< EdgePath > & | fromContours = {}, | ||
const PartMapping & | map = {} ) |
fromFaces contains mapping from this-topology (considering it is empty) to from-topology
MRMESH_API void MR::MeshTopology::addPartByMask | ( | const MeshTopology & | from, |
const FaceBitSet & | fromFaces, | ||
bool | flipOrientation = false, | ||
const std::vector< EdgePath > & | thisContours = {}, | ||
const std::vector< EdgePath > & | fromContours = {}, | ||
const PartMapping & | map = {} ) |
this version has more parameters
flipOrientation | if true then every from triangle is inverted before adding |
thisContours | contours on this mesh (no left face) that have to be stitched with |
fromContours | contours on from mesh during addition (no left face if flipOrientation otherwise no right face) |
MRMESH_API void MR::MeshTopology::addPartByMask | ( | const MeshTopology & | from, |
const FaceBitSet & | fromFaces, | ||
const PartMapping & | map ) |
the same but copies only portion of (from) specified by fromFaces,
|
inlinenodiscard |
creates new vert-id not associated with any edge yet
|
nodiscard |
returns the first boundary edge (for given region or for whole mesh if region is nullptr) in counter-clockwise order starting from given edge with the same left; returns invalid edge if no boundary edge is found
|
nodiscard |
returns the first boundary edge (for given region or for whole mesh if region is nullptr) in counter-clockwise order starting from given edge with the same origin; returns invalid edge if no boundary edge is found
|
inlinenodiscard |
returns a boundary edge with given left face considering boundary of given region (or for whole mesh if region is nullptr); returns invalid edge if no boundary edge is found
|
inlinenodiscard |
returns a boundary edge with given vertex in origin considering boundary of given region (or for whole mesh if region is nullptr); returns invalid edge if no boundary edge is found
MRMESH_API bool MR::MeshTopology::buildGridMesh | ( | const GridSettings & | settings, |
ProgressCallback | cb = {} ) |
MRMESH_API bool MR::MeshTopology::checkValidity | ( | ProgressCallback | cb = {}, |
bool | allVerts = true ) const |
verifies that all internal data structures are valid; if allVerts=true then checks in addition that all not-lone edges have valid vertices on both ends
MRMESH_API EdgeId MR::MeshTopology::collapseEdge | ( | EdgeId | e, |
const std::function< void(EdgeId del, EdgeId rem)> & | onEdgeDel ) |
collapses given edge in a vertex and deletes 1) faces: left( e ) and right( e ); 2) edges: e, next( e.sym() ), prev( e.sym() ), and optionally next( e ), prev( e ) if their left and right triangles are deleted; 3) all vertices that lost their last edge; calls onEdgeDel for every deleted edge (del) including given (e); if valid (rem) is given then dest( del ) = dest( rem ) and their origins are in different ends of collapsing edge, (rem) shall take the place of (del)
|
nodiscard |
computes the number of not-lone (valid) undirected edges
MRMESH_API bool MR::MeshTopology::computeValidsFromEdges | ( | ProgressCallback | cb = {} | ) |
compute 1) numValidVerts_ and validVerts_ from edgePerVertex_ 2) numValidFaces_ and validFaces_ from edgePerFace_ and activates their auto-update
MRMESH_API void MR::MeshTopology::deleteFace | ( | FaceId | f, |
const UndirectedEdgeBitSet * | keepEdges = nullptr ) |
deletes the face, also deletes its edges and vertices if they were not shared by other faces ant not in
keepFaces |
MRMESH_API void MR::MeshTopology::deleteFaces | ( | const FaceBitSet & | fs, |
const UndirectedEdgeBitSet * | keepEdges = nullptr ) |
deletes multiple given faces by calling deleteFace for each
|
inlinenodiscard |
returns destination vertex of half-edge
|
inlinenodiscard |
returns the number of allocated edge records
|
inlinenodiscard |
for all valid faces this vector contains an edge with that face at left
|
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
|
inlinenodiscard |
returns valid edge if given vertex is present in the mesh
MRMESH_API void MR::MeshTopology::excludeLoneEdges | ( | UndirectedEdgeBitSet & | edges | ) | const |
remove all lone edges from given set
|
inlinenodiscard |
returns the number of allocated face records
|
inline |
sets the capacity of faces vector
MRMESH_API void MR::MeshTopology::faceResize | ( | size_t | newSize | ) |
explicitly increases the size of faces vector
MRMESH_API void MR::MeshTopology::faceResizeWithReserve | ( | size_t | newSize | ) |
explicitly increases the size of faces vector, doubling the current capacity if it was not enough
|
inlinenodiscard |
returns the number of face records including invalid ones
|
nodiscard |
returns all boundary edges, where each edge does not have valid left face
|
nodiscard |
returns all boundary faces, having at least one boundary edge;
region | if given then search among faces there otherwise among all valid faces |
|
nodiscard |
returns all boundary vertices, incident to at least one boundary edge;
region | if given then search among vertices there otherwise among all valid vertices |
|
nodiscard |
finds and returns edge from o to d in the mesh; returns invalid edge otherwise
|
nodiscard |
returns one edge with no valid left face for every boundary in the mesh
|
nodiscard |
finds and returns all not-lone (valid) undirected edges
|
nodiscard |
returns the number of hole loops in the mesh;
holeRepresentativeEdges | optional output of the smallest edge id with no valid left face in every hole |
|
inline |
sets in (fs) all valid faces that were not selected before the call, and resets other bits
|
inline |
sets in (vs) all valid vertices that were not selected before the call, and resets other bits
MRMESH_API void MR::MeshTopology::flipEdge | ( | EdgeId | e | ) |
given the edge with left and right triangular faces, which form together a quadrangle, rotates the edge counter-clockwise inside the quadrangle
void MR::MeshTopology::flipEdgesIn | ( | EdgeId | e0, |
T && | flipNeeded ) |
tests all edges e having valid left and right faces and org(e0) == dest(next(e)); if the test has passed, then flips the edge so increasing the degree of org(e0)
|
inline |
tests all edges e having valid left and right faces and v == dest(next(e)); if the test has passed, then flips the edge so increasing the degree of vertex v
void MR::MeshTopology::flipEdgesOut | ( | EdgeId | e0, |
T && | flipNeeded ) |
tests all edges e having valid left and right faces and org(e0) == org(e); if the test has passed, then flips the edge so decreasing the degree of org(e0)
|
inline |
tests all edges e having valid left and right faces and v == org(e); if the test has passed, then flips the edge so decreasing the degree of vertex v
MRMESH_API void MR::MeshTopology::flipOrientation | ( | const UndirectedEdgeBitSet * | fullComponents = nullptr | ) |
flip orientation (normals) of
fullComponents | is nullptr, or |
fullComponents. | The behavior is undefined if fullComponents is given but there are connected components with some edges included and not-included there. |
void MR::MeshTopology::forEachVertex | ( | const MeshTriPoint & | p, |
T && | callback ) const |
if given point is 1) in vertex, then invokes callback once with it; 2) on edge, then invokes callback twice with every vertex of the edge; 3) inside triangle, then invokes callback trice with every vertex of the triangle
|
nodiscard |
returns true if a and b are both from the same left face ring
|
nodiscard |
returns true if a and b are both from the same origin ring
|
nodiscard |
returns three vertex ids for valid triangles, invalid triangles are skipped
|
inlinenodiscard |
returns the number of edges around the given face: 3 for triangular faces, ...
|
inlinenodiscard |
if region pointer is not null then converts it in reference, otherwise returns all valid faces in the mesh
|
nodiscard |
returns the number of edges around the left face: 3 for triangular faces, ...
|
nodiscard |
returns full edge-loop of left face from (e) starting from (e) itself
|
nodiscard |
returns full edge-loops of left faces from every edge in (es); each edge-loop will be returned only once even if some faces are represented by more than one edge in (es)
|
inlinenodiscard |
|
inline |
MRMESH_API void MR::MeshTopology::getLeftTriVerts | ( | EdgeId | a, |
VertId & | v0, | ||
VertId & | v1, | ||
VertId & | v2 ) const |
gets 3 vertices of the left face ( face-id may not exist, but the shape must be triangular) the vertices are returned in counter-clockwise order if look from mesh outside
|
inline |
|
nodiscard |
returns the number of edges around the origin vertex, returns 1 for lone edges
|
nodiscard |
returns all valid left faces of path edges
|
nodiscard |
returns all valid right faces of path edges
|
nodiscard |
returns all vertices incident to path edges
|
nodiscard |
returns three vertex ids for valid triangles (which can be accessed by FaceId), vertex ids for invalid triangles are undefined, and shall not be read
MRMESH_API void MR::MeshTopology::getTriEdges | ( | FaceId | f, |
EdgeId & | e0, | ||
EdgeId & | e1, | ||
EdgeId & | e2 ) const |
gets 3 edges of given triangular face, oriented to have it on the left; the edges are returned in counter-clockwise order if look from mesh outside
|
inline |
|
inlinenodiscard |
|
inline |
|
inline |
gets 3 vertices of given triangular face; the vertices are returned in counter-clockwise order if look from mesh outside
|
inline |
|
inlinenodiscard |
returns cached set of all valid faces
|
inlinenodiscard |
returns cached set of all valid vertices
|
inlinenodiscard |
returns the number of edges around the given vertex
|
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 face is present in the mesh
|
inlinenodiscard |
returns true if given vertex is present in the mesh
|
nodiscard |
returns the amount of memory this object occupies on heap
|
inlinenodiscard |
return true if given edge is boundary for given region (or for whole mesh if region is nullptr)
|
inlinenodiscard |
returns true if given face is on (region) boundary
|
inlinenodiscard |
returns true if given vertex is on (region) boundary
|
inlinenodiscard |
returns true if edge's left is on (region) boundary
|
inlinenodiscard |
returns true if edge's origin is on (region) boundary
|
nodiscard |
returns true if the mesh (region) does not have any neighboring holes
|
inlinenodiscard |
return true if given edge is inner for given region (or for whole mesh if region is nullptr)
|
inlinenodiscard |
return true if given edge is inner or boundary for given region (or for whole mesh if region is nullptr), returns false for lone edges
|
nodiscard |
returns true if one of incident faces of given vertex pertain to given region (or any such face exists if region is nullptr)
|
inlinenodiscard |
returns true if left face of given edge belongs to given region (if provided) and right face either does not exist or does not belong
|
inlinenodiscard |
return true if left face of given edge belongs to region (or just have valid id if region is nullptr)
|
nodiscard |
returns true if the cell to the left of a is quadrangular
|
nodiscard |
returns true if the cell to the left of a is triangular
|
nodiscard |
checks whether the edge is disconnected from all other edges and disassociated from all vertices and faces (as if after makeEdge)
|
nodiscard |
returns last not lone edge id, or invalid id if no such edge exists
|
nodiscard |
returns last valid face id, or invalid id if no single valid face exists
|
nodiscard |
returns last valid vertex id, or invalid id if no single valid vertex exists
|
inlinenodiscard |
returns left face of half-edge
|
nodiscard |
creates an edge not associated with any vertex or face
|
inlinenodiscard |
next (counter clock wise) half-edge in the origin ring
|
nodiscard |
given a (region) boundary edge with no right face in given region, returns next boundary edge for the same region: dest(e)==org(res)
|
inlinenodiscard |
returns the number of valid faces
|
inlinenodiscard |
returns the number of valid vertices
|
nodiscard |
compare that two topologies are exactly the same
|
inlinenodiscard |
returns origin vertex of half-edge
MRMESH_API void MR::MeshTopology::pack | ( | const PackMapping & | map | ) |
tightly packs all arrays eliminating lone edges and invalid faces and vertices; reorder all faces, vertices and edges according to given maps, each containing old id -> new id mapping
MRMESH_API void MR::MeshTopology::pack | ( | FaceMap * | outFmap = nullptr, |
VertMap * | outVmap = nullptr, | ||
WholeEdgeMap * | outEmap = nullptr, | ||
bool | rearrangeTriangles = false ) |
tightly packs all arrays eliminating lone edges and invalid faces and vertices
outFmap,outVmap,outEmap | if given returns mappings: old.id -> new.id; |
rearrangeTriangles | if true then calls rotateTriangles() and selects the order of triangles according to the order of their vertices |
MRMESH_API void MR::MeshTopology::packMinMem | ( | const PackMapping & | map | ) |
tightly packs all arrays eliminating lone edges and invalid faces and vertices; reorder all faces, vertices and edges according to given maps, each containing old id -> new id mapping; unlike pack method, this method allocates minimal amount of memory for its operation but works much slower
MRMESH_API void MR::MeshTopology::preferEdges | ( | const UndirectedEdgeBitSet & | stableEdges | ) |
for incident vertices and faces of given edges, remember one of them as edgeWithOrg and edgeWithLeft; this is important in parallel algorithms where other edges may change but stable ones will survive
|
inlinenodiscard |
previous (clock wise) half-edge in the origin ring
|
nodiscard |
given a (region) boundary edge with no right face in given region, returns previous boundary edge for the same region; dest(res)==org(e)
MRMESH_API Expected< void > MR::MeshTopology::read | ( | std::istream & | s, |
ProgressCallback | callback = {} ) |
loads from binary stream
MRMESH_API void MR::MeshTopology::resizeBeforeParallelAdd | ( | size_t | edgeSize, |
size_t | vertSize, | ||
size_t | faceSize ) |
These function are for parallel mesh creation from different threads. If you are not sure, do not use them.
resizes all internal vectors and sets the numbers of valid elements in preparation for addPackedPart; edges are resized without initialization (so the user must initialize them using addPackedPart)
|
inlinenodiscard |
returns right face of half-edge
MRMESH_API void MR::MeshTopology::rotateTriangles | ( | ) |
for each triangle selects edgeWithLeft with minimal origin vertex
MRMESH_API void MR::MeshTopology::setLeft | ( | EdgeId | a, |
FaceId | f ) |
sets new left face to the full left ring including this edge; edgePerFace_ table is updated accordingly
MRMESH_API void MR::MeshTopology::setOrg | ( | EdgeId | a, |
VertId | v ) |
sets new origin to the full origin ring including this edge; edgePerVertex_ table is updated accordingly
|
nodiscard |
if two valid faces share the same edge then it is found and returned
|
nodiscard |
if two valid edges belong to same valid face then it is found and returned
|
nodiscard |
if two valid edges share the same vertex then it is found and returned as Edge with this vertex in origin
|
nodiscard |
if two valid faces share the same vertex then it is found and returned as Edge with this vertex in origin
MRMESH_API void MR::MeshTopology::shrinkToFit | ( | ) |
requests the removal of unused capacity
MRMESH_API void MR::MeshTopology::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::MeshTopology::splitEdge | ( | EdgeId | e, |
FaceBitSet * | region = nullptr, | ||
FaceHashMap * | new2Old = nullptr ) |
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)
left and right faces of given edge if valid are also subdivided on two parts each; the split edge will have the same face IDs, and the new edge will have new face IDs; if left or right faces of the original edge were in the region, then include new parts of these faces in the region
new2Old | receive mapping from newly appeared triangle to its original triangle (part to full) |
MRMESH_API VertId MR::MeshTopology::splitFace | ( | FaceId | f, |
FaceBitSet * | region = nullptr, | ||
FaceHashMap * | new2Old = nullptr ) |
split given triangle on three triangles, introducing new vertex (which is returned) inside original triangle and connecting it to its vertices
if region is given, then it must include (f) and new faces will be added there as well
new2Old | receive mapping from newly appeared triangle to its original triangle (part to full) |
MRMESH_API void MR::MeshTopology::stopUpdatingValids | ( | ) |
stops updating validVerts(), validFaces(), numValidVerts(), numValidFaces() for parallel processing of mesh parts
|
inlinenodiscard |
returns the number of allocated undirected edges (pairs of half-edges)
|
inlinenodiscard |
returns the number of undirected edges (pairs of half-edges) including lone ones
|
inlinenodiscard |
returns whether the methods validVerts(), validFaces(), numValidVerts(), numValidFaces() can be called
|
inlinenodiscard |
returns the number of allocated vert records
|
inline |
sets the capacity of vertices vector
MRMESH_API void MR::MeshTopology::vertResize | ( | size_t | newSize | ) |
explicitly increases the size of vertices vector
MRMESH_API void MR::MeshTopology::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::MeshTopology::write | ( | std::ostream & | s | ) | const |
saves in binary stream
|
friend |