![]() |
VCG Library
|
A class for managing curves on a 2-manifold (Curve on Manifold - CoM). More...
#include <curve_on_manifold.h>
Classes | |
| class | EdgePointPred |
| struct | EdgePointSplit |
| class | Param |
| Parameter class controlling the behavior of CoM algorithms. More... | |
Public Types | |
| typedef MeshType::ScalarType | ScalarType |
| typedef MeshType::CoordType | CoordType |
| typedef MeshType::VertexType | VertexType |
| typedef MeshType::VertexPointer | VertexPointer |
| typedef MeshType::VertexIterator | VertexIterator |
| typedef MeshType::EdgeIterator | EdgeIterator |
| typedef MeshType::EdgeType | EdgeType |
| typedef MeshType::FaceType | FaceType |
| typedef MeshType::FacePointer | FacePointer |
| typedef MeshType::FaceIterator | FaceIterator |
| typedef Box3< ScalarType > | Box3Type |
| typedef Segment3< ScalarType > | Segment3Type |
| typedef vcg::GridStaticPtr< FaceType, ScalarType > | MeshGrid |
| typedef vcg::GridStaticPtr< EdgeType, ScalarType > | EdgeGrid |
| typedef face::Pos< FaceType > | PosType |
| typedef tri::UpdateTopology< MeshType >::PEdge | PEdge |
Public Member Functions | |
| CoM (MeshType &_m) | |
| Constructor: initializes the CoM with a base mesh. | |
| FaceType * | GetClosestFace (const CoordType &p) |
| Get the closest face to a query point. | |
| FaceType * | GetClosestFaceIP (const CoordType &p, CoordType &ip) |
| Get the closest face and its barycentric coordinates. | |
| FaceType * | GetClosestFaceIP (const CoordType &p, CoordType &ip, CoordType &in) |
| Get the closest face, barycentric coordinates, and normal. | |
| FaceType * | GetClosestFacePoint (const CoordType &p, CoordType &closestP) |
| Get the closest face and the closest point on it. | |
| bool | IsWellSnapped (const CoordType &ip) |
| Test if a barycentric coordinate is well snapped. | |
| bool | IsSnappedEdge (CoordType &ip, int &ei) |
| Check if a barycentric coordinate is snapped to an edge. | |
| bool | IsSnappedVertex (CoordType &ip, int &vi) |
| Check if a barycentric coordinate is snapped to a vertex. | |
| VertexPointer | FindVertexSnap (FacePointer fp, CoordType &ip) |
| Find the vertex pointer for a vertex-snapped barycentric coordinate. | |
| bool | TagFaceEdgeSelWithPolyLine (MeshType &poly, bool markFlag=true) |
| Tag face edges of the base mesh that coincide with polyline edges. | |
| ScalarType | MinDistOnEdge (CoordType samplePnt, EdgeGrid &edgeGrid, MeshType &poly, CoordType &closestPoint) |
| Find the minimum distance from a sample point to the polyline. | |
| bool | SnapPolyline (MeshType &poly) |
| SnapPolyline snaps the vertexes of a polyline onto the base mesh. | |
| void | SelectBoundaryVertex (MeshType &poly) |
| void | SelectUniformlyDistributed (MeshType &poly, int k) |
| void | DecomposeNonManifoldPolyline (MeshType &poly, bool singSplitFlag=true) |
| void | SplitMeshWithPolyline (MeshType &poly) |
| Split the base mesh to make it conforming with the polyline. | |
| void | Init () |
| Initialize the CoM data structures for processing. | |
| void | SimplifyNullEdges (MeshType &poly) |
| Remove duplicate/zero-length edges from a polyline. | |
| void | SimplifyMidEdge (MeshType &poly) |
| void | SimplifyMidFace (MeshType &poly) |
| SimplifyMidFace remove all the vertices that in the mid of a face and between two of the points snapped onto the edges of the same face. | |
| void | Simplify (MeshType &poly) |
| void | EvaluateHausdorffDistance (MeshType &poly, Distribution< ScalarType > &dist) |
| bool | BarycentricSnap (CoordType &ip) |
| Snap barycentric coordinates to 0 or 1 if within threshold. | |
| bool | TestSplitSegWithMesh (VertexType *v0, VertexType *v1, CoordType &splitPt) |
| TestSplitSegWithMesh Given a poly segment decide if it should be split along elements of base mesh. | |
| bool | SnappedOnSameFace (FacePointer f0, CoordType i0, FacePointer f1, CoordType i1) |
| SnappedOnSameFace Return true if the two points are snapped to a common face;. | |
| bool | TestSplitSegWithMeshAdapt (VertexType *v0, VertexType *v1, CoordType &splitPt) |
| TestSplitSegWithMesh Given a poly segment decide if it should be split along elements of base mesh. | |
| bool | TestSplitSegWithMeshAdaptOld (VertexType *v0, VertexType *v1, CoordType &splitPt) |
| ScalarType | MaxSegDist (VertexType *v0, VertexType *v1, CoordType &farthestPointOnSurf, CoordType &farthestN, Distribution< ScalarType > *dist=0) |
| void | RefineCurveByDistance (MeshType &poly) |
| RefineCurve. | |
| void | RefineCurveByBaseMesh (MeshType &poly) |
| RefineCurveByBaseMesh. | |
| void | SmoothProject (MeshType &poly, int iterNum, ScalarType smoothWeight, ScalarType projectWeight) |
| SmoothProject. | |
Static Public Member Functions | |
| static ScalarType | MinDistOnEdge (VertexType *v0, VertexType *v1, EdgeGrid &edgeGrid, MeshType &poly, CoordType &closestPoint) |
| Find the closest point on a mesh edge to the polyline (static version) | |
| static void | ExtractVertex (const MeshType &srcMesh, const FaceType &f, int whichWedge, const MeshType &dstMesh, VertexType &v) |
| Extract vertex attributes for seam processing. | |
| static bool | CompareVertex (const MeshType &m, const VertexType &vA, const VertexType &vB) |
| Compare two vertices for seam compatibility. | |
| static CoordType | QLerp (VertexType *v0, VertexType *v1) |
| Compute quality-weighted linear interpolation between two vertices. | |
Public Attributes | |
| MeshType & | base |
| Reference to the base triangulated surface mesh. | |
| MeshGrid | uniformGrid |
| Spatial acceleration structure for closest point queries. | |
| Param | par |
| Parameters controlling algorithm behavior. | |
A class for managing curves on a 2-manifold (Curve on Manifold - CoM).
This class is used to project, simplify, smooth, and snap polylines (represented as edge meshes) over a triangulated surface (the "base mesh").
base)poly in parameters)
|
inline |
Snap barycentric coordinates to 0 or 1 if within threshold.
| ip | Input/Output: barycentric coordinates (must sum to 1.0) |
This is one of the MOST IMPORTANT functions in the class - it's used throughout!
Given barycentric coordinates of a point in a triangle, this function decides whether it should be "snapped" to a vertex or edge based on the par.barycentricSnapThr threshold.
Algorithm:
barycentricSnapThr of 0, snap it to 0barycentricSnapThr of 1, snap it to 1Snapping Cases:
Return Value:
true: Point is on a vertex or edge (at least one coordinate is 0)false: Point is in the interior of the trianglepar.barycentricSnapThr (default 0.05) controls snapping sensitivity
|
inlinestatic |
Compare two vertices for seam compatibility.
| m | The mesh (unused but required by interface) |
| vA | First vertex |
| vB | Second vertex |
This callback is used by the attribute_seam system to determine if two vertices can be considered the same across a seam boundary. Current implementation: Red and Blue colored vertices are considered incompatible.
|
inlinestatic |
Extract vertex attributes for seam processing.
| srcMesh | Source mesh (unused but required by interface) |
| f | The face containing the vertex |
| whichWedge | Which vertex (0,1,2) of the face to extract |
| dstMesh | Destination mesh (unused but required by interface) |
| v | Output: vertex with copied attributes |
This is a callback function used by the attribute_seam system. It copies all per-vertex properties and uses the face color.
|
inline |
Find the vertex pointer for a vertex-snapped barycentric coordinate.
| fp | The face containing the point |
| ip | The barycentric coordinate (should be snapped to a vertex) |
|
inline |
Get the closest face to a query point.
| p | The query point |
|
inline |
Get the closest face and its barycentric coordinates.
| p | The query point |
| ip | Output: barycentric coordinates of the closest point on the returned face |
|
inline |
Get the closest face, barycentric coordinates, and normal.
| p | The query point |
| ip | Output: barycentric coordinates of the closest point on the returned face |
| in | Output: normal at the closest point |
|
inline |
Get the closest face and the closest point on it.
| p | The query point |
| closestP | Output: the 3D coordinates of the closest point on the surface |
|
inline |
Initialize the CoM data structures for processing.
This must be called after construction and whenever the base mesh is modified. It performs:
|
inline |
Check if a barycentric coordinate is snapped to an edge.
| ip | The barycentric coordinate (must be snapped) |
| ei | Output: index (0,1,2) of the edge opposite to the zero coordinate |
Edge snapping means the point lies on one of the three edges of the triangle. Edge i is the edge from vertex i to vertex (i+1)%3, opposite to vertex (i+2)%3.
|
inline |
Check if a barycentric coordinate is snapped to a vertex.
| ip | The barycentric coordinate (must be snapped) |
| vi | Output: index (0,1,2) of the vertex with coordinate == 1.0 |
|
inline |
Test if a barycentric coordinate is well snapped.
| ip | The barycentric coordinate to test (must sum to 1.0) |
A barycentric coordinate is "well snapped" if each component is either:
This indicates the point doesn't need further snapping adjustment.
|
inline |
Find the minimum distance from a sample point to the polyline.
| samplePnt | The point to measure distance from |
| edgeGrid | Spatial acceleration grid for the polyline edges |
| poly | The polyline (as edge mesh) |
| closestPoint | Output: the closest point on the polyline |
|
inlinestatic |
Find the closest point on a mesh edge to the polyline (static version)
| v0 | First vertex of the mesh edge |
| v1 | Second vertex of the mesh edge |
| edgeGrid | Spatial acceleration grid for the polyline edges |
| poly | The polyline (as edge mesh) |
| closestPoint | Output: the point on the edge [v0,v1] closest to the polyline |
This samples the edge [v0,v1] uniformly and finds which sample is closest to the polyline.
|
inlinestatic |
Compute quality-weighted linear interpolation between two vertices.
| v0 | First vertex |
| v1 | Second vertex |
Points with higher quality (larger absolute value) contribute less to the result. This is useful for adaptive refinement based on error metrics stored in quality.
|
inline |
RefineCurveByBaseMesh.
| poly |
|
inline |
RefineCurve.
| poly | the curve to be refined |
| uniformFlag |
Make one pass of refinement for all the edges of the curve that are distant from the basemesh uses two parameters:
|
inline |
SimplifyMidFace remove all the vertices that in the mid of a face and between two of the points snapped onto the edges of the same face.
| poly |
It assumes that the mesh has been snapped and refined by the BaseMesh
|
inline |
Remove duplicate/zero-length edges from a polyline.
| poly | The polyline to simplify |
Removes vertices that have collapsed to the same position.
|
inline |
SmoothProject.
| poly | |
| iterNum | |
| smoothWeight | [0..1] range; |
| projectWeight | [0..1] range; |
The very important function to adapt a polyline onto the base mesh The projection process must be done slowly to guarantee some empirical convergence... For each iteration it choose a new position of each vertex of the polyline. The new position is a blend between the smoothed position, the closest point on the surface and the original position. You need a good balance... after each iteration the polyline is refined and simplified.
|
inline |
SnappedOnSameFace Return true if the two points are snapped to a common face;.
| f0 | |
| i0 | |
| f1 | |
| i0 |
Require FFAdj. se assume that both SNAPPED. Three cases:
|
inline |
SnapPolyline snaps the vertexes of a polyline onto the base mesh.
| poly | |
| newVertVec | the vector of the indexes of the snapped vertices |
Polyline vertices can be snapped either on vertexes or on edges. Usually the only points that we should allow to not be snapped are the endpoints and non manifold points. Vertexes are colored according to their snapping state
|
inline |
Split the base mesh to make it conforming with the polyline.
| poly | The polyline to integrate into the base mesh |
This is a complex two-phase algorithm:
Phase 1: Vertex Insertion
Phase 2: Edge Splitting (iterative)
After completion, the polyline edges should coincide with base mesh edges, allowing subsequent operations like mesh cutting or constrained triangulation.
|
inline |
Tag face edges of the base mesh that coincide with polyline edges.
| poly | The polyline (as edge mesh) to use for tagging |
| markFlag | If true, clears all FaceEdgeS flags before tagging (default: true) |
This function marks edges in the base mesh (using FaceEdgeS flag) where they coincide with edges from the polyline. The polyline edges must be snapped to mesh vertices at both endpoints for this to work.
|
inline |
TestSplitSegWithMesh Given a poly segment decide if it should be split along elements of base mesh.
| v0 | |
| v1 | |
| splitPt |
We make a few samples onto the edge and if some of them snaps onto a an edge we use it. In case there are more than one candidate we choose the sample closeset to its snapping point. We explicitly avoid snapping twice on the same edge by checking the starting and ending edges.
Two cases:
Note that we have to check the case where
|
inline |
TestSplitSegWithMesh Given a poly segment decide if it should be split along elements of base mesh.
| v0 | |
| v1 | |
| splitPt |
We make a few samples onto the edge and if some of them snaps onto a an edge we use it. In case there are more than one candidate we choose the sample closeset to its snapping point. We explicitly avoid snapping twice on the same edge by checking the starting and ending edges.
Two cases:
Note that we have to check the case where