ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/outil/src/ot_boite_3d.cpp
Revision: 926
Committed: Tue May 1 20:38:42 2018 UTC (7 years, 1 month ago) by couturad
Original Path: magic/lib/outil/src/ot_boite_3d.cpp
File size: 5310 byte(s)
Log Message:
Ajout de nouvelles fonctionnalités de representation et d'analyse des VES
*Modification du CMakeLists.txt de microstructure

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