quick mael review

This commit is contained in:
Dmitry Anisimov 2021-06-08 13:36:09 +02:00
parent a4b645a6ad
commit cac04ed149
9 changed files with 45 additions and 58 deletions

View File

@ -392,15 +392,12 @@ private:
const FT cotan_k = CGAL::Weights::cotangent(p_j, p_k, p_i, traits);
const Vector_3& a = m_X[face_i];
const double i_entry =
(CGAL::to_double(scalar_product(a, v_ij) * cotan_k)) +
(CGAL::to_double(scalar_product(a, v_ik) * cotan_j));
const double j_entry =
(CGAL::to_double(scalar_product(a, v_jk) * cotan_i)) +
(CGAL::to_double(scalar_product(a, v_ji) * cotan_k));
const double k_entry =
(CGAL::to_double(scalar_product(a, v_ki) * cotan_j)) +
(CGAL::to_double(scalar_product(a, v_kj) * cotan_i));
const double i_entry = (CGAL::to_double(scalar_product(a, v_ij) * cotan_k)) +
(CGAL::to_double(scalar_product(a, v_ik) * cotan_j));
const double j_entry = (CGAL::to_double(scalar_product(a, v_jk) * cotan_i)) +
(CGAL::to_double(scalar_product(a, v_ji) * cotan_k));
const double k_entry = (CGAL::to_double(scalar_product(a, v_ki) * cotan_j)) +
(CGAL::to_double(scalar_product(a, v_kj) * cotan_i));
indexD.add_coef(i, 0, (1./2)*i_entry);
indexD.add_coef(j, 0, (1./2)*j_entry);

View File

@ -449,8 +449,7 @@ private:
const Point_3& position_vj = get(ppmap, vj);
const Point_3& position_vk = get(ppmap, vk);
const NT cot = CGAL::Weights::
cotangent(position_vi, position_vj, position_vk);
const NT cot = CGAL::Weights::cotangent(position_vi, position_vj, position_vk);
put(ctmap, hd, cot);
}

View File

@ -180,15 +180,14 @@ protected:
const Point_3& position_v_j = get(ppmap, *neighbor_vertex_v_j);
vertex_around_target_circulator previous_vertex_v_k = neighbor_vertex_v_j;
previous_vertex_v_k--;
--previous_vertex_v_k;
const Point_3& position_v_k = get(ppmap, *previous_vertex_v_k);
vertex_around_target_circulator next_vertex_v_l = neighbor_vertex_v_j;
next_vertex_v_l++;
++next_vertex_v_l;
const Point_3& position_v_l = get(ppmap, *next_vertex_v_l);
return CGAL::Weights::authalic_weight(
position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
return CGAL::Weights::authalic_weight(position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
}
};

View File

@ -176,15 +176,14 @@ protected:
const Point_3& position_v_j = get(ppmap, *neighbor_vertex_v_j);
vertex_around_target_circulator previous_vertex_v_k = neighbor_vertex_v_j;
previous_vertex_v_k--;
--previous_vertex_v_k;
const Point_3& position_v_k = get(ppmap, *previous_vertex_v_k);
vertex_around_target_circulator next_vertex_v_l = neighbor_vertex_v_j;
next_vertex_v_l++;
++next_vertex_v_l;
const Point_3& position_v_l = get(ppmap, *next_vertex_v_l);
return CGAL::Weights::cotangent_weight(
position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
return CGAL::Weights::cotangent_weight(position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
}
};

View File

@ -636,29 +636,27 @@ private:
Vertex_around_target_circulator<Triangle_mesh> neighbor_vertex_v_j) const
{
const PPM ppmap = get(vertex_point, tmesh);
const Point_3& position_v_i = get(ppmap, main_vertex_v_i);
const Point_3& position_v_j = get(ppmap, *neighbor_vertex_v_j);
const PPM_ref position_v_i = get(ppmap, main_vertex_v_i);
const PPM_ref position_v_j = get(ppmap, *neighbor_vertex_v_j);
const Vector_3 edge = position_v_i - position_v_j;
const NT squared_length = edge * edge;
vertex_around_target_circulator previous_vertex_v_k = neighbor_vertex_v_j;
previous_vertex_v_k--;
const Point_3& position_v_k = get(ppmap, *previous_vertex_v_k);
--previous_vertex_v_k;
const PPM_ref position_v_k = get(ppmap, *previous_vertex_v_k);
vertex_around_target_circulator next_vertex_v_l = neighbor_vertex_v_j;
next_vertex_v_l++;
const Point_3& position_v_l = get(ppmap, *next_vertex_v_l);
++next_vertex_v_l;
const PPM_ref position_v_l = get(ppmap, *next_vertex_v_l);
NT weight = NT(0);
CGAL_assertion(squared_length > NT(0)); // two points are identical!
if (squared_length != NT(0)) {
if(squared_length != NT(0)) {
// This version was commented out to be an alternative weight
// in the original code by authors.
// weight = CGAL::Weights::authalic_weight(
// position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
weight = CGAL::Weights::cotangent_weight(
position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
// weight = CGAL::Weights::authalic_weight(position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
weight = CGAL::Weights::cotangent_weight(position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
}
return weight;
}

View File

@ -393,8 +393,7 @@ private:
const Point_2& p = pk;
const Point_2& q = pi;
const Point_2& r = pj;
const CGAL::Weights::internal::
Tangent_weight_wrapper<NT> tangent_weight(p, q, r);
const CGAL::Weights::internal::Tangent_weight_wrapper<NT> tangent_weight(p, q, r);
// Set w_ij in matrix
const NT w_ij = tangent_weight.get_w_r();

View File

@ -199,15 +199,14 @@ protected:
const Point_3& position_v_j = get(ppmap, *neighbor_vertex_v_j);
vertex_around_target_circulator previous_vertex_v_k = neighbor_vertex_v_j;
previous_vertex_v_k--;
--previous_vertex_v_k;
const Point_3& position_v_k = get(ppmap, *previous_vertex_v_k);
vertex_around_target_circulator next_vertex_v_l = neighbor_vertex_v_j;
next_vertex_v_l++;
++next_vertex_v_l;
const Point_3& position_v_l = get(ppmap, *next_vertex_v_l);
return CGAL::Weights::tangent_weight(
position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
return CGAL::Weights::tangent_weight(position_v_k, position_v_j, position_v_l, position_v_i) / NT(2);
}
};

View File

@ -722,24 +722,23 @@ private:
const Point_3& p = pk;
const Point_3& q = pi;
const Point_3& r = pj;
const CGAL::Weights::internal::
Tangent_weight_wrapper<NT> tangent_weight(p, q, r);
const CGAL::Weights::internal::Tangent_weight_wrapper<NT> tangent_weight(p, q, r);
// Set w_ij in matrix
const NT w_ij = tangent_weight.get_w_r();
M.add_coef(2 * i, 2 * j, w_ij);
M.add_coef(2 * i + 1, 2 * j + 1, w_ij);
M.add_coef(2*i, 2*j, w_ij);
M.add_coef(2*i + 1, 2*j + 1, w_ij);
// Set w_ik in matrix
const NT w_ik = tangent_weight.get_w_p();
M.add_coef(2 * i, 2 * k, w_ik);
M.add_coef(2 * i + 1, 2 * k + 1, w_ik);
M.add_coef(2*i, 2*k, w_ik);
M.add_coef(2*i + 1, 2*k + 1, w_ik);
// Add to w_ii (w_ii = - sum w_ij)
const NT w_ii = - w_ij - w_ik;
M.add_coef(2 * i, 2 * i, w_ii);
M.add_coef(2 * i + 1, 2 * i + 1, w_ii);
M.add_coef(2*i, 2*i, w_ii);
M.add_coef(2*i + 1, 2*i + 1, w_ii);
}
// Compute the mean value Laplacian matrix.
@ -789,20 +788,20 @@ private:
const NT w_ij = NT(2) * cotangent_weight(hd, mesh, pmap);
// ij
M.set_coef(2 * i, 2 * j, w_ij, true /* new coef */);
M.set_coef(2 * i + 1, 2 * j + 1, w_ij, true /* new coef */);
M.set_coef(2*i, 2*j, w_ij, true /* new coef */);
M.set_coef(2*i + 1, 2*j + 1, w_ij, true /* new coef */);
// ji
M.set_coef(2 * j, 2 * i, w_ij, true /* new coef */);
M.set_coef(2 * j + 1, 2 * i + 1, w_ij, true /* new coef */);
M.set_coef(2*j, 2*i, w_ij, true /* new coef */);
M.set_coef(2*j + 1, 2*i + 1, w_ij, true /* new coef */);
// ii
M.add_coef(2 * i, 2 * i, - w_ij);
M.add_coef(2 * i + 1, 2 * i + 1, - w_ij);
M.add_coef(2*i, 2*i, - w_ij);
M.add_coef(2*i + 1, 2*i + 1, - w_ij);
// jj
M.add_coef(2 * j, 2 * j, - w_ij);
M.add_coef(2 * j + 1, 2 * j + 1, - w_ij);
M.add_coef(2*j, 2*j, - w_ij);
M.add_coef(2*j + 1, 2*j + 1, - w_ij);
}
}

View File

@ -223,8 +223,7 @@ public:
typedef typename boost::graph_traits<mTriangleMesh>::edge_iterator edge_iterator;
// Get weight from the weight interface.
typedef CGAL::Weights::internal::
Cotangent_weight_wrapper<mTriangleMesh> Weight_calculator;
typedef CGAL::Weights::internal::Cotangent_weight_wrapper<mTriangleMesh> Weight_calculator;
typedef internal::Curve_skeleton<mTriangleMesh,
VertexIndexMap,
@ -372,14 +371,14 @@ public:
Mean_curvature_flow_skeletonization(const TriangleMesh& tmesh,
VertexPointMap vertex_point_map,
const Traits& traits = Traits())
: m_traits(traits), m_weight_calculator(true)
: m_traits(traits), m_weight_calculator(true /* use_secure_version */)
{
init(tmesh, vertex_point_map);
}
Mean_curvature_flow_skeletonization(const TriangleMesh& tmesh,
const Traits& traits = Traits())
: m_traits(traits), m_weight_calculator(true)
: m_traits(traits), m_weight_calculator(true /* use_secure_version */)
{
init(tmesh);
}
@ -887,8 +886,7 @@ private:
m_edge_weight.reserve(2 * num_edges(m_tmesh));
for(halfedge_descriptor hd : halfedges(m_tmesh))
{
m_edge_weight.push_back(
m_weight_calculator(hd, m_tmesh, m_tmesh_point_pmap));
m_edge_weight.push_back(m_weight_calculator(hd, m_tmesh, m_tmesh_point_pmap));
}
}