1 // File: IntCurveSurface_Polyhedron.gxx
2 // Created: Wed Feb 3 11:33:09 1993
3 // Author: Laurent BUCHARD
10 #include <TColgp_Array2OfPnt.hxx>
11 #include <TColStd_Array2OfReal.hxx>
13 #include <Bnd_Array1OfBox.hxx>
15 #include <Standard_ConstructionError.hxx>
17 //#if defined (WNT) || !defined (DEB)
24 //-----------------------------------------------------
25 #define LONGUEUR_MINI_EDGE_TRIANGLE 1e-15
28 //=======================================================================
29 //function : IntCurveSurface_Polyhedron
31 //=======================================================================
32 IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
33 const Standard_Integer nbdU,
34 const Standard_Integer nbdV,
35 const Standard_Real u1,
36 const Standard_Real v1,
37 const Standard_Real u2,
38 const Standard_Real v2)
39 : nbdeltaU((nbdU<3)? 3 : nbdU),
40 nbdeltaV((nbdV<3)? 3 : nbdV),
41 TheDeflection(Epsilon(100.)),
42 C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
44 Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
45 gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
46 Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
47 Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
49 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
50 Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
52 C_MyIsOnBounds = (void *)CMyIsOnBounds;
53 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
54 Init(Surface,u1,v1,u2,v2);
57 //=======================================================================
58 //function : IntCurveSurface_Polyhedron
60 //=======================================================================
61 IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
62 const TColStd_Array1OfReal& Upars,
63 const TColStd_Array1OfReal& Vpars)
64 : nbdeltaU(Upars.Length()-1),
65 nbdeltaV(Vpars.Length()-1),
66 TheDeflection(Epsilon(100.)),
67 C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
69 Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
70 gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
71 Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
72 Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
74 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
75 Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
77 C_MyIsOnBounds = (void *)CMyIsOnBounds;
78 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
79 Init(Surface, Upars, Vpars);
83 void IntCurveSurface_Polyhedron::Destroy() {
84 //-- printf("\n IntCurveSurface_Polyhedron::Destroy\n");
85 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts; if(C_MyPnts) delete [] CMyPnts;
86 Standard_Real *CMyU = (Standard_Real *)C_MyU; if(C_MyU) delete [] CMyU;
87 Standard_Real *CMyV = (Standard_Real *)C_MyV; if(C_MyV) delete [] CMyV;
89 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
90 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
92 if(C_MyIsOnBounds) delete [] CMyIsOnBounds;
93 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
95 C_MyPnts=C_MyU=C_MyV=C_MyIsOnBounds=NULL;
98 //=======================================================================
101 //=======================================================================
102 void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
103 const Standard_Real U0,
104 const Standard_Real V0,
105 const Standard_Real U1,
106 const Standard_Real V1) {
107 const Standard_Integer DebugDump = 0;
108 Standard_Integer i1,i2;
110 Standard_Real U1mU0sNbdeltaU = (U1-U0)/(Standard_Real)nbdeltaU;
111 Standard_Real V1mV0sNbdeltaV = (V1-V0)/(Standard_Real)nbdeltaV;
113 Standard_Integer Index=1;
114 //-- --------------------------------------------------
115 //-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
116 //-- V est la colonne
118 //-- --------------------------------------------------
119 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
120 Standard_Real *CMyU = (Standard_Real *)C_MyU;
121 Standard_Real *CMyV = (Standard_Real *)C_MyV;
122 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
124 for (i1 = 0, U = U0; i1 <= nbdeltaU; i1++, U+= U1mU0sNbdeltaU) {
125 for (i2 = 0, V = V0; i2 <= nbdeltaV; i2++, V+= V1mV0sNbdeltaV ) {
126 ThePSurfaceTool::D0(Surface,U,V,TP);
127 //-- Point(TP,i1, i2,U,V);
131 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
132 CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
133 i2 == 0 || i2 == nbdeltaV);
134 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
139 //-- Calcul de la deflection Triangle <-> Point milieu
140 Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
141 for (i1=1; i1<=nbtriangles; i1++) {
142 Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
143 if(tol1>tol) tol=tol1;
145 //-- Calcul de la deflection Bord <-> Point milieu
148 DeflectionOverEstimation(tol*1.2);
151 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
152 Standard_Real aDeflection;
154 TheBorderDeflection = RealFirst();
156 // Compute the deflection on the lower bound (U-isoline) of the surface.
157 aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
159 if (aDeflection > TheBorderDeflection)
160 TheBorderDeflection = aDeflection;
162 // Compute the deflection on the upper bound (U-isoline) of the surface.
163 aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
165 if (aDeflection > TheBorderDeflection)
166 TheBorderDeflection = aDeflection;
168 // Compute the deflection on the lower bound (V-isoline) of the surface.
169 aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
171 if (aDeflection > TheBorderDeflection)
172 TheBorderDeflection = aDeflection;
174 // Compute the deflection on the upper bound (V-isoline) of the surface.
175 aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
177 if (aDeflection > TheBorderDeflection)
178 TheBorderDeflection = aDeflection;
180 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
186 //=======================================================================
189 //=======================================================================
190 void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
191 const TColStd_Array1OfReal& Upars,
192 const TColStd_Array1OfReal& Vpars) {
193 const Standard_Integer DebugDump = 0;
194 Standard_Integer i1,i2;
197 Standard_Integer Index=1;
198 //-- --------------------------------------------------
199 //-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
200 //-- V est la colonne
202 //-- --------------------------------------------------
203 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
204 Standard_Real *CMyU = (Standard_Real *)C_MyU;
205 Standard_Real *CMyV = (Standard_Real *)C_MyV;
206 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
207 Standard_Integer i0 = Upars.Lower(), j0 = Vpars.Lower();
209 for (i1 = 0; i1 <= nbdeltaU; i1++) {
211 for (i2 = 0; i2 <= nbdeltaV; i2++) {
213 ThePSurfaceTool::D0(Surface,U,V,TP);
214 //-- Point(TP,i1, i2,U,V);
218 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
219 CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
220 i2 == 0 || i2 == nbdeltaV);
221 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
226 //-- Calcul de la deflection Triangle <-> Point milieu
227 Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
228 for (i1=1; i1<=nbtriangles; i1++) {
229 Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
230 if(tol1>tol) tol=tol1;
232 //-- Calcul de la deflection Bord <-> Point milieu
235 DeflectionOverEstimation(tol*1.2);
238 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
239 Standard_Real aDeflection;
241 TheBorderDeflection = RealFirst();
242 Standard_Real U0 = Upars(i0);
243 Standard_Real V0 = Vpars(j0);
244 Standard_Real U1 = Upars(Upars.Upper());
245 Standard_Real V1 = Vpars(Vpars.Upper());
247 // Compute the deflection on the lower bound (U-isoline) of the surface.
248 aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
250 if (aDeflection > TheBorderDeflection)
251 TheBorderDeflection = aDeflection;
253 // Compute the deflection on the upper bound (U-isoline) of the surface.
254 aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
256 if (aDeflection > TheBorderDeflection)
257 TheBorderDeflection = aDeflection;
259 // Compute the deflection on the lower bound (V-isoline) of the surface.
260 aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
262 if (aDeflection > TheBorderDeflection)
263 TheBorderDeflection = aDeflection;
265 // Compute the deflection on the upper bound (V-isoline) of the surface.
266 aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
268 if (aDeflection > TheBorderDeflection)
269 TheBorderDeflection = aDeflection;
271 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
277 //=======================================================================
278 //function : DeflectionOnTriangle
280 //=======================================================================
281 Standard_Real IntCurveSurface_Polyhedron::DeflectionOnTriangle (const ThePSurface& Surface,
282 const Standard_Integer Triang) const
284 Standard_Integer i1,i2,i3;
285 Triangle(Triang,i1,i2,i3);
286 //-- Calcul de l equation du plan
287 Standard_Real u1,v1,u2,v2,u3,v3;
289 P1 = Point(i1,u1,v1);
290 P2 = Point(i2,u2,v2);
291 P3 = Point(i3,u3,v3);
292 if(P1.SquareDistance(P2)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
293 if(P1.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
294 if(P2.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
295 gp_XYZ XYZ1=P2.XYZ()-P1.XYZ();
296 gp_XYZ XYZ2=P3.XYZ()-P2.XYZ();
297 gp_XYZ XYZ3=P1.XYZ()-P3.XYZ();
298 gp_Vec NormalVector((XYZ1^XYZ2)+(XYZ2^XYZ3)+(XYZ3^XYZ1));
299 NormalVector.Normalize();
300 //-- Standard_Real PolarDistance = NormalVector * P1.XYZ();
301 //-- Calcul du point u,v au centre du triangle
302 Standard_Real u = (u1+u2+u3)/3.0;
303 Standard_Real v = (v1+v2+v3)/3.0;
304 gp_Pnt P = ThePSurfaceTool::Value(Surface,u,v);
306 return(Abs(P1P.Dot(NormalVector)));
308 //=======================================================================
309 //function : Parameters
311 //=======================================================================
312 void IntCurveSurface_Polyhedron::Parameters( const Standard_Integer Index
314 ,Standard_Real &V) const
317 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
318 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
321 Standard_Real *CMyU = (Standard_Real *)C_MyU;
323 Standard_Real *CMyV = (Standard_Real *)C_MyV;
326 //=======================================================================
327 //function : DeflectionOverEstimation
329 //=======================================================================
330 void IntCurveSurface_Polyhedron::DeflectionOverEstimation(const Standard_Real flec)
333 TheDeflection=0.0001;
334 TheBnd.Enlarge(0.0001);
338 TheBnd.Enlarge(flec);
341 //=======================================================================
342 //function : DeflectionOverEstimation
344 //=======================================================================
345 Standard_Real IntCurveSurface_Polyhedron::DeflectionOverEstimation() const
347 return TheDeflection;
349 //=======================================================================
350 //function : Bounding
352 //=======================================================================
353 const Bnd_Box& IntCurveSurface_Polyhedron::Bounding() const
357 //=======================================================================
358 //function : FillBounding
360 //=======================================================================
361 void IntCurveSurface_Polyhedron::FillBounding()
363 TheComponentsBnd=new Bnd_HArray1OfBox(1, NbTriangles());
365 Standard_Integer np1, np2, np3;
366 Standard_Integer nbtriangles = NbTriangles();
367 for (Standard_Integer iTri=1; iTri<=nbtriangles; iTri++) {
368 Triangle(iTri, np1, np2, np3);
369 gp_Pnt p1(Point(np1));
370 gp_Pnt p2(Point(np2));
371 gp_Pnt p3(Point(np3));
373 if(p1.SquareDistance(p2)>LONGUEUR_MINI_EDGE_TRIANGLE) {
374 if(p1.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
375 if(p2.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
379 Boite.Enlarge(TheDeflection);
383 Boite.Enlarge(TheDeflection);
384 TheComponentsBnd->SetValue(iTri,Boite);
387 //=======================================================================
388 //function : ComponentsBounding
390 //=======================================================================
391 const Handle(Bnd_HArray1OfBox)&
392 IntCurveSurface_Polyhedron::ComponentsBounding() const
394 return TheComponentsBnd;
396 //=======================================================================
397 //function : NbTriangles
399 //=======================================================================
400 Standard_Integer IntCurveSurface_Polyhedron::NbTriangles () const
402 return nbdeltaU*nbdeltaV*2;
404 //=======================================================================
405 //function : NbPoints
407 //=======================================================================
408 Standard_Integer IntCurveSurface_Polyhedron::NbPoints () const
410 return (nbdeltaU+1)*(nbdeltaV+1);
412 //=======================================================================
413 //function : TriConnex
415 //=======================================================================
416 Standard_Integer IntCurveSurface_Polyhedron::TriConnex
417 (const Standard_Integer Triang,
418 const Standard_Integer Pivot,
419 const Standard_Integer Pedge,
420 Standard_Integer& TriCon,
421 Standard_Integer& OtherP) const
423 Standard_Integer Pivotm1 = Pivot-1;
424 Standard_Integer nbdeltaVp1 = nbdeltaV+1;
425 Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
427 // Pivot position in the MaTriangle :
428 Standard_Integer ligP = Pivotm1/nbdeltaVp1;
429 Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
431 // Point sur Edge position in the MaTriangle and edge typ :
433 Standard_Integer ligE =0, colE =0, typE =0;
435 Standard_Integer ligE, colE, typE;
438 ligE= (Pedge-1)/nbdeltaVp1;
439 colE= (Pedge-1) - (ligE * nbdeltaVp1);
441 if (ligP==ligE) typE=1;
443 else if (colP==colE) typE=2;
451 // Triangle position General case :
453 Standard_Integer linT =0, colT =0;
454 Standard_Integer linO =0, colO =0;
455 Standard_Integer t =0, tt =0;
457 Standard_Integer linT, colT;
458 Standard_Integer linO, colO;
459 Standard_Integer t,tt;
462 t = (Triang-1)/(nbdeltaVm2);
463 tt= (Triang-1)-t*nbdeltaVm2;
473 if (colT==ligP+ligP) {
486 case 1: // Horizontal
490 colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
495 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
499 if (colT==(colP+colP)) {
501 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
506 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
513 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
514 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
518 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
519 colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
525 // Unknown Triangle position :
528 linT=(1>ligP)? 1 : ligP; //--linT=Max(1, ligP);
529 colT=(1>(colP+colP))? 1 : (colP+colP); //--colT=Max(1, colP+colP);
530 if (ligP==0) linO=ligP+1;
535 // Known edge We take the left or down connectivity :
537 case 1: // Horizontal
539 colT=(colP>colE)? colP : colE; //--colT=Max(colP,colE);
542 colO=(colP>colE)? colP : colE; //--colO=Max(colP,colE);
545 linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
547 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
551 linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
553 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
554 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
560 TriCon=(linT-1)*nbdeltaVm2 + colT;
565 if (colO<0) {colO=0;linO=1;}
566 else if (colO>nbdeltaV) {colO=nbdeltaV;linO=1;}
569 else if (linT>nbdeltaU) {
572 if (colO<0) {colO=0;linO=nbdeltaU-1;}
573 else if (colO>nbdeltaV) {colO=nbdeltaV;linO=nbdeltaU-1;}
580 if (linO<0) {linO=0;colO=1;}
581 else if (linO>nbdeltaU) {linO=nbdeltaU;colO=1;}
584 else if (colT>nbdeltaV) {
587 if (linO<0) {linO=0;colO=nbdeltaV-1;}
588 else if (linO>nbdeltaU) {linO=nbdeltaU;colO=nbdeltaV-1;}
592 OtherP=linO*nbdeltaVp1 + colO+1;
598 //=======================================================================
599 //function : PlaneEquation
601 //=======================================================================
602 void IntCurveSurface_Polyhedron::PlaneEquation (const Standard_Integer Triang,
603 gp_XYZ& NormalVector,
604 Standard_Real& PolarDistance) const
606 Standard_Integer i1,i2,i3;
607 Triangle(Triang,i1,i2,i3);
609 //-- gp_XYZ v1=Point(i2).XYZ()-Point(i1).XYZ();
610 //-- gp_XYZ v2=Point(i3).XYZ()-Point(i2).XYZ();
611 //-- gp_XYZ v3=Point(i1).XYZ()-Point(i3).XYZ();
613 gp_XYZ Pointi1(Point(i1).XYZ());
614 gp_XYZ Pointi2(Point(i2).XYZ());
615 gp_XYZ Pointi3(Point(i3).XYZ());
618 gp_XYZ v1= Pointi2 - Pointi1;
619 gp_XYZ v2= Pointi3 - Pointi2;
620 gp_XYZ v3= Pointi1 - Pointi3;
622 if(v1.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
623 if(v2.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
624 if(v3.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
626 NormalVector= (v1^v2)+(v2^v3)+(v3^v1);
627 NormalVector.Normalize();
628 PolarDistance = NormalVector * Point(i1).XYZ();
630 //=======================================================================
633 //=======================================================================
634 Standard_Boolean IntCurveSurface_Polyhedron::Contain (const Standard_Integer Triang,
635 const gp_Pnt& ThePnt) const
637 Standard_Integer i1,i2,i3;
638 Triangle(Triang,i1,i2,i3);
639 gp_XYZ Pointi1(Point(i1).XYZ());
640 gp_XYZ Pointi2(Point(i2).XYZ());
641 gp_XYZ Pointi3(Point(i3).XYZ());
643 gp_XYZ v1=(Pointi2-Pointi1)^(ThePnt.XYZ()-Pointi1);
644 gp_XYZ v2=(Pointi3-Pointi2)^(ThePnt.XYZ()-Pointi2);
645 gp_XYZ v3=(Pointi1-Pointi3)^(ThePnt.XYZ()-Pointi3);
646 if (v1*v2 >= 0. && v2*v3 >= 0. && v3*v1>=0.)
647 return Standard_True;
649 return Standard_False;
651 //=======================================================================
654 //=======================================================================
655 void IntCurveSurface_Polyhedron::Dump() const
659 //=======================================================================
662 //=======================================================================
663 void IntCurveSurface_Polyhedron::Size (Standard_Integer& nbdu,
664 Standard_Integer& nbdv) const
669 //=======================================================================
670 //function : Triangle
672 //=======================================================================
673 void IntCurveSurface_Polyhedron::Triangle (const Standard_Integer Index,
674 Standard_Integer& P1,
675 Standard_Integer& P2,
676 Standard_Integer& P3) const
678 Standard_Integer line=1+((Index-1)/(nbdeltaV*2));
679 Standard_Integer colon=1+((Index-1)%(nbdeltaV*2));
680 Standard_Integer colpnt=(colon+1)/2;
682 // General formula = (line-1)*(nbdeltaV+1)+colpnt
684 // Position of P1 = MesXYZ(line,colpnt);
685 P1= (line-1)*(nbdeltaV+1) + colpnt;
687 // Position of P2= MesXYZ(line+1,colpnt+((colon-1)%2));
688 P2= line*(nbdeltaV+1) + colpnt+((colon-1)%2);
690 // Position of P3= MesXYZ(line+(colon%2),colpnt+1);
691 P3= (line-1+(colon%2))*(nbdeltaV+1) + colpnt + 1;
693 //=======================================================================
695 //=======================================================================
696 const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index
698 ,Standard_Real& V) const
701 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
702 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
705 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
706 Standard_Real *CMyU = (Standard_Real *)C_MyU;
707 Standard_Real *CMyV = (Standard_Real *)C_MyV;
710 return CMyPnts[Index];
712 //=======================================================================
714 //=======================================================================
715 const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index) const {
717 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
718 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
722 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
723 return CMyPnts[Index];
725 //=======================================================================
727 //=======================================================================
728 //void IntCurveSurface_Polyhedron::Point (const gp_Pnt& p,
729 // const Standard_Integer lig,
730 // const Standard_Integer col,
731 // const Standard_Real u,
732 // const Standard_Real v)
733 void IntCurveSurface_Polyhedron::Point (const gp_Pnt& ,
734 const Standard_Integer ,
735 const Standard_Integer ,
736 const Standard_Real ,
737 const Standard_Real )
739 printf("\n IntCurveSurface_Polyhedron::Point : Ne dois pas etre appelle\n");
741 //=======================================================================
743 //=======================================================================
744 void IntCurveSurface_Polyhedron::Point (const Standard_Integer Index,gp_Pnt& P) const
747 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
748 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
752 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
756 // Modified by Sergey KHROMOV - Fri Dec 7 10:12:47 2001 Begin
758 //=======================================================================
759 //function : IsOnBound
760 //purpose : This method returns true if the edge based on points with
761 // indices Index1 and Index2 represents a boundary edge.
762 //=======================================================================
764 Standard_Boolean IntCurveSurface_Polyhedron::IsOnBound
765 (const Standard_Integer Index1,
766 const Standard_Integer Index2) const
769 if(Index1<0 || Index1>((nbdeltaU+1)*(nbdeltaV+1))) {
770 printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
772 if(Index2<0 || Index2>((nbdeltaU+1)*(nbdeltaV+1))) {
773 printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
776 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
777 Standard_Integer aDiff = Abs(Index1 - Index2);
780 // Check if points are neighbour ones.
781 if (aDiff != 1 && aDiff != nbdeltaV + 1)
782 return Standard_False;
784 for (i = 0; i <= nbdeltaU; i++) {
785 if ((Index1 == 1 + i*(nbdeltaV + 1)) && (Index2 == Index1 - 1))
786 return Standard_False;
788 if ((Index1 == (1 + i)*(nbdeltaV + 1)) && (Index2 == Index1 + 1))
789 return Standard_False;
792 return (CMyIsOnBounds[Index1] && CMyIsOnBounds[Index2]);
795 //=======================================================================
796 //function : ComputeBorderDeflection
797 //purpose : This method computes and returns a deflection of isoline
798 // of given parameter on Surface.
799 //=======================================================================
801 Standard_Real IntCurveSurface_Polyhedron::ComputeBorderDeflection
802 (const ThePSurface &Surface,
803 const Standard_Real Parameter,
804 const Standard_Real PMin,
805 const Standard_Real PMax,
806 const Standard_Boolean isUIso) const
808 Standard_Integer aNbSamples;
812 aNbSamples = nbdeltaV;
814 aNbSamples = nbdeltaU;
816 Standard_Real aDelta = (PMax - PMin)/aNbSamples;
817 Standard_Real aPar = PMin;
818 Standard_Real aDeflection = RealFirst();
824 for (i = 0; i <= aNbSamples; i++, aPar+= aDelta) {
826 aP1 = ThePSurfaceTool::Value(Surface, Parameter, aPar).XYZ();
827 aP2 = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta).XYZ();
828 aPParMid = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta/2.).XYZ();
830 aP1 = ThePSurfaceTool::Value(Surface, aPar, Parameter).XYZ();
831 aP2 = ThePSurfaceTool::Value(Surface, aPar + aDelta, Parameter).XYZ();
832 aPParMid = ThePSurfaceTool::Value(Surface, aPar + aDelta/2., Parameter).XYZ();
834 aPMid = (aP2 + aP1)/2.;
836 Standard_Real aDist = (aPMid - aPParMid).Modulus();
838 if (aDist > aDeflection)
845 // Modified by Sergey KHROMOV - Fri Dec 7 11:21:52 2001 End