1 // Created on: 1993-02-03
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
22 #include <TColgp_Array2OfPnt.hxx>
23 #include <TColStd_Array2OfReal.hxx>
25 #include <Bnd_Array1OfBox.hxx>
27 #include <Standard_ConstructionError.hxx>
34 //-----------------------------------------------------
35 #define LONGUEUR_MINI_EDGE_TRIANGLE 1e-15
38 //=======================================================================
39 //function : IntCurveSurface_Polyhedron
41 //=======================================================================
42 IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
43 const Standard_Integer nbdU,
44 const Standard_Integer nbdV,
45 const Standard_Real u1,
46 const Standard_Real v1,
47 const Standard_Real u2,
48 const Standard_Real v2)
49 : nbdeltaU((nbdU<3)? 3 : nbdU),
50 nbdeltaV((nbdV<3)? 3 : nbdV),
51 TheDeflection(Epsilon(100.)),
52 C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
54 Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
55 gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
56 Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
57 Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
59 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
60 Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
62 C_MyIsOnBounds = (void *)CMyIsOnBounds;
63 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
64 Init(Surface,u1,v1,u2,v2);
67 //=======================================================================
68 //function : IntCurveSurface_Polyhedron
70 //=======================================================================
71 IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
72 const TColStd_Array1OfReal& Upars,
73 const TColStd_Array1OfReal& Vpars)
74 : nbdeltaU(Upars.Length()-1),
75 nbdeltaV(Vpars.Length()-1),
76 TheDeflection(Epsilon(100.)),
77 C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
79 Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
80 gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
81 Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
82 Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
84 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
85 Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
87 C_MyIsOnBounds = (void *)CMyIsOnBounds;
88 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
89 Init(Surface, Upars, Vpars);
93 void IntCurveSurface_Polyhedron::Destroy() {
94 //-- printf("\n IntCurveSurface_Polyhedron::Destroy\n");
95 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts; if(C_MyPnts) delete [] CMyPnts;
96 Standard_Real *CMyU = (Standard_Real *)C_MyU; if(C_MyU) delete [] CMyU;
97 Standard_Real *CMyV = (Standard_Real *)C_MyV; if(C_MyV) delete [] CMyV;
99 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
100 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
102 if(C_MyIsOnBounds) delete [] CMyIsOnBounds;
103 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
105 C_MyPnts=C_MyU=C_MyV=C_MyIsOnBounds=NULL;
108 //=======================================================================
111 //=======================================================================
112 void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
113 const Standard_Real U0,
114 const Standard_Real V0,
115 const Standard_Real U1,
116 const Standard_Real V1) {
118 Standard_Integer i1,i2;
120 Standard_Real U1mU0sNbdeltaU = (U1-U0)/(Standard_Real)nbdeltaU;
121 Standard_Real V1mV0sNbdeltaV = (V1-V0)/(Standard_Real)nbdeltaV;
123 Standard_Integer Index=1;
124 //-- --------------------------------------------------
125 //-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
126 //-- V est la colonne
128 //-- --------------------------------------------------
129 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
130 Standard_Real *CMyU = (Standard_Real *)C_MyU;
131 Standard_Real *CMyV = (Standard_Real *)C_MyV;
132 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
134 for (i1 = 0, U = U0; i1 <= nbdeltaU; i1++, U+= U1mU0sNbdeltaU) {
135 for (i2 = 0, V = V0; i2 <= nbdeltaV; i2++, V+= V1mV0sNbdeltaV ) {
136 ThePSurfaceTool::D0(Surface,U,V,TP);
137 //-- Point(TP,i1, i2,U,V);
141 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
142 CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
143 i2 == 0 || i2 == nbdeltaV);
144 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
149 //-- Calcul de la deflection Triangle <-> Point milieu
150 Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
151 for (i1=1; i1<=nbtriangles; i1++) {
152 Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
153 if(tol1>tol) tol=tol1;
155 //-- Calcul de la deflection Bord <-> Point milieu
158 DeflectionOverEstimation(tol*1.2);
161 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
162 Standard_Real aDeflection;
164 TheBorderDeflection = RealFirst();
166 // Compute the deflection on the lower bound (U-isoline) of the surface.
167 aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
169 if (aDeflection > TheBorderDeflection)
170 TheBorderDeflection = aDeflection;
172 // Compute the deflection on the upper bound (U-isoline) of the surface.
173 aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
175 if (aDeflection > TheBorderDeflection)
176 TheBorderDeflection = aDeflection;
178 // Compute the deflection on the lower bound (V-isoline) of the surface.
179 aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
181 if (aDeflection > TheBorderDeflection)
182 TheBorderDeflection = aDeflection;
184 // Compute the deflection on the upper bound (V-isoline) of the surface.
185 aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
187 if (aDeflection > TheBorderDeflection)
188 TheBorderDeflection = aDeflection;
190 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
192 #ifdef OCCT_DEBUG_DUMP
196 //=======================================================================
199 //=======================================================================
200 void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
201 const TColStd_Array1OfReal& Upars,
202 const TColStd_Array1OfReal& Vpars) {
204 Standard_Integer i1,i2;
207 Standard_Integer Index=1;
208 //-- --------------------------------------------------
209 //-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
210 //-- V est la colonne
212 //-- --------------------------------------------------
213 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
214 Standard_Real *CMyU = (Standard_Real *)C_MyU;
215 Standard_Real *CMyV = (Standard_Real *)C_MyV;
216 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
217 Standard_Integer i0 = Upars.Lower(), j0 = Vpars.Lower();
219 for (i1 = 0; i1 <= nbdeltaU; i1++) {
221 for (i2 = 0; i2 <= nbdeltaV; i2++) {
223 ThePSurfaceTool::D0(Surface,U,V,TP);
224 //-- Point(TP,i1, i2,U,V);
228 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
229 CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
230 i2 == 0 || i2 == nbdeltaV);
231 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
236 //-- Calcul de la deflection Triangle <-> Point milieu
237 Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
238 for (i1=1; i1<=nbtriangles; i1++) {
239 Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
240 if(tol1>tol) tol=tol1;
242 //-- Calcul de la deflection Bord <-> Point milieu
245 DeflectionOverEstimation(tol*1.2);
248 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
249 Standard_Real aDeflection;
251 TheBorderDeflection = RealFirst();
252 Standard_Real U0 = Upars(i0);
253 Standard_Real V0 = Vpars(j0);
254 Standard_Real U1 = Upars(Upars.Upper());
255 Standard_Real V1 = Vpars(Vpars.Upper());
257 // Compute the deflection on the lower bound (U-isoline) of the surface.
258 aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
260 if (aDeflection > TheBorderDeflection)
261 TheBorderDeflection = aDeflection;
263 // Compute the deflection on the upper bound (U-isoline) of the surface.
264 aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
266 if (aDeflection > TheBorderDeflection)
267 TheBorderDeflection = aDeflection;
269 // Compute the deflection on the lower bound (V-isoline) of the surface.
270 aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
272 if (aDeflection > TheBorderDeflection)
273 TheBorderDeflection = aDeflection;
275 // Compute the deflection on the upper bound (V-isoline) of the surface.
276 aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
278 if (aDeflection > TheBorderDeflection)
279 TheBorderDeflection = aDeflection;
281 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
283 #ifdef OCCT_DEBUG_DUMP
287 //=======================================================================
288 //function : DeflectionOnTriangle
290 //=======================================================================
291 Standard_Real IntCurveSurface_Polyhedron::DeflectionOnTriangle (const ThePSurface& Surface,
292 const Standard_Integer Triang) const
294 Standard_Integer i1,i2,i3;
295 Triangle(Triang,i1,i2,i3);
296 //-- Calcul de l equation du plan
297 Standard_Real u1,v1,u2,v2,u3,v3;
299 P1 = Point(i1,u1,v1);
300 P2 = Point(i2,u2,v2);
301 P3 = Point(i3,u3,v3);
302 if(P1.SquareDistance(P2)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
303 if(P1.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
304 if(P2.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
305 gp_XYZ XYZ1=P2.XYZ()-P1.XYZ();
306 gp_XYZ XYZ2=P3.XYZ()-P2.XYZ();
307 gp_XYZ XYZ3=P1.XYZ()-P3.XYZ();
308 gp_Vec NormalVector((XYZ1^XYZ2)+(XYZ2^XYZ3)+(XYZ3^XYZ1));
309 Standard_Real aNormLen = NormalVector.Magnitude();
310 if (aNormLen < gp::Resolution()) {
314 NormalVector.Divide(aNormLen);
315 //-- Standard_Real PolarDistance = NormalVector * P1.XYZ();
316 //-- Calcul du point u,v au centre du triangle
317 Standard_Real u = (u1+u2+u3)/3.0;
318 Standard_Real v = (v1+v2+v3)/3.0;
319 gp_Pnt P = ThePSurfaceTool::Value(Surface,u,v);
321 return(Abs(P1P.Dot(NormalVector)));
323 //=======================================================================
324 //function : Parameters
326 //=======================================================================
327 void IntCurveSurface_Polyhedron::Parameters( const Standard_Integer Index
329 ,Standard_Real &V) const
332 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
333 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
336 Standard_Real *CMyU = (Standard_Real *)C_MyU;
338 Standard_Real *CMyV = (Standard_Real *)C_MyV;
341 //=======================================================================
342 //function : DeflectionOverEstimation
344 //=======================================================================
345 void IntCurveSurface_Polyhedron::DeflectionOverEstimation(const Standard_Real flec)
348 TheDeflection=0.0001;
349 TheBnd.Enlarge(0.0001);
353 TheBnd.Enlarge(flec);
356 //=======================================================================
357 //function : DeflectionOverEstimation
359 //=======================================================================
360 Standard_Real IntCurveSurface_Polyhedron::DeflectionOverEstimation() const
362 return TheDeflection;
364 //=======================================================================
365 //function : Bounding
367 //=======================================================================
368 const Bnd_Box& IntCurveSurface_Polyhedron::Bounding() const
372 //=======================================================================
373 //function : FillBounding
375 //=======================================================================
376 void IntCurveSurface_Polyhedron::FillBounding()
378 TheComponentsBnd=new Bnd_HArray1OfBox(1, NbTriangles());
380 Standard_Integer np1, np2, np3;
381 Standard_Integer nbtriangles = NbTriangles();
382 for (Standard_Integer iTri=1; iTri<=nbtriangles; iTri++) {
383 Triangle(iTri, np1, np2, np3);
384 gp_Pnt p1(Point(np1));
385 gp_Pnt p2(Point(np2));
386 gp_Pnt p3(Point(np3));
388 if(p1.SquareDistance(p2)>LONGUEUR_MINI_EDGE_TRIANGLE) {
389 if(p1.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
390 if(p2.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
394 Boite.Enlarge(TheDeflection);
398 Boite.Enlarge(TheDeflection);
399 TheComponentsBnd->SetValue(iTri,Boite);
402 //=======================================================================
403 //function : ComponentsBounding
405 //=======================================================================
406 const Handle(Bnd_HArray1OfBox)&
407 IntCurveSurface_Polyhedron::ComponentsBounding() const
409 return TheComponentsBnd;
411 //=======================================================================
412 //function : NbTriangles
414 //=======================================================================
415 Standard_Integer IntCurveSurface_Polyhedron::NbTriangles () const
417 return nbdeltaU*nbdeltaV*2;
419 //=======================================================================
420 //function : NbPoints
422 //=======================================================================
423 Standard_Integer IntCurveSurface_Polyhedron::NbPoints () const
425 return (nbdeltaU+1)*(nbdeltaV+1);
427 //=======================================================================
428 //function : TriConnex
430 //=======================================================================
431 Standard_Integer IntCurveSurface_Polyhedron::TriConnex
432 (const Standard_Integer Triang,
433 const Standard_Integer Pivot,
434 const Standard_Integer Pedge,
435 Standard_Integer& TriCon,
436 Standard_Integer& OtherP) const
438 Standard_Integer Pivotm1 = Pivot-1;
439 Standard_Integer nbdeltaVp1 = nbdeltaV+1;
440 Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
442 // Pivot position in the MaTriangle :
443 Standard_Integer ligP = Pivotm1/nbdeltaVp1;
444 Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
446 // Point sur Edge position in the MaTriangle and edge typ :
447 Standard_Integer ligE =0, colE =0, typE =0;
449 ligE= (Pedge-1)/nbdeltaVp1;
450 colE= (Pedge-1) - (ligE * nbdeltaVp1);
452 if (ligP==ligE) typE=1;
454 else if (colP==colE) typE=2;
462 // Triangle position General case :
464 Standard_Integer linT =0, colT =0;
465 Standard_Integer linO =0, colO =0;
466 Standard_Integer t =0, tt =0;
469 t = (Triang-1)/(nbdeltaVm2);
470 tt= (Triang-1)-t*nbdeltaVm2;
480 if (colT==ligP+ligP) {
493 case 1: // Horizontal
497 colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
502 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
506 if (colT==(colP+colP)) {
508 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
513 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
520 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
521 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
525 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
526 colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
532 // Unknown Triangle position :
535 linT=(1>ligP)? 1 : ligP; //--linT=Max(1, ligP);
536 colT=(1>(colP+colP))? 1 : (colP+colP); //--colT=Max(1, colP+colP);
537 if (ligP==0) linO=ligP+1;
542 // Known edge We take the left or down connectivity :
544 case 1: // Horizontal
546 colT=(colP>colE)? colP : colE; //--colT=Max(colP,colE);
549 colO=(colP>colE)? colP : colE; //--colO=Max(colP,colE);
552 linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
554 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
558 linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
560 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
561 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
567 TriCon=(linT-1)*nbdeltaVm2 + colT;
572 if (colO<0) {colO=0;linO=1;}
573 else if (colO>nbdeltaV) {colO=nbdeltaV;linO=1;}
576 else if (linT>nbdeltaU) {
579 if (colO<0) {colO=0;linO=nbdeltaU-1;}
580 else if (colO>nbdeltaV) {colO=nbdeltaV;linO=nbdeltaU-1;}
587 if (linO<0) {linO=0;colO=1;}
588 else if (linO>nbdeltaU) {linO=nbdeltaU;colO=1;}
591 else if (colT>nbdeltaV) {
594 if (linO<0) {linO=0;colO=nbdeltaV-1;}
595 else if (linO>nbdeltaU) {linO=nbdeltaU;colO=nbdeltaV-1;}
599 OtherP=linO*nbdeltaVp1 + colO+1;
605 //=======================================================================
606 //function : PlaneEquation
608 //=======================================================================
609 void IntCurveSurface_Polyhedron::PlaneEquation (const Standard_Integer Triang,
610 gp_XYZ& NormalVector,
611 Standard_Real& PolarDistance) const
613 Standard_Integer i1,i2,i3;
614 Triangle(Triang,i1,i2,i3);
616 //-- gp_XYZ v1=Point(i2).XYZ()-Point(i1).XYZ();
617 //-- gp_XYZ v2=Point(i3).XYZ()-Point(i2).XYZ();
618 //-- gp_XYZ v3=Point(i1).XYZ()-Point(i3).XYZ();
620 gp_XYZ Pointi1(Point(i1).XYZ());
621 gp_XYZ Pointi2(Point(i2).XYZ());
622 gp_XYZ Pointi3(Point(i3).XYZ());
625 gp_XYZ v1= Pointi2 - Pointi1;
626 gp_XYZ v2= Pointi3 - Pointi2;
627 gp_XYZ v3= Pointi1 - Pointi3;
629 if(v1.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
630 if(v2.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
631 if(v3.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
633 NormalVector= (v1^v2)+(v2^v3)+(v3^v1);
634 Standard_Real aNormLen = NormalVector.Modulus();
635 if (aNormLen < gp::Resolution()) {
639 NormalVector.Divide(aNormLen);
640 PolarDistance = NormalVector * Point(i1).XYZ();
643 //=======================================================================
646 //=======================================================================
647 Standard_Boolean IntCurveSurface_Polyhedron::Contain (const Standard_Integer Triang,
648 const gp_Pnt& ThePnt) const
650 Standard_Integer i1,i2,i3;
651 Triangle(Triang,i1,i2,i3);
652 gp_XYZ Pointi1(Point(i1).XYZ());
653 gp_XYZ Pointi2(Point(i2).XYZ());
654 gp_XYZ Pointi3(Point(i3).XYZ());
656 gp_XYZ v1=(Pointi2-Pointi1)^(ThePnt.XYZ()-Pointi1);
657 gp_XYZ v2=(Pointi3-Pointi2)^(ThePnt.XYZ()-Pointi2);
658 gp_XYZ v3=(Pointi1-Pointi3)^(ThePnt.XYZ()-Pointi3);
659 if (v1*v2 >= 0. && v2*v3 >= 0. && v3*v1>=0.)
660 return Standard_True;
662 return Standard_False;
664 //=======================================================================
667 //=======================================================================
668 void IntCurveSurface_Polyhedron::Dump() const
672 //=======================================================================
675 //=======================================================================
676 void IntCurveSurface_Polyhedron::Size (Standard_Integer& nbdu,
677 Standard_Integer& nbdv) const
682 //=======================================================================
683 //function : Triangle
685 //=======================================================================
686 void IntCurveSurface_Polyhedron::Triangle (const Standard_Integer Index,
687 Standard_Integer& P1,
688 Standard_Integer& P2,
689 Standard_Integer& P3) const
691 Standard_Integer line=1+((Index-1)/(nbdeltaV*2));
692 Standard_Integer colon=1+((Index-1)%(nbdeltaV*2));
693 Standard_Integer colpnt=(colon+1)/2;
695 // General formula = (line-1)*(nbdeltaV+1)+colpnt
697 // Position of P1 = MesXYZ(line,colpnt);
698 P1= (line-1)*(nbdeltaV+1) + colpnt;
700 // Position of P2= MesXYZ(line+1,colpnt+((colon-1)%2));
701 P2= line*(nbdeltaV+1) + colpnt+((colon-1)%2);
703 // Position of P3= MesXYZ(line+(colon%2),colpnt+1);
704 P3= (line-1+(colon%2))*(nbdeltaV+1) + colpnt + 1;
706 //=======================================================================
708 //=======================================================================
709 const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index
711 ,Standard_Real& V) const
714 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
715 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
718 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
719 Standard_Real *CMyU = (Standard_Real *)C_MyU;
720 Standard_Real *CMyV = (Standard_Real *)C_MyV;
723 return CMyPnts[Index];
725 //=======================================================================
727 //=======================================================================
728 const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index) const {
730 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
731 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
735 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
736 return CMyPnts[Index];
738 //=======================================================================
740 //=======================================================================
741 //void IntCurveSurface_Polyhedron::Point (const gp_Pnt& p,
742 // const Standard_Integer lig,
743 // const Standard_Integer col,
744 // const Standard_Real u,
745 // const Standard_Real v)
746 void IntCurveSurface_Polyhedron::Point (const gp_Pnt& ,
747 const Standard_Integer ,
748 const Standard_Integer ,
749 const Standard_Real ,
750 const Standard_Real )
752 printf("\n IntCurveSurface_Polyhedron::Point : Ne dois pas etre appelle\n");
754 //=======================================================================
756 //=======================================================================
757 void IntCurveSurface_Polyhedron::Point (const Standard_Integer Index,gp_Pnt& P) const
760 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
761 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
765 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
769 // Modified by Sergey KHROMOV - Fri Dec 7 10:12:47 2001 Begin
771 //=======================================================================
772 //function : IsOnBound
773 //purpose : This method returns true if the edge based on points with
774 // indices Index1 and Index2 represents a boundary edge.
775 //=======================================================================
777 Standard_Boolean IntCurveSurface_Polyhedron::IsOnBound
778 (const Standard_Integer Index1,
779 const Standard_Integer Index2) const
782 if(Index1<0 || Index1>((nbdeltaU+1)*(nbdeltaV+1))) {
783 printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
785 if(Index2<0 || Index2>((nbdeltaU+1)*(nbdeltaV+1))) {
786 printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
789 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
790 Standard_Integer aDiff = Abs(Index1 - Index2);
793 // Check if points are neighbour ones.
794 if (aDiff != 1 && aDiff != nbdeltaV + 1)
795 return Standard_False;
797 for (i = 0; i <= nbdeltaU; i++) {
798 if ((Index1 == 1 + i*(nbdeltaV + 1)) && (Index2 == Index1 - 1))
799 return Standard_False;
801 if ((Index1 == (1 + i)*(nbdeltaV + 1)) && (Index2 == Index1 + 1))
802 return Standard_False;
805 return (CMyIsOnBounds[Index1] && CMyIsOnBounds[Index2]);
808 //=======================================================================
809 //function : ComputeBorderDeflection
810 //purpose : This method computes and returns a deflection of isoline
811 // of given parameter on Surface.
812 //=======================================================================
814 Standard_Real IntCurveSurface_Polyhedron::ComputeBorderDeflection
815 (const ThePSurface &Surface,
816 const Standard_Real Parameter,
817 const Standard_Real PMin,
818 const Standard_Real PMax,
819 const Standard_Boolean isUIso) const
821 Standard_Integer aNbSamples;
825 aNbSamples = nbdeltaV;
827 aNbSamples = nbdeltaU;
829 Standard_Real aDelta = (PMax - PMin)/aNbSamples;
830 Standard_Real aPar = PMin;
831 Standard_Real aDeflection = RealFirst();
837 for (i = 0; i <= aNbSamples; i++, aPar+= aDelta) {
839 aP1 = ThePSurfaceTool::Value(Surface, Parameter, aPar).XYZ();
840 aP2 = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta).XYZ();
841 aPParMid = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta/2.).XYZ();
843 aP1 = ThePSurfaceTool::Value(Surface, aPar, Parameter).XYZ();
844 aP2 = ThePSurfaceTool::Value(Surface, aPar + aDelta, Parameter).XYZ();
845 aPParMid = ThePSurfaceTool::Value(Surface, aPar + aDelta/2., Parameter).XYZ();
847 aPMid = (aP2 + aP1)/2.;
849 Standard_Real aDist = (aPMid - aPParMid).Modulus();
851 if (aDist > aDeflection)
858 // Modified by Sergey KHROMOV - Fri Dec 7 11:21:52 2001 End