6 #include <CGAL/basic.h> 7 #include <CGAL/Cartesian.h> 8 #include <CGAL/IO/Color.h> 9 #include <CGAL/Triangulation_euclidean_traits_2.h> 10 #include <CGAL/Triangulation_default_data_structure_2.h> 11 #include <CGAL/Triangulation_2.h> 12 #include <CGAL/Delaunay_triangulation_2.h> 13 #include <CGAL/Voronoi_diagram_2.h> 14 #include <CGAL/Delaunay_triangulation_adaptation_traits_2.h> 15 #include <CGAL/Delaunay_triangulation_adaptation_policies_2.h> 31 Triangulation_face_base_2<Gt>() {}
33 Triangulation_face_base_2<Gt>(v0,v1,v2) {}
34 My_face_base(
void* v0,
void* v1,
void* v2,
void* n0,
void* n1,
void* n2) :
35 Triangulation_face_base_2<Gt>(v0,v1,v2,n0,n1,n2) {}
38 typedef Cartesian<double> Rp;
39 typedef Triangulation_euclidean_traits_2<Rp> Gt;
40 typedef Triangulation_vertex_base_2<Gt> Vb;
42 typedef Triangulation_default_data_structure_2<Gt,Vb,Fb > Tds;
43 typedef Triangulation_2<Gt,Tds> Triangulation;
45 typedef Delaunay_triangulation_2<Gt,Tds> DT;
46 typedef Delaunay_triangulation_adaptation_traits_2<DT> AT;
47 typedef Delaunay_triangulation_caching_degeneracy_removal_policy_2 <DT> AP;
48 typedef Voronoi_diagram_2<DT,AT,AP> VD;
49 typedef Point_2<Rp> Point;
50 typedef Triangulation::Face_handle Face_handle;
51 typedef Triangulation::Face_iterator Face_iterator;
52 typedef Triangulation::Vertex Vertex;
53 typedef Triangulation::Vertex_handle Vertex_handle;
54 typedef Triangulation::Vertex_iterator Vertex_iterator;
60 typedef Triangulation::Finite_vertices_iterator Finite_vertices_iterator;
63 double BoxRadInv = pInvEdge(3);
65 double AreaMean = 3.*.5*Gen->NChain/(Gen->Edge[CLat1]*Gen->Edge[CLat2]);
71 for(
int c=0;c<Gen->NChain;c++){
72 if(CHAIN_IF_TYPE(Ch[c].Type,CHAIN_UP) ){
73 Point ChPos(Ch[c].Pos[CLat1],Ch[c].Pos[CLat2]);
77 Point ChPos(Ch[c].Pos[CLat1],Ch[c].Pos[CLat2]);
82 Face_iterator fcTrUp = dtUp.finite_faces_begin();
83 Face_iterator fcTrDown = dtDown.finite_faces_begin();
86 double *Norma =
new double[Values];
87 memset(RadDistr,0.,Values*
sizeof(
double));
88 vector <double> Areas;
89 for(;fcTrUp != dtUp.faces_end(); ++fcTrUp){
90 Vertex_handle vf1 = fcTrUp->vertex(0),
91 vf2 = fcTrUp->vertex(1),vf3 = fcTrUp->vertex(2);
92 Point pf1 = vf1->point();
93 Point pf2 = vf2->point();
94 Point pf3 = vf3->point();
95 Vettore v1(pf1.x() - pf2.x(),pf1.y() - pf2.y(),0.);
96 Vettore v2(pf3.x() - pf2.x(),pf3.y() - pf2.y(),0.);
97 double Area = v1.
VetV(&v2);
98 double Distx = Nano->Pos[CLat1] - (pf1.x() + pf2.x() + pf3.x())/3.;
99 double Disty = Nano->Pos[CLat2] - (pf1.y() + pf2.y() + pf3.y())/3.;
100 double Rad = sqrt( SQR(Distx) + SQR(Disty) );
101 if(Rad < Nano->Rad){
continue;}
102 int v = (int)(Rad*BoxRadInv*Values);
104 if(v < 0 || v >= Values){
continue;}
106 Areas.push_back(Area);
110 for(;fcTrDown != dtDown.faces_end(); ++fcTrDown){
111 Vertex_handle vf1 = fcTrDown->vertex(0),
112 vf2 = fcTrDown->vertex(1),vf3 = fcTrDown->vertex(2);
113 Point pf1 = vf1->point();
114 Point pf2 = vf2->point();
115 Point pf3 = vf3->point();
116 Vettore v1(pf1.x() - pf2.x(),pf1.y() - pf2.y(),0.);
117 Vettore v2(pf3.x() - pf2.x(),pf3.y() - pf2.y(),0.);
118 double Area = v1.
VetV(&v2);
119 double Distx = Nano->Pos[CLat1] - (pf1.x() + pf2.x() + pf3.x())/3.;
120 double Disty = Nano->Pos[CLat2] - (pf1.y() + pf2.y() + pf3.y())/3.;
121 double Rad = sqrt( SQR(Distx) + SQR(Disty) );
123 int v = (int)(Rad*BoxRadInv*Values);
124 if(v < 0 || v >= Values){
continue;}
126 Areas.push_back(Area);
133 vector <double>::iterator iArea;
134 for(iArea=Areas.begin();iArea!=Areas.end();iArea++){
135 int v = (int)(*iArea/AreaMean*Values);
136 if(v < 0 || v >= Values){
continue;}
171 printf(
"AreaDistr without CGAL not implemented\n");
void AreaDistr(double *Distr, double *RadDistr, int NSample)
Calculate the (temporal/radial) area distribution.
Geometrical operations on vectors.
double VetV(const Vettore *u, const Vettore *v)
Vectorial product between two Vettore returns the area.