23 #include "cgalsettings.pb.h"
25 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
26 #include <CGAL/Mesh_triangulation_3.h>
27 #include <CGAL/Mesh_complex_3_in_triangulation_3.h>
28 #include <CGAL/Mesh_criteria_3.h>
30 #include <CGAL/Nef_polyhedron_3.h>
31 #include <CGAL/IO/Nef_polyhedron_iostream_3.h>
33 #include <CGAL/Polyhedral_mesh_domain_3.h>
34 #include <CGAL/make_mesh_3.h>
35 #include <CGAL/refine_mesh_3.h>
38 #include <CGAL/IO/Polyhedron_iostream.h>
41 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
44 #include <CGAL/Polyhedron_3.h>
47 #include <CGAL/Nef_polyhedron_3.h>
48 #include <CGAL/Nef_3/SNC_indexed_items.h>
50 #include <CGAL/bounding_box.h>
53 #include <CGAL/AABB_tree.h>
54 #include <CGAL/AABB_traits.h>
55 #include <CGAL/AABB_face_graph_triangle_primitive.h>
57 #include <CGAL/Side_of_triangle_mesh.h>
59 #include <vtkSmartPointer.h>
60 #include <vtkUnstructuredGrid.h>
61 #include <vtkPolyData.h>
62 #include <vtkSelectEnclosedPoints.h>
65 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
66 typedef CGAL::Polyhedron_3<K> Polyhedron;
67 typedef CGAL::Polyhedral_mesh_domain_3<Polyhedron, K> Mesh_domain;
69 typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_Kernel;
70 typedef CGAL::Polyhedron_3<Exact_Kernel> Exact_polyhedron;
71 typedef CGAL::Cartesian_converter<Exact_Kernel,K> EK_to_K;
72 typedef CGAL::Cartesian_converter<K,Exact_Kernel> K_to_EK;
73 typedef CGAL::Polyhedral_mesh_domain_3<Exact_polyhedron, Exact_Kernel> Exact_Mesh_domain;
74 typedef CGAL::Nef_polyhedron_3<Exact_Kernel,
75 CGAL::SNC_indexed_items,
78 typedef K::Point_3 Point;
79 typedef Exact_Kernel::Point_3 Exact_Point;
81 typedef FT (Function)(
const Point&);
83 typedef Exact_polyhedron::HalfedgeDS Exact_HalfedgeDS;
86 typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
87 typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
89 typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
90 typedef CGAL::AABB_traits<K, Primitive> Traits;
91 typedef CGAL::AABB_tree<Traits> Tree;
93 typedef CGAL::Side_of_triangle_mesh<Polyhedron,K> Side_of_triangle_mesh;
100 typedef std::map< int, std::shared_ptr<Polyhedron> > region_ip_map;
101 typedef std::map< int, std::shared_ptr<Exact_polyhedron> > region_ep_map;
103 int simplify(Polyhedron& boundary);
123 Zone(
int id,
float cl,
float priority) :
124 activity_sphere(NULL), _id(
id), _cl(cl), _priority(priority) {}
126 bool set_activity_sphere(
float x,
float y,
float z,
float r,
int i);
127 void print_activity_sphere();
128 int get_id()
const {
return _id; }
129 float get_priority()
const {
return _priority; }
130 float get_cl()
const {
return _cl; }
131 virtual bool is_container()
const = 0;
132 virtual std::shared_ptr<Exact_polyhedron> exact_polyhedron() = 0;
134 int contains(
const K::Point_3& p,
bool check_activity_sphere=
true)
const {
138 int id = contains_all(p) ? _id : 0;
140 if (
id && check_activity_sphere) {
141 int inactivity_index;
142 if ((inactivity_index = outside_activity_sphere(p)) != 0)
143 return inactivity_index;
148 virtual bool has_tree()
const = 0;
149 virtual float squared_distance(
const K::Point_3& p)
const = 0;
150 virtual bool add_tree() = 0;
151 virtual bool load(std::string filename) = 0;
152 virtual bool is_valid() = 0;
156 virtual bool contains_all(
const K::Point_3& p)
const = 0;
157 int outside_activity_sphere(
const K::Point_3& p)
const {
158 if (activity_sphere) {
159 Point* centre = activity_sphere->centre;
160 float radius = activity_sphere->r;
161 if (CGAL::squared_distance(*centre, p) > radius * radius)
163 return -activity_sphere->i;
173 std::shared_ptr<Side_of_triangle_mesh> _pip;
174 std::shared_ptr<Polyhedron> _ip;
175 std::shared_ptr<Exact_polyhedron> _ep;
179 _tree(NULL), _ip(NULL), _ep(NULL) {}
180 bool is_container()
const {
return (
bool)_pip; }
181 std::shared_ptr<Exact_polyhedron> exact_polyhedron() {
return _ep; }
183 bool has_tree()
const {
return _tree; }
184 float squared_distance(
const K::Point_3& p)
const {
187 return _tree->squared_distance(p);
190 if (!_ip || has_tree())
194 _tree->insert(_ip->facets_begin(), _ip->facets_end(), *_ip);
198 bool is_valid() {
return _ep && _ep->is_valid(); }
199 bool load(std::string filename);
202 bool contains_all(
const K::Point_3& p)
const {
203 return (*_pip)(p) != CGAL::ON_UNBOUNDED_SIDE;
207 bool create_polyhedra(std::shared_ptr<Exact_polyhedron> ep);
211 vtkSmartPointer<vtkUnstructuredGrid> _grid;
215 bool is_container()
const {
return true; };
216 std::shared_ptr<Exact_polyhedron> exact_polyhedron() {
return NULL; };
218 bool has_tree()
const {
return false; };
219 float squared_distance(
const K::Point_3&)
const {
return 0; };
220 bool add_tree() {
return false; };
221 bool is_valid() {
return true; };
222 bool load(std::string filename);
225 bool contains_all(
const K::Point_3& p)
const;
229 vtkSmartPointer<vtkPolyData> _poly;
230 vtkSmartPointer<vtkSelectEnclosedPoints> _select_enclosed;
234 bool is_container()
const {
return true; };
235 std::shared_ptr<Exact_polyhedron> exact_polyhedron() {
return NULL; };
237 bool has_tree()
const {
return false; };
238 float squared_distance(
const K::Point_3&)
const {
return 0; };
239 bool add_tree() {
return false; };
240 bool load(std::string filename);
241 bool is_valid() {
return true; };
244 bool contains_all(
const K::Point_3& p)
const;
Definition: mesher_cgal.h:105
Definition: mesher_cgal.h:210
Definition: implicit_zone_function.h:17
Definition: mesher_cgal.h:228
Definition: mesher_cgal.h:111
Definition: mesher_cgal.h:171