mirror of https://github.com/CGAL/cgal
Merge pull request #5389 from sloriot/Mesh_3-fix_patch_id_map
Clean and fix default facet patch id map
This commit is contained in:
commit
fa7393cb15
|
|
@ -0,0 +1,76 @@
|
|||
// Copyright (c) 2010,2012 GeometryFactory Sarl (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
//
|
||||
// Author(s) : Laurent Rineau
|
||||
//
|
||||
|
||||
#ifndef CGAL_MESH_3_FACET_PATCH_ID_MAP_H
|
||||
#define CGAL_MESH_3_FACET_PATCH_ID_MAP_H
|
||||
|
||||
#include <CGAL/license/Mesh_3.h>
|
||||
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
#include <CGAL/is_iterator.h>
|
||||
|
||||
namespace CGAL { namespace Mesh_3 {
|
||||
|
||||
/// A property map that, from a primitive of a AABB tree
|
||||
/// retrieve the patch_id() of the facet.
|
||||
template <typename MeshDomain,
|
||||
typename Primitive,
|
||||
bool id_is_iterator = CGAL::is_iterator<typename Primitive::Id>::value >
|
||||
struct Facet_patch_id_map;
|
||||
|
||||
// Primitive::Id is an iterator type
|
||||
template <typename MeshDomain,
|
||||
typename Primitive>
|
||||
struct Facet_patch_id_map<MeshDomain, Primitive, true>
|
||||
{
|
||||
typedef typename Primitive::Id Id;
|
||||
typedef typename std::iterator_traits<Id>::value_type Face;
|
||||
typedef typename Face::Patch_id value_type;
|
||||
typedef const value_type& reference;
|
||||
typedef typename Primitive::Id key_type;
|
||||
typedef boost::readable_property_map_tag category;
|
||||
|
||||
friend reference get(Facet_patch_id_map<MeshDomain, Primitive, true>, key_type primitive_id)
|
||||
{
|
||||
return primitive_id->patch_id();
|
||||
}
|
||||
};
|
||||
|
||||
// Primitive::Id is a std::pair
|
||||
template <typename MeshDomain,
|
||||
typename Primitive>
|
||||
struct Facet_patch_id_map<MeshDomain, Primitive, false>
|
||||
{
|
||||
typedef typename MeshDomain::AABB_primitive::Id Id;
|
||||
typedef typename MeshDomain::Patch_id value_type;
|
||||
typedef value_type reference;
|
||||
typedef typename MeshDomain::AABB_primitive::Id key_type;
|
||||
typedef boost::readable_property_map_tag category;
|
||||
|
||||
friend reference get(Facet_patch_id_map<MeshDomain, Primitive, false>, key_type primitive_id)
|
||||
{
|
||||
typedef typename boost::property_map<
|
||||
typename MeshDomain::Polyhedron,
|
||||
face_patch_id_t<typename MeshDomain::Patch_id> >::type Fpim;
|
||||
Fpim fpim = get(face_patch_id_t<typename MeshDomain::Patch_id>(),
|
||||
*(primitive_id.second));
|
||||
typename MeshDomain::Patch_id patch_index = get(fpim,
|
||||
primitive_id.first);
|
||||
return patch_index;
|
||||
}
|
||||
};
|
||||
|
||||
}} // end namespace CGAL::Mesh_3
|
||||
|
||||
#endif // CGAL_MESH_3_FACET_PATCH_ID_MAP_H
|
||||
|
|
@ -16,108 +16,14 @@
|
|||
|
||||
#include <CGAL/license/Mesh_3.h>
|
||||
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <CGAL/Mesh_3/experimental/Facet_patch_id_map.h>
|
||||
|
||||
namespace CGAL { namespace Mesh_3 {
|
||||
|
||||
namespace internal {
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Primitive_has_Id, Id, false)
|
||||
} // end namespace CGAL::Mesh_3::internal
|
||||
|
||||
/// A property map that, from a primitive of a AABB tree of polyhedron
|
||||
/// facets, retrieve the patch_id() of the facet.
|
||||
template <typename Primitive>
|
||||
struct Get_facet_patch_id{};
|
||||
|
||||
|
||||
// generic version, that test if Primitive::Id exists
|
||||
template <typename Primitive,
|
||||
bool = internal::Primitive_has_Id<Primitive>::value >
|
||||
struct Get_facet_patch_id_property_traits {
|
||||
};
|
||||
|
||||
// specialization when Primitive::Id exists
|
||||
template <typename Primitive>
|
||||
struct Get_facet_patch_id_property_traits<Primitive, true>
|
||||
{
|
||||
typedef typename Primitive::Id Id;
|
||||
typedef typename std::iterator_traits<Id>::value_type Face;
|
||||
typedef typename Face::Patch_id value_type;
|
||||
typedef value_type& reference;
|
||||
typedef Primitive key_type;
|
||||
typedef boost::readable_property_map_tag category;
|
||||
};
|
||||
|
||||
}} // end namespace CGAL::Mesh_3
|
||||
|
||||
namespace boost {
|
||||
// specialization for using pointers as property maps
|
||||
template <typename Primitive>
|
||||
struct property_traits<CGAL::Mesh_3::Get_facet_patch_id<Primitive> >
|
||||
: public CGAL::Mesh_3::Get_facet_patch_id_property_traits<Primitive> {};
|
||||
}
|
||||
|
||||
namespace CGAL { namespace Mesh_3 {
|
||||
|
||||
template <typename Primitive>
|
||||
typename boost::property_traits< Get_facet_patch_id<Primitive> >::value_type
|
||||
get(const Get_facet_patch_id<Primitive>, const typename Primitive::Id& primitive_id) {
|
||||
return primitive_id->patch_id();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// A property map that, from a primitive of a AABB tree of Gwdwg<Surface_mesh>
|
||||
/// facets, retrieve the patch_id() of the facet.
|
||||
// backward compatibility with user code
|
||||
template <typename MeshDomain>
|
||||
struct Get_facet_patch_id_sm{};
|
||||
using Get_facet_patch_id_sm = Facet_patch_id_map<MeshDomain, typename MeshDomain::AABB_tree>;
|
||||
|
||||
|
||||
// generic version, that test if Primitive::Id exists
|
||||
template <typename MeshDomain,
|
||||
bool = internal::Primitive_has_Id<typename MeshDomain::AABB_primitive>::value>
|
||||
struct Get_facet_patch_id_sm_property_traits {
|
||||
};
|
||||
|
||||
// specialization when Primitive::Id exists
|
||||
template <typename MeshDomain>
|
||||
struct Get_facet_patch_id_sm_property_traits<MeshDomain, true>
|
||||
{
|
||||
typedef typename MeshDomain::AABB_primitive::Id Id;
|
||||
typedef typename MeshDomain::Patch_id value_type;
|
||||
|
||||
typedef value_type& reference;
|
||||
typedef typename MeshDomain::AABB_primitive key_type;
|
||||
typedef boost::readable_property_map_tag category;
|
||||
};
|
||||
|
||||
}} // end namespace CGAL::Mesh_3
|
||||
|
||||
namespace boost {
|
||||
// specialization for using pointers as property maps
|
||||
template <typename MeshDomain>
|
||||
struct property_traits<CGAL::Mesh_3::Get_facet_patch_id_sm<MeshDomain> >
|
||||
: public CGAL::Mesh_3::Get_facet_patch_id_sm_property_traits<MeshDomain> {};
|
||||
}
|
||||
|
||||
namespace CGAL { namespace Mesh_3 {
|
||||
|
||||
template <typename MeshDomain>
|
||||
typename boost::property_traits< Get_facet_patch_id_sm<MeshDomain> >::value_type
|
||||
get(const Get_facet_patch_id_sm<MeshDomain>,
|
||||
const typename MeshDomain::AABB_primitive::Id& primitive_id)
|
||||
{
|
||||
typedef typename boost::property_map<
|
||||
typename MeshDomain::Polyhedron,
|
||||
face_patch_id_t<typename MeshDomain::Patch_id> >::type Fpim;
|
||||
Fpim fpim = get(face_patch_id_t<typename MeshDomain::Patch_id>(),
|
||||
*(primitive_id.second));
|
||||
typename MeshDomain::Patch_id patch_index = get(fpim,
|
||||
primitive_id.first);
|
||||
return patch_index;
|
||||
}
|
||||
}} // end namespace CGAL::Mesh_3
|
||||
|
||||
#endif // CGAL_MESH_3_GET_FACET_PATCH_ID_H
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include <CGAL/AABB_triangle_primitive.h>
|
||||
|
||||
#include <CGAL/Mesh_3/experimental/AABB_filtered_projection_traits.h>
|
||||
#include <CGAL/Mesh_3/experimental/Get_facet_patch_id.h>
|
||||
#include <CGAL/Mesh_3/experimental/Facet_patch_id_map.h>
|
||||
|
||||
#include <CGAL/Mesh_3/experimental/Lipschitz_sizing_parameters.h>
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ namespace Mesh_3
|
|||
template <class Kernel, class MeshDomain
|
||||
, typename AABBTreeTemplate = CGAL::Default
|
||||
#ifdef CGAL_MESH_3_EXPERIMENTAL_USE_PATCHES_IDS
|
||||
, typename Get_facet_patch_id_ = CGAL::Default
|
||||
, typename Facet_patch_id_map_ = CGAL::Default
|
||||
, typename Patches_ids_ = CGAL::Default
|
||||
#endif
|
||||
>
|
||||
|
|
@ -77,12 +77,12 @@ public:
|
|||
typedef std::vector<Patches_ids> Patches_ids_map;
|
||||
|
||||
typedef typename CGAL::Default::Get<
|
||||
Get_facet_patch_id_,
|
||||
CGAL::Mesh_3::Get_facet_patch_id<typename Tree::Primitive>
|
||||
>::type Get_facet_patch_id;
|
||||
Facet_patch_id_map_,
|
||||
CGAL::Mesh_3::Facet_patch_id_map<MeshDomain, typename Tree::Primitive>
|
||||
>::type Facet_patch_id_map;
|
||||
|
||||
typedef CGAL::Mesh_3::Filtered_projection_traits<
|
||||
typename Tree::AABB_traits, Get_facet_patch_id> AABB_filtered_traits;
|
||||
typename Tree::AABB_traits, Facet_patch_id_map> AABB_filtered_traits;
|
||||
|
||||
private:
|
||||
typedef CGAL::Search_traits_3<Kernel> KdTreeTraits;
|
||||
|
|
@ -106,7 +106,7 @@ private:
|
|||
//help to accelerate aabb_tree queries in m_ptree
|
||||
boost::shared_ptr<Kd_tree> m_kd_tree;
|
||||
|
||||
Get_facet_patch_id m_get_facet_patch_id;
|
||||
Facet_patch_id_map m_facet_patch_id_map;
|
||||
const Patches_ids_map& patches_ids_map;
|
||||
#endif
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ public:
|
|||
, m_bbox(bbox)
|
||||
, m_domain_is_a_box(domain_is_a_box)
|
||||
#ifdef CGAL_MESH_3_EXPERIMENTAL_USE_PATCHES_IDS
|
||||
, m_get_facet_patch_id()
|
||||
, m_facet_patch_id_map()
|
||||
, patches_ids_map(patches_ids_map)
|
||||
#endif
|
||||
{
|
||||
|
|
@ -425,7 +425,7 @@ private:
|
|||
boundary_ids.begin(),
|
||||
boundary_ids.end(),
|
||||
m_ptree->traits(),
|
||||
m_get_facet_patch_id);
|
||||
m_facet_patch_id_map);
|
||||
kd_tree();//build it if needed
|
||||
Neighbor_search search(*m_kd_tree, p, 1);
|
||||
projection_traits.reset(search.begin()->first);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <CGAL/Profile_counter.h>
|
||||
#include <CGAL/Delaunay_triangulation_3.h>
|
||||
#include "Get_facet_patch_id.h"
|
||||
#include "Facet_patch_id_map.h"
|
||||
#include "Get_curve_index.h"
|
||||
#include <CGAL/Mesh_3/Protect_edges_sizing_field.h> // for weight_modifier
|
||||
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
template <typename GeomTraits, typename MeshDomain,
|
||||
typename Input_facets_AABB_tree = typename MeshDomain::AABB_tree,
|
||||
typename Get_curve_index_ = CGAL::Default,
|
||||
typename Get_facet_patch_id_ = CGAL::Default
|
||||
typename Facet_patch_id_map_ = CGAL::Default
|
||||
>
|
||||
struct Sizing_field_with_aabb_tree
|
||||
{
|
||||
|
|
@ -66,22 +66,23 @@ struct Sizing_field_with_aabb_tree
|
|||
CGAL::Mesh_3::Get_curve_index<typename MeshDomain::Curves_AABB_tree::Primitive>
|
||||
>::type Get_curve_index;
|
||||
typedef typename CGAL::Default::Get<
|
||||
Get_facet_patch_id_,
|
||||
CGAL::Mesh_3::Get_facet_patch_id<typename Input_facets_AABB_tree::Primitive>
|
||||
>::type Get_facet_patch_id;
|
||||
Facet_patch_id_map_,
|
||||
CGAL::Mesh_3::Facet_patch_id_map<MeshDomain,
|
||||
typename Input_facets_AABB_tree::Primitive>
|
||||
>::type Facet_patch_id_map;
|
||||
|
||||
Sizing_field_with_aabb_tree
|
||||
(typename Kernel_::FT d,
|
||||
const Input_facets_AABB_tree_& aabb_tree,
|
||||
const MeshDomain& domain,
|
||||
Get_curve_index get_curve_index = Get_curve_index(),
|
||||
Get_facet_patch_id get_facet_patch_id = Get_facet_patch_id()
|
||||
Facet_patch_id_map facet_patch_id_map = Facet_patch_id_map()
|
||||
)
|
||||
: d_(d), aabb_tree(aabb_tree),
|
||||
domain(domain),
|
||||
dt(),
|
||||
get_curve_index(get_curve_index),
|
||||
get_facet_patch_id(get_facet_patch_id)
|
||||
facet_patch_id_map(facet_patch_id_map)
|
||||
{
|
||||
{
|
||||
Corner_index maximal_corner_index = 0;
|
||||
|
|
@ -230,10 +231,10 @@ struct Sizing_field_with_aabb_tree
|
|||
|
||||
CGAL::Mesh_3::Filtered_projection_traits<
|
||||
typename Input_facets_AABB_tree_::AABB_traits,
|
||||
Get_facet_patch_id
|
||||
Facet_patch_id_map
|
||||
> projection_traits(ids.begin(), ids.end(),
|
||||
aabb_tree.traits(),
|
||||
get_facet_patch_id);
|
||||
facet_patch_id_map);
|
||||
|
||||
aabb_tree.traversal(p, projection_traits);
|
||||
|
||||
|
|
@ -257,7 +258,7 @@ struct Sizing_field_with_aabb_tree
|
|||
"Ids are { ")
|
||||
% group(setprecision(17),result)
|
||||
% group(setprecision(17),p)
|
||||
% CGAL::oformat(get(get_facet_patch_id,
|
||||
% CGAL::oformat(get(facet_patch_id_map,
|
||||
projection_traits.closest_point_and_primitive().second))
|
||||
% group(setprecision(17),
|
||||
projection_traits.closest_point_and_primitive().first);
|
||||
|
|
@ -293,10 +294,10 @@ struct Sizing_field_with_aabb_tree
|
|||
CGAL::Mesh_3::Filtered_projection_traits
|
||||
<
|
||||
typename Input_facets_AABB_tree_::AABB_traits
|
||||
, Get_facet_patch_id
|
||||
, Facet_patch_id_map
|
||||
> projection_traits(ids.begin(), ids.end(),
|
||||
aabb_tree.traits(),
|
||||
get_facet_patch_id);
|
||||
facet_patch_id_map);
|
||||
|
||||
aabb_tree.traversal(p, projection_traits);
|
||||
|
||||
|
|
@ -307,7 +308,7 @@ struct Sizing_field_with_aabb_tree
|
|||
return result;
|
||||
}
|
||||
|
||||
CGAL_assertion(ids.count(get(get_facet_patch_id,
|
||||
CGAL_assertion(ids.count(get(facet_patch_id_map,
|
||||
projection_traits.closest_point_and_primitive().second)) == 0);
|
||||
|
||||
result =
|
||||
|
|
@ -326,7 +327,7 @@ struct Sizing_field_with_aabb_tree
|
|||
"Closest face id: %4%\n"
|
||||
"Ids are { ")
|
||||
% result % p % curve_id
|
||||
% CGAL::oformat(get(get_facet_patch_id,
|
||||
% CGAL::oformat(get(facet_patch_id_map,
|
||||
projection_traits.closest_point_and_primitive().second));
|
||||
for(Patch_index i : ids) {
|
||||
s << CGAL::oformat(i) << " ";
|
||||
|
|
@ -345,7 +346,7 @@ struct Sizing_field_with_aabb_tree
|
|||
"Closest face id: %4%\n"
|
||||
"Ids are { ")
|
||||
% result % p % curve_id
|
||||
% CGAL::oformat(get(get_facet_patch_id,
|
||||
% CGAL::oformat(get(facet_patch_id_map,
|
||||
projection_traits.closest_point_and_primitive().second));
|
||||
for(Patch_index i : ids) {
|
||||
s << CGAL::oformat(i) << " ";
|
||||
|
|
@ -527,7 +528,7 @@ private:
|
|||
Corners_incident_patches corners_incident_patches;
|
||||
Corners_incident_curves corners_incident_curves;
|
||||
Get_curve_index get_curve_index;
|
||||
Get_facet_patch_id get_facet_patch_id;
|
||||
Facet_patch_id_map facet_patch_id_map;
|
||||
};
|
||||
|
||||
#endif // CGAL_MESH_3_SIZING_FIELD_WITH_AABB_TREE_H
|
||||
|
|
|
|||
|
|
@ -35,23 +35,11 @@
|
|||
#include <CGAL/use.h>
|
||||
|
||||
#include <boost/any.hpp>
|
||||
#include <CGAL/Mesh_3/experimental/Get_facet_patch_id.h>
|
||||
|
||||
namespace CGAL {
|
||||
class Image_3;
|
||||
}
|
||||
namespace internal{
|
||||
//general case for polyhedron
|
||||
template<class Domain>
|
||||
struct Get_facet_patch_id_selector {
|
||||
typedef CGAL::Default type;
|
||||
};
|
||||
//specialization for surface_mesh
|
||||
template<>
|
||||
struct Get_facet_patch_id_selector<Polyhedral_mesh_domain> {
|
||||
typedef CGAL::Mesh_3::Get_facet_patch_id_sm<Polyhedral_mesh_domain> type;
|
||||
};
|
||||
}//end internal
|
||||
|
||||
struct Mesh_parameters
|
||||
{
|
||||
double facet_angle;
|
||||
|
|
@ -264,14 +252,7 @@ edge_criteria(double edge_size, Mesh_fnt::Polyhedral_domain_tag)
|
|||
{
|
||||
if(p_.use_sizing_field_with_aabb_tree) {
|
||||
typedef typename Domain::Surface_patch_index_set Set_of_patch_ids;
|
||||
typedef Sizing_field_with_aabb_tree
|
||||
<
|
||||
Kernel
|
||||
, Domain
|
||||
, typename Domain::AABB_tree
|
||||
, CGAL::Default
|
||||
, typename internal::Get_facet_patch_id_selector<Domain>::type
|
||||
> Mesh_sizing_field; // type of sizing field for 0D and 1D features
|
||||
typedef Sizing_field_with_aabb_tree<Kernel, Domain> Mesh_sizing_field; // type of sizing field for 0D and 1D features
|
||||
typedef std::vector<Set_of_patch_ids> Patches_ids_vector;
|
||||
typedef typename Domain::Curve_index Curve_index;
|
||||
const Curve_index max_index = domain_->maximal_curve_index();
|
||||
|
|
|
|||
Loading…
Reference in New Issue