Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sloriot committed Nov 13, 2023
1 parent 21b9ad7 commit eb648c7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ The implementation is generic in terms of mesh data structure. It can be used on
`Polyhedron_3` and other polygonal mesh structures based on the concept `FaceGraph`.

These computations are performed using (on all vertices of the mesh) `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()`
where function named parameters are used to select the curvatures (and possibly directions) to be computed. An overlay with the same name
where function named parameters are used to select the curvatures (and possibly directions) to be computed. An overload function with the same name
but taking a given vertex is also available in case the computation should be done only for that vertex.

\subsection ICCResults Results & Performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,26 +378,6 @@ std::array<typename GT::FT, 3 * 3> interpolated_corrected_anisotropic_measure_fa
return muXY;
}

//template<typename GT>
//typename GT::FT triangle_in_ball_ratio(const typename GT::Vector_3 x1,
// const typename GT::Vector_3 x2,
// const typename GT::Vector_3 x3,
// const typename GT::FT r,
// const typename GT::Vector_3 c,
// const std::size_t res = 3)
//{
// const typename GT::FT R = r * r;
// const typename GT::FT acc = 1.0 / res;
// std::size_t samples_in = 0;
// for (typename GT::FT alpha = acc / 3; alpha < 1; alpha += acc)
// for (typename GT::FT beta = acc / 3; beta < 1 - alpha; beta += acc)
// {
// if ((alpha * x1 + beta * x2 + (1 - alpha - beta) * x3 - c).squared_length() < R)
// samples_in++;
// }
// return samples_in / (typename GT::FT)(res * (res + 1) / 2);
//}

template<typename GT>
typename GT::FT face_in_ball_ratio(const std::vector<typename GT::Vector_3>& x,
const typename GT::FT r,
Expand Down Expand Up @@ -490,8 +470,8 @@ Vertex_measures<GT> interpolated_corrected_measures_one_vertex_no_radius(
const VNM vnm
)
{
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor Face_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor Vertex_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor face_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor;
typedef typename GT::Point_3 Point_3;
typedef typename GT::Vector_3 Vector_3;
typedef typename GT::FT FT;
Expand All @@ -502,14 +482,14 @@ Vertex_measures<GT> interpolated_corrected_measures_one_vertex_no_radius(
std::vector<Vector_3> u;

// compute for each face around the vertex (except the null (boundary) face)
for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) {
for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) {
if (f != boost::graph_traits<PolygonMesh>::null_face())
{
// looping over vertices in face to get point coordinates and normal vectors
for (Vertex_descriptor vi : vertices_around_face(halfedge(f, pmesh), pmesh))
for (vertex_descriptor vi : vertices_around_face(halfedge(f, pmesh), pmesh))
{
Point_3 pi = get(vpm, vi);
Vector_3 ui = get(vnm, vi);
const Point_3& pi = get(vpm, vi);
const Vector_3& ui = get(vnm, vi);
x.push_back(Vector_3(pi.x(), pi.y(), pi.z()));
u.push_back(ui);
}
Expand Down Expand Up @@ -550,22 +530,22 @@ Vertex_measures<GT> interpolated_corrected_measures_one_vertex(
const VNM vnm
)
{
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor Face_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor Vertex_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor face_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor;
typedef typename GT::Point_3 Point_3;
typedef typename GT::Vector_3 Vector_3;
typedef typename GT::FT FT;

// the ball expansion is done using a BFS traversal from the vertex
std::queue<Face_descriptor> bfs_queue;
std::unordered_set<Face_descriptor> bfs_visited;
std::queue<face_descriptor> bfs_queue;
std::unordered_set<face_descriptor> bfs_visited;

Vertex_measures<GT> vertex_measures;

Point_3 vp = get(vpm, v);
Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z());
const Point_3& vp = get(vpm, v);
Vector_3 c(vp.x(), vp.y(), vp.z());

for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) {
for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) {
if (f != boost::graph_traits<PolygonMesh>::null_face())
{
bfs_queue.push(f);
Expand All @@ -575,14 +555,14 @@ Vertex_measures<GT> interpolated_corrected_measures_one_vertex(
std::vector<Vector_3> x;
std::vector<Vector_3> u;
while (!bfs_queue.empty()) {
Face_descriptor fi = bfs_queue.front();
face_descriptor fi = bfs_queue.front();
bfs_queue.pop();

// looping over vertices in face to get point coordinates and normal vectors
for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh))
for (vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh))
{
Point_3 pi = get(vpm, vi);
Vector_3 ui = get(vnm, vi);
const Point_3& pi = get(vpm, vi);
const Vector_3& ui = get(vnm, vi);
x.push_back(Vector_3(pi.x(), pi.y(), pi.z()));
u.push_back(ui);
}
Expand All @@ -609,7 +589,7 @@ Vertex_measures<GT> interpolated_corrected_measures_one_vertex(
vertex_measures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i];
}

for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh))
for (face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh))
{
if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits<PolygonMesh>::null_face())
{
Expand Down Expand Up @@ -724,7 +704,7 @@ template<typename PolygonMesh,

if (is_principal_curvatures_and_directions_selected) {
// compute the principal curvatures and directions from the anisotropic measures
const typename GT::Vector_3 v_normal = get(vnm, v);
const typename GT::Vector_3& v_normal = get(vnm, v);
const Principal_curvatures_and_directions<GT> principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures<GT>(
vertex_measures.anisotropic_measure,
vertex_measures.area_measure,
Expand All @@ -747,8 +727,8 @@ class Interpolated_corrected_curvatures_computer

typedef typename boost::graph_traits<PolygonMesh>::halfedge_descriptor Halfedge_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::edge_descriptor Edge_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor Face_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor Vertex_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor face_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor;

typedef typename GetVertexPointMap<PolygonMesh, NamedParameters>::const_type Vertex_position_map;

Expand All @@ -758,7 +738,7 @@ class Interpolated_corrected_curvatures_computer
NamedParameters,
Default_vector_map>::type Vertex_normal_map;

typedef Constant_property_map<Vertex_descriptor, FT> Default_scalar_map;
typedef Constant_property_map<vertex_descriptor, FT> Default_scalar_map;
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_mean_curvature_map_t,
NamedParameters,
Default_scalar_map>::type Vertex_mean_curvature_map;
Expand All @@ -767,7 +747,7 @@ class Interpolated_corrected_curvatures_computer
NamedParameters,
Default_scalar_map>::type Vertex_Gaussian_curvature_map;

typedef Constant_property_map<Vertex_descriptor, Principal_curvatures_and_directions<GT>> Default_principal_map;
typedef Constant_property_map<vertex_descriptor, Principal_curvatures_and_directions<GT>> Default_principal_map;
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_principal_curvatures_and_directions_map_t,
NamedParameters,
Default_principal_map>::type Vertex_principal_curvatures_and_directions_map;
Expand Down Expand Up @@ -867,12 +847,15 @@ class Interpolated_corrected_curvatures_computer
{
std::vector<Vector_3> x;
std::vector<Vector_3> u;
// minimal number of vertices per face is 3
x.reserve(3);
u.reserve(3);

for (Face_descriptor f : faces(pmesh))
for (face_descriptor f : faces(pmesh))
{
for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh))
for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh))
{
Point_3 p = get(vpm, v);
const Point_3& p = get(vpm, v);
x.push_back(Vector_3(p.x(), p.y(), p.z()));
u.push_back(get(vnm, v));
}
Expand All @@ -893,12 +876,12 @@ class Interpolated_corrected_curvatures_computer
}

// expand the measures of the faces incident to v
Vertex_measures<GT> expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v)
Vertex_measures<GT> expand_interpolated_corrected_measure_vertex_no_radius(vertex_descriptor v)
{
Vertex_measures<GT> vertex_measures;

// add the measures of the faces incident to v (excluding the null (boundary) face)
for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) {
for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) {
if (f == boost::graph_traits<PolygonMesh>::null_face())
continue;

Expand All @@ -923,34 +906,34 @@ class Interpolated_corrected_curvatures_computer
}

// expand the measures of the faces inside the ball of radius r around v
Vertex_measures<GT> expand_interpolated_corrected_measure_vertex(Vertex_descriptor v)
Vertex_measures<GT> expand_interpolated_corrected_measure_vertex(vertex_descriptor v)
{
// the ball expansion is done using a BFS traversal from the vertex
std::queue<Face_descriptor> bfs_queue;
std::unordered_set<Face_descriptor> bfs_visited;
std::queue<face_descriptor> bfs_queue;
std::unordered_set<face_descriptor> bfs_visited;

Point_3 vp = get(vpm, v);
Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z());
const Point_3& vp = get(vpm, v);
const Vector_3& c = Vector_3(vp.x(), vp.y(), vp.z());

Vertex_measures<GT> vertex_measures;

// add the measures of the faces incident to v (excluding the null (boundary) face)
for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) {
for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) {
if (f != boost::graph_traits<PolygonMesh>::null_face())
{
bfs_queue.push(f);
bfs_visited.insert(f);
}
}
while (!bfs_queue.empty()) {
Face_descriptor fi = bfs_queue.front();
face_descriptor fi = bfs_queue.front();
bfs_queue.pop();

// looping over vertices in face to get point coordinates
std::vector<Vector_3> x;
for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh))
for (vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh))
{
Point_3 pi = get(vpm, vi);
const Point_3& pi = get(vpm, vi);
x.push_back(Vector_3(pi.x(), pi.y(), pi.z()));
}

Expand All @@ -976,7 +959,7 @@ class Interpolated_corrected_curvatures_computer
vertex_measures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i];
}

for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh))
for (face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh))
{
if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits<PolygonMesh>::null_face())
{
Expand All @@ -992,7 +975,7 @@ class Interpolated_corrected_curvatures_computer
void compute_selected_curvatures() {
interpolated_corrected_selected_measures_all_faces();

for (Vertex_descriptor v : vertices(pmesh))
for (vertex_descriptor v : vertices(pmesh))
{
// expand the computed measures (on faces) to the vertices
Vertex_measures<GT> vertex_measures = (is_negative(ball_radius)) ?
Expand All @@ -1015,7 +998,7 @@ class Interpolated_corrected_curvatures_computer

if (is_principal_curvatures_and_directions_selected) {
// compute the principal curvatures and directions from the anisotropic measure
const Vector_3 v_normal = get(vnm, v);
const Vector_3& v_normal = get(vnm, v);
const Principal_curvatures_and_directions<GT> principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures<GT>(
vertex_measures.anisotropic_measure,
vertex_measures.area_measure,
Expand Down

0 comments on commit eb648c7

Please sign in to comment.