mirror of https://github.com/CGAL/cgal
Merge branch 'PMP-length_of_border-GF-old' into PMP-length_of_border-GF
This commit is contained in:
commit
3448f7cd57
|
|
@ -8,6 +8,7 @@
|
|||
/// \defgroup keep_connected_components_grp CGAL::keep_connected_components()
|
||||
/// \ingroup PkgPolygonMeshProcessing
|
||||
/// \defgroup remove_connected_components_grp CGAL::remove_connected_components()
|
||||
/// \defgroup measure_grp Geometric Measure functions
|
||||
/// \ingroup PkgPolygonMeshProcessing
|
||||
|
||||
/*!
|
||||
|
|
@ -86,8 +87,16 @@ and provides a list of the parameters that are used in this package.
|
|||
- \link keep_connected_components_grp `CGAL::Polygon_mesh_processing::keep_connected_components()` \endlink
|
||||
- \link remove_connected_components_grp `CGAL::Polygon_mesh_processing::remove_connected_components()` \endlink
|
||||
|
||||
## Geometric Measure functions
|
||||
- \link measure_grp `CGAL::Polygon_mesh_processing::face_area()` \endlink
|
||||
- \link measure_grp `CGAL::Polygon_mesh_processing::area()` \endlink
|
||||
- \link measure_grp `CGAL::Polygon_mesh_processing::volume()` \endlink
|
||||
- \link measure_grp `CGAL::Polygon_mesh_processing::edge_length()` \endlink
|
||||
- \link measure_grp `CGAL::Polygon_mesh_processing::face_border_length()` \endlink
|
||||
|
||||
## Miscellaneous ##
|
||||
- `CGAL::Polygon_mesh_slicer`
|
||||
- `CGAL::Polygon_mesh_processing::bbox_3()`
|
||||
|
||||
\todo make template parameter names uniform in other packages using BGL. Here we chose PolygonMesh as template parameter.
|
||||
It can be made short to PM. And TriangleMesh (or TM) specifies when the parameter should be a triangle mesh.
|
||||
|
|
|
|||
|
|
@ -420,6 +420,7 @@ the propagation of a connected component index to cross it.
|
|||
|
||||
\cgalExample{Polygon_mesh_processing/connected_components_example.cpp}
|
||||
|
||||
|
||||
****************************************
|
||||
\section PMPAll Requirements Summary
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
// Copyright (c) 2015 GeometryFactory (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Jane Tournois
|
||||
|
||||
#ifndef CGAL_POLYGON_MESH_PROCESSING_BOUNDING_BOX_H
|
||||
#define CGAL_POLYGON_MESH_PROCESSING_BOUNDING_BOX_H
|
||||
|
||||
#include <CGAL/Bbox_3.h>
|
||||
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/internal/named_function_params.h>
|
||||
#include <CGAL/Polygon_mesh_processing/internal/named_params_helper.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace Polygon_mesh_processing {
|
||||
|
||||
/*!
|
||||
* \ingroup PkgPolygonMeshProcessing
|
||||
* computes a bounding box of a triangulated surface mesh
|
||||
*
|
||||
* @tparam PolygonMesh a model of `HalfedgeListGraph`
|
||||
* that has an internal property map for `CGAL::vertex_point_t`
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param pmesh a polygon mesh
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh` \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* @return a bounding box of `pmesh`
|
||||
*/
|
||||
template<typename PolygonMesh, typename NamedParameters>
|
||||
CGAL::Bbox_3 bbox_3(const PolygonMesh& pmesh,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
using boost::choose_const_pmap;
|
||||
using boost::get_param;
|
||||
typename GetVertexPointMap<PolygonMesh, NamedParameters>::const_type
|
||||
vpm = choose_const_pmap(get_param(np, CGAL::vertex_point),
|
||||
pmesh,
|
||||
CGAL::vertex_point);
|
||||
|
||||
typedef typename boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
||||
halfedge_descriptor h0 = *(halfedges(pmesh).first);
|
||||
CGAL::Bbox_3 bb = get(vpm, target(h0, pmesh)).bbox();
|
||||
BOOST_FOREACH(halfedge_descriptor h, halfedges(pmesh))
|
||||
{
|
||||
bb += get(vpm, target(h, pmesh)).bbox();
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
template<typename PolygonMesh>
|
||||
CGAL::Bbox_3 bbox_3(const PolygonMesh& pmesh)
|
||||
{
|
||||
return bbox_3(pmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //CGAL_POLYGON_MESH_PROCESSING_BOUNDING_BOX_H
|
||||
|
||||
|
|
@ -28,7 +28,6 @@
|
|||
#include <CGAL/Origin.h>
|
||||
#include <CGAL/Kernel/global_functions_3.h>
|
||||
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
#include <CGAL/Polygon_mesh_processing/internal/named_function_params.h>
|
||||
#include <CGAL/Polygon_mesh_processing/internal/named_params_helper.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,397 @@
|
|||
// Copyright (c) 2015 GeometryFactory (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
|
||||
#ifndef CGAL_POLYGON_MESH_PROCESSING_MEASURE_H
|
||||
#define CGAL_POLYGON_MESH_PROCESSING_MEASURE_H
|
||||
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/internal/named_function_params.h>
|
||||
#include <CGAL/Polygon_mesh_processing/internal/named_params_helper.h>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters
|
||||
#define CGAL_PMP_NP_CLASS NamedParameters
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace Polygon_mesh_processing {
|
||||
|
||||
/**
|
||||
* \ingroup measure_grp
|
||||
* computes the length of a halfedge of a given polygon mesh.
|
||||
*
|
||||
* @tparam PolygonMesh a model of `HalfedgeGraph` that has an internal property map
|
||||
* for `CGAL::vertex_point_t`
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param h the halfedge of which the length is computed
|
||||
* @param pmesh the polygon mesh to which `h` belongs
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh` \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* @return the length of `h`. The return type `FT` is a number type. It is
|
||||
* either deduced from the `geom_traits` \ref namedparameters if provided,
|
||||
* or the geometric traits class deduced from the point property map
|
||||
* of `pmesh`.
|
||||
*
|
||||
* @sa `face_border_length()`
|
||||
*/
|
||||
template<typename PolygonMesh,
|
||||
typename NamedParameters>
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
FT
|
||||
#else
|
||||
typename GetGeomTraits<PolygonMesh, NamedParameters>::type::FT
|
||||
#endif
|
||||
edge_length(typename boost::graph_traits<PolygonMesh>::halfedge_descriptor h
|
||||
, const PolygonMesh& pmesh
|
||||
, const NamedParameters& np)
|
||||
{
|
||||
using boost::choose_const_pmap;
|
||||
using boost::get_param;
|
||||
|
||||
typename GetVertexPointMap<PolygonMesh, NamedParameters>::const_type
|
||||
vpm = choose_const_pmap(get_param(np, CGAL::vertex_point),
|
||||
pmesh,
|
||||
CGAL::vertex_point);
|
||||
|
||||
return CGAL::sqrt(CGAL::squared_distance(get(vpm, source(h, pmesh)),
|
||||
get(vpm, target(h, pmesh))));
|
||||
}
|
||||
|
||||
template<typename PolygonMesh>
|
||||
typename CGAL::Kernel_traits<typename property_map_value<PolygonMesh,
|
||||
CGAL::vertex_point_t>::type>::Kernel::FT
|
||||
edge_length(typename boost::graph_traits<PolygonMesh>::halfedge_descriptor h
|
||||
, const PolygonMesh& pmesh)
|
||||
{
|
||||
return edge_length(h, pmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup measure_grp
|
||||
* computes the length of the border polyline
|
||||
* that contains a given border halfedge.
|
||||
*
|
||||
* @pre `h` is a border halfedge
|
||||
* @tparam PolygonMesh a model of `HalfedgeGraph` that has an internal property map
|
||||
* for `CGAL::vertex_point_t`
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param h a halfedge of the border polyline of which the length is computed
|
||||
* @param pmesh the polygon mesh to which `h` belongs
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh` \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* @return the length of the sequence of border edges of `face(h, pmesh)`.
|
||||
* The return type `FT` is a number type. It is
|
||||
* either deduced from the `geom_traits` \ref namedparameters if provided,
|
||||
* or the geometric traits class deduced from the point property map
|
||||
* of `pmesh`.
|
||||
*
|
||||
* @sa `edge_length()`
|
||||
*/
|
||||
template<typename PolygonMesh,
|
||||
typename NamedParameters>
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
FT
|
||||
#else
|
||||
typename GetGeomTraits<PolygonMesh, NamedParameters>::type::FT
|
||||
#endif
|
||||
face_border_length(
|
||||
typename boost::graph_traits<PolygonMesh>::halfedge_descriptor h
|
||||
, const PolygonMesh& pmesh
|
||||
, const NamedParameters& np)
|
||||
{
|
||||
CGAL_precondition(is_border(h, pmesh));
|
||||
|
||||
double result = 0.;
|
||||
BOOST_FOREACH(typename boost::graph_traits<PolygonMesh>::halfedge_descriptor haf,
|
||||
halfedges_around_face(h, pmesh))
|
||||
{
|
||||
result += edge_length(haf, pmesh, np);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename PolygonMesh>
|
||||
typename CGAL::Kernel_traits<typename property_map_value<PolygonMesh,
|
||||
CGAL::vertex_point_t>::type>::Kernel::FT
|
||||
face_border_length(
|
||||
typename boost::graph_traits<PolygonMesh>::halfedge_descriptor h
|
||||
, const PolygonMesh& pmesh)
|
||||
{
|
||||
return face_border_length(h, pmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup measure_grp
|
||||
* computes the area of a face of a given
|
||||
* triangulated surface mesh.
|
||||
*
|
||||
* @tparam TriangleMesh a model of `HalfedgeGraph` that has an internal property map
|
||||
* for `CGAL::vertex_point_t`
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param f the face of which the area is computed
|
||||
* @param tmesh the triangulated surface mesh to which `f` belongs
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh` \cgalParamEnd
|
||||
* \cgalParamBegin{geom_traits} a geometric traits class instance \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
|
||||
* @return the area of `f`.
|
||||
* The return type `FT` is a number type. It is
|
||||
* either deduced from the `geom_traits` \ref namedparameters if provided,
|
||||
* or the geometric traits class deduced from the point property map
|
||||
* of `tmesh`.
|
||||
*
|
||||
* @sa `area()`
|
||||
*/
|
||||
template<typename TriangleMesh,
|
||||
typename CGAL_PMP_NP_TEMPLATE_PARAMETERS>
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
FT
|
||||
#else
|
||||
typename GetGeomTraits<TriangleMesh, CGAL_PMP_NP_CLASS>::type::FT
|
||||
#endif
|
||||
face_area(typename boost::graph_traits<TriangleMesh>::face_descriptor f
|
||||
, const TriangleMesh& tmesh
|
||||
, const CGAL_PMP_NP_CLASS& np)
|
||||
{
|
||||
using boost::choose_const_pmap;
|
||||
using boost::get_param;
|
||||
|
||||
typename GetVertexPointMap<TriangleMesh, CGAL_PMP_NP_CLASS>::const_type
|
||||
vpm = choose_const_pmap(get_param(np, CGAL::vertex_point),
|
||||
tmesh,
|
||||
CGAL::vertex_point);
|
||||
|
||||
typedef typename boost::graph_traits<TriangleMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
halfedge_descriptor hd = halfedge(f, tmesh);
|
||||
halfedge_descriptor nhd = next(hd, tmesh);
|
||||
|
||||
typename GetGeomTraits<TriangleMesh, CGAL_PMP_NP_CLASS>::type traits;
|
||||
|
||||
return traits.compute_area_3_object()(get(vpm, source(hd, tmesh)),
|
||||
get(vpm, target(hd, tmesh)),
|
||||
get(vpm, target(nhd, tmesh)));
|
||||
}
|
||||
|
||||
template<typename TriangleMesh>
|
||||
typename CGAL::Kernel_traits<typename property_map_value<TriangleMesh,
|
||||
CGAL::vertex_point_t>::type>::Kernel::FT
|
||||
face_area(typename boost::graph_traits<TriangleMesh>::face_descriptor f
|
||||
, const TriangleMesh& tmesh)
|
||||
{
|
||||
return face_area(f, tmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup measure_grp
|
||||
* computes the area of a range of faces of a given
|
||||
* triangulated surface mesh.
|
||||
*
|
||||
* @tparam FaceRange range of `boost::graph_traits<PolygonMesh>::%face_descriptor`,
|
||||
model of `Range`.
|
||||
Its iterator type is `InputIterator`.
|
||||
* @tparam TriangleMesh a model of `HalfedgeGraph` that has an internal property map
|
||||
* for `CGAL::vertex_point_t`
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param face_range the range of faces of which the area is computed
|
||||
* @param tmesh the triangulated surface mesh to which the faces of `face_range` belong
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh` \cgalParamEnd
|
||||
* \cgalParamBegin{geom_traits} a geometric traits class instance \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* @return sum of face areas of `faces`.
|
||||
* The return type `FT` is a number type. It is
|
||||
* either deduced from the `geom_traits` \ref namedparameters if provided,
|
||||
* or the geometric traits class deduced from the point property map
|
||||
* of `tmesh`.
|
||||
*
|
||||
* @sa `face_area()`
|
||||
*/
|
||||
template<typename FaceRange,
|
||||
typename TriangleMesh,
|
||||
typename CGAL_PMP_NP_TEMPLATE_PARAMETERS>
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
FT
|
||||
#else
|
||||
typename GetGeomTraits<TriangleMesh, CGAL_PMP_NP_CLASS>::type::FT
|
||||
#endif
|
||||
area(FaceRange face_range
|
||||
, const TriangleMesh& tmesh
|
||||
, const CGAL_PMP_NP_CLASS& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<TriangleMesh>::face_descriptor face_descriptor;
|
||||
double result = 0.;
|
||||
BOOST_FOREACH(face_descriptor f, face_range)
|
||||
{
|
||||
result += face_area(f, tmesh, np);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename FaceRange, typename TriangleMesh>
|
||||
double area(FaceRange face_range, const TriangleMesh& tmesh)
|
||||
{
|
||||
return area(face_range, tmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup measure_grp
|
||||
* computes the surface area of a triangulated surface mesh.
|
||||
*
|
||||
* @tparam TriangleMesh a model of `HalfedgeGraph` that has an internal property map
|
||||
* for `CGAL::vertex_point_t`
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param tmesh the triangulated surface mesh
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh` \cgalParamEnd
|
||||
* \cgalParamBegin{geom_traits} a geometric traits class instance \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* @return the surface area of `tmesh`.
|
||||
* The return type `FT` is a number type. It is
|
||||
* either deduced from the `geom_traits` \ref namedparameters if provided,
|
||||
* or the geometric traits class deduced from the point property map
|
||||
* of `tmesh`.
|
||||
*
|
||||
* @sa `face_area()`
|
||||
*/
|
||||
template<typename TriangleMesh
|
||||
, typename CGAL_PMP_NP_TEMPLATE_PARAMETERS>
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
FT
|
||||
#else
|
||||
typename GetGeomTraits<TriangleMesh, CGAL_PMP_NP_CLASS>::type::FT
|
||||
#endif
|
||||
area(const TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np)
|
||||
{
|
||||
return area(faces(tmesh), tmesh, np);
|
||||
}
|
||||
|
||||
template<typename TriangleMesh>
|
||||
typename CGAL::Kernel_traits<typename property_map_value<TriangleMesh,
|
||||
CGAL::vertex_point_t>::type>::Kernel::FT
|
||||
area(const TriangleMesh& tmesh)
|
||||
{
|
||||
return area(faces(tmesh), tmesh);
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup measure_grp
|
||||
* computes the volume of the domain bounded by
|
||||
* a closed triangulated surface mesh.
|
||||
*
|
||||
* @tparam TriangleMesh a model of `HalfedgeGraph` that has an internal property map
|
||||
* for `CGAL::vertex_point_t`
|
||||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param tmesh the closed triangulated surface mesh bounding the volume
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* @pre `tmesh` is closed
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh` \cgalParamEnd
|
||||
* \cgalParamBegin{geom_traits} a geometric traits class instance \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* @return the volume bounded by `tmesh`.
|
||||
* The return type `FT` is a number type. It is
|
||||
* either deduced from the `geom_traits` \ref namedparameters if provided,
|
||||
* or the geometric traits class deduced from the point property map
|
||||
* of `tmesh`.
|
||||
*/
|
||||
template<typename TriangleMesh
|
||||
, typename CGAL_PMP_NP_TEMPLATE_PARAMETERS>
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
FT
|
||||
#else
|
||||
typename GetGeomTraits<TriangleMesh, CGAL_PMP_NP_CLASS>::type::FT
|
||||
#endif
|
||||
volume(const TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np)
|
||||
{
|
||||
CGAL_assertion(is_triangle_mesh(tmesh));
|
||||
CGAL_assertion(is_closed(tmesh));
|
||||
|
||||
using boost::choose_const_pmap;
|
||||
using boost::get_param;
|
||||
|
||||
typename GetVertexPointMap<TriangleMesh, CGAL_PMP_NP_CLASS>::const_type
|
||||
vpm = choose_const_pmap(get_param(np, CGAL::vertex_point),
|
||||
tmesh,
|
||||
CGAL::vertex_point);
|
||||
typename GetGeomTraits<TriangleMesh, CGAL_PMP_NP_CLASS>::type::Point_3
|
||||
origin(0, 0, 0);
|
||||
|
||||
typedef typename boost::graph_traits<TriangleMesh>::face_descriptor face_descriptor;
|
||||
|
||||
double volume = 0.;
|
||||
BOOST_FOREACH(face_descriptor f, faces(tmesh))
|
||||
{
|
||||
volume += CGAL::volume(origin,
|
||||
get(vpm, target(halfedge(f, tmesh), tmesh)),
|
||||
get(vpm, target(next(halfedge(f, tmesh), tmesh), tmesh)),
|
||||
get(vpm, target(prev(halfedge(f, tmesh), tmesh), tmesh)));
|
||||
}
|
||||
return volume;
|
||||
}
|
||||
|
||||
template<typename TriangleMesh>
|
||||
typename CGAL::Kernel_traits<typename property_map_value<TriangleMesh,
|
||||
CGAL::vertex_point_t>::type>::Kernel::FT
|
||||
volume(const TriangleMesh& tmesh)
|
||||
{
|
||||
return volume(tmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CGAL_POLYGON_MESH_PROCESSING_MEASURE_H
|
||||
|
|
@ -76,6 +76,7 @@ if (EIGEN3_FOUND)
|
|||
create_single_source_cgal_program("test_stitching.cpp")
|
||||
create_single_source_cgal_program("remove_degeneracies_test.cpp")
|
||||
create_single_source_cgal_program("test_pmp_bgl_named_params.cpp")
|
||||
create_single_source_cgal_program("measures_test.cpp")
|
||||
|
||||
if(NOT (${EIGEN3_VERSION} VERSION_LESS 3.2.0))
|
||||
create_single_source_cgal_program("fairing_test.cpp")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,132 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/boost/graph/properties_Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/properties_Surface_mesh.h>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||
#include <CGAL/Polygon_mesh_processing/bbox.h>
|
||||
#include <CGAL/Polygon_mesh_processing/stitch_borders.h>
|
||||
|
||||
#include <CGAL/Bbox_3.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <list>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef K::Point_3 Point;
|
||||
|
||||
typedef CGAL::Polyhedron_3<K> Polyhedron;
|
||||
typedef CGAL::Surface_mesh<Point> Surface_mesh;
|
||||
|
||||
namespace PMP = CGAL::Polygon_mesh_processing;
|
||||
|
||||
template<typename Mesh>
|
||||
void test(const Mesh& pmesh)
|
||||
{
|
||||
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
|
||||
|
||||
halfedge_descriptor border_he;
|
||||
BOOST_FOREACH(halfedge_descriptor h, halfedges(pmesh))
|
||||
{
|
||||
if (is_border(h, pmesh))
|
||||
{
|
||||
border_he = h;
|
||||
break;
|
||||
}
|
||||
}
|
||||
double border_l = PMP::face_border_length(border_he, pmesh);
|
||||
std::cout << "length of hole border = " << border_l << std::endl;
|
||||
|
||||
std::list<face_descriptor> patch;
|
||||
BOOST_FOREACH(halfedge_descriptor h, halfedges(pmesh))
|
||||
{
|
||||
if (is_border(h, pmesh) || is_border(opposite(h, pmesh), pmesh))
|
||||
continue;
|
||||
else
|
||||
{
|
||||
double face_area = PMP::face_area(face(h, pmesh), pmesh);
|
||||
std::cout << "face area = " << face_area << std::endl;
|
||||
|
||||
patch.push_back(face(h, pmesh));
|
||||
patch.push_back(face(opposite(h, pmesh), pmesh));
|
||||
patch.push_back(face(opposite(next(h, pmesh), pmesh), pmesh));
|
||||
patch.push_back(face(opposite(prev(h, pmesh), pmesh), pmesh));
|
||||
break;
|
||||
}
|
||||
}
|
||||
double patch_area = PMP::area(patch, pmesh);
|
||||
std::cout << "patch area = " << patch_area << std::endl;
|
||||
|
||||
double mesh_area = PMP::area(pmesh);
|
||||
std::cout << "mesh area = " << mesh_area << std::endl;
|
||||
|
||||
double mesh_area_np = PMP::area(pmesh,
|
||||
PMP::parameters::geom_traits(K()));
|
||||
std::cout << "mesh area (NP) = " << mesh_area_np << std::endl;
|
||||
|
||||
|
||||
CGAL::Bbox_3 bb = PMP::bbox_3(pmesh);
|
||||
std::cout << "bbox x[" << bb.xmin() << "; " << bb.xmax() << "]" << std::endl;
|
||||
std::cout << " y[" << bb.ymin() << "; " << bb.ymax() << "]" << std::endl;
|
||||
std::cout << " z[" << bb.zmin() << "; " << bb.zmax() << "]" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
void test_polyhedron(const char* filename)
|
||||
{
|
||||
//run test for a Polyhedron
|
||||
Polyhedron poly; // file should contain oriented polyhedron
|
||||
std::ifstream input(filename);
|
||||
|
||||
if (!input || !(input >> poly))
|
||||
{
|
||||
std::cerr << "Error: cannot read Polyhedron : " << filename << "\n";
|
||||
assert(!poly.empty());
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
test(poly);
|
||||
}
|
||||
|
||||
void test_closed_surface_mesh(const char* filename)
|
||||
{
|
||||
Surface_mesh sm;
|
||||
std::ifstream input(filename);
|
||||
|
||||
if (!input || !(input >> sm))
|
||||
{
|
||||
std::cerr << "Error: cannot read Surface mesh : " << filename << "\n";
|
||||
assert(sm.number_of_vertices() > 0);
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
test(sm);
|
||||
|
||||
double vol = PMP::volume(sm);
|
||||
std::cout << "volume = " << vol << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* filename_polyhedron =
|
||||
(argc > 1) ? argv[1] : "data/mech-holes-shark.off";
|
||||
test_polyhedron(filename_polyhedron);
|
||||
|
||||
const char* filename_surface_mesh =
|
||||
(argc > 1) ? argv[1] : "data/elephant.off";
|
||||
test_closed_surface_mesh(filename_surface_mesh);
|
||||
|
||||
std::cerr << "All done." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
||||
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||
|
||||
#include <CGAL/statistics_helpers.h>
|
||||
|
||||
|
|
@ -824,30 +825,11 @@ init()
|
|||
area=-std::numeric_limits<double>::infinity();
|
||||
if (poly->is_pure_triangle())
|
||||
{
|
||||
// compute the volume if the polyhedron is closed
|
||||
if (poly->is_closed())
|
||||
{
|
||||
volume=0;
|
||||
Polyhedron::Vertex::Point p(0,0,0);
|
||||
Q_FOREACH(Polyhedron::Face_handle fh, faces(*poly))
|
||||
{
|
||||
volume+=CGAL::volume( p,
|
||||
fh->halfedge()->vertex()->point(),
|
||||
fh->halfedge()->next()->vertex()->point(),
|
||||
fh->halfedge()->prev()->vertex()->point() );
|
||||
}
|
||||
}
|
||||
volume = CGAL::Polygon_mesh_processing::volume(*poly);
|
||||
|
||||
// compute the surface area
|
||||
area=0;
|
||||
Q_FOREACH(Polyhedron::Face_handle fh, faces(*poly))
|
||||
{
|
||||
area+=std::sqrt( CGAL::squared_area(
|
||||
fh->halfedge()->vertex()->point(),
|
||||
fh->halfedge()->next()->vertex()->point(),
|
||||
fh->halfedge()->prev()->vertex()->point() )
|
||||
);
|
||||
}
|
||||
area = CGAL::Polygon_mesh_processing::area(*poly);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@
|
|||
\todo code: implement the random sampling of surface using the work started by Alexandru during its gsoc to get a better approximation of poles
|
||||
\todo code: expose in polygon mesh processing the function to compute the voronoi pole of a close triangle mesh
|
||||
\todo code: expose in polygon mesh processing the function to remesh locally a triangle mesh with the angle and edge length parameters
|
||||
\todo code: expose in polygon mesh processing the function compute the surface area of a polygon mesh
|
||||
\todo code: avoid using EPEC for the triangulation
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
#include <CGAL/internal/Surface_mesh_skeletonization/Debug.h>
|
||||
|
||||
// Some helper functions
|
||||
#include <CGAL/internal/Surface_mesh_skeletonization/Utility.h>
|
||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||
|
||||
// For detect_degenarcy
|
||||
#include <CGAL/internal/Surface_mesh_skeletonization/Detect_degeneracy.h>
|
||||
|
|
@ -720,7 +720,8 @@ public:
|
|||
|
||||
MCFSKEL_DEBUG(print_edges();)
|
||||
|
||||
MCFSKEL_INFO(double area = internal::get_surface_area(m_tmesh, m_tmesh_point_pmap);)
|
||||
MCFSKEL_INFO(double area = CGAL::Polygon_mesh_processing::area(m_tmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(m_tmesh_point_pmap));)
|
||||
MCFSKEL_INFO(std::cout << "area " << area << "\n";)
|
||||
}
|
||||
|
||||
|
|
@ -743,7 +744,9 @@ public:
|
|||
remesh();
|
||||
detect_degeneracies();
|
||||
|
||||
double area = internal::get_surface_area(m_tmesh, m_tmesh_point_pmap, m_traits);
|
||||
double area = CGAL::Polygon_mesh_processing::area(m_tmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(m_tmesh_point_pmap)
|
||||
.geom_traits(m_traits));
|
||||
double area_ratio = fabs(last_area - area) / m_original_area;
|
||||
|
||||
MCFSKEL_INFO(std::cout << "area " << area << "\n";)
|
||||
|
|
@ -851,7 +854,9 @@ private:
|
|||
//, m_hedge_id_pmap(get(boost::halfedge_index, m_tmesh))
|
||||
m_are_poles_computed = false;
|
||||
|
||||
m_original_area = internal::get_surface_area(m_tmesh, m_tmesh_point_pmap, m_traits);
|
||||
m_original_area = CGAL::Polygon_mesh_processing::area(m_tmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::vertex_point_map(m_tmesh_point_pmap)
|
||||
.geom_traits(m_traits));
|
||||
|
||||
m_vertex_id_count = static_cast<int>(num_vertices(m_tmesh));
|
||||
m_max_id = m_vertex_id_count;
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
// Copyright (c) 2013 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
// Author(s) : Xiang Gao <gaox@ethz.ch>
|
||||
//
|
||||
|
||||
#ifndef CGAL_MCFSKEL_UTILITY_H
|
||||
#define CGAL_MCFSKEL_UTILITY_H
|
||||
|
||||
/// @cond CGAL_DOCUMENT_INTERNAL
|
||||
|
||||
/**
|
||||
* @file Utility.h
|
||||
* @brief This file contains some helper functions like splitting an edge at a
|
||||
* given point.
|
||||
*/
|
||||
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <cmath>
|
||||
|
||||
namespace CGAL {
|
||||
namespace internal {
|
||||
|
||||
template<class TriangleMesh, class TriangleMeshPointPMap, class Traits>
|
||||
double get_surface_area(TriangleMesh& hg, TriangleMeshPointPMap& hg_point_pmap, const Traits& traits)
|
||||
{
|
||||
typedef typename Traits::Point_3 Point;
|
||||
typedef typename boost::graph_traits<TriangleMesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<TriangleMesh>::face_descriptor face_descriptor;
|
||||
typedef typename boost::graph_traits<TriangleMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
||||
double total_area = 0;
|
||||
BOOST_FOREACH(face_descriptor fd, faces(hg))
|
||||
{
|
||||
halfedge_descriptor hd = halfedge(fd, hg);
|
||||
|
||||
vertex_descriptor v1 = target(hd, hg);
|
||||
hd = next(hd, hg);
|
||||
vertex_descriptor v2 = target(hd, hg);
|
||||
hd = next(hd, hg);
|
||||
vertex_descriptor v3 = target(hd, hg);
|
||||
Point p1 = get(hg_point_pmap, v1);
|
||||
Point p2 = get(hg_point_pmap, v2);
|
||||
Point p3 = get(hg_point_pmap, v3);
|
||||
total_area += traits.compute_area_3_object()(p1, p2, p3);
|
||||
}
|
||||
return total_area;
|
||||
}
|
||||
|
||||
} //namespace internal
|
||||
} //namespace CGAL
|
||||
|
||||
/// @endcond
|
||||
|
||||
#endif //CGAL_MCFSKEL_UTILITY_H
|
||||
Loading…
Reference in New Issue