VCG Library
Loading...
Searching...
No Matches
Classes | Public Types | Static Public Member Functions | List of all members
vcg::tri::CoMEmbed< MeshType > Class Template Reference

A class for managing curves on a 2-manifold (Curve on Manifold - CoM). More...

#include <curve_on_manifold.h>

Public Types

typedef CoM< MeshType > CoMType
 
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::FaceType FaceType
 
typedef MeshType::FacePointer FacePointer
 
typedef MeshType::FaceIterator FaceIterator
 

Static Public Member Functions

static bool TagFaceEdgeSelWithPolyLine (CoMType &com, MeshType &poly, bool markFlag=true)
 Tag face edges of the base mesh that coincide with polyline edges.
 
static void SplitMeshWithPolyline (CoMType &com, MeshType &poly)
 Make the base mesh conform to the polyline: afterwards every polyline edge is an edge of the base mesh, with its face-edge selection bit set on both sides.
 

Detailed Description

template<class MeshType>
class vcg::tri::CoMEmbed< MeshType >

A class for managing curves on a 2-manifold (Curve on Manifold - CoM).

Embed a curve in the surface it lies on: the operations on a CoM that change the surface.

This class is used to project, simplify, smooth, and snap polylines (represented as edge meshes) over a triangulated surface (the "base mesh").

Overview
The CoM class provides tools to:
  • Project polylines onto a surface
  • Snap polyline vertices to mesh vertices or edges
  • Refine polylines to follow surface features
  • Simplify polylines while maintaining surface fidelity
  • Split the base mesh along polylines for mesh cutting operations (in CoMEmbed)
Terminology
  • Base mesh: The triangulated surface mesh (stored in base)
  • Polyline/Curve: An edge mesh passed to the various methods (typically named poly in parameters)
  • Snapping: The process of aligning polyline vertices to mesh vertices or edges using barycentric thresholds
Curves, strands and control points
A curve on the surface is a graph of control points, joined by strands. A strand stands for a geodesic between its two control points: its other vertices are only a discretization of it, which smoothing moves towards the geodesic and refinement and simplification add or remove. Control points are fixed: they are projected onto the surface and never smoothed, snapped, simplified or merged away. They are the selected vertices of the polyline; SetControlPoints() chooses them: every vertex, the ends and junctions (the default), or the selection as given. Since a geodesic on a triangle mesh is straight inside each face, RefineCurveByBaseMesh() leaves a strand with only its control points and its exact edge crossings.
Requirements
The base mesh should be:
  • 2-manifold
  • Have reasonable triangle quality
  • Have up-to-date topology (FaceFace adjacency)
  • Have bounding box correctly set
Usage Pattern
  1. Initialize the class with a base mesh: CoM<MeshType> com(baseMesh);
  2. Call Init() to build the spatial acceleration structures
  3. Pass polylines (as edge meshes) to various methods for processing
  4. Adjust parameters via the par member for fine control
Implementation Notes
  • The class uses barycentric coordinates to determine if a point of the polyline should snap to vertices or edges
  • All spatial queries use a uniform grid for acceleration
  • Many operations are iterative and may require multiple passes
Errors
Violated preconditions throw vcg::MissingPreconditionException instead of asserting: a base mesh with no faces, non-manifold edges or zero-area faces (Init()), an empty curve (MoveAndProject()), a curve point farther than Param::gridBailout from the surface (every closest-face query), and a curve that CoMEmbed::SplitMeshWithPolyline() cannot embed. After an exception the base mesh and the curve may be partially modified, so a caller that needs them intact should work on copies.
Attributes
The methods that change the base mesh keep its per-vertex color, quality, normal and texture coordinates and its per-face attributes: the vertices and faces created by splitting interpolate or inherit them. Progress and diagnostic messages go to Param::cb, when set. The methods that change the base mesh are in CoMEmbed.
Note
There is some naming inconsistency: methods use both "Curve" and "Polyline" interchangeably to refer to the edge mesh being processed.

CoM is a query structure over a fixed surface; what only reads the surface, or changes the curve, lives there. These two change the base mesh itself, its connectivity and its face-edge selection, so they are kept apart. Both take the CoM already built over the surface, typically the one just used to smooth and refine the curve, so its spatial grid is not built twice. SplitMeshWithPolyline() re-initializes it on the split surface, so it stays valid afterwards.

tri::CoM<MyMesh> com(base);
com.Init();
com.SmoothProject(poly, 10, 0.5, 0.5);
com.RefineCurveByBaseMesh(poly);
tri::CutMeshAlongSelectedFaceEdges(base);
static bool TagFaceEdgeSelWithPolyLine(CoMType &com, MeshType &poly, bool markFlag=true)
Tag face edges of the base mesh that coincide with polyline edges.
Definition: curve_on_manifold.h:1274
static void SplitMeshWithPolyline(CoMType &com, MeshType &poly)
Make the base mesh conform to the polyline: afterwards every polyline edge is an edge of the base mes...
Definition: curve_on_manifold.h:1355
Definition: curve_on_manifold.h:122

See the sample trimesh_topological_cut.cpp.

Member Function Documentation

◆ SplitMeshWithPolyline()

template<class MeshType >
static void vcg::tri::CoMEmbed< MeshType >::SplitMeshWithPolyline ( CoMType &  com,
MeshType &  poly 
)
inlinestatic

Make the base mesh conform to the polyline: afterwards every polyline edge is an edge of the base mesh, with its face-edge selection bit set on both sides.

Parameters
comThe CoM built over the base mesh, typically the one just used to refine the polyline; it is re-initialized on the split mesh, so it stays valid
polyThe polyline; its vertices are moved onto the vertices created for them

Precondition: RefineCurveByBaseMesh() has been called, so every polyline segment lies inside one face or along one edge of the base mesh.

Curves may cross and touch. The mesh realizes the union of the curves: it gets a vertex at every crossing, and curve points or segments that coincide within rounding distance share mesh vertices and edges. The polyline keeps its own topology: a segment cut at a crossing or a touching point gets a vertex of its own there, so two strands stay two strands, each passing through the shared mesh vertex. CoM::ConnectCrossings() turns those meeting points into junctions, when the caller wants them.

Any number of segments may cross the same triangle, from different curves or from the same one passing several times, as a spiral on a cylinder does. Each crossed triangle is rebuilt on its own, in its barycentric frame: the polyline points on its edges are inserted by splitting the sub-triangle that owns that piece of the edge, points inside it by splitting the sub-triangle that contains them, and every segment is then recovered as an edge by flipping the edges that cross it, after which the other edges are flipped to the constrained Delaunay triangulation (S. W. Sloan, "A fast algorithm for generating constrained Delaunay triangulations", Computers & Structures 47(3), 1993). The Delaunay step is not cosmetic: a curve point kept inside a triangle (a control point) between the two points where its straight strand crosses the triangle's edges otherwise leaves a sliver of near-zero area, which turns over once its vertices are stored in floating point. Sub-triangles keep the attributes of their triangle, and their wedge texture coordinates are the triangle's at each vertex; new vertices interpolate the attributes of the surface where they are (VertexInterpolator).

Exceptions
vcg::MissingPreconditionExceptionif a segment does not lie in one face or along one edge, or if a segment cannot be recovered
See also
CoM::RefineCurveByBaseMesh, TagFaceEdgeSelWithPolyLine

◆ TagFaceEdgeSelWithPolyLine()

template<class MeshType >
static bool vcg::tri::CoMEmbed< MeshType >::TagFaceEdgeSelWithPolyLine ( CoMType &  com,
MeshType &  poly,
bool  markFlag = true 
)
inlinestatic

Tag face edges of the base mesh that coincide with polyline edges.

Parameters
comThe CoM built over the base mesh
polyThe polyline (as edge mesh) to use for tagging
markFlagIf true, clears all FaceEdgeS flags before tagging (default: true)
Returns
true if ALL edges of the polyline are fully snapped onto mesh edges

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. This function requires VertexFace and FaceFace adjacency.

Note
This is typically used as a preparation step before cutting the mesh along the polyline using CutMeshAlongCrease or similar functions.
Warning
Returns false if any polyline edge is not properly snapped, or if the snapped vertices don't form an edge in the base mesh.
See also
SplitMeshWithPolyline, CutMeshAlongCrease

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