Skip to content

Commit

Permalink
Rename function and move it to PMP::measure
Browse files Browse the repository at this point in the history
  • Loading branch information
afabri committed Jan 8, 2025
1 parent 3767bd4 commit 7e298c1
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 99 deletions.
4 changes: 4 additions & 0 deletions Installation/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

- Introduces two traits decorators, namely `Arr_tracing_traits_2` and `Arr_counting_traits_2`, which can be used to extract debugging and informative metadata about the traits in use while a program is being executed.

### [Polygon Mesh Processing](https://doc.cgal.org/6.0/Manual/packages.html#PkgPolygonMeshProcessing)

- Added the function `minmax_dihedral_angle()` to identify the sharpest edges of a triangle mesh

## [Release 6.0.1](https://github.com/CGAL/cgal/releases/tag/v6.0.1)

### [Poisson Surface Reconstruction](https://doc.cgal.org/6.0.1/Manual/packages.html#PkgPoissonSurfaceReconstruction3)
Expand Down
1 change: 0 additions & 1 deletion Lab/demo/Lab/Scene_surface_mesh_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
#include <CGAL/Polygon_mesh_processing/repair_polygon_soup.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include "triangulate_primitive.h"

#include <CGAL/IO/OBJ.h>
Expand Down
3 changes: 2 additions & 1 deletion Lab/demo/Lab/include/CGAL/statistics_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <CGAL/Distance_3/Point_3_Point_3.h>
#include <CGAL/Distance_3/Point_3_Line_3.h>
#include <CGAL/Polygon_mesh_processing/repair.h>
#include <CGAL/Polygon_mesh_processing/measure.h>

#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
Expand Down Expand Up @@ -84,7 +85,7 @@ void angles(Mesh* poly, double& mini, double& maxi, double& ave)
template<typename Mesh>
void dihedral_angles(Mesh* poly, double& minda, double& maxda)
{
auto da = CGAL::Polygon_mesh_processing::detect_sharp_edges(*poly);
auto da = CGAL::Polygon_mesh_processing::minmax_dihedral_angle(*poly);
minda = da.first.second;
maxda = da.second.second;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage.
- \link PMP_measure_grp `CGAL::Polygon_mesh_processing::longest_border()` \endlink
- \link PMP_measure_grp `CGAL::Polygon_mesh_processing::centroid()` \endlink
- \link PMP_measure_grp `CGAL::Polygon_mesh_processing::match_faces()` \endlink
- \link PMP_measure_grp `CGAL::Polygon_mesh_processing::minmax_dihedral_angle()` \endlink

\cgalCRPSection{Feature Detection Functions}
- `CGAL::Polygon_mesh_processing::sharp_edges_segmentation()`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>

#include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>

Expand All @@ -25,7 +26,7 @@ int main(int argc, char* argv[])
return 1;
}

std::pair<std::pair<edge_descriptor,double>, std::pair<edge_descriptor,double>> res = PMP::detect_sharp_edges(mesh);
std::pair<std::pair<edge_descriptor,double>, std::pair<edge_descriptor,double>> res = PMP::minmax_dihedral_angle(mesh);

std::cout << "Sharpest dihedral angles: " << res.first.second << " " << res.second.second << std::endl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,102 +306,6 @@ void detect_sharp_edges(const PolygonMesh& pmesh,
get_parameter(np, internal_np::vertex_feature_degree));
}

/*!
* \ingroup PMP_detect_features_grp
*
* \brief detects the edges with the smallest and largest dihedral angle in degrees.
*
* \tparam TriangleMesh a model of `HalfedgeListGraph`
* \tparam FT a number type. It is
* either deduced from the `geom_traits` \ref bgl_namedparameters "Named Parameters" if provided,
* or from the geometric traits class deduced from the point property map
* of `TriangleMesh`.
* \tparam EdgeIsFeatureMap a model of `ReadWritePropertyMap` with `boost::graph_traits<TriangleMesh>::%edge_descriptor`
* as key type and `bool` as value type. It must be default constructible.
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
*
* \param pmesh the polygon mesh
* \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below.
* `GT` stands for the type of the object provided to the named parameter `geom_traits()`.
*
* \cgalNamedParamsBegin
*
* \cgalParamNBegin{vertex_point_map}
* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.}
* \cgalParamType{a class model of `ReadablePropertyMap` with
* `boost::graph_traits<TriangleMesh>::%vertex_descriptor`
* as key type and `GT::Point_3` as value type.}
* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.}
* \cgalParamExtra{If this parameter is omitted, an internal property map for
* `CGAL::vertex_point_t` must be available in `TriangleMesh`.}
* \cgalParamNEnd
* \cgalParamNBegin{geom_traits}
* \cgalParamDescription{an instance of a geometric traits class}
* \cgalParamType{a class model of `Kernel`}
* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`}
* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.}
* \cgalParamNEnd
* \cgalNamedParamsEnd
*
* \see `sharp_edges_segmentation()`
*/
#ifdef DOXYGEN_RUNNING
template<typename TriangleMesh, typename FT,
typename CGAL_NP_TEMPLATE_PARAMETERS>
#else
template<typename TriangleMesh,
typename CGAL_NP_TEMPLATE_PARAMETERS>
#endif
#ifdef DOXYGEN_RUNNING
std::pair<std::pair<edge_descriptor,FT>, std::pair<edge_descriptor,FT>>
#else
std::pair<
std::pair<typename boost::graph_traits<TriangleMesh>::edge_descriptor, typename GetGeomTraits<TriangleMesh, CGAL_NP_CLASS>::type::FT>,
std::pair<typename boost::graph_traits<TriangleMesh>::edge_descriptor, typename GetGeomTraits<TriangleMesh, CGAL_NP_CLASS>::type::FT>
>
#endif
detect_sharp_edges(const TriangleMesh& pmesh,
const CGAL_NP_CLASS& np = parameters::default_values())
{
using parameters::choose_parameter;
using parameters::get_parameter;

// extract types from NPs
typedef typename GetGeomTraits<TriangleMesh, CGAL_NP_CLASS>::type GT;
// GT gt = choose_parameter<GT>(get_parameter(np, internal_np::geom_traits));

typedef typename GetVertexPointMap<TriangleMesh, CGAL_NP_CLASS>::const_type VPM;
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
get_const_property_map(boost::vertex_point, pmesh));

typedef typename GT::FT FT;
typedef typename boost::graph_traits<TriangleMesh>::edge_descriptor edge_descriptor;
typedef typename boost::graph_traits<TriangleMesh>::halfedge_descriptor halfedge_descriptor;
typedef typename boost::graph_traits<TriangleMesh>::vertex_descriptor vertex_descriptor;
edge_descriptor low, high;
FT lo(200), hi(-200);
for (edge_descriptor e : edges(pmesh)){
if(! is_border(e,pmesh)){
halfedge_descriptor h = halfedge(e,pmesh);
vertex_descriptor p = source(h,pmesh);
vertex_descriptor q = target(h,pmesh);
vertex_descriptor r = target(next(h,pmesh),pmesh);
vertex_descriptor s = target(next(opposite(h,pmesh),pmesh),pmesh);
FT da = approximate_dihedral_angle(get(vpm,p),get(vpm,q),get(vpm,r),get(vpm,s));
if(da < lo){
low = e;
lo = da;
}
if(da > hi){
high = e;
hi = da;
}
}
}
return std::make_pair(std::make_pair(low, lo),std::make_pair(high,hi));
}

/*!
* \ingroup PMP_detect_features_grp
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,103 @@ void match_faces(const PolygonMesh1& m1,
}
}


/*!
* \ingroup PMP_measure_grp
*
* \brief detects the edges with the smallest and largest dihedral angle in degrees.
*
* \tparam TriangleMesh a model of `HalfedgeListGraph`
* \tparam FT a number type. It is
* either deduced from the `geom_traits` \ref bgl_namedparameters "Named Parameters" if provided,
* or from the geometric traits class deduced from the point property map
* of `TriangleMesh`.
* \tparam EdgeIsFeatureMap a model of `ReadWritePropertyMap` with `boost::graph_traits<TriangleMesh>::%edge_descriptor`
* as key type and `bool` as value type. It must be default constructible.
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
*
* \param pmesh the polygon mesh
* \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below.
* `GT` stands for the type of the object provided to the named parameter `geom_traits()`.
*
* \cgalNamedParamsBegin
*
* \cgalParamNBegin{vertex_point_map}
* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.}
* \cgalParamType{a class model of `ReadablePropertyMap` with
* `boost::graph_traits<TriangleMesh>::%vertex_descriptor`
* as key type and `GT::Point_3` as value type.}
* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.}
* \cgalParamExtra{If this parameter is omitted, an internal property map for
* `CGAL::vertex_point_t` must be available in `TriangleMesh`.}
* \cgalParamNEnd
* \cgalParamNBegin{geom_traits}
* \cgalParamDescription{an instance of a geometric traits class}
* \cgalParamType{a class model of `Kernel`}
* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`}
* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.}
* \cgalParamNEnd
* \cgalNamedParamsEnd
*
* \see `sharp_edges_segmentation()`
*/
#ifdef DOXYGEN_RUNNING
template<typename TriangleMesh, typename FT,
typename CGAL_NP_TEMPLATE_PARAMETERS>
#else
template<typename TriangleMesh,
typename CGAL_NP_TEMPLATE_PARAMETERS>
#endif
#ifdef DOXYGEN_RUNNING
std::pair<std::pair<edge_descriptor,FT>, std::pair<edge_descriptor,FT>>
#else
std::pair<
std::pair<typename boost::graph_traits<TriangleMesh>::edge_descriptor, typename GetGeomTraits<TriangleMesh, CGAL_NP_CLASS>::type::FT>,
std::pair<typename boost::graph_traits<TriangleMesh>::edge_descriptor, typename GetGeomTraits<TriangleMesh, CGAL_NP_CLASS>::type::FT>
>
#endif
minmax_dihedral_angle(const TriangleMesh& pmesh,
const CGAL_NP_CLASS& np = parameters::default_values())
{
using parameters::choose_parameter;
using parameters::get_parameter;

// extract types from NPs
typedef typename GetGeomTraits<TriangleMesh, CGAL_NP_CLASS>::type GT;
// GT gt = choose_parameter<GT>(get_parameter(np, internal_np::geom_traits));

typedef typename GetVertexPointMap<TriangleMesh, CGAL_NP_CLASS>::const_type VPM;
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
get_const_property_map(boost::vertex_point, pmesh));

typedef typename GT::FT FT;
typedef typename boost::graph_traits<TriangleMesh>::edge_descriptor edge_descriptor;
typedef typename boost::graph_traits<TriangleMesh>::halfedge_descriptor halfedge_descriptor;
typedef typename boost::graph_traits<TriangleMesh>::vertex_descriptor vertex_descriptor;
edge_descriptor low, high;
FT lo(200), hi(-200);
for (edge_descriptor e : edges(pmesh)){
if(! is_border(e,pmesh)){
halfedge_descriptor h = halfedge(e,pmesh);
vertex_descriptor p = source(h,pmesh);
vertex_descriptor q = target(h,pmesh);
vertex_descriptor r = target(next(h,pmesh),pmesh);
vertex_descriptor s = target(next(opposite(h,pmesh),pmesh),pmesh);
FT da = approximate_dihedral_angle(get(vpm,p),get(vpm,q),get(vpm,r),get(vpm,s));
if(da < lo){
low = e;
lo = da;
}
if(da > hi){
high = e;
hi = da;
}
}
}
return std::make_pair(std::make_pair(low, lo),std::make_pair(high,hi));
}

} // namespace Polygon_mesh_processing
} // namespace CGAL

Expand Down

0 comments on commit 7e298c1

Please sign in to comment.