ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/reconstruction/src/occ_fonction.cpp
Revision: 547
Committed: Wed Sep 10 14:48:44 2014 UTC (10 years, 8 months ago) by francois
File size: 16821 byte(s)
Log Message:
Compatibilite avec ubuntu 14.04 LTS

File Contents

# User Rev Content
1 louhichi 211 //---------------------------------------------------------------------------
2 5 #include "gestionversion.h"
3 louhichi 211 #ifdef BREP_OCC
4 5
5     #pragma hdrstop
6    
7 francois 481 #include "occ_fonction.h"
8 5 #include "tpl_map_entite.h"
9    
10 louhichi 211
11 5 //---------------------------------------------------------------------------
12    
13     #pragma package(smart_init)
14    
15 louhichi 211
16    
17 5 OCC_FONCTION::OCC_FONCTION()
18     {
19 louhichi 211
20 5 }
21    
22     OCC_FONCTION::~OCC_FONCTION()
23     {
24     }
25 francois 38
26 louhichi 211
27     //********************************** Classe Reconstruction generale ************
28 5 int OCC_FONCTION::Creer_Coquille()
29     {
30 louhichi 211 B.MakeShell(Sh);
31 souaissa 116 return true;
32 louhichi 211
33 5 }
34     int OCC_FONCTION::Ajouter_face_Coquille()
35     {
36 louhichi 211 B.Add(Sh,F1);
37 souaissa 116 return true;
38 5 }
39 louhichi 211 int OCC_FONCTION::Enregistrer(char* fich)
40 5 {
41 louhichi 211 TopoDS_Solid Sol;
42     B.MakeSolid(Sol);
43     B.Add(Sol,Sh);
44     STEPControl_Writer writer;
45     writer.Transfer(Sol, STEPControl_ManifoldSolidBrep);
46     writer.Write(fich);
47 souaissa 116 return true;
48 louhichi 211 }
49 souaissa 116
50 louhichi 211 //************************************ Classe Face Plane ***********************
51    
52    
53 souaissa 116 int OCC_FONCTION::Ajouter_Contour_Face(int num_loop)
54 5 {
55 louhichi 211 TopoDS_Wire W11 = W1;
56 souaissa 116 if (num_loop==0)
57     {
58     //W11.Reverse();
59 francois 547 const Handle_Geom_Surface Surf=Surf1;
60     F1 = BRepBuilderAPI_MakeFace(Surf,W11,Standard_True);
61 louhichi 211
62 francois 547 BRepBuilderAPI_MakeFace F3(Surf,1e-6);
63     F3.Init(Surf,Standard_False,1e-6);
64 souaissa 116 F3.Add(W11);
65    
66 louhichi 211 F1 = F3;
67    
68 souaissa 116 Face_Revol = F3.IsDone();
69     }
70     if(num_loop > 0)
71     {
72 francois 547 BRepBuilderAPI_MakeFace F2(Surf1,1e-6);
73     F2.Init(Surf1,Standard_False,1e-6);
74 souaissa 116 F2.Add(W11);
75 louhichi 211
76 souaissa 116 if(F2.IsDone())
77     {
78     W11.Reverse();
79     }
80 louhichi 211 F1 = BRepBuilderAPI_MakeFace(F1,W11);
81     }
82 souaissa 116 return true;
83 5 }
84    
85    
86 louhichi 211
87     //************************************* Classe Face Cylindrique ****************
88    
89     int OCC_FONCTION::Creer_Surface_Cylindrique(double Pnt_Insersion[], double Vect_Directeur[], double Rayon)
90 5 {
91 souaissa 116 gp_Pnt Pnt(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]);
92     gp_Dir Vect(Vect_Directeur[0],Vect_Directeur[1],Vect_Directeur[2]);
93    
94 louhichi 211 gp_Ax3 Axe(Pnt,Vect);
95 souaissa 116
96 louhichi 211 Surf1 = new Geom_CylindricalSurface(gp_Cylinder(Axe, Rayon));
97 souaissa 116 return true;
98 5 }
99 louhichi 211
100     //************************************* Classe Face Conique ********************
101    
102 5 int OCC_FONCTION::Creer_Surface_Conique(double Pnt_Insersion[3], double Vect_Directeur[3],double Rayon, double Angle)
103     {
104 souaissa 116 gp_Pnt Pnt(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]);
105     gp_Dir Vect(Vect_Directeur[0],Vect_Directeur[1],Vect_Directeur[2]);
106    
107     gp_Ax3 Axe(Pnt,Vect);
108    
109 louhichi 211 Surf1 = new Geom_ConicalSurface(Axe,Angle,Rayon);
110 souaissa 116 return true;
111 louhichi 211 }
112 souaissa 116
113 louhichi 211
114     //************************************ Classe Tore *****************************
115    
116 5 int OCC_FONCTION::Creer_Surface_Torique(double Pnt_Insersion[], double Vect_Directeur[], double GRayon, double PRayon)
117     {
118 souaissa 116 gp_Pnt Pnt(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]);
119     gp_Dir Vect(Vect_Directeur[0],Vect_Directeur[1],Vect_Directeur[2]);
120    
121     gp_Ax3 Axe(Pnt,Vect);
122    
123 louhichi 211 Surf1 = new Geom_ToroidalSurface(Axe,GRayon,PRayon);
124 souaissa 116 return true;
125 5 }
126 louhichi 211
127     //*********************************** Classe Spherique *************************
128    
129 5 int OCC_FONCTION::Creer_Surf_Spherique(double Pnt_Insersion[], double Vect_Directeur[], double Rayon)
130     {
131 souaissa 116 gp_Pnt Pnt(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]);
132     gp_Dir Vect(Vect_Directeur[0],Vect_Directeur[1],Vect_Directeur[2]);
133    
134     gp_Ax3 Axe(Pnt,Vect);
135    
136 louhichi 211 Surf1 = new Geom_SphericalSurface(Axe,Rayon);
137 souaissa 116 return true;
138 5 }
139 louhichi 211
140    
141     //*********************************** Classe Face NURBS ************************
142    
143 5 int OCC_FONCTION::Initialiser_Surface()
144     {
145 louhichi 211 BPSurf = GeomPlate_BuildPlateSurface(3,10,3);
146 souaissa 116 return true;
147 5 }
148 louhichi 211 int OCC_FONCTION::Rapprocher_Surface_Point(double x, double y, double z)
149 5 {
150 louhichi 211 gp_Pnt P(x,y,z);
151 souaissa 116 Handle(GeomPlate_PointConstraint) PCont= new GeomPlate_PointConstraint(P,0);
152 louhichi 211 BPSurf.Add(PCont);
153 souaissa 116
154     return true;
155 5 }
156     int OCC_FONCTION::Calculer_Surface()
157     {
158 louhichi 211 BPSurf.Perform();
159     return true;
160 5 }
161     int OCC_FONCTION::Determiner_Surface()
162     {
163 louhichi 211 Standard_Integer MaxSeg = 50;
164 souaissa 116 Standard_Integer MaxDegree=8;
165     Standard_Integer CritOrder=4;
166     Standard_Real dmax,Tol;
167     Handle(GeomPlate_Surface) PSurf1 = BPSurf.Surface();
168     dmax = Max(0.0001,10*BPSurf.G0Error());
169     Tol=0.0;
170     GeomPlate_MakeApprox Mapp1(PSurf1,Tol,MaxSeg,MaxDegree,dmax,0);
171 louhichi 211 Surf1 = Mapp1.Surface();
172 souaissa 116 return true;
173 5 }
174 souaissa 116
175 louhichi 211
176 5 //******************************************************************************
177 louhichi 211
178    
179 souaissa 116 TColgp_Array1OfPnt Array(1,1000);
180 louhichi 211
181     int OCC_FONCTION::Ajouter_Point_Courbe(double x, double y, double z, int i)
182 5 {
183 louhichi 211 Array.SetValue(i,gp_Pnt(x,y,z));
184 souaissa 116 return true;
185 5 }
186 souaissa 116
187 louhichi 211
188    
189 souaissa 116 TColGeom_Array1OfBSplineCurve ArrayCurve(1,4);
190 louhichi 211
191     int OCC_FONCTION::Ajouter_courbe_liste(int nbpts,int num)
192 5 {
193 louhichi 211 TColgp_Array1OfPnt Array00(1,nbpts);
194    
195     for(int ii = 1; ii<=nbpts;ii++)
196 souaissa 116 {
197     Array00.SetValue(ii,Array(ii));
198     }
199    
200 francois 314 Handle(Geom_BSplineCurve) SPL0 = GeomAPI_PointsToBSpline(Array00,3,8,GeomAbs_C1,0.).Curve();
201 souaissa 116 ArrayCurve.SetValue(num,SPL0);
202    
203     return true;
204 5 }
205 louhichi 211
206    
207    
208     int OCC_FONCTION::Construire_Surface_Contour(int nb_aretes_ext)
209 5 {
210 louhichi 211 if(nb_aretes_ext ==3)
211 souaissa 116 {
212     Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(ArrayCurve(1));
213 louhichi 211 Handle(GeomFill_SimpleBound) B1 = new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular());
214 souaissa 116 Handle(GeomAdaptor_HCurve) SPL2Adaptor = new GeomAdaptor_HCurve(ArrayCurve(2));
215 louhichi 211 Handle(GeomFill_SimpleBound) B2 = new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular());
216 souaissa 116 Handle(GeomAdaptor_HCurve) SPL3Adaptor = new GeomAdaptor_HCurve(ArrayCurve(3));
217 louhichi 211 Handle(GeomFill_SimpleBound) B3 = new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular());
218    
219 souaissa 116 Standard_Boolean NoCheck= Standard_False;
220     Standard_Integer MaxDeg = 8;
221    
222     Standard_Integer MaxSeg = 50;
223 louhichi 211
224     GeomFill_ConstrainedFilling aConstrained(MaxDeg, MaxSeg);
225     aConstrained.Init(B1,B2,B3, NoCheck);
226     Surf1 = aConstrained.Surface();
227 souaissa 116 }
228    
229 louhichi 211 if(nb_aretes_ext ==4)
230 souaissa 116 {
231    
232     Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(ArrayCurve(1));
233 louhichi 211 Handle(GeomFill_SimpleBound) B1 = new GeomFill_SimpleBound(SPL1Adaptor,Precision::Approximation(),Precision::Angular());
234 souaissa 116 Handle(GeomAdaptor_HCurve) SPL2Adaptor = new GeomAdaptor_HCurve(ArrayCurve(2));
235 louhichi 211 Handle(GeomFill_SimpleBound) B2 = new GeomFill_SimpleBound(SPL2Adaptor,Precision::Approximation(),Precision::Angular());
236 souaissa 116 Handle(GeomAdaptor_HCurve) SPL3Adaptor = new GeomAdaptor_HCurve(ArrayCurve(3));
237 louhichi 211 Handle(GeomFill_SimpleBound) B3 = new GeomFill_SimpleBound(SPL3Adaptor,Precision::Approximation(),Precision::Angular());
238 souaissa 116 Handle(GeomAdaptor_HCurve) SPL4Adaptor = new GeomAdaptor_HCurve(ArrayCurve(4));
239 louhichi 211 Handle(GeomFill_SimpleBound) B4 = new GeomFill_SimpleBound(SPL4Adaptor,Precision::Approximation(),Precision::Angular());
240    
241 souaissa 116 Standard_Boolean NoCheck= Standard_False;
242     Standard_Integer MaxDeg = 8;
243 louhichi 211
244 souaissa 116 Standard_Integer MaxSeg = 50;
245 louhichi 211
246     GeomFill_ConstrainedFilling aConstrained(MaxDeg, MaxSeg);
247     aConstrained.Init(B1,B2,B3,B4, NoCheck);
248     Surf1 = aConstrained.Surface();
249 souaissa 116 }
250     return true;
251 5 }
252 souaissa 116
253 louhichi 211
254    
255    
256 5 int OCC_FONCTION::Creer_Face_Surface()
257     {
258 francois 547 F1 = BRepBuilderAPI_MakeFace(Surf1,1e-6);
259 souaissa 116 return true;
260 5 }
261 souaissa 116
262 louhichi 211 //*************************** Classe Contour ***********************************
263 souaissa 116
264 louhichi 211 //BRepBuilderAPI_MakeWire W1;
265 5 int OCC_FONCTION::Creer_Contour()
266     {
267 souaissa 116 TopoDS_Wire W;
268 louhichi 211 W1 = W;
269 souaissa 116
270     return true;
271 5 }
272 souaissa 116
273    
274 louhichi 211 //*************************** Classe Arete Lineaire ****************************
275 souaissa 116
276 5 int OCC_FONCTION::Creer_Arete_Lineaire(double P1[3], double P2[3])
277     {
278 louhichi 211
279     GeomAPI_ProjectPointOnSurf Proj1(gp_Pnt(P1[0],P1[1],P1[2]),Surf1);
280 souaissa 116 Proj1.LowerDistanceParameters(U, V);
281     gp_Pnt2d P1_2D(U,V);
282    
283 louhichi 211 GeomAPI_ProjectPointOnSurf Proj2(gp_Pnt(P2[0],P2[1],P2[2]),Surf1);
284 souaissa 116 Proj2.LowerDistanceParameters(U, V);
285 louhichi 211 gp_Pnt2d P2_2D(U,V);
286 souaissa 116
287 louhichi 211 Curve = GCE2d_MakeSegment (P1_2D, P2_2D);
288 souaissa 116
289 louhichi 211 E = BRepBuilderAPI_MakeEdge(Curve,Surf1);
290 souaissa 116
291 louhichi 211 W1.Add(E);
292 souaissa 116
293     return true;
294 louhichi 211
295 5 }
296 souaissa 116
297 louhichi 211
298     //**************************** Classe Arete Circulaire *************************
299 5 int OCC_FONCTION::Creer_Arete_Circulaire(double Pnt_Insersion[3], double Normal[3],double P1[3], double P2[3], double Rayon)
300 louhichi 211 {
301     GeomAPI_ProjectPointOnSurf Proj(gp_Pnt(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]),Surf1);
302 souaissa 116 Proj.LowerDistanceParameters(U, V);
303     gp_Pnt2d Pnt_Ins2D(U,V);
304    
305 louhichi 211 GeomAPI_ProjectPointOnSurf Proj1(gp_Pnt(P1[0],P1[1],P1[2]),Surf1);
306 souaissa 116 Proj1.LowerDistanceParameters(U, V);
307     gp_Pnt2d P1_2D(U,V);
308    
309 louhichi 211 GeomAPI_ProjectPointOnSurf Proj2(gp_Pnt(P2[0],P2[1],P2[2]),Surf1);
310 souaissa 116 Proj2.LowerDistanceParameters(U, V);
311     gp_Pnt2d P2_2D(U,V);
312    
313    
314     gp_Dir2d Vect(P1_2D.X()-Pnt_Ins2D.X(),P1_2D.Y()-Pnt_Ins2D.Y());
315    
316 louhichi 211 gp_Ax2d Axe(Pnt_Ins2D,Vect);
317 souaissa 116
318 louhichi 211 gp_Circ2d Circ(Axe, Rayon, Standard_True);
319 souaissa 116
320    
321 louhichi 211 Curve = GCE2d_MakeArcOfCircle (Circ, P1_2D, P2_2D, Standard_True);
322     E = BRepBuilderAPI_MakeEdge(Curve,Surf1);
323     W1.Add(E);
324 souaissa 116 return true;
325 5 }
326 louhichi 211
327    
328     //*************************** Classe Arete Elliptique **************************
329    
330 5 int OCC_FONCTION::Creer_Arete_Elliptique(double Pnt_Insersion[3], double P1[3], double P2[3], double GRayon, double PRayon)
331     {
332 louhichi 211 GeomAPI_ProjectPointOnSurf Proj(gp_Pnt(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]),Surf1);
333 souaissa 116 Proj.LowerDistanceParameters(U, V);
334     gp_Pnt2d Pnt_Ins2D(U,V);
335    
336 louhichi 211 GeomAPI_ProjectPointOnSurf Proj1(gp_Pnt(P1[0],P1[1],P1[2]),Surf1);
337 souaissa 116 Proj1.LowerDistanceParameters(U, V);
338     gp_Pnt2d P1_2D(U,V);
339    
340 louhichi 211 GeomAPI_ProjectPointOnSurf Proj2(gp_Pnt(P2[0],P2[1],P2[2]),Surf1);
341 souaissa 116 Proj2.LowerDistanceParameters(U, V);
342     gp_Pnt2d P2_2D(U,V);
343    
344    
345     gp_Dir2d Vect(P1_2D.X()-Pnt_Ins2D.X(),P1_2D.Y()-Pnt_Ins2D.Y());
346    
347 louhichi 211 gp_Ax2d Axe(Pnt_Ins2D,Vect);
348 souaissa 116
349 louhichi 211 gp_Elips2d Ellipse(Axe, GRayon, PRayon, Standard_True);
350 souaissa 116
351 louhichi 211 Curve = GCE2d_MakeArcOfEllipse (Ellipse, P1_2D, P2_2D, Standard_True);
352     E = BRepBuilderAPI_MakeEdge(Curve,Surf1);
353 souaissa 116
354     return true;
355 5 }
356 souaissa 116
357    
358 louhichi 211 //*************************** Classe Arete Spline ******************************
359    
360 souaissa 116 TColgp_Array1OfPnt2d Array01(1,1000);
361 louhichi 211
362 5 int OCC_FONCTION::Ajouter_Point_Arete(double x, double y, double z, int i)
363     {
364 souaissa 116 gp_Pnt P(x,y,z);
365 louhichi 211 GeomAPI_ProjectPointOnSurf Proj(P,Surf1);
366 souaissa 116 Proj.LowerDistanceParameters(U, V);
367 louhichi 211 Array01.SetValue(i,gp_Pnt2d(U,V));
368    
369 souaissa 116 return true;
370 5 }
371    
372 louhichi 211
373    
374    
375 francois 38 int OCC_FONCTION::Rapprocher_Surface_Courbe_Spline(int nb_pts)
376 5 {
377 souaissa 116 TColgp_Array1OfPnt Arr(1,nb_pts);
378 louhichi 211
379 souaissa 116 for(int ii = 1; ii<=nb_pts;ii++)
380     {
381 louhichi 211 Arr.SetValue(ii,Array(ii));
382 souaissa 116 }
383    
384 francois 314 Handle(Geom_BSplineCurve) SPL = GeomAPI_PointsToBSpline (Arr,3,8,GeomAbs_C1,0.).Curve();
385 souaissa 116 Handle(GeomAdaptor_HCurve) SPL1Adaptor = new GeomAdaptor_HCurve(SPL);
386     Handle(BRepFill_CurveConstraint) Cont= new BRepFill_CurveConstraint(SPL1Adaptor,0);
387     BPSurf.Add(Cont);
388    
389     return true;
390 5 }
391 louhichi 211
392    
393    
394 souaissa 116 int OCC_FONCTION::Ajouter_Arete_Contour(int nbpts)
395     {
396 louhichi 211 TColgp_Array1OfPnt2d Array02(1,nbpts);
397 5
398 souaissa 116 for(int ii = 1; ii<=nbpts;ii++)
399     {
400     gp_Pnt2d PP = Array01(ii);
401     Array02.SetValue(ii,PP);
402     }
403    
404 francois 314 Handle(Geom2d_BSplineCurve) SSPL1 = Geom2dAPI_PointsToBSpline(Array02,3,8,GeomAbs_C1,0.).Curve();
405 louhichi 211 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(SSPL1,Surf1);
406     W1.Add(E);
407 souaissa 116
408    
409     return true;
410 5 }
411 louhichi 211
412    
413 5 int OCC_FONCTION::Initialiser_Surface_Cylindrique(double Pnt_Insersion[3], double Vect_Directeur[3],double Rayon)
414     {
415 souaissa 116 gp_Pnt Pnt(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]);
416     gp_Dir Vect(Vect_Directeur[0],Vect_Directeur[1],Vect_Directeur[2]);
417 louhichi 211 gp_Ax3 Axe(Pnt,Vect);
418 souaissa 116
419 louhichi 211 Handle (Geom_Surface) Surf = new Geom_CylindricalSurface(Axe, Rayon);
420 souaissa 116 BPSurf = GeomPlate_BuildPlateSurface(Surf,3,10,3);
421     return true;
422 5 }
423 louhichi 211
424 5 int OCC_FONCTION::Initialiser_Surface_Surface()
425     {
426 louhichi 211 BPSurf = GeomPlate_BuildPlateSurface(Surf1,3,10,3);
427 souaissa 116 return true;
428 5 }
429    
430 souaissa 116 TColgp_Array1OfPnt Array_Point_Ideal(1,1000);
431    
432 5 int OCC_FONCTION::Ajouter_Point_Array_Ideal(double x, double y, double z, int i)
433     {
434 souaissa 116 gp_Pnt Pnt(x,y,z);
435     Array_Point_Ideal.SetValue(i,Pnt);
436    
437     return true;
438 5 }
439    
440 souaissa 116 int OCC_FONCTION::Determiner_Param_Boite(int nb)
441 5 {
442 louhichi 211 TColgp_Array1OfPnt Array_Point_Ideal1(1,nb);
443 souaissa 116
444     for(int i = 1; i<=nb;i++)
445     {
446     Array_Point_Ideal1.SetValue(i,Array_Point_Ideal(i));
447     }
448    
449     GProp_PEquation Boite = GProp_PEquation(Array_Point_Ideal1,0);
450    
451     Boite.Box(P_def, V11_def, V22_def, V33_def);
452    
453     Array_Boite[1] = P_def.X();
454     Array_Boite[2] = P_def.Y();
455     Array_Boite[3] = P_def.Z();
456    
457     Array_Boite[4] = V11_def.X();
458     Array_Boite[5] = V11_def.Y();
459     Array_Boite[6] = V11_def.Z();
460    
461     Array_Boite[7] = V22_def.X();
462     Array_Boite[8] = V22_def.Y();
463     Array_Boite[9] = V22_def.Z();
464    
465     Array_Boite[10] = V33_def.X();
466     Array_Boite[11] = V33_def.Y();
467     Array_Boite[12] = V33_def.Z();
468    
469     return true;
470 5 }
471    
472 souaissa 116 double OCC_FONCTION::Get_Param_Boite(int ii)
473 5 {
474 souaissa 116 return Array_Boite[ii];
475 louhichi 211
476 5 }
477    
478 souaissa 116
479 5 int OCC_FONCTION::Determiner_Plan(int nb, double Epsilon)
480     {
481 souaissa 116 TColgp_Array1OfPnt Array_Point_Ideal1(1,nb);
482    
483 louhichi 211 for(int i = 1; i<=nb;i++)
484 souaissa 116 {
485 louhichi 211 Array_Point_Ideal1.SetValue(i,Array_Point_Ideal(i));
486 souaissa 116 }
487    
488     GProp_PEquation Equa_plan(Array_Point_Ideal1,Epsilon);
489     gp_Pln Plan = Equa_plan.Plane();
490 louhichi 211 Surf1 = new Geom_Plane(Plan);
491 souaissa 116
492     return true;
493 5 }
494    
495 louhichi 211
496     int OCC_FONCTION::Ligne_Revolution(double Pnt_Insersion[], double Vect_Directeur[])
497 5 {
498 louhichi 211 gp_Pnt P(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]);
499     gp_Dir V(Vect_Directeur[0],Vect_Directeur[1],Vect_Directeur[2]);
500 souaissa 116
501 louhichi 211 Handle(Geom_Line) Line = new Geom_Line (P,V);
502 souaissa 116 Curve_Projection = Line;
503    
504     return true;
505 5 }
506    
507     double OCC_FONCTION::Distance_Point_Curve(double x, double y, double z)
508     {
509 souaissa 116 gp_Pnt P(x,y,z);
510     GeomAPI_ProjectPointOnCurve PPC (P,Curve_Projection);
511     N = PPC.NearestPoint();
512    
513     double distance = PPC.LowerDistance();
514 louhichi 211
515     return distance;
516 souaissa 116
517 5 }
518    
519     int OCC_FONCTION::Creer_Surface_Cylindrique_Revolution(double Pnt_Insersion[3], double Vect_Directeur[3],double Vecteur1[3],double Rayon)
520     {
521 souaissa 116 gp_Pnt Pnt(Pnt_Insersion[0]+Rayon*Vecteur1[0],Pnt_Insersion[1]+Rayon*Vecteur1[1],Pnt_Insersion[2]+Rayon*Vecteur1[2]);
522     gp_Dir Vect(Vect_Directeur[0],Vect_Directeur[1],Vect_Directeur[2]);
523    
524     Handle (Geom_Curve) C1 = new Geom_Line(Pnt,Vect);
525 louhichi 211 Surf1 = new Geom_SurfaceOfRevolution(C1,gp_Ax1(gp_Pnt(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]),Vect));
526 5
527 souaissa 116 return true;
528 5 }
529    
530 louhichi 211 int OCC_FONCTION::Face_Revolution()
531     {
532     return Face_Revol;
533     }
534    
535    
536    
537    
538    
539    
540    
541 5 int OCC_FONCTION::Pt_Proj_Ligne()
542     {
543 souaissa 116 Pt_Proj_Line[1] = N.X();
544     Pt_Proj_Line[2] = N.Y();
545     Pt_Proj_Line[3] = N.Z();
546    
547     return true;
548 5 }
549 louhichi 211
550 5 double OCC_FONCTION::Pnt_Proj_Ligne(int ii)
551     {
552 souaissa 116 return Pt_Proj_Line[ii];
553 5 }
554    
555 louhichi 211
556 5 int OCC_FONCTION::GCercle_Tore(double Pnt_Insersion[3], double Vect_Directeur[3],double Rayon)
557     {
558 souaissa 116 gp_Pnt P(Pnt_Insersion[0],Pnt_Insersion[1],Pnt_Insersion[2]);
559     gp_Dir V(Vect_Directeur[0],Vect_Directeur[1],Vect_Directeur[2]);
560    
561     Handle(Geom_Circle) GCercle = new Geom_Circle (gp_Ax2(P,V),Rayon);
562     Curve_Projection = GCercle;
563    
564     return true;
565    
566 5 }
567    
568 souaissa 116 TColGeom_Array1OfSurface Array_Surface_Ideal(1,100);
569 5
570     int OCC_FONCTION::Ajouter_Surface_liste_Ideal(int num)
571     {
572 louhichi 211 Array_Surface_Ideal.SetValue(num,Surf1);
573 souaissa 116 return true;
574 5 }
575    
576 louhichi 211
577 5 int OCC_FONCTION::Projeter_Point_Surface_Idealisee(double x, double y,double z, int num)
578     {
579 souaissa 116 gp_Pnt P(x,y,z);
580     Handle (Geom_Surface) Surf = Array_Surface_Ideal(num);
581     GeomAPI_ProjectPointOnSurf Proj(P,Surf);
582    
583     Point_Projetee = Proj.NearestPoint();
584    
585     return true;
586 5 }
587 louhichi 211
588 5 int OCC_FONCTION::Pt_Proj_Surface_Ideal()
589     {
590 souaissa 116 Pt_Proj_Surf_Ideal[1] = Point_Projetee.X();
591     Pt_Proj_Surf_Ideal[2] = Point_Projetee.Y();
592     Pt_Proj_Surf_Ideal[3] = Point_Projetee.Z();
593    
594     return true;
595 5 }
596    
597 louhichi 211
598 5 double OCC_FONCTION::Pnt_Proj_Surface_Ideal(int ii)
599     {
600 souaissa 116 return Pt_Proj_Surf_Ideal[ii];
601 5 }
602    
603 louhichi 211
604 francois 38 int OCC_FONCTION::Projeter_Point_Plan_Idealisee(double x, double y,double z)
605     {
606 souaissa 116 gp_Pnt P(x,y,z);
607 louhichi 211 GeomAPI_ProjectPointOnSurf Proj(P,Surf1);
608 souaissa 116 Point_Projetee = Proj.NearestPoint();
609 francois 38
610 souaissa 116 return true;
611     }
612 louhichi 211
613    
614 francois 38 int OCC_FONCTION::Ajouter_Point_AreteUV(int testU, int testV, double x, double y, double z, int i)
615     {
616 souaissa 116 gp_Pnt P(x,y,z);
617 louhichi 211 GeomAPI_ProjectPointOnSurf Proj(P,Surf1);
618 souaissa 116 Proj.LowerDistanceParameters(U, V);
619 francois 547 if((testU==1) && (U<=M_PI/2))
620 souaissa 116 {
621 francois 547 U = U+ 2*M_PI;
622 souaissa 116 }
623    
624 francois 547 if((testV==1) && (V<=M_PI/2))
625 souaissa 116 {
626 francois 547 V = V+ 2*M_PI;
627 souaissa 116 }
628 louhichi 211 Array01.SetValue(i,gp_Pnt2d(U,V));
629    
630 souaissa 116 return true;
631 francois 38 }
632 louhichi 211
633 francois 38 double OCC_FONCTION::Analyser_interval_AreteU(double x, double y, double z)
634     {
635 souaissa 116 gp_Pnt P(x,y,z);
636 louhichi 211 GeomAPI_ProjectPointOnSurf Proj(P,Surf1);
637 souaissa 116 Proj.LowerDistanceParameters(U, V);
638 louhichi 211 return U;
639     }
640 souaissa 116
641 francois 38 double OCC_FONCTION::Analyser_interval_AreteV(double x, double y, double z)
642     {
643 souaissa 116 gp_Pnt P(x,y,z);
644 louhichi 211 GeomAPI_ProjectPointOnSurf Proj(P,Surf1);
645 souaissa 116 Proj.LowerDistanceParameters(U, V);
646 louhichi 211 return V;
647     }
648 souaissa 116
649    
650 louhichi 211
651     #endif
652    
653