ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/outil/src/ot_boite_3d.cpp
Revision: 951
Committed: Fri Aug 10 15:17:17 2018 UTC (6 years, 10 months ago) by couturad
Original Path: magic/lib/outil/src/ot_boite_3d.cpp
File size: 6369 byte(s)
Log Message:
-> Ajout de Project Chrono (voir CMakeLists.txt).
-> Ajout d'un générateur de microstructure basé sur la dynamique des corps rigides (MSTRUCT_GENERATEUR_DCR).
-> Ajout d'un opérateur de décallage de la topologie (MG_CG_OP_TRANSF_DECALLAGE).
-> Retrait de «using namespace std»  (conflit avec namespace chrono) et modification des fichiers affectés.
-> Modification de mailleur2d.cpp afin d'enregistrer un fichier MAGiC (void.magic) lorsque le nombre d'itération dépasse la valeur maximale.

File Contents

# User Rev Content
1 francois 283 //------------------------------------------------------------
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 francois 481 #include "ot_boite_3d.h"
27 francois 283 #include <math.h>
28 francois 632 #include <algorithm>
29 francois 283
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 francois 950 if (dx<0.0000001)
35     {
36     dx=0.00000001;
37     x=x-dx/2.;
38     }
39     if (dy<0.0000001)
40     {
41     dy=0.00000001;
42     y=y-dy/2.;
43     }
44     if (dz<0.0000001)
45     {
46     dz=0.00000001;
47     z=z-dz/2.;
48     }
49 francois 283 }
50    
51     BOITE_3D::BOITE_3D(void)
52     {
53     }
54    
55     void BOITE_3D::reinit(double xmin,double ymin,double zmin,double xmax,double ymax,double zmax)
56     {
57     x=xmin;
58     y=ymin;
59     z=zmin;
60     dx=xmax-xmin;
61     dy=ymax-ymin;
62     dz=zmax-zmin;
63 francois 950 if (dx<0.0000001)
64     {
65     dx=0.00000001;
66     x=x-dx/2.;
67     }
68     if (dy<0.0000001)
69     {
70     dy=0.00000001;
71     y=y-dy/2.;
72     }
73     if (dz<0.0000001)
74     {
75     dz=0.00000001;
76     z=z-dz/2.;
77     }
78 francois 283 }
79    
80     void BOITE_3D::reinit(BOITE_3D& boite)
81     {
82     x=boite.x;
83     y=boite.y;
84     z=boite.z;
85     dx=boite.dx;
86     dy=boite.dy;
87     dz=boite.dz;
88     }
89    
90     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)
91     {
92     }
93    
94     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)
95     {
96     }
97    
98     BOITE_3D::~BOITE_3D()
99     {
100     }
101    
102     double BOITE_3D::get_xmin(void)
103     {
104     return x;
105     }
106    
107     double BOITE_3D::get_xmax(void)
108     {
109     return (x+dx);
110     }
111    
112     double BOITE_3D::get_ymin(void)
113     {
114     return y;
115     }
116    
117     double BOITE_3D::get_ymax(void)
118     {
119     return (y+dy);
120     }
121    
122     double BOITE_3D::get_zmin(void)
123     {
124     return z;
125     }
126    
127     double BOITE_3D::get_zmax(void)
128     {
129     return (z+dz);
130     }
131    
132 francois 632 /*BOITE_3D BOITE_3D::operator=(BOITE_3D& boite)
133 francois 283 {
134     x=boite.x;
135     y=boite.y;
136     z=boite.z;
137     dx=boite.dx;
138     dy=boite.dy;
139     dz=boite.dz;
140     return *this;
141 francois 632 }*/
142 francois 283 double BOITE_3D::get_rayon(void)
143     {
144     return (0.5*sqrt(dx*dx+dy*dy+dz*dz));
145     }
146    
147     void BOITE_3D::get_centre(double *coo)
148     {
149     coo[0]=x+dx*0.5;
150     coo[1]=y+dy*0.5;
151     coo[2]=z+dz*0.5;
152     }
153    
154     double BOITE_3D::get_xcentre(void)
155     {
156     return x+dx*0.5;
157     }
158    
159     double BOITE_3D::get_ycentre(void)
160     {
161     return y+dy*0.5;
162     }
163    
164     double BOITE_3D::get_zcentre(void)
165     {
166     return z+dz*0.5;
167     }
168    
169 couturad 913 double BOITE_3D::get_volume(void)
170     {
171     return(get_xmax()-get_xmin())*(get_ymax()-get_ymin())*(get_zmax()-get_zmin());
172     }
173    
174 francois 378 void BOITE_3D::change_grosseur(double f)
175     {
176     double centre[3];
177     get_centre(centre);
178     dx=dx*f;
179     dy=dy*f;
180     dz=dz*f;
181     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.);
182     }
183 francois 283
184     int BOITE_3D::operator*(BOITE_3D& boite)
185     {
186     if ( x+dx>=boite.x)
187     if ( y+dy>=boite.y)
188     if ( z+dz>=boite.z)
189     if ( x<(boite.x+boite.dx))
190     if ( y<(boite.y+boite.dy))
191     if ( z<(boite.z+boite.dz))
192     return 1;
193     return 0;
194     }
195    
196 couturad 951
197     int BOITE_3D::get_intersection(BOITE_3D& boite)
198     {
199     if((boite.get_xmin()<=get_xmax() && boite.get_xmax()>=get_xmin()) || (get_xmin()<=boite.get_xmax() && get_xmax()>=boite.get_xmin()))
200     if((boite.get_ymin()<=get_ymax() && boite.get_ymax()>=get_ymin()) || (get_ymin()<=boite.get_ymax() && get_ymax()>=boite.get_ymin()))
201     if((boite.get_zmin()<=get_zmax() && boite.get_zmax()>=get_zmin()) || (get_zmin()<=boite.get_zmax() && get_zmax()>=boite.get_zmin())) return 1;
202     return 0;
203     }
204    
205    
206    
207 francois 945 int BOITE_3D::operator*(const BOITE_3D& boite)
208     {
209     if ( x+dx>=boite.x)
210     if ( y+dy>=boite.y)
211     if ( z+dz>=boite.z)
212     if ( x<(boite.x+boite.dx))
213     if ( y<(boite.y+boite.dy))
214     if ( z<(boite.z+boite.dz))
215     return 1;
216     return 0;
217     }
218    
219 couturad 951
220 francois 632 BOITE_3D operator&(const BOITE_3D& boite1,const BOITE_3D& boite2)
221     {
222     double xmin1=boite1.x;
223     double ymin1=boite1.y;
224     double zmin1=boite1.z;
225     double xmin2=boite2.x;
226     double ymin2=boite2.y;
227     double zmin2=boite2.z;
228     double xmax1=boite1.x+boite1.dx;
229     double ymax1=boite1.y+boite1.dy;
230     double zmax1=boite1.z+boite1.dz;
231     double xmax2=boite2.x+boite2.dx;
232     double ymax2=boite2.y+boite2.dy;
233     double zmax2=boite2.z+boite2.dz;
234     double xmin=std::max(xmin1,xmin2);
235     double ymin=std::max(ymin1,ymin2);
236     double zmin=std::max(zmin1,zmin2);
237     double xmax=std::min(xmax1,xmax2);
238     double ymax=std::min(ymax1,ymax2);
239     double zmax=std::min(zmax1,zmax2);
240     BOITE_3D tmp(xmin,ymin,zmin,xmax,ymax,zmax);
241     return tmp;
242     }
243    
244    
245     BOITE_3D operator+(const BOITE_3D& boite1,const BOITE_3D& boite2)
246     {
247     double xmin1=boite1.x;
248     double ymin1=boite1.y;
249     double zmin1=boite1.z;
250     double xmin2=boite2.x;
251     double ymin2=boite2.y;
252     double zmin2=boite2.z;
253     double xmax1=boite1.x+boite1.dx;
254     double ymax1=boite1.y+boite1.dy;
255     double zmax1=boite1.z+boite1.dz;
256     double xmax2=boite2.x+boite2.dx;
257     double ymax2=boite2.y+boite2.dy;
258     double zmax2=boite2.z+boite2.dz;
259     double xmin=std::min(xmin1,xmin2);
260     double ymin=std::min(ymin1,ymin2);
261     double zmin=std::min(zmin1,zmin2);
262     double xmax=std::max(xmax1,xmax2);
263     double ymax=std::max(ymax1,ymax2);
264     double zmax=std::max(zmax1,zmax2);
265     BOITE_3D tmp(xmin,ymin,zmin,xmax,ymax,zmax);
266     return tmp;
267     }
268 francois 283 int BOITE_3D::contient(double xx,double yy,double zz)
269     {
270     if (xx>=x)
271     if (yy>=y)
272     if (zz>=z)
273     if (xx<=x+dx)
274     if (yy<=y+dy)
275     if (zz<=z+dz)
276     return 1;
277    
278    
279     return 0;
280     }
281    
282    
283 couturad 926