Demo: if you define CGAL_MESH_3_DEMO_ACTIVATE_SHARP_FEATURES_IN_POLYHEDRAL_DOMAIN, the sharp features are now detected and handled on polyhedral domains. The drawback is that it disables the other oracles (implicit...) because Triangulation and C3t3 are not compatible anymore (gives compilation errors, which seem very difficult to solve).

This commit is contained in:
Clément Jamin 2012-09-24 14:02:13 +00:00
parent 4ce1337ba8
commit 416691ef8a
6 changed files with 69 additions and 23 deletions

View File

@ -10,6 +10,7 @@
#include <CGAL/Mesh_3/Robust_intersection_traits_3.h>
#include <CGAL/Polyhedral_mesh_domain_3.h>
#include <CGAL/Polyhedral_mesh_domain_with_features_3.h>
#include <CGAL/Labeled_image_mesh_domain_3.h>
#include <CGAL/tags.h>
@ -31,6 +32,7 @@ private:
namespace CGAL {
#ifndef CGAL_MESH_3_DEMO_ACTIVATE_SHARP_FEATURES_IN_POLYHEDRAL_DOMAIN
// A specialisation of Triangle_accessor_3 which fits our Polyhedron type
template <typename K>
class Triangle_accessor_3<Polyhedron, K>
@ -61,11 +63,17 @@ public:
return Triangle_3(a,b,c);
}
};
#endif
}
typedef CGAL::Mesh_3::Robust_intersection_traits_3<Kernel> RKernel;
typedef CGAL::Polyhedral_mesh_domain_3<Polyhedron,RKernel> Polyhedral_mesh_domain;
typedef CGAL::Polyhedral_mesh_domain_3<Polyhedron,RKernel> Polyhedral_mesh_domain_without_features;
#ifdef CGAL_MESH_3_DEMO_ACTIVATE_SHARP_FEATURES_IN_POLYHEDRAL_DOMAIN
typedef CGAL::Polyhedral_mesh_domain_with_features_3<Kernel> Polyhedral_mesh_domain;
#else
typedef Polyhedral_mesh_domain_without_features Polyhedral_mesh_domain;
#endif
typedef CGAL::Labeled_image_mesh_domain_3<Image,Kernel> Image_mesh_domain;
typedef Wrapper<Kernel> Function_wrapper;
typedef CGAL::Mesh_3::Labeled_mesh_domain_3<Function_wrapper, Kernel> Function_mesh_domain;
@ -73,11 +81,10 @@ typedef CGAL::Mesh_3::Labeled_mesh_domain_3<Function_wrapper, Kernel> Function
// Triangulation
#ifdef CONCURRENT_MESH_3
typedef CGAL::Parallel_mesh_triangulation_3<Polyhedral_mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr, CGAL::Parallel_tag> C3t3;
#else
typedef CGAL::Mesh_triangulation_3<Polyhedral_mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr, CGAL::Sequential_tag> C3t3;
#endif
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
// 3D complex

View File

@ -21,6 +21,9 @@ Meshing_thread* cgal_code_mesh_3(const Polyhedron* pMesh,
if( NULL == pMesh ) { return NULL; }
Polyhedral_mesh_domain* p_domain = new Polyhedral_mesh_domain(*pMesh);
#ifdef CGAL_MESH_3_DEMO_ACTIVATE_SHARP_FEATURES_IN_POLYHEDRAL_DOMAIN
p_domain->detect_features();
#endif
Scene_c3t3_item* p_new_item = new Scene_c3t3_item();

View File

@ -35,6 +35,7 @@
#include <CGAL/Mesh_3/Mesher_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Mesh_3/Protect_edges_sizing_field.h>
#include "C3t3_type.h"
#include "Meshing_thread.h"
@ -52,6 +53,23 @@ struct Mesh_parameters
};
template < typename EdgeCriteria >
struct Edge_criteria_sizing_field_wrapper
{
typedef typename EdgeCriteria::Index Index;
typedef typename EdgeCriteria::FT FT;
typedef typename EdgeCriteria::Point_3 Point_3;
Edge_criteria_sizing_field_wrapper(const EdgeCriteria& ec) : ec_(ec) {}
FT operator()(const Point_3& p, const int dim, const Index& index) const
{ return ec_.sizing_field(p,dim,index); }
private:
// No need to copy EdgeCriteria here
const EdgeCriteria& ec_;
};
template < typename Domain_ >
class Mesh_function
: public Mesh_function_interface
@ -82,6 +100,7 @@ private:
typedef C3t3::Triangulation Tr;
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
typedef Mesh_criteria::Edge_criteria Edge_criteria;
typedef Mesh_criteria::Facet_criteria Facet_criteria;
typedef Mesh_criteria::Cell_criteria Cell_criteria;
@ -155,7 +174,16 @@ launch()
#ifdef CGAL_MESH_3_INITIAL_POINTS_NO_RANDOM_SHOOTING
CGAL::default_random = CGAL::Random(0);
#endif
// Create mesh criteria
Mesh_criteria criteria(Edge_criteria(p_.facet_sizing),
Facet_criteria(p_.facet_angle,
p_.facet_sizing,
p_.facet_approx),
Cell_criteria(p_.tet_shape,
p_.tet_sizing));
#ifndef CGAL_MESH_3_DEMO_ACTIVATE_SHARP_FEATURES_IN_POLYHEDRAL_DOMAIN
// Mesh initialization : get some points and add them to the mesh
Initial_points_vector initial_points;
domain_->construct_initial_points_object()(std::back_inserter(initial_points));
@ -173,14 +201,13 @@ launch()
c3t3_.set_index(v,it->second);
}
}
// Create mesh criteria
Mesh_criteria criteria(Facet_criteria(p_.facet_angle,
p_.facet_sizing,
p_.facet_approx),
Cell_criteria(p_.tet_shape,
p_.tet_sizing));
#else
typedef Edge_criteria_sizing_field_wrapper<Edge_criteria> Sizing_field;
CGAL::Mesh_3::Protect_edges_sizing_field<C3t3,D_,Sizing_field>
protect_edges(c3t3_, *domain_, Sizing_field(criteria.edge_criteria_object()));
protect_edges(true);
#endif
// Build mesher and launch refinement process
mesher_ = new Mesher(c3t3_, *domain_, criteria);
mesher_->refine_mesh();

View File

@ -9,6 +9,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
// surface mesh
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Mesh_polyhedron_3.h>
#include "Polyhedron_type_fwd.h"
@ -24,6 +25,6 @@ typedef Kernel::Iso_cuboid_3 Iso_cuboid;
typedef Kernel::Plane_3 Plane_3;
// surface mesh
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Mesh_polyhedron_3<Kernel>::type Polyhedron;
#endif // POLYHEDRON_TYPE_H

View File

@ -2,6 +2,8 @@
#define POLYHEDRON_TYPE_FWD_H
#include <CGAL/Filtered_kernel_fwd.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_polyhedron_3.h>
#include <memory>
#ifdef USE_FORWARD_DECL
@ -13,7 +15,7 @@ namespace CGAL {
template < typename FT_ >
struct Simple_cartesian;
class Epick;
//class Epick;
class Polyhedron_items_3;
@ -38,13 +40,15 @@ namespace CGAL {
// kernel
typedef CGAL::Epick Kernel;
//typedef CGAL::Epick Kernel;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
// surface mesh
typedef CGAL::Polyhedron_3<Kernel,
typedef CGAL::Mesh_polyhedron_3<Kernel>::type Polyhedron;
/*typedef CGAL::Polyhedron_3<Kernel,
CGAL::Polyhedron_items_3,
CGAL::HalfedgeDS_default,
std::allocator<int> > Polyhedron;
std::allocator<int> > Polyhedron;*/
#else // USE_FORWARD_DECL

View File

@ -9,7 +9,7 @@
//#define CGAL_MESH_3_VERY_VERBOSE
#define CGAL_MESH_3_IO_VERBOSE
#define SHOW_REMAINING_BAD_ELEMENT_IN_RED
//#define SHOW_REMAINING_BAD_ELEMENT_IN_RED
#ifndef CGAL_POLYHEDRON_DEMO_NO_PARAMETRIZATION
# define CGAL_POLYHEDRON_DEMO_USE_PARAMETRIZATION
@ -23,8 +23,12 @@
# define CGAL_POLYHEDRON_DEMO_USE_SURFACE_MESHER
#endif
#define CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS
//#define CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES
// If you define this, implicit function and segmented images won't be available
//#define CGAL_MESH_3_DEMO_ACTIVATE_SHARP_FEATURES_IN_POLYHEDRAL_DOMAIN
#ifndef CGAL_MESH_3_DEMO_ACTIVATE_SHARP_FEATURES_IN_POLYHEDRAL_DOMAIN
# define CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS
//# define CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES
#endif
// ==========================================================================
// MESH_3 GENERAL PARAMETERS
@ -33,7 +37,7 @@
//#define CGAL_MESH_3_USE_OLD_SURFACE_RESTRICTED_DELAUNAY_UPDATE // WARNING: VERY SLOW
#define CGAL_MESH_3_INITIAL_POINTS_NO_RANDOM_SHOOTING
//#define CGAL_MESHES_DEBUG_REFINEMENT_POINTS
#define CHECK_AND_DISPLAY_THE_NUMBER_OF_BAD_ELEMENTS_IN_THE_END
//#define CHECK_AND_DISPLAY_THE_NUMBER_OF_BAD_ELEMENTS_IN_THE_END
// ==========================================================================
// CONCURRENCY
@ -116,8 +120,8 @@
#else // !CONCURRENT_MESH_3
//# define CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE
# define CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE
# define CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE
//# define CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE
# define CGAL_MESH_3_IF_UNSORTED_QUEUE_JUST_SORT_AFTER_SCAN
// For better performance on meshes like fandisk