0b8b2ebd0a13422801bca4f79f23d6c0e165212e
[occt.git] / src / IntPatch / IntPatch_Polyhedron.cxx
1 // Created on: 1993-02-03
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #include <IntPatch_Polyhedron.ixx>
23
24 #include <IntPatch_HInterTool.hxx>
25
26 #include <gp_Pnt.hxx>
27 #include <gp_Vec.hxx>
28 #include <TColgp_Array2OfPnt.hxx>
29 #include <TColStd_Array2OfReal.hxx>
30 #include <Bnd_Array1OfBox.hxx>
31 #include <Standard_ConstructionError.hxx>
32 #include <Precision.hxx>
33 #include <stdio.h>
34
35 #define MSG_DEBUG                   0
36
37 #define LONGUEUR_MINI_EDGE_TRIANGLE 1e-14
38 #define DEFLECTION_COEFF            1.1
39 #define NBMAXUV                     30
40
41 //================================================================================
42 static Standard_Integer NbPOnU (const Handle(Adaptor3d_HSurface)& S)
43 {
44   const Standard_Real u0 = S->FirstUParameter();
45   const Standard_Real u1 = S->LastUParameter();
46   const Standard_Integer nbpu = IntPatch_HInterTool::NbSamplesU(S,u0,u1);
47   return (nbpu>NBMAXUV? NBMAXUV : nbpu);
48 }
49 //================================================================================
50 static Standard_Integer NbPOnV (const Handle(Adaptor3d_HSurface)& S)
51 {
52   const Standard_Real v0 = S->FirstVParameter();
53   const Standard_Real v1 = S->LastVParameter();
54   const Standard_Integer nbpv = IntPatch_HInterTool::NbSamplesV(S,v0,v1);
55   return (nbpv>NBMAXUV? NBMAXUV : nbpv);
56 }
57
58 //=======================================================================
59 //function : Destroy
60 //purpose  : 
61 //=======================================================================
62 void IntPatch_Polyhedron::Destroy()
63 {
64   gp_Pnt *CMyPnts     = (gp_Pnt *)C_MyPnts;       if(C_MyPnts) delete [] CMyPnts;
65   Standard_Real *CMyU = (Standard_Real *)C_MyU;   if(C_MyU)    delete [] CMyU;
66   Standard_Real *CMyV = (Standard_Real *)C_MyV;   if(C_MyV)    delete [] CMyV;
67   C_MyPnts=C_MyU=C_MyV=NULL;
68 }
69
70 //=======================================================================
71 //function : IntPatch_Polyhedron
72 //purpose  : 
73 //=======================================================================
74 IntPatch_Polyhedron::IntPatch_Polyhedron (const Handle(Adaptor3d_HSurface)& Surface)
75      : TheDeflection(Epsilon(100.)),
76        nbdeltaU(NbPOnU(Surface)),
77        nbdeltaV(NbPOnV(Surface)),
78        C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),
79        UMinSingular(IntPatch_HInterTool::SingularOnVMin(Surface)),
80        UMaxSingular(IntPatch_HInterTool::SingularOnVMin(Surface)),
81        VMinSingular(IntPatch_HInterTool::SingularOnVMin(Surface)),
82        VMaxSingular(IntPatch_HInterTool::SingularOnVMin(Surface))
83
84   const Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
85   gp_Pnt *CMyPnts     = new gp_Pnt[t];
86   Standard_Real *CMyU = new Standard_Real[t];
87   Standard_Real *CMyV = new Standard_Real[t];
88   C_MyPnts = CMyPnts;
89   C_MyU    = CMyU;
90   C_MyV    = CMyV;
91   
92   const Standard_Real u0 = Surface->FirstUParameter();
93   const Standard_Real u1 = Surface->LastUParameter();
94   const Standard_Real v0 = Surface->FirstVParameter();
95   const Standard_Real v1 = Surface->LastVParameter();
96
97   const Standard_Real U1mU0sNbdeltaU = (u1-u0)/(Standard_Real)nbdeltaU;
98   const Standard_Real V1mV0sNbdeltaV = (v1-v0)/(Standard_Real)nbdeltaV;
99
100   gp_Pnt TP;
101   Standard_Real    U,V;
102   Standard_Integer i1, i2, Index=1;
103   for (i1 = 0, U = u0; i1 <= nbdeltaU; i1++, U+= U1mU0sNbdeltaU) {
104     for (i2 = 0, V = v0; i2 <= nbdeltaV; i2++, V+= V1mV0sNbdeltaV ) {
105       Surface->D0(U,V,TP);
106       CMyPnts[Index] = TP;
107       CMyU[Index]    = U;
108       CMyV[Index]    = V;
109       TheBnd.Add(TP);
110       Index++;
111     }
112   }
113
114   Standard_Real tol=0.0;
115   const Standard_Integer nbtriangles = NbTriangles();
116   for (i1=1; i1<=nbtriangles; i1++) {
117     const Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
118     if(tol1>tol) tol=tol1;
119   }
120
121   tol*=DEFLECTION_COEFF;
122
123   DeflectionOverEstimation(tol);
124   FillBounding();
125 }
126
127 //=======================================================================
128 //function : IntPatch_Polyhedron
129 //purpose  : 
130 //=======================================================================
131 IntPatch_Polyhedron::IntPatch_Polyhedron (const Handle(Adaptor3d_HSurface)& Surface,
132                                           const Standard_Integer nbu,
133                                           const Standard_Integer nbv)
134 : TheDeflection(Epsilon(100.)),
135   nbdeltaU(nbu),
136   nbdeltaV(nbv),
137   C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),
138   UMinSingular(IntPatch_HInterTool::SingularOnVMin(Surface)),
139   UMaxSingular(IntPatch_HInterTool::SingularOnVMin(Surface)),
140   VMinSingular(IntPatch_HInterTool::SingularOnVMin(Surface)),
141   VMaxSingular(IntPatch_HInterTool::SingularOnVMin(Surface))
142
143   const Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
144   gp_Pnt *CMyPnts     = new gp_Pnt[t];
145   Standard_Real *CMyU = new Standard_Real[t];
146   Standard_Real *CMyV = new Standard_Real[t];
147   C_MyPnts = CMyPnts;
148   C_MyU    = CMyU;
149   C_MyV    = CMyV;
150   
151   const Standard_Real u0 = Surface->FirstUParameter();
152   const Standard_Real u1 = Surface->LastUParameter();
153   const Standard_Real v0 = Surface->FirstVParameter();
154   const Standard_Real v1 = Surface->LastVParameter();
155
156   const Standard_Real U1mU0sNbdeltaU = (u1-u0)/(Standard_Real)nbdeltaU;
157   const Standard_Real V1mV0sNbdeltaV = (v1-v0)/(Standard_Real)nbdeltaV;
158
159   gp_Pnt TP;
160   Standard_Real U,V;
161   Standard_Integer i1, i2, Index=1;
162   for (i1 = 0, U = u0; i1 <= nbdeltaU; i1++, U+= U1mU0sNbdeltaU) {
163     for (i2 = 0, V = v0; i2 <= nbdeltaV; i2++, V+= V1mV0sNbdeltaV ) {
164       Surface->D0(U,V,TP);
165       CMyPnts[Index] = TP;
166       CMyU[Index]    = U;
167       CMyV[Index]    = V;
168       TheBnd.Add(TP);
169       Index++;      
170     }
171   }
172
173   Standard_Real tol=0.0;
174   const Standard_Integer nbtriangles = NbTriangles();
175   for (i1=1; i1<=nbtriangles; i1++) {
176     const Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
177     if(tol1>tol) tol=tol1;
178   }
179   
180   tol*=DEFLECTION_COEFF;
181
182   DeflectionOverEstimation(tol);
183   FillBounding();
184 }
185
186
187 //=======================================================================
188 //function : DeflectionOnTriangle
189 //purpose  : 
190 //=======================================================================
191
192 Standard_Real IntPatch_Polyhedron::DeflectionOnTriangle
193   (const Handle(Adaptor3d_HSurface)& Surface,
194    const Standard_Integer Triang) const 
195 {
196   Standard_Integer i1,i2,i3;    
197
198   Triangle(Triang,i1,i2,i3);
199   //-- Calcul de l eqution du plan
200   Standard_Real u1,v1,u2,v2,u3,v3;
201   gp_Pnt P1,P2,P3;
202   P1 = Point(i1,u1,v1);
203   P2 = Point(i2,u2,v2);
204   P3 = Point(i3,u3,v3);
205   if(P1.SquareDistance(P2)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
206   if(P1.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
207   if(P2.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
208   gp_XYZ XYZ1=P2.XYZ()-P1.XYZ();
209   gp_XYZ XYZ2=P3.XYZ()-P2.XYZ();
210   gp_XYZ XYZ3=P1.XYZ()-P3.XYZ();
211   gp_Vec NormalVector((XYZ1^XYZ2)+(XYZ2^XYZ3)+(XYZ3^XYZ1));
212   NormalVector.Normalize();
213   //-- Calcul du point u,v  au centre du triangle
214   Standard_Real u = (u1+u2+u3)/3.0;
215   Standard_Real v = (v1+v2+v3)/3.0;
216   gp_Vec P1P(P1,Surface->Value(u,v));
217   return(Abs(P1P.Dot(NormalVector)));
218 }
219
220 //=======================================================================
221 //function : Parameters
222 //purpose  : 
223 //=======================================================================
224 void IntPatch_Polyhedron::Parameters( const Standard_Integer Index
225                                      ,Standard_Real &U
226                                      ,Standard_Real &V) const 
227 {
228   U = ((Standard_Real *)C_MyU)[Index];
229   V = ((Standard_Real *)C_MyV)[Index];
230 }
231
232 //=======================================================================
233 //function : DeflectionOverEstimation
234 //purpose  : 
235 //=======================================================================
236 void IntPatch_Polyhedron::DeflectionOverEstimation(const Standard_Real flec)
237 {
238   if(flec<0.0001) {  
239     TheDeflection=0.0001;
240     TheBnd.Enlarge(0.0001);
241   }
242   else { 
243     TheDeflection=flec;
244     TheBnd.Enlarge(flec);
245   }
246 }
247
248 //=======================================================================
249 //function : DeflectionOverEstimation
250 //purpose  :
251 //=======================================================================
252 Standard_Real IntPatch_Polyhedron::DeflectionOverEstimation() const
253 {
254   return TheDeflection;
255 }
256
257 //=======================================================================
258 //function : Bounding
259 //purpose  : 
260 //=======================================================================
261 const Bnd_Box& IntPatch_Polyhedron::Bounding() const
262 {
263   return TheBnd;
264 }
265
266 //=======================================================================
267 //function : FillBounding
268 //purpose  : 
269 //=======================================================================
270 void IntPatch_Polyhedron::FillBounding()
271 {
272   TheComponentsBnd=new Bnd_HArray1OfBox(1, NbTriangles());
273   Bnd_Box Boite;
274   Standard_Integer p1, p2, p3;
275   Standard_Integer nbtriangles = NbTriangles();
276   for (Standard_Integer iTri=1; iTri<=nbtriangles; iTri++) {
277     Triangle(iTri, p1, p2, p3);
278     Boite.SetVoid();
279     const gp_Pnt& P1 = Point(p1);
280     const gp_Pnt& P2 = Point(p2);
281     const gp_Pnt& P3 = Point(p3);
282     if(P1.SquareDistance(P2)>LONGUEUR_MINI_EDGE_TRIANGLE) {
283       if(P1.SquareDistance(P3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
284         if(P2.SquareDistance(P3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
285           Boite.Add(P1);
286           Boite.Add(P2);
287           Boite.Add(P3);
288         }  
289       }
290     }
291     Boite.Enlarge(TheDeflection);
292     TheComponentsBnd->SetValue(iTri,Boite);  
293   }
294 }
295
296 //=======================================================================
297 //function : ComponentsBounding
298 //purpose  : 
299 //=======================================================================
300 const Handle(Bnd_HArray1OfBox)& IntPatch_Polyhedron::ComponentsBounding () const
301 {
302   return TheComponentsBnd;
303 }
304
305 //=======================================================================
306 //function : NbTriangles
307 //purpose  : 
308 //=======================================================================
309 Standard_Integer IntPatch_Polyhedron::NbTriangles () const
310 {
311   return nbdeltaU*nbdeltaV*2;
312 }
313
314 //=======================================================================
315 //function : NbPoints
316 //purpose  : 
317 //=======================================================================
318 Standard_Integer IntPatch_Polyhedron::NbPoints () const
319 {
320   return (nbdeltaU+1)*(nbdeltaV+1);
321 }
322
323 //=======================================================================
324 //function : TriConnex
325 //purpose  : 
326 //=======================================================================
327 Standard_Integer IntPatch_Polyhedron::TriConnex (const Standard_Integer Triang,
328                                                  const Standard_Integer Pivot,
329                                                  const Standard_Integer Pedge,
330                                                  Standard_Integer&      TriCon,
331                                                  Standard_Integer&      OtherP)   const {
332
333   Standard_Integer Pivotm1    = Pivot-1;
334   Standard_Integer nbdeltaVp1 = nbdeltaV+1;
335   Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
336
337 // Pivot position in the MaTriangle :
338   Standard_Integer ligP = Pivotm1/nbdeltaVp1;
339   Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
340
341 // Point sur Edge position in the MaTriangle and edge typ :
342   Standard_Integer ligE = 0, colE = 0, typE = 0;
343   if (Pedge!=0) {
344     ligE= (Pedge-1)/nbdeltaVp1;
345     colE= (Pedge-1) - (ligE * nbdeltaVp1);
346   // Horizontal
347     if      (ligP==ligE) typE=1;
348   // Vertical
349     else if (colP==colE) typE=2;
350   // Oblique
351     else                 typE=3;
352   }
353   else {
354     typE=0;
355   }
356
357 // Triangle position General case :
358   Standard_Integer linT = 0, colT = 0;
359   Standard_Integer linO = 0, colO = 0;
360   Standard_Integer t,tt;
361   if (Triang!=0) {
362     t = (Triang-1)/(nbdeltaVm2);
363     tt= (Triang-1)-t*nbdeltaVm2;
364     linT= 1+t;
365     colT= 1+tt;
366     if (typE==0) {
367       if (ligP==linT) {
368         ligE=ligP-1;
369         colE=colP-1;
370         typE=3;
371       }
372       else {
373         if (colT==ligP+ligP) {
374           ligE=ligP;
375           colE=colP-1;
376           typE=1;
377         }
378         else {
379           ligE=ligP+1;
380           colE=colP+1;
381           typE=3;
382         }
383       }
384     }
385     switch (typE) {
386     case 1:  // Horizontal
387       if (linT==ligP) {
388         linT++;
389         linO=ligP+1;
390         colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
391       }
392       else {
393         linT--;
394         linO=ligP-1;
395         colO=(colP<colE)? colP : colE;  //--colO=Min(colP, colE);
396       }
397       break;
398     case 2:  // Vertical
399       if (colT==(colP+colP)) {
400         colT++;
401         linO=(ligP>ligE)? ligP : ligE;  //--linO=Max(ligP, ligE);
402         colO=colP+1;;
403       }
404       else {
405         colT--;
406         linO=(ligP<ligE)? ligP : ligE;  //--linO=Min(ligP, ligE);
407         colO=colP-1;;
408       }
409       break;
410     case 3:  // Oblique
411       if ((colT&1)==0) {
412         colT--;
413         linO=(ligP>ligE)? ligP : ligE;  //--linO=Max(ligP, ligE);
414         colO=(colP<colE)? colP : colE;  //--colO=Min(colP, colE);
415       }
416       else {
417         colT++;
418         linO=(ligP<ligE)? ligP : ligE;  //--linO=Min(ligP, ligE);
419         colO=(colP>colE)? colP : colE;  //--colO=Max(colP, colE);
420       }
421       break;
422     }
423   }
424   else {
425     // Unknown Triangle position :
426     if (Pedge==0) {
427       // Unknown edge :
428       linT=(1>ligP)? 1 : ligP;      //--linT=Max(1, ligP);
429       colT=(1>(colP+colP))? 1 : (colP+colP);       //--colT=Max(1, colP+colP);
430       if (ligP==0) linO=ligP+1;
431       else         linO=ligP-1;
432       colO=colP;
433     }
434     else {
435       // Known edge We take the left or down connectivity :
436       switch (typE) {
437       case 1:  // Horizontal
438         linT=ligP+1;
439         colT=(colP>colE)? colP : colE;  //--colT=Max(colP,colE);
440         colT+=colT;
441         linO=ligP+1;
442         colO=(colP>colE)? colP : colE;  //--colO=Max(colP,colE);
443         break;
444       case 2:  // Vertical
445         linT=(ligP>ligE)? ligP : ligE;  //--linT=Max(ligP, ligE);
446         colT=colP+colP;
447         linO=(ligP<ligE)? ligP : ligE;  //--linO=Min(ligP, ligE);
448         colO=colP-1;
449         break;
450       case 3:  // Oblique
451         linT=(ligP>ligE)? ligP : ligE;  //--linT=Max(ligP, ligE);
452         colT=colP+colE;
453         linO=(ligP>ligE)? ligP : ligE;  //--linO=Max(ligP, ligE);
454         colO=(colP<colE)? colP : colE;  //--colO=Min(colP, colE);
455         break;
456       }
457     }
458   }
459
460   TriCon=(linT-1)*nbdeltaVm2 + colT;
461
462   if (linT<1) {
463     linO=0;
464     colO=colP+colP-colE;
465     if (colO<0) {colO=0;linO=1;}
466     else if (colO>nbdeltaV) {colO=nbdeltaV;linO=1;}
467     TriCon=0;
468   }
469   else if (linT>nbdeltaU) {
470     linO=nbdeltaU;
471     colO=colP+colP-colE;
472     if (colO<0) {colO=0;linO=nbdeltaU-1;}
473     else if (colO>nbdeltaV) {colO=nbdeltaV;linO=nbdeltaU-1;}
474     TriCon=0;
475   }
476
477   if (colT<1) {
478     colO=0;
479     linO=ligP+ligP-ligE;
480     if (linO<0) {linO=0;colO=1;}
481     else if (linO>nbdeltaU) {linO=nbdeltaU;colO=1;}
482     TriCon=0;
483   }
484   else if (colT>nbdeltaV) {
485     colO=nbdeltaV;
486     linO=ligP+ligP-ligE;
487     if (linO<0) {linO=0;colO=nbdeltaV-1;}
488     else if (linO>nbdeltaU) {linO=nbdeltaU;colO=nbdeltaV-1;}
489     TriCon=0;
490   }
491
492   OtherP=linO*nbdeltaVp1 + colO+1;
493
494
495   //----------------------------------------------------
496   //-- Detection des cas ou le triangle retourne est
497   //-- invalide. Dans ce cas, on retourne le triangle
498   //-- suivant par un nouvel appel a TriConnex.
499   //-- 
500   //-- Si En entree : Point(Pivot)==Point(Pedge) 
501   //-- Alors on retourne OtherP a 0 
502   //-- et Tricon = Triangle
503   //--
504   if(Point(Pivot).SquareDistance(Point(Pedge))<=LONGUEUR_MINI_EDGE_TRIANGLE) { 
505     OtherP=0;
506     TriCon=Triang;
507 #if MSG_DEBUG
508     cout<<" Probleme ds IntCurveSurface_Polyhedron : Pivot et PEdge Confondus "<<endl;
509 #endif
510     return(TriCon);
511   }
512   if(Point(OtherP).SquareDistance(Point(Pedge))<=LONGUEUR_MINI_EDGE_TRIANGLE) { 
513 #if MSG_DEBUG
514     cout<<" Probleme ds IntCurveSurface_Polyhedron : OtherP et PEdge Confondus "<<endl;
515 #endif
516     Standard_Integer TempTri,TempOtherP;
517     TempTri = TriCon;
518     TempOtherP = OtherP;
519
520     return(0); //-- BUG NON CORRIGE ( a revoir le role de nbdeltaU et nbdeltaV)
521
522     return(TriConnex(TempTri,Pivot,TempOtherP,TriCon,OtherP));
523   }
524   return TriCon;
525 }
526
527
528
529 //=======================================================================
530 //function : PlaneEquation
531 //purpose  : 
532 //=======================================================================
533
534 void IntPatch_Polyhedron::PlaneEquation (const Standard_Integer Triang,
535                                          gp_XYZ&        NormalVector,
536                                          Standard_Real& PolarDistance)  const
537 {
538   Standard_Integer i1,i2,i3;
539   Triangle(Triang,i1,i2,i3);
540
541   gp_XYZ Pointi1(Point(i1).XYZ());
542   gp_XYZ Pointi2(Point(i2).XYZ());
543   gp_XYZ Pointi3(Point(i3).XYZ());
544   
545
546   gp_XYZ v1= Pointi2 - Pointi1;
547   gp_XYZ v2= Pointi3 - Pointi2;
548   gp_XYZ v3= Pointi1 - Pointi3;
549
550   if(v1.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; } 
551   if(v2.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; } 
552   if(v3.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; } 
553
554   NormalVector= (v1^v2)+(v2^v3)+(v3^v1);
555   NormalVector.Normalize();
556   PolarDistance = NormalVector * Point(i1).XYZ();
557 }
558 //=======================================================================
559 //function : Contain
560 //purpose  : 
561 //=======================================================================
562 Standard_Boolean IntPatch_Polyhedron::Contain (const Standard_Integer Triang,
563                                                const gp_Pnt& ThePnt) const
564 {  
565   Standard_Integer i1,i2,i3;
566   Triangle(Triang,i1,i2,i3);
567   gp_XYZ Pointi1(Point(i1).XYZ());
568   gp_XYZ Pointi2(Point(i2).XYZ());
569   gp_XYZ Pointi3(Point(i3).XYZ());
570   
571   gp_XYZ v1=(Pointi2-Pointi1)^(ThePnt.XYZ()-Pointi1);
572   gp_XYZ v2=(Pointi3-Pointi2)^(ThePnt.XYZ()-Pointi2);
573   gp_XYZ v3=(Pointi1-Pointi3)^(ThePnt.XYZ()-Pointi3);
574   if (v1*v2 >= 0. && v2*v3 >= 0. && v3*v1>=0.) 
575     return Standard_True;
576   else 
577     return Standard_False;
578 }
579 //=======================================================================
580 //function : Dump
581 //purpose  : 
582 //=======================================================================
583
584 void IntPatch_Polyhedron::Dump()const
585 {
586 }
587 //=======================================================================
588 //function : Size
589 //purpose  : 
590 //=======================================================================
591 void IntPatch_Polyhedron::Size(Standard_Integer& nbdu,
592                                Standard_Integer& nbdv) const
593 {
594   nbdu=nbdeltaU;
595   nbdv=nbdeltaV;
596 }
597 //=======================================================================
598 //function : Triangle
599 //purpose  : 
600 //=======================================================================
601 void IntPatch_Polyhedron::Triangle (const Standard_Integer Index,
602                                     Standard_Integer& P1,
603                                     Standard_Integer& P2,
604                                     Standard_Integer& P3) const
605 {
606   Standard_Integer line=1+((Index-1)/(nbdeltaV*2));
607   Standard_Integer colon=1+((Index-1)%(nbdeltaV*2));
608   Standard_Integer colpnt=(colon+1)/2;
609
610 // General formula = (line-1)*(nbdeltaV+1)+colpnt
611   
612 //  Position of P1 = MesXYZ(line,colpnt);
613   P1= (line-1)*(nbdeltaV+1) + colpnt;
614
615 //  Position of P2= MesXYZ(line+1,colpnt+((colon-1)%2));
616   P2= line*(nbdeltaV+1) + colpnt+((colon-1)%2);
617
618 //  Position of P3= MesXYZ(line+(colon%2),colpnt+1);
619   P3= (line-1+(colon%2))*(nbdeltaV+1) + colpnt + 1;
620   //-- printf("\nTriangle %4d    P1:%4d   P2:%4d   P3:%4d",Index,P1,P2,P3);
621 }
622 //=======================================================================
623 //function : Point
624 //=======================================================================
625 const gp_Pnt& IntPatch_Polyhedron::Point( const Standard_Integer Index
626                                          ,Standard_Real& U
627                                          ,Standard_Real& V) const 
628 {
629   gp_Pnt *CMyPnts     = (gp_Pnt *)C_MyPnts;
630   Standard_Real *CMyU = (Standard_Real *)C_MyU;
631   Standard_Real *CMyV = (Standard_Real *)C_MyV;
632   U=CMyU[Index];
633   V=CMyV[Index];
634   return CMyPnts[Index];
635 }
636 //=======================================================================
637 //function : Point
638 //=======================================================================
639 const gp_Pnt& IntPatch_Polyhedron::Point(const Standard_Integer Index) const {
640   gp_Pnt *CMyPnts     = (gp_Pnt *)C_MyPnts;
641   return CMyPnts[Index];
642 }
643
644 //=======================================================================
645 //function : Point
646 //=======================================================================
647 void IntPatch_Polyhedron::Point (const gp_Pnt& /*p*/, 
648                                  const Standard_Integer /*lig*/,
649                                  const Standard_Integer /*col*/,
650                                  const Standard_Real /*u*/,
651                                  const Standard_Real /*v*/) 
652 {
653   //printf("\n IntPatch_Polyhedron::Point : Ne dois pas etre appelle\n");
654 }
655
656 //=======================================================================
657 //function : Point
658 //=======================================================================
659 void IntPatch_Polyhedron::Point (const Standard_Integer Index, gp_Pnt& P) const
660 {
661   gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
662   P = CMyPnts[Index];
663 }
664 //=======================================================================