ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/reconstruction/src/occ_fonction.cpp
Revision: 116
Committed: Thu Jun 26 16:23:07 2008 UTC (16 years, 10 months ago) by souaissa
Original Path: magic/lib/reconstruction/reconstruction/src/OCC_fonction.cpp
File size: 26451 byte(s)
Log Message:
mise a jour de OCC_FONCTION version open_cascade 6.2

File Contents

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