template<class TM, class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
class CGAL::Surface_mesh_deformation< TM, VIM, HIM, TAG, WC, ST, CR, VPM >
Class providing the functionalities for deforming a triangulated surface mesh.
- Template Parameters
-
- Examples
- Surface_mesh_deformation/all_roi_assign_example.cpp, Surface_mesh_deformation/custom_weight_for_edges_example.cpp, Surface_mesh_deformation/deform_mesh_for_botsch08_format_sre_arap.cpp, Surface_mesh_deformation/deform_polyhedron_with_custom_pmap_example.cpp, and Surface_mesh_deformation/k_ring_roi_translate_rotate_example.cpp.
|
void | set_target_position (vertex_descriptor vd, const Point &target_position) |
| Sets the target position of a control vertex. More...
|
|
template<class Vect > |
void | translate (vertex_descriptor vd, const Vect &t) |
| Updates the target position of vd by applying a translation of vector t . More...
|
|
template<class InputIterator , class Vect > |
void | translate (InputIterator begin, InputIterator end, const Vect &t) |
| Equivalent to calling the overload taking only one control vertex, for each vertex in the range [begin,end[ . More...
|
|
template<typename Quaternion , typename Vect > |
void | rotate (vertex_descriptor vd, const Vect &to_rotation_center, const Quaternion &quat) |
| Updates the target position of vd by applying to its last target position a rotation defined by the quaternion quat , the center of the rotation being the origin translated by to_rotation_center . More...
|
|
template<typename InputIterator , typename Vect , typename Quaternion > |
void | rotate (InputIterator begin, InputIterator end, const Vect &to_rotation_center, const Quaternion &quat) |
| Equivalent to calling the overload taking only one control vertex, for each vertex in the range [begin,end[ . More...
|
|
const Point & | target_position (vertex_descriptor vd) |
| Returns the target position of a control vertex. More...
|
|
void | deform () |
| Deforms the region-of-interest according to the deformation algorithm, using the target positions of each control vertex set by using rotate() , translate() , or set_target_position() . More...
|
|
void | deform (unsigned int iterations, double tolerance) |
| Same as deform() but the number of iterations and the tolerance are one-time parameters. More...
|
|
void | reset () |
| Resets the points associated to the vertices of the region-of-interest at their initial positions at time of the functor construction or after the last call to overwrite_initial_geometry() . More...
|
|
void | overwrite_initial_geometry () |
| Sets the initial positions of the vertices from the region-of-interest to the current positions. More...
|
|
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
A constant iterator range over the vertices of the region-of-interest.
It is a model of ConstRange
with vertex_descriptor
as iterator value type.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
CGAL::Surface_mesh_deformation< TM, VIM, HIM, TAG, WC, ST, CR, VPM >::Surface_mesh_deformation |
( |
Triangle_mesh & |
triangle_mesh, |
|
|
Vertex_index_map |
vertex_index_map = unspecified_internal_vertex_index_map , |
|
|
Hedge_index_map |
hedge_index_map = unspecified_internal_halfedge_index_map , |
|
|
Vertex_point_map |
vertex_point_map = get(boost::vertex_point, triangle_mesh) , |
|
|
Weight_calculator |
weight_calculator = Weight_calculator() |
|
) |
| |
The constructor of a deformation object.
- Precondition
triangle_mesh
consists of only triangular facets
- Parameters
-
triangle_mesh | triangulated surface mesh to deform |
vertex_index_map | a property map which associates a unique id to each vertex, between 0 to num_vertices(triangle_mesh)-1 . |
hedge_index_map | property map which associates a unique id to each halfedge, between 0 to 2*num_edges(triangle_mesh)-1 . |
vertex_point_map | property map which associates a point to each vertex of the triangle mesh. |
weight_calculator | function object or pointer for weight calculation |
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Same as deform()
but the number of iterations and the tolerance are one-time parameters.
- Parameters
-
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Erases a vertex from the set of control vertices.
- Parameters
-
vd | the vertex to be erased |
- Returns
true
if vd
was a control vertex.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Erases a vertex from the region-of-interest and the set of control vertices.
- Note
- At the next call to
preprocess()
, any vertex that is no longer in the region-of-interest will be assigned to its original position (that is the position of the vertex at the time of construction or after the last call to overwrite_initial_geometry()
).
- Parameters
-
vd | the vertex to be erased |
- Returns
true
vd
was a vertex from the region-of-interest.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Inserts a vertex in the set of control vertices.
The vertex is also inserted in the region-of-interest if it is not already in it.
- Parameters
-
vd | the vertex to be inserted |
- Returns
true
if vd
is not already a control vertex.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
template<class InputIterator >
Inserts a range of vertices in the set of control vertices.
The vertices are also inserted in the region-of-interest if they are not already in it.
- Template Parameters
-
InputIterator | input iterator type with vertex_descriptor as value type |
- Parameters
-
begin | first iterator of the range of vertices |
end | past-the-end iterator of the range of vertices |
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Inserts a vertex in the region-of-interest.
- Parameters
-
vd | the vertex to be inserted |
- Returns
true
if vd
is not already in the region-of-interest.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
template<class InputIterator >
Inserts a range of vertices in the region-of-interest.
- Template Parameters
-
InputIterator | input iterator with vertex_descriptor as value type |
- Parameters
-
begin | first iterator of the range of vertices |
end | past-the-end iterator of the range of vertices |
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Tests whether a vertex is a control vertex.
- Parameters
-
- Returns
true
if vd
has been inserted to (and not erased from) the set of control vertices.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Tests whether a vertex is inside the region-of-interest.
- Parameters
-
- Returns
true
if vd
has been inserted to (and not erased from) the region-of-interest.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Sets the initial positions of the vertices from the region-of-interest to the current positions.
Calling this function has the same effect as creating a new deformation object with the current deformed triangle mesh, keeping the region-of-interest and the set of control vertices.
- Note
- if the region-of-interest or the set of control vertices have been modified since the last call to
preprocess()
, it will be called prior to the overwrite.
Advanced
This function might have a non-negligible effect on the result. The Laplacian matrix of the free vertices and the optimal rotations are computed using the original positions of the points associated to the vertices. Thus, if a deformed version of the surface mesh is used as reference, the surface mesh properties the algorithm tries to preserve are those of an altered version (which are already degraded).
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Preprocessing function that need to be called each time the region-of-interest or the set of control vertices are changed before calling deform()
.
If not already done, deform()
first calls this function.
Advanced
Collects the vertices not in the region-of-interest that are adjacent to a vertex from the region-of-interest (these vertices are internally considered as fixed control vertices). Then assembles and factorizes the Laplacian matrix used in the function deform()
.
- Note
- A modification of the set of control vertices or the region-of-interest invalidates the preprocessing data.
- Returns
true
if successful. A common reason for failure is that the system is rank deficient, which happens for example when all the vertices are in the region-of-interest and no control vertices are set, or if the weighting scheme used features too many zero and breaks the connectivity information.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Resets the points associated to the vertices of the region-of-interest at their initial positions at time of the functor construction or after the last call to overwrite_initial_geometry()
.
- Note
- if the region-of-interest or the set of control vertices have been modified since the last call to
preprocess()
, it will be called prior to the reset.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
template<typename InputIterator , typename Vect , typename Quaternion >
void CGAL::Surface_mesh_deformation< TM, VIM, HIM, TAG, WC, ST, CR, VPM >::rotate |
( |
InputIterator |
begin, |
|
|
InputIterator |
end, |
|
|
const Vect & |
to_rotation_center, |
|
|
const Quaternion & |
quat |
|
) |
| |
Equivalent to calling the overload taking only one control vertex, for each vertex in the range [begin,end[
.
- Template Parameters
-
InputIterator | input iterator type with vertex_descriptor as value type |
Quaternion | is a quaternion class with Vect operator*(Quaternion, Vect) returning the product of a quaternion with a vector |
Vect | is a 3D vector class, with Vect(double x,double y, double z) being a constructor from its Cartesian coordinates and double Vect::operator[](int i) with i=0,1 or 2 returning its Cartesian coordinates. |
- Parameters
-
begin | first iterator of the range of vertices |
end | past-the-end iterator of the range of vertices |
to_rotation_center | the vector to translate the origin to the center of the rotation |
quat | quaternion of the rotation |
- Precondition
quad
represents a rotation
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
template<typename Quaternion , typename Vect >
Updates the target position of vd
by applying to its last target position a rotation defined by the quaternion quat
, the center of the rotation being the origin translated by to_rotation_center
.
- Template Parameters
-
Quaternion | is a quaternion class with Vect operator*(Quaternion, Vect) returning the product of a quaternion with a vector |
Vect | is a 3D vector class, with Vect(double x,double y, double z) being a constructor from its Cartesian coordinates and double Vect::operator[](int i) with i=0,1 or 2 returning its Cartesian coordinates. |
- Parameters
-
vd | a control vertex |
to_rotation_center | the vector to translate the origin to the center of the rotation |
quat | quaternion of the rotation |
- Precondition
is_control_vertex(vd)
-
quad
represents a rotation
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Sets the alpha coefficient that determines the weight of the bending term (rotation smoothness) for the SRE-ARAP deformation technique.
The range of values can be from 0 to infinity. When alpha=0, the method reverts to ARAP. When alpha is increased, neighboring rotations become similar to each other, where alpha=infinity results in a global rigid transformation of the ROI. The value of alpha depends on the surface area and shape. Since alpha is not too sensitive, it can be tweaked in most cases by multiplying it by powers of 10. The default value for alpha is 0.02.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Sets the target position of a control vertex.
- Parameters
-
vd | the control vertex the target position is set |
target_position | the new target position |
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Sets the tolerance of the convergence used in deform()
.
If tolerance==0
, no energy based termination criteria is used (preventing to do the energy computation at each iteration step)
tolerance >
\(|\mathrm{energy}(m_i) - \mathrm{energy}(m_{i-1})| / \mathrm{energy}(m_i)\) will be used as a termination criterium.
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
Returns the target position of a control vertex.
- Parameters
-
- Precondition
is_control_vertex(vd)
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
template<class InputIterator , class Vect >
Equivalent to calling the overload taking only one control vertex, for each vertex in the range [begin,end[
.
- Template Parameters
-
InputIterator | input iterator type with vertex_descriptor as value type |
Vect | is a 3D vector class, with Vect(double x,double y, double z) being a constructor from its Cartesian coordinates and double Vect::operator[](int i) with i=0,1 or 2 returning its Cartesian coordinates. |
- Parameters
-
begin | first iterator of the range of vertices |
end | past-the-end iterator of the range of vertices |
t | translation vector |
template<class TM , class VIM = Default, class HIM = Default, Deformation_algorithm_tag TAG = SPOKES_AND_RIMS, class WC = Default, class ST = Default, class CR = Default, class VPM = Default>
template<class Vect >
Updates the target position of vd
by applying a translation of vector t
.
- Template Parameters
-
Vect | is a 3D vector class, with Vect(double x,double y, double z) being a constructor from its Cartesian coordinates and double Vect::operator[](int i) with i=0,1 or 2 returning its Cartesian coordinates. |
- Parameters
-
vd | a control vertex |
t | translation vector |
- Precondition
is_control_vertex(vd)