ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/CAD4FE_PolySurface.cpp
Revision: 1075
Committed: Tue Aug 10 17:02:54 2021 UTC (4 years ago) by francois
File size: 8968 byte(s)
Log Message:
suppression de warning avec le dernier compilateur

File Contents

# Content
1 //---------------------------------------------------------------------------
2
3 //---------------------------------------------------------------------------
4 // include MAGIC Headers
5 #include "gestionversion.h"
6 #include "mg_geometrie.h"
7 #include "mg_arete.h"
8 #include "tpl_fonction.h"
9
10 //---------------------------------------------------------------------------
11 // include STL headers
12 //---------------------------------------------------------------------------
13 #include <map>
14 #include <ostream>
15 #include <string>
16 #include <vector>
17 //---------------------------------------------------------------------------
18
19
20 #pragma hdrstop
21
22 #include "CAD4FE_PolySurface.h"
23 #include "CAD4FE_MCVertex.h"
24 #include "ot_mathematique.h"
25 #include "math.h"
26
27 //---------------------------------------------------------------------------
28
29 #pragma package(smart_init)
30
31 #ifdef __BORLANDC__
32 #pragma warn -8012
33 #endif
34
35 using namespace CAD4FE;
36
37 //---------------------------------------------------------------------------
38 PolySurface::PolySurface(MG_FACE * __refFace)
39 {
40 // Add the reference face in the list of faces
41 _lst_ref_faces.insert(__refFace);
42 }
43 //---------------------------------------------------------------------------
44
45 void PolySurface::InsertSurface(MG_FACE *__refFace)
46 {
47 // Add the reference face in the list of faces
48 _lst_ref_faces.insert(__refFace);
49 }
50 //---------------------------------------------------------------------------
51
52 void PolySurface::Merge( PolySurface & __polySurface )
53 {
54 // Add the reference faces in the list of faces
55 std::set<MG_FACE*> & r = __polySurface._lst_ref_faces;
56
57 for (std::set<MG_FACE*>::iterator itRefFace = r.begin();
58 itRefFace != r.end();
59 itRefFace++)
60 _lst_ref_faces.insert(*itRefFace);
61 }
62
63 //---------------------------------------------------------------------------
64
65 void PolySurface::evaluer(double *uv,double *xyz)
66 {
67
68 }
69
70 //---------------------------------------------------------------------------
71
72 void PolySurface::deriver(double *uv,double *xyzdu, double *xyzdv)
73 {
74
75 }
76
77
78 //---------------------------------------------------------------------------
79 void PolySurface::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz, double *xyzdu, double *xyzdv)
80 {
81
82 }
83
84
85 //---------------------------------------------------------------------------
86 void PolySurface::inverser(double *uv,double *xyz,double precision)
87 {
88
89 }
90
91 bool PolySurface::est_sur_surface(double* xyz, double precision)
92 {
93 std::cout <<" *** PolySurface::est_sur_surface : FONCTION NON IMPLEMENTE ***" << std::endl;
94 return false;
95 }
96
97 //---------------------------------------------------------------------------
98
99 int PolySurface::est_periodique_u(void)
100 {
101
102 return 0;
103 }
104
105
106 //---------------------------------------------------------------------------
107 int PolySurface::est_periodique_v(void)
108 {
109
110 return 0;
111 }
112
113
114 //---------------------------------------------------------------------------
115 double PolySurface::get_periode_u(void)
116 {
117
118 return 0;
119 }
120
121 //---------------------------------------------------------------------------
122
123 double PolySurface::get_periode_v(void)
124 {
125 return 0;
126
127 }
128
129
130 //---------------------------------------------------------------------------
131
132 void PolySurface::enregistrer(std::ostream& o,double version)
133 {
134 // %ID=CAD4FE_POLYSURFACE(MG_FACE_1,MG_FACE_2,...,MG_FACE_N)
135 unsigned int i;
136
137 o << "%" << get_id()
138 << "=CAD4FE_POLYSURFACE(" << GetRefFaceCount() << ",(";
139
140 for (i=0; i < GetRefFaceCount(); i++)
141 {
142 if ( i ) o <<",";
143 o << "$" << GetRefFace(i)->get_id();
144 }
145
146 o << "));" << std::endl;;
147 }
148
149
150 //---------------------------------------------------------------------------
151 int PolySurface::get_type_geometrique(TPL_LISTE_ENTITE<double> &param)
152 {
153 return 0;
154 }
155 //---------------------------------------------------------------------------
156
157 bool PolySurface::Contains(MG_ARETE * __refEdge)
158 {
159 int nb_coedge = __refEdge->get_nb_mg_coarete();
160 for (int i=0; i<nb_coedge; i++)
161 {
162 MG_FACE * f = __refEdge->get_mg_coarete(i)->get_boucle()->get_mg_face();
163 if (Contains(f))
164 return true;
165 }
166 return false;
167 }
168 //---------------------------------------------------------------------------
169
170 bool PolySurface::Contains(MG_FACE * __refFace)
171 {
172 return ( _lst_ref_faces.find(__refFace) != _lst_ref_faces.end());
173 }
174 //---------------------------------------------------------------------------
175
176 MG_FACE * PolySurface::GetRefFace(unsigned int __index)
177 {
178 std::set<MG_FACE*>::iterator itFace = _lst_ref_faces.begin();
179 std::advance (itFace, __index);
180 return *itFace;
181 }
182 //---------------------------------------------------------------------------
183
184 std::set<MG_FACE*> & PolySurface::GetRefFaces()
185 {
186 return _lst_ref_faces;
187 }
188 //---------------------------------------------------------------------------
189
190 unsigned int PolySurface::GetRefFaceCount()
191 {
192 return _lst_ref_faces.size();
193 }
194 //---------------------------------------------------------------------------
195 void PolySurface::calcul_normale_unitaire(MG_SOMMET *v, double __normal[3], int * __nbRefFace)
196 {
197 double angleTot=0;
198 OT_VECTEUR_3D normalTriangle(0,0,0);
199
200 MG_NOEUD * refNode = 0;
201 TPL_SET < MG_ELEMENT_MAILLAGE * > * refNodeMesh = v->get_lien_maillage();
202 TPL_SET < MG_ELEMENT_MAILLAGE * >::ITERATEUR it;
203 refNode = (MG_NOEUD *)refNodeMesh->get_premier(it);
204 TPL_LISTE_ENTITE<MG_TRIANGLE*>* adjacentTriangles = refNode->get_lien_triangle();
205 unsigned itTriang;
206 for (itTriang=0;itTriang <adjacentTriangles->get_nb(); itTriang++)
207 {
208 MG_TRIANGLE* t = adjacentTriangles->get(itTriang);
209 MG_FACE * refFace = (MG_FACE*) t->get_lien_topologie();
210 if ( Contains(refFace) == false)
211 continue;
212 int id=-1;
213 MG_NOEUD * nos[3]={t->get_noeud1(),t->get_noeud2(),t->get_noeud3()};
214 for (int j=0;j<3;j++)
215 if (nos[j] == refNode)
216 {
217 id = j;
218 break;
219 }
220 OT_VECTEUR_3D x[3];
221 for (int j=0;j<3;j++)
222 x[j]=OT_VECTEUR_3D(nos[j]->get_coord());
223 OT_VECTEUR_3D x1x2 = x[id]-x[(id+2)%3];
224 x1x2.norme();
225 OT_VECTEUR_3D x2x3 = x[(id+1)%3]-x[id];
226 x2x3.norme();
227 OT_VECTEUR_3D normal = x1x2&x2x3;
228 double angle = acos(-(x1x2*x2x3));
229 normal *= angle;
230 angleTot += angle;
231 normalTriangle += normal;
232 }
233 if (angleTot != 0)
234 {
235 normalTriangle /= angleTot;
236 for (int j=0;j<3;j++)
237 __normal[j]=normalTriangle[j];
238 }
239 else
240 {
241 for (int j=0;j<3;j++)
242 __normal[j]=0;
243 }
244 *__nbRefFace = ceil(angleTot);
245 }
246 //---------------------------------------------------------------------------
247
248 void PolySurface::calcul_normale_unitaire(MCVertex * __mcVertex, double __n[3], int *__nbRefFace)
249 {
250 // normal = 1/n * sum_i=1,n ( normal(ref face) )
251 // where n is the number of reference faces adjacent to reference vertex and contained in the MC Face
252
253 OT_VECTEUR_3D tmpNormal(0,0,0);
254 MG_SOMMET * v = __mcVertex->GetRefVertex();
255 int nbRefFace=0;
256 calcul_normale_unitaire(v, __n, &nbRefFace);
257 std::map <unsigned long, MG_SOMMET *> & mergedVertices = __mcVertex->GetMergedRefVertices();
258 for (std::map <unsigned long, MG_SOMMET *>::iterator itRefVertex=mergedVertices.begin();
259 itRefVertex != mergedVertices.end();
260 itRefVertex++)
261 {
262 v = itRefVertex->second;
263 int tmpnbRefFace;
264 calcul_normale_unitaire(v, tmpNormal, &tmpnbRefFace);
265 for (int i=0;i<3;i++) __n[i]+=tmpNormal[i];
266 nbRefFace += tmpnbRefFace;
267 }
268 *__nbRefFace = nbRefFace;
269 }
270 //---------------------------------------------------------------------------
271
272 void PolySurface::calcul_normale_unitaire(const std::map<MG_FACE *, OT_VECTEUR_3D > & __tabRefFaceUV, double __n[3], int *__nbRefFace)
273 {
274 (*__nbRefFace) = 0;
275 OT_VECTEUR_3D n(0,0,0);
276
277 for (std::map<MG_FACE *, OT_VECTEUR_3D >::const_iterator itF = __tabRefFaceUV.begin();
278 itF != __tabRefFaceUV.end(); itF++)
279 {
280 MG_FACE * refFace = itF->first;
281
282 if ( _lst_ref_faces.find(refFace) == _lst_ref_faces.end() )
283 continue;
284
285 OT_VECTEUR_3D refFaceNormal;
286 OT_VECTEUR_3D refFaceUV=itF->second;
287 refFace->calcul_normale_unitaire(refFaceUV,refFaceNormal);
288
289 n += refFaceNormal;
290
291 (*__nbRefFace)++;
292 }
293
294 if ((*__nbRefFace)==0)
295 return;
296
297 n /= (*__nbRefFace);
298
299 double inv_n_norm = 1/n.get_longueur();
300 for (int i=0; i<3; i++)
301 __n[i]=n[i]*inv_n_norm;
302 }
303
304 void PolySurface::get_param_NURBS(int& indx_premier_ptctr, TPL_LISTE_ENTITE<double> &param)
305 {
306 return;
307 }
308
309 void PolySurface::get_liste_pole(std::vector<double> *liste_pole,double eps)
310 {
311 printf("void PolySurface::get_liste_pole(std::vector<double> *liste_pole) : Fonction non implementee !\n");
312 }
313
314
315