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
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.
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.
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.
26 #include <TColgp_Array2OfPnt.hxx>
27 #include <TColStd_Array2OfReal.hxx>
29 #include <Bnd_Array1OfBox.hxx>
31 #include <Standard_ConstructionError.hxx>
33 //#if defined (WNT) || !defined (DEB)
40 //-----------------------------------------------------
41 #define LONGUEUR_MINI_EDGE_TRIANGLE 1e-15
44 //=======================================================================
45 //function : IntCurveSurface_Polyhedron
47 //=======================================================================
48 IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
49 const Standard_Integer nbdU,
50 const Standard_Integer nbdV,
51 const Standard_Real u1,
52 const Standard_Real v1,
53 const Standard_Real u2,
54 const Standard_Real v2)
55 : nbdeltaU((nbdU<3)? 3 : nbdU),
56 nbdeltaV((nbdV<3)? 3 : nbdV),
57 TheDeflection(Epsilon(100.)),
58 C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
60 Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
61 gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
62 Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
63 Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
65 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
66 Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
68 C_MyIsOnBounds = (void *)CMyIsOnBounds;
69 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
70 Init(Surface,u1,v1,u2,v2);
73 //=======================================================================
74 //function : IntCurveSurface_Polyhedron
76 //=======================================================================
77 IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
78 const TColStd_Array1OfReal& Upars,
79 const TColStd_Array1OfReal& Vpars)
80 : nbdeltaU(Upars.Length()-1),
81 nbdeltaV(Vpars.Length()-1),
82 TheDeflection(Epsilon(100.)),
83 C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
85 Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
86 gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
87 Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
88 Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
90 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
91 Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
93 C_MyIsOnBounds = (void *)CMyIsOnBounds;
94 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
95 Init(Surface, Upars, Vpars);
99 void IntCurveSurface_Polyhedron::Destroy() {
100 //-- printf("\n IntCurveSurface_Polyhedron::Destroy\n");
101 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts; if(C_MyPnts) delete [] CMyPnts;
102 Standard_Real *CMyU = (Standard_Real *)C_MyU; if(C_MyU) delete [] CMyU;
103 Standard_Real *CMyV = (Standard_Real *)C_MyV; if(C_MyV) delete [] CMyV;
105 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
106 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
108 if(C_MyIsOnBounds) delete [] CMyIsOnBounds;
109 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
111 C_MyPnts=C_MyU=C_MyV=C_MyIsOnBounds=NULL;
114 //=======================================================================
117 //=======================================================================
118 void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
119 const Standard_Real U0,
120 const Standard_Real V0,
121 const Standard_Real U1,
122 const Standard_Real V1) {
123 const Standard_Integer DebugDump = 0;
124 Standard_Integer i1,i2;
126 Standard_Real U1mU0sNbdeltaU = (U1-U0)/(Standard_Real)nbdeltaU;
127 Standard_Real V1mV0sNbdeltaV = (V1-V0)/(Standard_Real)nbdeltaV;
129 Standard_Integer Index=1;
130 //-- --------------------------------------------------
131 //-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
132 //-- V est la colonne
134 //-- --------------------------------------------------
135 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
136 Standard_Real *CMyU = (Standard_Real *)C_MyU;
137 Standard_Real *CMyV = (Standard_Real *)C_MyV;
138 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
140 for (i1 = 0, U = U0; i1 <= nbdeltaU; i1++, U+= U1mU0sNbdeltaU) {
141 for (i2 = 0, V = V0; i2 <= nbdeltaV; i2++, V+= V1mV0sNbdeltaV ) {
142 ThePSurfaceTool::D0(Surface,U,V,TP);
143 //-- Point(TP,i1, i2,U,V);
147 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
148 CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
149 i2 == 0 || i2 == nbdeltaV);
150 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
155 //-- Calcul de la deflection Triangle <-> Point milieu
156 Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
157 for (i1=1; i1<=nbtriangles; i1++) {
158 Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
159 if(tol1>tol) tol=tol1;
161 //-- Calcul de la deflection Bord <-> Point milieu
164 DeflectionOverEstimation(tol*1.2);
167 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
168 Standard_Real aDeflection;
170 TheBorderDeflection = RealFirst();
172 // Compute the deflection on the lower bound (U-isoline) of the surface.
173 aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
175 if (aDeflection > TheBorderDeflection)
176 TheBorderDeflection = aDeflection;
178 // Compute the deflection on the upper bound (U-isoline) of the surface.
179 aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
181 if (aDeflection > TheBorderDeflection)
182 TheBorderDeflection = aDeflection;
184 // Compute the deflection on the lower bound (V-isoline) of the surface.
185 aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
187 if (aDeflection > TheBorderDeflection)
188 TheBorderDeflection = aDeflection;
190 // Compute the deflection on the upper bound (V-isoline) of the surface.
191 aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
193 if (aDeflection > TheBorderDeflection)
194 TheBorderDeflection = aDeflection;
196 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
202 //=======================================================================
205 //=======================================================================
206 void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
207 const TColStd_Array1OfReal& Upars,
208 const TColStd_Array1OfReal& Vpars) {
209 const Standard_Integer DebugDump = 0;
210 Standard_Integer i1,i2;
213 Standard_Integer Index=1;
214 //-- --------------------------------------------------
215 //-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
216 //-- V est la colonne
218 //-- --------------------------------------------------
219 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
220 Standard_Real *CMyU = (Standard_Real *)C_MyU;
221 Standard_Real *CMyV = (Standard_Real *)C_MyV;
222 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
223 Standard_Integer i0 = Upars.Lower(), j0 = Vpars.Lower();
225 for (i1 = 0; i1 <= nbdeltaU; i1++) {
227 for (i2 = 0; i2 <= nbdeltaV; i2++) {
229 ThePSurfaceTool::D0(Surface,U,V,TP);
230 //-- Point(TP,i1, i2,U,V);
234 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
235 CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
236 i2 == 0 || i2 == nbdeltaV);
237 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
242 //-- Calcul de la deflection Triangle <-> Point milieu
243 Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
244 for (i1=1; i1<=nbtriangles; i1++) {
245 Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
246 if(tol1>tol) tol=tol1;
248 //-- Calcul de la deflection Bord <-> Point milieu
251 DeflectionOverEstimation(tol*1.2);
254 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
255 Standard_Real aDeflection;
257 TheBorderDeflection = RealFirst();
258 Standard_Real U0 = Upars(i0);
259 Standard_Real V0 = Vpars(j0);
260 Standard_Real U1 = Upars(Upars.Upper());
261 Standard_Real V1 = Vpars(Vpars.Upper());
263 // Compute the deflection on the lower bound (U-isoline) of the surface.
264 aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
266 if (aDeflection > TheBorderDeflection)
267 TheBorderDeflection = aDeflection;
269 // Compute the deflection on the upper bound (U-isoline) of the surface.
270 aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
272 if (aDeflection > TheBorderDeflection)
273 TheBorderDeflection = aDeflection;
275 // Compute the deflection on the lower bound (V-isoline) of the surface.
276 aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
278 if (aDeflection > TheBorderDeflection)
279 TheBorderDeflection = aDeflection;
281 // Compute the deflection on the upper bound (V-isoline) of the surface.
282 aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
284 if (aDeflection > TheBorderDeflection)
285 TheBorderDeflection = aDeflection;
287 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
293 //=======================================================================
294 //function : DeflectionOnTriangle
296 //=======================================================================
297 Standard_Real IntCurveSurface_Polyhedron::DeflectionOnTriangle (const ThePSurface& Surface,
298 const Standard_Integer Triang) const
300 Standard_Integer i1,i2,i3;
301 Triangle(Triang,i1,i2,i3);
302 //-- Calcul de l equation du plan
303 Standard_Real u1,v1,u2,v2,u3,v3;
305 P1 = Point(i1,u1,v1);
306 P2 = Point(i2,u2,v2);
307 P3 = Point(i3,u3,v3);
308 if(P1.SquareDistance(P2)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
309 if(P1.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
310 if(P2.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
311 gp_XYZ XYZ1=P2.XYZ()-P1.XYZ();
312 gp_XYZ XYZ2=P3.XYZ()-P2.XYZ();
313 gp_XYZ XYZ3=P1.XYZ()-P3.XYZ();
314 gp_Vec NormalVector((XYZ1^XYZ2)+(XYZ2^XYZ3)+(XYZ3^XYZ1));
315 NormalVector.Normalize();
316 //-- Standard_Real PolarDistance = NormalVector * P1.XYZ();
317 //-- Calcul du point u,v au centre du triangle
318 Standard_Real u = (u1+u2+u3)/3.0;
319 Standard_Real v = (v1+v2+v3)/3.0;
320 gp_Pnt P = ThePSurfaceTool::Value(Surface,u,v);
322 return(Abs(P1P.Dot(NormalVector)));
324 //=======================================================================
325 //function : Parameters
327 //=======================================================================
328 void IntCurveSurface_Polyhedron::Parameters( const Standard_Integer Index
330 ,Standard_Real &V) const
333 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
334 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
337 Standard_Real *CMyU = (Standard_Real *)C_MyU;
339 Standard_Real *CMyV = (Standard_Real *)C_MyV;
342 //=======================================================================
343 //function : DeflectionOverEstimation
345 //=======================================================================
346 void IntCurveSurface_Polyhedron::DeflectionOverEstimation(const Standard_Real flec)
349 TheDeflection=0.0001;
350 TheBnd.Enlarge(0.0001);
354 TheBnd.Enlarge(flec);
357 //=======================================================================
358 //function : DeflectionOverEstimation
360 //=======================================================================
361 Standard_Real IntCurveSurface_Polyhedron::DeflectionOverEstimation() const
363 return TheDeflection;
365 //=======================================================================
366 //function : Bounding
368 //=======================================================================
369 const Bnd_Box& IntCurveSurface_Polyhedron::Bounding() const
373 //=======================================================================
374 //function : FillBounding
376 //=======================================================================
377 void IntCurveSurface_Polyhedron::FillBounding()
379 TheComponentsBnd=new Bnd_HArray1OfBox(1, NbTriangles());
381 Standard_Integer np1, np2, np3;
382 Standard_Integer nbtriangles = NbTriangles();
383 for (Standard_Integer iTri=1; iTri<=nbtriangles; iTri++) {
384 Triangle(iTri, np1, np2, np3);
385 gp_Pnt p1(Point(np1));
386 gp_Pnt p2(Point(np2));
387 gp_Pnt p3(Point(np3));
389 if(p1.SquareDistance(p2)>LONGUEUR_MINI_EDGE_TRIANGLE) {
390 if(p1.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
391 if(p2.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
395 Boite.Enlarge(TheDeflection);
399 Boite.Enlarge(TheDeflection);
400 TheComponentsBnd->SetValue(iTri,Boite);
403 //=======================================================================
404 //function : ComponentsBounding
406 //=======================================================================
407 const Handle(Bnd_HArray1OfBox)&
408 IntCurveSurface_Polyhedron::ComponentsBounding() const
410 return TheComponentsBnd;
412 //=======================================================================
413 //function : NbTriangles
415 //=======================================================================
416 Standard_Integer IntCurveSurface_Polyhedron::NbTriangles () const
418 return nbdeltaU*nbdeltaV*2;
420 //=======================================================================
421 //function : NbPoints
423 //=======================================================================
424 Standard_Integer IntCurveSurface_Polyhedron::NbPoints () const
426 return (nbdeltaU+1)*(nbdeltaV+1);
428 //=======================================================================
429 //function : TriConnex
431 //=======================================================================
432 Standard_Integer IntCurveSurface_Polyhedron::TriConnex
433 (const Standard_Integer Triang,
434 const Standard_Integer Pivot,
435 const Standard_Integer Pedge,
436 Standard_Integer& TriCon,
437 Standard_Integer& OtherP) const
439 Standard_Integer Pivotm1 = Pivot-1;
440 Standard_Integer nbdeltaVp1 = nbdeltaV+1;
441 Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
443 // Pivot position in the MaTriangle :
444 Standard_Integer ligP = Pivotm1/nbdeltaVp1;
445 Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
447 // Point sur Edge position in the MaTriangle and edge typ :
448 Standard_Integer ligE =0, colE =0, typE =0;
450 ligE= (Pedge-1)/nbdeltaVp1;
451 colE= (Pedge-1) - (ligE * nbdeltaVp1);
453 if (ligP==ligE) typE=1;
455 else if (colP==colE) typE=2;
463 // Triangle position General case :
465 Standard_Integer linT =0, colT =0;
466 Standard_Integer linO =0, colO =0;
467 Standard_Integer t =0, tt =0;
470 t = (Triang-1)/(nbdeltaVm2);
471 tt= (Triang-1)-t*nbdeltaVm2;
481 if (colT==ligP+ligP) {
494 case 1: // Horizontal
498 colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
503 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
507 if (colT==(colP+colP)) {
509 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
514 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
521 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
522 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
526 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
527 colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
533 // Unknown Triangle position :
536 linT=(1>ligP)? 1 : ligP; //--linT=Max(1, ligP);
537 colT=(1>(colP+colP))? 1 : (colP+colP); //--colT=Max(1, colP+colP);
538 if (ligP==0) linO=ligP+1;
543 // Known edge We take the left or down connectivity :
545 case 1: // Horizontal
547 colT=(colP>colE)? colP : colE; //--colT=Max(colP,colE);
550 colO=(colP>colE)? colP : colE; //--colO=Max(colP,colE);
553 linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
555 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
559 linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
561 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
562 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
568 TriCon=(linT-1)*nbdeltaVm2 + colT;
573 if (colO<0) {colO=0;linO=1;}
574 else if (colO>nbdeltaV) {colO=nbdeltaV;linO=1;}
577 else if (linT>nbdeltaU) {
580 if (colO<0) {colO=0;linO=nbdeltaU-1;}
581 else if (colO>nbdeltaV) {colO=nbdeltaV;linO=nbdeltaU-1;}
588 if (linO<0) {linO=0;colO=1;}
589 else if (linO>nbdeltaU) {linO=nbdeltaU;colO=1;}
592 else if (colT>nbdeltaV) {
595 if (linO<0) {linO=0;colO=nbdeltaV-1;}
596 else if (linO>nbdeltaU) {linO=nbdeltaU;colO=nbdeltaV-1;}
600 OtherP=linO*nbdeltaVp1 + colO+1;
606 //=======================================================================
607 //function : PlaneEquation
609 //=======================================================================
610 void IntCurveSurface_Polyhedron::PlaneEquation (const Standard_Integer Triang,
611 gp_XYZ& NormalVector,
612 Standard_Real& PolarDistance) const
614 Standard_Integer i1,i2,i3;
615 Triangle(Triang,i1,i2,i3);
617 //-- gp_XYZ v1=Point(i2).XYZ()-Point(i1).XYZ();
618 //-- gp_XYZ v2=Point(i3).XYZ()-Point(i2).XYZ();
619 //-- gp_XYZ v3=Point(i1).XYZ()-Point(i3).XYZ();
621 gp_XYZ Pointi1(Point(i1).XYZ());
622 gp_XYZ Pointi2(Point(i2).XYZ());
623 gp_XYZ Pointi3(Point(i3).XYZ());
626 gp_XYZ v1= Pointi2 - Pointi1;
627 gp_XYZ v2= Pointi3 - Pointi2;
628 gp_XYZ v3= Pointi1 - Pointi3;
630 if(v1.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
631 if(v2.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
632 if(v3.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
634 NormalVector= (v1^v2)+(v2^v3)+(v3^v1);
635 NormalVector.Normalize();
636 PolarDistance = NormalVector * Point(i1).XYZ();
638 //=======================================================================
641 //=======================================================================
642 Standard_Boolean IntCurveSurface_Polyhedron::Contain (const Standard_Integer Triang,
643 const gp_Pnt& ThePnt) const
645 Standard_Integer i1,i2,i3;
646 Triangle(Triang,i1,i2,i3);
647 gp_XYZ Pointi1(Point(i1).XYZ());
648 gp_XYZ Pointi2(Point(i2).XYZ());
649 gp_XYZ Pointi3(Point(i3).XYZ());
651 gp_XYZ v1=(Pointi2-Pointi1)^(ThePnt.XYZ()-Pointi1);
652 gp_XYZ v2=(Pointi3-Pointi2)^(ThePnt.XYZ()-Pointi2);
653 gp_XYZ v3=(Pointi1-Pointi3)^(ThePnt.XYZ()-Pointi3);
654 if (v1*v2 >= 0. && v2*v3 >= 0. && v3*v1>=0.)
655 return Standard_True;
657 return Standard_False;
659 //=======================================================================
662 //=======================================================================
663 void IntCurveSurface_Polyhedron::Dump() const
667 //=======================================================================
670 //=======================================================================
671 void IntCurveSurface_Polyhedron::Size (Standard_Integer& nbdu,
672 Standard_Integer& nbdv) const
677 //=======================================================================
678 //function : Triangle
680 //=======================================================================
681 void IntCurveSurface_Polyhedron::Triangle (const Standard_Integer Index,
682 Standard_Integer& P1,
683 Standard_Integer& P2,
684 Standard_Integer& P3) const
686 Standard_Integer line=1+((Index-1)/(nbdeltaV*2));
687 Standard_Integer colon=1+((Index-1)%(nbdeltaV*2));
688 Standard_Integer colpnt=(colon+1)/2;
690 // General formula = (line-1)*(nbdeltaV+1)+colpnt
692 // Position of P1 = MesXYZ(line,colpnt);
693 P1= (line-1)*(nbdeltaV+1) + colpnt;
695 // Position of P2= MesXYZ(line+1,colpnt+((colon-1)%2));
696 P2= line*(nbdeltaV+1) + colpnt+((colon-1)%2);
698 // Position of P3= MesXYZ(line+(colon%2),colpnt+1);
699 P3= (line-1+(colon%2))*(nbdeltaV+1) + colpnt + 1;
701 //=======================================================================
703 //=======================================================================
704 const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index
706 ,Standard_Real& V) const
709 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
710 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
713 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
714 Standard_Real *CMyU = (Standard_Real *)C_MyU;
715 Standard_Real *CMyV = (Standard_Real *)C_MyV;
718 return CMyPnts[Index];
720 //=======================================================================
722 //=======================================================================
723 const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index) const {
725 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
726 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
730 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
731 return CMyPnts[Index];
733 //=======================================================================
735 //=======================================================================
736 //void IntCurveSurface_Polyhedron::Point (const gp_Pnt& p,
737 // const Standard_Integer lig,
738 // const Standard_Integer col,
739 // const Standard_Real u,
740 // const Standard_Real v)
741 void IntCurveSurface_Polyhedron::Point (const gp_Pnt& ,
742 const Standard_Integer ,
743 const Standard_Integer ,
744 const Standard_Real ,
745 const Standard_Real )
747 printf("\n IntCurveSurface_Polyhedron::Point : Ne dois pas etre appelle\n");
749 //=======================================================================
751 //=======================================================================
752 void IntCurveSurface_Polyhedron::Point (const Standard_Integer Index,gp_Pnt& P) const
755 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
756 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
760 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
764 // Modified by Sergey KHROMOV - Fri Dec 7 10:12:47 2001 Begin
766 //=======================================================================
767 //function : IsOnBound
768 //purpose : This method returns true if the edge based on points with
769 // indices Index1 and Index2 represents a boundary edge.
770 //=======================================================================
772 Standard_Boolean IntCurveSurface_Polyhedron::IsOnBound
773 (const Standard_Integer Index1,
774 const Standard_Integer Index2) const
777 if(Index1<0 || Index1>((nbdeltaU+1)*(nbdeltaV+1))) {
778 printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
780 if(Index2<0 || Index2>((nbdeltaU+1)*(nbdeltaV+1))) {
781 printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
784 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
785 Standard_Integer aDiff = Abs(Index1 - Index2);
788 // Check if points are neighbour ones.
789 if (aDiff != 1 && aDiff != nbdeltaV + 1)
790 return Standard_False;
792 for (i = 0; i <= nbdeltaU; i++) {
793 if ((Index1 == 1 + i*(nbdeltaV + 1)) && (Index2 == Index1 - 1))
794 return Standard_False;
796 if ((Index1 == (1 + i)*(nbdeltaV + 1)) && (Index2 == Index1 + 1))
797 return Standard_False;
800 return (CMyIsOnBounds[Index1] && CMyIsOnBounds[Index2]);
803 //=======================================================================
804 //function : ComputeBorderDeflection
805 //purpose : This method computes and returns a deflection of isoline
806 // of given parameter on Surface.
807 //=======================================================================
809 Standard_Real IntCurveSurface_Polyhedron::ComputeBorderDeflection
810 (const ThePSurface &Surface,
811 const Standard_Real Parameter,
812 const Standard_Real PMin,
813 const Standard_Real PMax,
814 const Standard_Boolean isUIso) const
816 Standard_Integer aNbSamples;
820 aNbSamples = nbdeltaV;
822 aNbSamples = nbdeltaU;
824 Standard_Real aDelta = (PMax - PMin)/aNbSamples;
825 Standard_Real aPar = PMin;
826 Standard_Real aDeflection = RealFirst();
832 for (i = 0; i <= aNbSamples; i++, aPar+= aDelta) {
834 aP1 = ThePSurfaceTool::Value(Surface, Parameter, aPar).XYZ();
835 aP2 = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta).XYZ();
836 aPParMid = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta/2.).XYZ();
838 aP1 = ThePSurfaceTool::Value(Surface, aPar, Parameter).XYZ();
839 aP2 = ThePSurfaceTool::Value(Surface, aPar + aDelta, Parameter).XYZ();
840 aPParMid = ThePSurfaceTool::Value(Surface, aPar + aDelta/2., Parameter).XYZ();
842 aPMid = (aP2 + aP1)/2.;
844 Standard_Real aDist = (aPMid - aPParMid).Modulus();
846 if (aDist > aDeflection)
853 // Modified by Sergey KHROMOV - Fri Dec 7 11:21:52 2001 End