mirror of https://github.com/CGAL/cgal
Re-united some function bodies with their declaration
This commit is contained in:
parent
9881f814a1
commit
f3671d45e1
|
|
@ -309,17 +309,121 @@ private:
|
||||||
/// Utility for setup_triangle_relations():
|
/// Utility for setup_triangle_relations():
|
||||||
/// Computes the coordinates of the vertices of a triangle
|
/// Computes the coordinates of the vertices of a triangle
|
||||||
/// in a local 2D orthonormal basis of the triangle's plane.
|
/// in a local 2D orthonormal basis of the triangle's plane.
|
||||||
void project_triangle(const Point_3& p0, const Point_3& p1, const Point_3& p2, // in
|
void project_triangle(const Point_3& p0, const Point_3& p1, const Point_3& p2, // in
|
||||||
Point_2& z0, Point_2& z1, Point_2& z2) const; // out
|
Point_2& z0, Point_2& z1, Point_2& z2) const // out
|
||||||
|
{
|
||||||
|
Vector_3 X = p1 - p0;
|
||||||
|
NT X_norm = std::sqrt(X * X);
|
||||||
|
if(X_norm != 0.0)
|
||||||
|
X = X / X_norm;
|
||||||
|
|
||||||
|
Vector_3 Z = CGAL::cross_product(X, p2 - p0);
|
||||||
|
NT Z_norm = std::sqrt(Z * Z);
|
||||||
|
if(Z_norm != 0.0)
|
||||||
|
Z = Z / Z_norm;
|
||||||
|
|
||||||
|
Vector_3 Y = CGAL::cross_product(Z, X);
|
||||||
|
|
||||||
|
const Point_3& O = p0;
|
||||||
|
|
||||||
|
NT x0 = 0;
|
||||||
|
NT y0 = 0;
|
||||||
|
NT x1 = std::sqrt( (p1 - O)*(p1 - O) );
|
||||||
|
NT y1 = 0;
|
||||||
|
NT x2 = (p2 - O) * X;
|
||||||
|
NT y2 = (p2 - O) * Y;
|
||||||
|
|
||||||
|
z0 = Point_2(x0, y0);
|
||||||
|
z1 = Point_2(x1, y1);
|
||||||
|
z2 = Point_2(x2, y2);
|
||||||
|
}
|
||||||
|
|
||||||
/// Create two lines in the linear system per triangle (one for u, one for v).
|
/// Create two lines in the linear system per triangle (one for u, one for v).
|
||||||
///
|
///
|
||||||
/// \pre vertices must be indexed.
|
/// \pre vertices of `mesh` must be indexed.
|
||||||
|
// Implementation note: LSCM equation is:
|
||||||
|
// (Z1 - Z0)(U2 - U0) = (Z2 - Z0)(U1 - U0)
|
||||||
|
// where Uk = uk + i.v_k is the complex number corresponding to (u,v) coords
|
||||||
|
// Zk = xk + i.yk is the complex number corresponding to local (x,y) coords
|
||||||
|
// cool: no divide with this expression; makes it more numerically stable
|
||||||
|
// in presence of degenerate triangles
|
||||||
template <typename VertexIndexMap >
|
template <typename VertexIndexMap >
|
||||||
Error_code setup_triangle_relations(LeastSquaresSolver& solver,
|
Error_code setup_triangle_relations(LeastSquaresSolver& solver,
|
||||||
const TriangleMesh& mesh,
|
const TriangleMesh& mesh,
|
||||||
face_descriptor facet,
|
face_descriptor facet,
|
||||||
VertexIndexMap vimap) const;
|
VertexIndexMap vimap) const
|
||||||
|
{
|
||||||
|
const PPM ppmap = get(vertex_point, mesh);
|
||||||
|
|
||||||
|
// Get the 3 vertices of the triangle
|
||||||
|
vertex_descriptor v0, v1, v2;
|
||||||
|
halfedge_descriptor h0 = halfedge(facet, mesh);
|
||||||
|
v0 = target(h0, mesh);
|
||||||
|
halfedge_descriptor h1 = next(h0, mesh);
|
||||||
|
v1 = target(h1, mesh);
|
||||||
|
halfedge_descriptor h2 = next(h1, mesh);
|
||||||
|
v2 = target(h2, mesh);
|
||||||
|
|
||||||
|
// Get the vertices index
|
||||||
|
int id0 = get(vimap, v0);
|
||||||
|
int id1 = get(vimap, v1);
|
||||||
|
int id2 = get(vimap, v2);
|
||||||
|
|
||||||
|
// Get the vertices position
|
||||||
|
const Point_3& p0 = get(ppmap, v0);
|
||||||
|
const Point_3& p1 = get(ppmap, v1);
|
||||||
|
const Point_3& p2 = get(ppmap, v2);
|
||||||
|
|
||||||
|
// Computes the coordinates of the vertices of a triangle
|
||||||
|
// in a local 2D orthonormal basis of the triangle's plane.
|
||||||
|
Point_2 z0, z1, z2;
|
||||||
|
project_triangle(p0, p1, p2, //in
|
||||||
|
z0, z1, z2); // out
|
||||||
|
Vector_2 z01 = z1 - z0;
|
||||||
|
Vector_2 z02 = z2 - z0;
|
||||||
|
NT a = z01.x();
|
||||||
|
NT b = z01.y();
|
||||||
|
NT c = z02.x();
|
||||||
|
NT d = z02.y();
|
||||||
|
CGAL_assertion(b == 0.0);
|
||||||
|
|
||||||
|
// Create two lines in the linear system per triangle (one for u, one for v)
|
||||||
|
// LSCM equation is:
|
||||||
|
// (Z1 - Z0)(U2 - U0) = (Z2 - Z0)(U1 - U0)
|
||||||
|
// where Uk = uk + i.v_k is the complex number corresponding to (u,v) coords
|
||||||
|
// Zk = xk + i.yk is the complex number corresponding to local (x,y) coords
|
||||||
|
//
|
||||||
|
// Note : 2*index --> u
|
||||||
|
// 2*index + 1 --> v
|
||||||
|
int u0_id = 2*id0 ;
|
||||||
|
int v0_id = 2*id0 + 1;
|
||||||
|
int u1_id = 2*id1 ;
|
||||||
|
int v1_id = 2*id1 + 1;
|
||||||
|
int u2_id = 2*id2 ;
|
||||||
|
int v2_id = 2*id2 + 1;
|
||||||
|
|
||||||
|
// Real part
|
||||||
|
// Note: b = 0
|
||||||
|
solver.begin_row();
|
||||||
|
solver.add_coefficient(u0_id, -a+c);
|
||||||
|
solver.add_coefficient(v0_id, b-d);
|
||||||
|
solver.add_coefficient(u1_id, -c);
|
||||||
|
solver.add_coefficient(v1_id, d);
|
||||||
|
solver.add_coefficient(u2_id, a);
|
||||||
|
solver.end_row();
|
||||||
|
//
|
||||||
|
// Imaginary part
|
||||||
|
// Note: b = 0
|
||||||
|
solver.begin_row();
|
||||||
|
solver.add_coefficient(u0_id, -b+d);
|
||||||
|
solver.add_coefficient(v0_id, -a+c);
|
||||||
|
solver.add_coefficient(u1_id, -d);
|
||||||
|
solver.add_coefficient(v1_id, -c);
|
||||||
|
solver.add_coefficient(v2_id, a);
|
||||||
|
solver.end_row();
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
// Private accessors
|
// Private accessors
|
||||||
private:
|
private:
|
||||||
|
|
@ -338,134 +442,7 @@ private:
|
||||||
Solver_traits m_linearAlgebra;
|
Solver_traits m_linearAlgebra;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Utility for setup_triangle_relations():
|
} // namespace Surface_mesh_parameterization
|
||||||
// Computes the coordinates of the vertices of a triangle
|
|
||||||
// in a local 2D orthonormal basis of the triangle's plane.
|
|
||||||
template<class TriangleMesh, class Border_param, class Sparse_LA>
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
LSCM_parameterizer_3<TriangleMesh, Border_param, Sparse_LA>::
|
|
||||||
project_triangle(const Point_3& p0, const Point_3& p1, const Point_3& p2, // in
|
|
||||||
Point_2& z0, Point_2& z1, Point_2& z2) const // out
|
|
||||||
{
|
|
||||||
Vector_3 X = p1 - p0;
|
|
||||||
NT X_norm = std::sqrt(X * X);
|
|
||||||
if(X_norm != 0.0)
|
|
||||||
X = X / X_norm;
|
|
||||||
|
|
||||||
Vector_3 Z = CGAL::cross_product(X, p2 - p0);
|
|
||||||
NT Z_norm = std::sqrt(Z * Z);
|
|
||||||
if(Z_norm != 0.0)
|
|
||||||
Z = Z / Z_norm;
|
|
||||||
|
|
||||||
Vector_3 Y = CGAL::cross_product(Z, X);
|
|
||||||
|
|
||||||
const Point_3& O = p0;
|
|
||||||
|
|
||||||
NT x0 = 0;
|
|
||||||
NT y0 = 0;
|
|
||||||
NT x1 = std::sqrt( (p1 - O)*(p1 - O) );
|
|
||||||
NT y1 = 0;
|
|
||||||
NT x2 = (p2 - O) * X;
|
|
||||||
NT y2 = (p2 - O) * Y;
|
|
||||||
|
|
||||||
z0 = Point_2(x0, y0);
|
|
||||||
z1 = Point_2(x1, y1);
|
|
||||||
z2 = Point_2(x2, y2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create two lines in the linear system per triangle (one for u, one for v).
|
|
||||||
///
|
|
||||||
/// \pre vertices of `mesh` must be indexed.
|
|
||||||
// Implementation note: LSCM equation is:
|
|
||||||
// (Z1 - Z0)(U2 - U0) = (Z2 - Z0)(U1 - U0)
|
|
||||||
// where Uk = uk + i.v_k is the complex number corresponding to (u,v) coords
|
|
||||||
// Zk = xk + i.yk is the complex number corresponding to local (x,y) coords
|
|
||||||
// cool: no divide with this expression; makes it more numerically stable
|
|
||||||
// in presence of degenerate triangles
|
|
||||||
template<class TriangleMesh, class Border_param, class Sparse_LA>
|
|
||||||
template <typename VertexIndexMap>
|
|
||||||
inline
|
|
||||||
Error_code
|
|
||||||
LSCM_parameterizer_3<TriangleMesh, Border_param, Sparse_LA>::
|
|
||||||
setup_triangle_relations(LeastSquaresSolver& solver,
|
|
||||||
const TriangleMesh& mesh,
|
|
||||||
face_descriptor facet,
|
|
||||||
VertexIndexMap vimap) const
|
|
||||||
{
|
|
||||||
const PPM ppmap = get(vertex_point, mesh);
|
|
||||||
|
|
||||||
// Get the 3 vertices of the triangle
|
|
||||||
vertex_descriptor v0, v1, v2;
|
|
||||||
halfedge_descriptor h0 = halfedge(facet, mesh);
|
|
||||||
v0 = target(h0, mesh);
|
|
||||||
halfedge_descriptor h1 = next(h0, mesh);
|
|
||||||
v1 = target(h1, mesh);
|
|
||||||
halfedge_descriptor h2 = next(h1, mesh);
|
|
||||||
v2 = target(h2, mesh);
|
|
||||||
|
|
||||||
// Get the vertices index
|
|
||||||
int id0 = get(vimap, v0);
|
|
||||||
int id1 = get(vimap, v1);
|
|
||||||
int id2 = get(vimap, v2);
|
|
||||||
|
|
||||||
// Get the vertices position
|
|
||||||
const Point_3& p0 = get(ppmap, v0);
|
|
||||||
const Point_3& p1 = get(ppmap, v1);
|
|
||||||
const Point_3& p2 = get(ppmap, v2);
|
|
||||||
|
|
||||||
// Computes the coordinates of the vertices of a triangle
|
|
||||||
// in a local 2D orthonormal basis of the triangle's plane.
|
|
||||||
Point_2 z0, z1, z2;
|
|
||||||
project_triangle(p0, p1, p2, //in
|
|
||||||
z0, z1, z2); // out
|
|
||||||
Vector_2 z01 = z1 - z0;
|
|
||||||
Vector_2 z02 = z2 - z0;
|
|
||||||
NT a = z01.x();
|
|
||||||
NT b = z01.y();
|
|
||||||
NT c = z02.x();
|
|
||||||
NT d = z02.y();
|
|
||||||
CGAL_assertion(b == 0.0);
|
|
||||||
|
|
||||||
// Create two lines in the linear system per triangle (one for u, one for v)
|
|
||||||
// LSCM equation is:
|
|
||||||
// (Z1 - Z0)(U2 - U0) = (Z2 - Z0)(U1 - U0)
|
|
||||||
// where Uk = uk + i.v_k is the complex number corresponding to (u,v) coords
|
|
||||||
// Zk = xk + i.yk is the complex number corresponding to local (x,y) coords
|
|
||||||
//
|
|
||||||
// Note : 2*index --> u
|
|
||||||
// 2*index + 1 --> v
|
|
||||||
int u0_id = 2*id0 ;
|
|
||||||
int v0_id = 2*id0 + 1;
|
|
||||||
int u1_id = 2*id1 ;
|
|
||||||
int v1_id = 2*id1 + 1;
|
|
||||||
int u2_id = 2*id2 ;
|
|
||||||
int v2_id = 2*id2 + 1;
|
|
||||||
|
|
||||||
// Real part
|
|
||||||
// Note: b = 0
|
|
||||||
solver.begin_row();
|
|
||||||
solver.add_coefficient(u0_id, -a+c);
|
|
||||||
solver.add_coefficient(v0_id, b-d);
|
|
||||||
solver.add_coefficient(u1_id, -c);
|
|
||||||
solver.add_coefficient(v1_id, d);
|
|
||||||
solver.add_coefficient(u2_id, a);
|
|
||||||
solver.end_row();
|
|
||||||
//
|
|
||||||
// Imaginary part
|
|
||||||
// Note: b = 0
|
|
||||||
solver.begin_row();
|
|
||||||
solver.add_coefficient(u0_id, -b+d);
|
|
||||||
solver.add_coefficient(v0_id, -a+c);
|
|
||||||
solver.add_coefficient(u1_id, -d);
|
|
||||||
solver.add_coefficient(v1_id, -c);
|
|
||||||
solver.add_coefficient(v2_id, a);
|
|
||||||
solver.end_row();
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue