ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/poly_occ/src/ot_boite_3d.cpp
Revision: 1009
Committed: Mon Mar 25 16:40:06 2019 UTC (6 years, 1 month ago) by francois
File size: 6713 byte(s)
Log Message:
ajout de fichier pour les polycristaux (ajout temporaire)

File Contents

# User Rev Content
1 francois 1009 //------------------------------------------------------------
2     //------------------------------------------------------------
3     // MAGiC
4     // Jean Christophe Cuilli�re et Vincent FRANCOIS
5     // D�partement de G�nie M�canique - UQTR
6     //------------------------------------------------------------
7     // Le projet MAGIC est un projet de recherche du d�partement
8     // de g�nie m�canique de l'Universit� du Qu�bec �
9     // Trois Rivi�res
10     // Les librairies ne peuvent �tre utilis�es sans l'accord
11     // des auteurs (contact : francois@uqtr.ca)
12     //------------------------------------------------------------
13     //------------------------------------------------------------
14     //
15     // ot_boite_3D.cpp
16     //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 � 11H23
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24    
25     //#include "gestionversion.h"
26     #include "ot_boite_3d.h"
27     #include <math.h>
28     #include <algorithm>
29    
30    
31    
32     BOITE_3D::BOITE_3D(double xmin,double ymin,double zmin,double xmax,double ymax,double zmax):x(xmin),y(ymin),z(zmin),dx(xmax-xmin),dy(ymax-ymin),dz(zmax-zmin)
33     {
34     bool recentrage=false;
35     if ((dx<0.0000001) && (dy<0.0000001) && (dz<0.0000001)) recentrage=true;
36     if (dx<0.0000001)
37     {
38     dx=0.00000001;
39     if (recentrage==true) x=x-dx/2.;
40     }
41     if (dy<0.0000001)
42     {
43     dy=0.00000001;
44     if (recentrage==true) y=y-dy/2.;
45     }
46     if (dz<0.0000001)
47     {
48     dz=0.00000001;
49     if (recentrage==true) z=z-dz/2.;
50     }
51     }
52    
53     BOITE_3D::BOITE_3D(void)
54     {
55     }
56    
57     void BOITE_3D::reinit(double xmin,double ymin,double zmin,double xmax,double ymax,double zmax)
58     {
59     x=xmin;
60     y=ymin;
61     z=zmin;
62     dx=xmax-xmin;
63     dy=ymax-ymin;
64     dz=zmax-zmin;
65     bool recentrage=false;
66     if ((dx<0.0000001) && (dy<0.0000001) && (dz<0.0000001)) recentrage=true;
67     if (dx<0.0000001)
68     {
69     dx=0.00000001;
70     if (recentrage==true) x=x-dx/2.;
71     }
72     if (dy<0.0000001)
73     {
74     dy=0.00000001;
75     if (recentrage==true) y=y-dy/2.;
76     }
77     if (dz<0.0000001)
78     {
79     dz=0.00000001;
80     if (recentrage==true) z=z-dz/2.;
81     }
82     }
83    
84     void BOITE_3D::reinit(BOITE_3D& boite)
85     {
86     x=boite.x;
87     y=boite.y;
88     z=boite.z;
89     dx=boite.dx;
90     dy=boite.dy;
91     dz=boite.dz;
92     }
93    
94     BOITE_3D::BOITE_3D(const BOITE_3D& mdd):x(mdd.x),y(mdd.y),z(mdd.z),dx(mdd.dx),dy(mdd.dy),dz(mdd.dz)
95     {
96     }
97    
98     BOITE_3D::BOITE_3D(BOITE_3D& mdd):x(mdd.x),y(mdd.y),z(mdd.z),dx(mdd.dx),dy(mdd.dy),dz(mdd.dz)
99     {
100     }
101    
102     BOITE_3D::~BOITE_3D()
103     {
104     }
105    
106     double BOITE_3D::get_xmin(void)
107     {
108     return x;
109     }
110    
111     double BOITE_3D::get_xmax(void)
112     {
113     return (x+dx);
114     }
115    
116     double BOITE_3D::get_ymin(void)
117     {
118     return y;
119     }
120    
121     double BOITE_3D::get_ymax(void)
122     {
123     return (y+dy);
124     }
125    
126     double BOITE_3D::get_zmin(void)
127     {
128     return z;
129     }
130    
131     double BOITE_3D::get_zmax(void)
132     {
133     return (z+dz);
134     }
135    
136     /*BOITE_3D BOITE_3D::operator=(BOITE_3D& boite)
137     {
138     x=boite.x;
139     y=boite.y;
140     z=boite.z;
141     dx=boite.dx;
142     dy=boite.dy;
143     dz=boite.dz;
144     return *this;
145     }*/
146     double BOITE_3D::get_rayon(void)
147     {
148     return (0.5*sqrt(dx*dx+dy*dy+dz*dz));
149     }
150    
151     void BOITE_3D::get_centre(double *coo)
152     {
153     coo[0]=x+dx*0.5;
154     coo[1]=y+dy*0.5;
155     coo[2]=z+dz*0.5;
156     }
157    
158     double BOITE_3D::get_xcentre(void)
159     {
160     return x+dx*0.5;
161     }
162    
163     double BOITE_3D::get_ycentre(void)
164     {
165     return y+dy*0.5;
166     }
167    
168     double BOITE_3D::get_zcentre(void)
169     {
170     return z+dz*0.5;
171     }
172    
173     double BOITE_3D::get_volume(void)
174     {
175     return(get_xmax()-get_xmin())*(get_ymax()-get_ymin())*(get_zmax()-get_zmin());
176     }
177    
178     void BOITE_3D::change_grosseur(double f)
179     {
180     double centre[3];
181     get_centre(centre);
182     dx=dx*f;
183     dy=dy*f;
184     dz=dz*f;
185     reinit(centre[0]-dx/2.,centre[1]-dy/2.,centre[2]-dz/2.,centre[0]+dx/2.,centre[1]+dy/2.,centre[2]+dz/2.);
186     }
187    
188     int BOITE_3D::operator*(BOITE_3D& boite)
189     {
190     if ( x+dx>=boite.x)
191     if ( y+dy>=boite.y)
192     if ( z+dz>=boite.z)
193     if ( x<(boite.x+boite.dx))
194     if ( y<(boite.y+boite.dy))
195     if ( z<(boite.z+boite.dz))
196     return 1;
197     return 0;
198     }
199    
200    
201     int BOITE_3D::get_intersection(BOITE_3D& boite)
202     {
203     if((boite.get_xmin()<=get_xmax() && boite.get_xmax()>=get_xmin()) || (get_xmin()<=boite.get_xmax() && get_xmax()>=boite.get_xmin()))
204     if((boite.get_ymin()<=get_ymax() && boite.get_ymax()>=get_ymin()) || (get_ymin()<=boite.get_ymax() && get_ymax()>=boite.get_ymin()))
205     if((boite.get_zmin()<=get_zmax() && boite.get_zmax()>=get_zmin()) || (get_zmin()<=boite.get_zmax() && get_zmax()>=boite.get_zmin())) return 1;
206     return 0;
207     }
208    
209    
210    
211     int BOITE_3D::operator*(const BOITE_3D& boite)
212     {
213     if ( x+dx>=boite.x)
214     if ( y+dy>=boite.y)
215     if ( z+dz>=boite.z)
216     if ( x<(boite.x+boite.dx))
217     if ( y<(boite.y+boite.dy))
218     if ( z<(boite.z+boite.dz))
219     return 1;
220     return 0;
221     }
222    
223    
224     BOITE_3D operator&(const BOITE_3D& boite1,const BOITE_3D& boite2)
225     {
226     double xmin1=boite1.x;
227     double ymin1=boite1.y;
228     double zmin1=boite1.z;
229     double xmin2=boite2.x;
230     double ymin2=boite2.y;
231     double zmin2=boite2.z;
232     double xmax1=boite1.x+boite1.dx;
233     double ymax1=boite1.y+boite1.dy;
234     double zmax1=boite1.z+boite1.dz;
235     double xmax2=boite2.x+boite2.dx;
236     double ymax2=boite2.y+boite2.dy;
237     double zmax2=boite2.z+boite2.dz;
238     double xmin=std::max(xmin1,xmin2);
239     double ymin=std::max(ymin1,ymin2);
240     double zmin=std::max(zmin1,zmin2);
241     double xmax=std::min(xmax1,xmax2);
242     double ymax=std::min(ymax1,ymax2);
243     double zmax=std::min(zmax1,zmax2);
244     BOITE_3D tmp(xmin,ymin,zmin,xmax,ymax,zmax);
245     return tmp;
246     }
247    
248    
249     BOITE_3D operator+(const BOITE_3D& boite1,const BOITE_3D& boite2)
250     {
251     double xmin1=boite1.x;
252     double ymin1=boite1.y;
253     double zmin1=boite1.z;
254     double xmin2=boite2.x;
255     double ymin2=boite2.y;
256     double zmin2=boite2.z;
257     double xmax1=boite1.x+boite1.dx;
258     double ymax1=boite1.y+boite1.dy;
259     double zmax1=boite1.z+boite1.dz;
260     double xmax2=boite2.x+boite2.dx;
261     double ymax2=boite2.y+boite2.dy;
262     double zmax2=boite2.z+boite2.dz;
263     double xmin=std::min(xmin1,xmin2);
264     double ymin=std::min(ymin1,ymin2);
265     double zmin=std::min(zmin1,zmin2);
266     double xmax=std::max(xmax1,xmax2);
267     double ymax=std::max(ymax1,ymax2);
268     double zmax=std::max(zmax1,zmax2);
269     BOITE_3D tmp(xmin,ymin,zmin,xmax,ymax,zmax);
270     return tmp;
271     }
272     int BOITE_3D::contient(double xx,double yy,double zz)
273     {
274     if (xx>=x)
275     if (yy>=y)
276     if (zz>=z)
277     if (xx<=x+dx)
278     if (yy<=y+dy)
279     if (zz<=z+dz)
280     return 1;
281    
282    
283     return 0;
284     }
285    
286    
287