Skip to content

Commit

Permalink
Merge pull request CGAL#7370 from sloriot/PMP-soup_self_intersections
Browse files Browse the repository at this point in the history
Add self-intersection test and report functions for triangle soups
  • Loading branch information
lrineau committed Apr 21, 2023
2 parents 91f0834 + 2393258 commit ad30839
Show file tree
Hide file tree
Showing 6 changed files with 727 additions and 85 deletions.
115 changes: 98 additions & 17 deletions BGL/include/CGAL/boost/graph/named_params_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,75 @@ class property_map_value
typedef typename boost::property_traits<PMap>::value_type type;
};


template <typename PolygonMesh,
typename VPM_from_NP>
struct GetVertexPointMap_impl
{
typedef VPM_from_NP type;
typedef VPM_from_NP const_type;

template<class NamedParameters>
static const_type
get_const_map(const NamedParameters& np, const PolygonMesh&)
{
return parameters::get_parameter(np, internal_np::vertex_point);
}

template<class NamedParameters>
static type
get_map(const NamedParameters& np, PolygonMesh&)
{
return parameters::get_parameter(np, internal_np::vertex_point);
}
};

template <typename PolygonMesh>
struct GetVertexPointMap_impl<PolygonMesh, internal_np::Param_not_found>
{
typedef typename property_map_selector<PolygonMesh, boost::vertex_point_t>::const_type const_type;
typedef typename property_map_selector<PolygonMesh, boost::vertex_point_t>::type type;

template<class NamedParameters>
static const_type
get_const_map(const NamedParameters& /* np */, const PolygonMesh& pm)
{
return get_const_property_map(boost::vertex_point, pm);
}

template<class NamedParameters>
static type
get_map(const NamedParameters& /* np */, PolygonMesh& pm)
{
return get_property_map(boost::vertex_point, pm);
}
};

template <typename PolygonMesh,
typename NamedParameters = parameters::Default_named_parameters>
class GetVertexPointMap
{
typedef typename property_map_selector<PolygonMesh, boost::vertex_point_t>::const_type
DefaultVPMap_const;
typedef typename property_map_selector<PolygonMesh, boost::vertex_point_t>::type
DefaultVPMap;

public:
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_point_t,
NamedParameters,
DefaultVPMap>::type type;
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_point_t,
NamedParameters,
DefaultVPMap_const>::type const_type;
internal_np::Param_not_found>::type VPM_from_NP;

typedef GetVertexPointMap_impl<PolygonMesh, VPM_from_NP> Impl;

public:
typedef typename Impl::type type;
typedef typename Impl::const_type const_type;

static const_type
get_const_map(const NamedParameters& np, const PolygonMesh& pm)
{
return Impl::get_const_map(np, pm);
}

static type
get_map(const NamedParameters& np, PolygonMesh& pm)
{
return Impl::get_map(np, pm);
}
};

template<typename PolygonMesh, typename NamedParameters>
Expand All @@ -138,10 +191,15 @@ class GetK
typedef typename CGAL::Kernel_traits<Point>::Kernel Kernel;
};

template <typename PolygonMesh,
typename NamedParametersGT = parameters::Default_named_parameters,
typename NamedParametersVPM = NamedParametersGT>
class GetGeomTraits

template<typename PolygonMesh, class GT, class NamedParametersVPM>
struct GetGeomTraits_impl
{
typedef GT type;
};

template<typename PolygonMesh, class NamedParametersVPM>
struct GetGeomTraits_impl<PolygonMesh, internal_np::Param_not_found, NamedParametersVPM>
{
typedef typename CGAL::graph_has_property<PolygonMesh, boost::vertex_point_t>::type Has_internal_pmap;

Expand All @@ -154,12 +212,20 @@ class GetGeomTraits
typedef typename boost::mpl::if_c<Has_internal_pmap::value ||
!std::is_same<internal_np::Param_not_found, NP_vpm>::value,
typename GetK<PolygonMesh, NamedParametersVPM>::Kernel,
Fake_GT>::type DefaultKernel;
Fake_GT>::type type;
};

public:
template <typename PolygonMesh,
typename NamedParametersGT = parameters::Default_named_parameters,
typename NamedParametersVPM = NamedParametersGT>
struct GetGeomTraits
{
typedef typename internal_np::Lookup_named_param_def<internal_np::geom_traits_t,
NamedParametersGT,
DefaultKernel>::type type;
internal_np::Param_not_found>::type GT_from_NP;
typedef typename GetGeomTraits_impl<PolygonMesh,
GT_from_NP,
NamedParametersVPM>::type type;
};

// Define the following structs:
Expand Down Expand Up @@ -278,6 +344,21 @@ class GetPointMap<PointRange, NamedParameters, false>
typedef typename CGAL::Identity_property_map<const Dummy_point> const_type;
};

template <typename PointRange, typename NamedParameters>
struct GetPolygonSoupGeomTraits
{
typedef typename internal_np::Lookup_named_param_def <
internal_np::geom_traits_t,
NamedParameters,
typename CGAL::Kernel_traits<
typename boost::property_traits<
typename GetPointMap<PointRange, NamedParameters>::type
>::value_type
>::type
> ::type type;
};


template <class PointRange, class NamedParameters, class PointMap = Default, class NormalMap = Default>
struct Point_set_processing_3_np_helper
{
Expand Down
2 changes: 2 additions & 0 deletions Installation/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ CGAL tetrahedral Delaunay refinement algorithm.

- Added a named parameter to `CGAL::Polygon_mesh_processing::smooth_shape()` to disable scaling to compensate volume loss.

- Added the functions `CGAL::Polygon_mesh_processing::does_triangle_soup_self_intersect()` and `CGAL::Polygon_mesh_processing::triangle_soup_self_intersections()` to identify and report self-intersections in a triangle soup, similarly to existing functions on triangle meshes.

### [3D Simplicial Mesh Data Structure](https://doc.cgal.org/5.6/Manual/packages.html#PkgSMDS3) (new package)

- This new package wraps all the existing code that deals with a `MeshComplex_3InTriangulation_3` to describe 3D simplicial meshes, and makes the data structure independent from the tetrahedral mesh generation package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage.
\cgalCRPSection{Intersection Functions}
- `CGAL::Polygon_mesh_processing::does_self_intersect()`
- `CGAL::Polygon_mesh_processing::self_intersections()`
- `CGAL::Polygon_mesh_processing::does_triangle_soup_self_intersect()`
- `CGAL::Polygon_mesh_processing::triangle_soup_self_intersections()`
- \link PMP_intersection_grp `CGAL::Polygon_mesh_processing::do_intersect()` \endlink
- `CGAL::Polygon_mesh_processing::intersecting_meshes()`

Expand Down
Loading

0 comments on commit ad30839

Please sign in to comment.