32 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> 35 #include <CGAL/Skin_surface_3.h> 36 #include <CGAL/mesh_skin_surface_3.h> 37 #include <CGAL/subdivide_skin_surface_mesh_3.h> 39 #include <CGAL/Polyhedron_3.h> 40 #include "skin_surface_writer.h" 41 #include <CGAL/IO/Polyhedron_iostream.h> 42 #include <CGAL/subdivide_skin_surface_mesh_3.h> 43 #include <CGAL/Skin_surface_refinement_policy_3.h> 46 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
47 typedef CGAL::Skin_surface_traits_3<K> Traits;
48 typedef CGAL::Skin_surface_3<Traits> Skin_surface_3;
49 typedef Skin_surface_3::FT FT;
50 typedef Skin_surface_3::Weighted_point Weighted_point;
52 typedef Weighted_point::Point Bare_point;
54 typedef CGAL::Polyhedron_3<K,
55 CGAL::Skin_surface_polyhedral_items_3<Skin_surface_3> > Polyhedron;
57 typedef Polyhedron::Traits::Vector_3 Vector;
58 typedef Polyhedron::Vertex_iterator Vertex_iterator;
59 typedef Polyhedron::Halfedge_iterator Halfedge_iterator;
60 typedef Polyhedron::Facet_iterator Facet_iterator;
61 typedef Polyhedron::Halfedge_around_facet_circulator HFC;
62 typedef Polyhedron::Vertex_handle Vertex_handle;
68 std::list<Weighted_point> l;
69 FT shrinkfactor = 0.5;
70 double *Plot =
new double[
pNType()*CUBE(NSample)];
71 double *Count =
new double[CUBE(NSample)];
73 double Radius =
pEdge(0)/(double)NSample;
74 for(
int p=0;p<
pNPart();p++){
76 int vx = (int)(
pPos(p,0)/
pEdge(0)*NSample);
77 int vy = (int)(
pPos(p,1)/
pEdge(1)*NSample);
78 int vz = (int)(
pPos(p,2)/
pEdge(2)*NSample);
79 int vTot = (vz*NSample+vy)*NSample+vx;
80 Plot[vTot*
pNType()+t] += 1.;
82 double *Norm = (
double *)calloc(
pNType(),
sizeof(double));
83 for(
int t=0;t<
pNType();t++){
84 for(
int v=0;v<CUBE(NSample);v++){
85 if(Norm[t] < Plot[v*
pNType()+t])
86 Norm[t] = Plot[v*
pNType()+t];
88 Norm[t] = Norm[t] <= 0. ? 1. : Norm[t];
90 for(
int vx=0;vx<NSample;vx++){
91 double x = vx*
pEdge(0)/(double)NSample;
92 for(
int vy=0;vy<NSample;vy++){
93 double y = vy*
pEdge(1)/(double)NSample;
94 for(
int vz=0;vz<NSample;vz++){
95 double z = vz*
pEdge(2)/(double)NSample;
96 int vTot = (vz*NSample+vy)*NSample+vx;
97 if(Plot[vTot*
pNType()] > Thre){
98 l.push_front(Weighted_point(Bare_point(x,y,z),Radius));
106 Skin_surface_3 skin_surface(l.begin(), l.end(), shrinkfactor);
107 CGAL::mesh_skin_surface_3(skin_surface, Polyhe);
135 CGAL::Inverse_index<Vertex_handle> index(Polyhe.vertices_begin(),
136 Polyhe.vertices_end());
138 for(Facet_iterator fi = Polyhe.facets_begin();fi != Polyhe.facets_end(); ++fi) {
139 HFC hc = fi->facet_begin();
141 Polyhedron::Vertex_handle vf1 = (*hc).vertex();
143 Polyhedron::Vertex_handle vf2 = (*hc).vertex();
145 Polyhedron::Vertex_handle vf3 = (*hc).vertex();
147 K::Point_3 pf1 = vf1->point();
148 K::Point_3 pf2 = vf2->point();
149 K::Point_3 pf3 = vf3->point();
150 Vettore v1(pf1.x(),pf1.y(),pf1.z());
151 Vettore v2(pf2.x(),pf2.y(),pf2.z());
152 Vettore v3(pf3.x(),pf3.y(),pf3.z());
157 vN = (v1-v2) ^ (v3-v2);
160 glColor4f(0.1,.4+Sfumatura,0.2,1.);
163 glColor4f(1.,.0,0.,1.);
217 printf(
"DefSurface without CGAL not implemented\n");
double InvScaleUn
Define the shrink factor between the box edges.
Draw provides the basic configuration of the openGL libraries used in every derived program...
Geometrical operations on vectors.
void DefineSkin(int NSample)
Find the covering surface for given points.
void DrTriaContour(Vettore *v00, Vettore *v01, Vettore *v11)
Draw the contour of three vectors.
int pType(int p)
Return the type.
double pEdge(int d)
xyzr edges of the simulation box
double Casuale()
Random uniform number.
GLuint Particles
Refers to the list of the total position of the particles which will be generated in another program...
Matematica * Mat
Implementation of all usefull algorythms.
int pNType()
of types of the particle
double pPos(int p, int d)
Return back folded position.
void DrTria(Vettore *v00, Vettore *v01, Vettore *v11, Vettore *vN)
single triangle defined by three vectors
int pNPart()
Number of particle.