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.
21 #include <TColgp_Array2OfPnt.hxx>
22 #include <TColStd_Array2OfReal.hxx>
24 #include <Bnd_Array1OfBox.hxx>
26 #include <Standard_ConstructionError.hxx>
33 //-----------------------------------------------------
34 #define LONGUEUR_MINI_EDGE_TRIANGLE 1e-15
37 //=======================================================================
38 //function : IntCurveSurface_Polyhedron
40 //=======================================================================
41 IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
42 const Standard_Integer nbdU,
43 const Standard_Integer nbdV,
44 const Standard_Real u1,
45 const Standard_Real v1,
46 const Standard_Real u2,
47 const Standard_Real v2)
48 : nbdeltaU((nbdU<3)? 3 : nbdU),
49 nbdeltaV((nbdV<3)? 3 : nbdV),
50 TheDeflection(Epsilon(100.)),
51 C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
53 Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
54 gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
55 Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
56 Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
58 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
59 Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
61 C_MyIsOnBounds = (void *)CMyIsOnBounds;
62 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
63 Init(Surface,u1,v1,u2,v2);
66 //=======================================================================
67 //function : IntCurveSurface_Polyhedron
69 //=======================================================================
70 IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
71 const TColStd_Array1OfReal& Upars,
72 const TColStd_Array1OfReal& Vpars)
73 : nbdeltaU(Upars.Length()-1),
74 nbdeltaV(Vpars.Length()-1),
75 TheDeflection(Epsilon(100.)),
76 C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
78 Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
79 gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
80 Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
81 Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
83 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
84 Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
86 C_MyIsOnBounds = (void *)CMyIsOnBounds;
87 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
88 Init(Surface, Upars, Vpars);
92 void IntCurveSurface_Polyhedron::Destroy() {
93 //-- printf("\n IntCurveSurface_Polyhedron::Destroy\n");
94 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts; if(C_MyPnts) delete [] CMyPnts;
95 Standard_Real *CMyU = (Standard_Real *)C_MyU; if(C_MyU) delete [] CMyU;
96 Standard_Real *CMyV = (Standard_Real *)C_MyV; if(C_MyV) delete [] CMyV;
98 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
99 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
101 if(C_MyIsOnBounds) delete [] CMyIsOnBounds;
102 // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
104 C_MyPnts=C_MyU=C_MyV=C_MyIsOnBounds=NULL;
107 //=======================================================================
110 //=======================================================================
111 void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
112 const Standard_Real U0,
113 const Standard_Real V0,
114 const Standard_Real U1,
115 const Standard_Real V1) {
117 Standard_Integer i1,i2;
119 Standard_Real U1mU0sNbdeltaU = (U1-U0)/(Standard_Real)nbdeltaU;
120 Standard_Real V1mV0sNbdeltaV = (V1-V0)/(Standard_Real)nbdeltaV;
122 Standard_Integer Index=1;
123 //-- --------------------------------------------------
124 //-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
125 //-- V est la colonne
127 //-- --------------------------------------------------
128 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
129 Standard_Real *CMyU = (Standard_Real *)C_MyU;
130 Standard_Real *CMyV = (Standard_Real *)C_MyV;
131 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
133 for (i1 = 0, U = U0; i1 <= nbdeltaU; i1++, U+= U1mU0sNbdeltaU) {
134 for (i2 = 0, V = V0; i2 <= nbdeltaV; i2++, V+= V1mV0sNbdeltaV ) {
135 ThePSurfaceTool::D0(Surface,U,V,TP);
136 //-- Point(TP,i1, i2,U,V);
140 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
141 CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
142 i2 == 0 || i2 == nbdeltaV);
143 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
148 //-- Calcul de la deflection Triangle <-> Point milieu
149 Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
150 for (i1=1; i1<=nbtriangles; i1++) {
151 Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
152 if(tol1>tol) tol=tol1;
154 //-- Calcul de la deflection Bord <-> Point milieu
157 DeflectionOverEstimation(tol*1.2);
160 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
161 Standard_Real aDeflection;
163 TheBorderDeflection = RealFirst();
165 // Compute the deflection on the lower bound (U-isoline) of the surface.
166 aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
168 if (aDeflection > TheBorderDeflection)
169 TheBorderDeflection = aDeflection;
171 // Compute the deflection on the upper bound (U-isoline) of the surface.
172 aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
174 if (aDeflection > TheBorderDeflection)
175 TheBorderDeflection = aDeflection;
177 // Compute the deflection on the lower bound (V-isoline) of the surface.
178 aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
180 if (aDeflection > TheBorderDeflection)
181 TheBorderDeflection = aDeflection;
183 // Compute the deflection on the upper bound (V-isoline) of the surface.
184 aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
186 if (aDeflection > TheBorderDeflection)
187 TheBorderDeflection = aDeflection;
189 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
191 #ifdef OCCT_DEBUG_DUMP
195 //=======================================================================
198 //=======================================================================
199 void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
200 const TColStd_Array1OfReal& Upars,
201 const TColStd_Array1OfReal& Vpars) {
203 Standard_Integer i1,i2;
206 Standard_Integer Index=1;
207 //-- --------------------------------------------------
208 //-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
209 //-- V est la colonne
211 //-- --------------------------------------------------
212 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
213 Standard_Real *CMyU = (Standard_Real *)C_MyU;
214 Standard_Real *CMyV = (Standard_Real *)C_MyV;
215 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
216 Standard_Integer i0 = Upars.Lower(), j0 = Vpars.Lower();
218 for (i1 = 0; i1 <= nbdeltaU; i1++) {
220 for (i2 = 0; i2 <= nbdeltaV; i2++) {
222 ThePSurfaceTool::D0(Surface,U,V,TP);
223 //-- Point(TP,i1, i2,U,V);
227 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
228 CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
229 i2 == 0 || i2 == nbdeltaV);
230 // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
235 //-- Calcul de la deflection Triangle <-> Point milieu
236 Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
237 for (i1=1; i1<=nbtriangles; i1++) {
238 Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
239 if(tol1>tol) tol=tol1;
241 //-- Calcul de la deflection Bord <-> Point milieu
244 DeflectionOverEstimation(tol*1.2);
247 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
248 Standard_Real aDeflection;
250 TheBorderDeflection = RealFirst();
251 Standard_Real U0 = Upars(i0);
252 Standard_Real V0 = Vpars(j0);
253 Standard_Real U1 = Upars(Upars.Upper());
254 Standard_Real V1 = Vpars(Vpars.Upper());
256 // Compute the deflection on the lower bound (U-isoline) of the surface.
257 aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
259 if (aDeflection > TheBorderDeflection)
260 TheBorderDeflection = aDeflection;
262 // Compute the deflection on the upper bound (U-isoline) of the surface.
263 aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
265 if (aDeflection > TheBorderDeflection)
266 TheBorderDeflection = aDeflection;
268 // Compute the deflection on the lower bound (V-isoline) of the surface.
269 aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
271 if (aDeflection > TheBorderDeflection)
272 TheBorderDeflection = aDeflection;
274 // Compute the deflection on the upper bound (V-isoline) of the surface.
275 aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
277 if (aDeflection > TheBorderDeflection)
278 TheBorderDeflection = aDeflection;
280 // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
282 #ifdef OCCT_DEBUG_DUMP
286 //=======================================================================
287 //function : DeflectionOnTriangle
289 //=======================================================================
290 Standard_Real IntCurveSurface_Polyhedron::DeflectionOnTriangle (const ThePSurface& Surface,
291 const Standard_Integer Triang) const
293 Standard_Integer i1,i2,i3;
294 Triangle(Triang,i1,i2,i3);
295 //-- Calcul de l equation du plan
296 Standard_Real u1,v1,u2,v2,u3,v3;
298 P1 = Point(i1,u1,v1);
299 P2 = Point(i2,u2,v2);
300 P3 = Point(i3,u3,v3);
301 if(P1.SquareDistance(P2)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
302 if(P1.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
303 if(P2.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
304 gp_XYZ XYZ1=P2.XYZ()-P1.XYZ();
305 gp_XYZ XYZ2=P3.XYZ()-P2.XYZ();
306 gp_XYZ XYZ3=P1.XYZ()-P3.XYZ();
307 gp_Vec NormalVector((XYZ1^XYZ2)+(XYZ2^XYZ3)+(XYZ3^XYZ1));
308 NormalVector.Normalize();
309 //-- Standard_Real PolarDistance = NormalVector * P1.XYZ();
310 //-- Calcul du point u,v au centre du triangle
311 Standard_Real u = (u1+u2+u3)/3.0;
312 Standard_Real v = (v1+v2+v3)/3.0;
313 gp_Pnt P = ThePSurfaceTool::Value(Surface,u,v);
315 return(Abs(P1P.Dot(NormalVector)));
317 //=======================================================================
318 //function : Parameters
320 //=======================================================================
321 void IntCurveSurface_Polyhedron::Parameters( const Standard_Integer Index
323 ,Standard_Real &V) const
326 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
327 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
330 Standard_Real *CMyU = (Standard_Real *)C_MyU;
332 Standard_Real *CMyV = (Standard_Real *)C_MyV;
335 //=======================================================================
336 //function : DeflectionOverEstimation
338 //=======================================================================
339 void IntCurveSurface_Polyhedron::DeflectionOverEstimation(const Standard_Real flec)
342 TheDeflection=0.0001;
343 TheBnd.Enlarge(0.0001);
347 TheBnd.Enlarge(flec);
350 //=======================================================================
351 //function : DeflectionOverEstimation
353 //=======================================================================
354 Standard_Real IntCurveSurface_Polyhedron::DeflectionOverEstimation() const
356 return TheDeflection;
358 //=======================================================================
359 //function : Bounding
361 //=======================================================================
362 const Bnd_Box& IntCurveSurface_Polyhedron::Bounding() const
366 //=======================================================================
367 //function : FillBounding
369 //=======================================================================
370 void IntCurveSurface_Polyhedron::FillBounding()
372 TheComponentsBnd=new Bnd_HArray1OfBox(1, NbTriangles());
374 Standard_Integer np1, np2, np3;
375 Standard_Integer nbtriangles = NbTriangles();
376 for (Standard_Integer iTri=1; iTri<=nbtriangles; iTri++) {
377 Triangle(iTri, np1, np2, np3);
378 gp_Pnt p1(Point(np1));
379 gp_Pnt p2(Point(np2));
380 gp_Pnt p3(Point(np3));
382 if(p1.SquareDistance(p2)>LONGUEUR_MINI_EDGE_TRIANGLE) {
383 if(p1.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
384 if(p2.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
388 Boite.Enlarge(TheDeflection);
392 Boite.Enlarge(TheDeflection);
393 TheComponentsBnd->SetValue(iTri,Boite);
396 //=======================================================================
397 //function : ComponentsBounding
399 //=======================================================================
400 const Handle(Bnd_HArray1OfBox)&
401 IntCurveSurface_Polyhedron::ComponentsBounding() const
403 return TheComponentsBnd;
405 //=======================================================================
406 //function : NbTriangles
408 //=======================================================================
409 Standard_Integer IntCurveSurface_Polyhedron::NbTriangles () const
411 return nbdeltaU*nbdeltaV*2;
413 //=======================================================================
414 //function : NbPoints
416 //=======================================================================
417 Standard_Integer IntCurveSurface_Polyhedron::NbPoints () const
419 return (nbdeltaU+1)*(nbdeltaV+1);
421 //=======================================================================
422 //function : TriConnex
424 //=======================================================================
425 Standard_Integer IntCurveSurface_Polyhedron::TriConnex
426 (const Standard_Integer Triang,
427 const Standard_Integer Pivot,
428 const Standard_Integer Pedge,
429 Standard_Integer& TriCon,
430 Standard_Integer& OtherP) const
432 Standard_Integer Pivotm1 = Pivot-1;
433 Standard_Integer nbdeltaVp1 = nbdeltaV+1;
434 Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
436 // Pivot position in the MaTriangle :
437 Standard_Integer ligP = Pivotm1/nbdeltaVp1;
438 Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
440 // Point sur Edge position in the MaTriangle and edge typ :
441 Standard_Integer ligE =0, colE =0, typE =0;
443 ligE= (Pedge-1)/nbdeltaVp1;
444 colE= (Pedge-1) - (ligE * nbdeltaVp1);
446 if (ligP==ligE) typE=1;
448 else if (colP==colE) typE=2;
456 // Triangle position General case :
458 Standard_Integer linT =0, colT =0;
459 Standard_Integer linO =0, colO =0;
460 Standard_Integer t =0, tt =0;
463 t = (Triang-1)/(nbdeltaVm2);
464 tt= (Triang-1)-t*nbdeltaVm2;
474 if (colT==ligP+ligP) {
487 case 1: // Horizontal
491 colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
496 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
500 if (colT==(colP+colP)) {
502 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
507 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
514 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
515 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
519 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
520 colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
526 // Unknown Triangle position :
529 linT=(1>ligP)? 1 : ligP; //--linT=Max(1, ligP);
530 colT=(1>(colP+colP))? 1 : (colP+colP); //--colT=Max(1, colP+colP);
531 if (ligP==0) linO=ligP+1;
536 // Known edge We take the left or down connectivity :
538 case 1: // Horizontal
540 colT=(colP>colE)? colP : colE; //--colT=Max(colP,colE);
543 colO=(colP>colE)? colP : colE; //--colO=Max(colP,colE);
546 linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
548 linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
552 linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
554 linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
555 colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
561 TriCon=(linT-1)*nbdeltaVm2 + colT;
566 if (colO<0) {colO=0;linO=1;}
567 else if (colO>nbdeltaV) {colO=nbdeltaV;linO=1;}
570 else if (linT>nbdeltaU) {
573 if (colO<0) {colO=0;linO=nbdeltaU-1;}
574 else if (colO>nbdeltaV) {colO=nbdeltaV;linO=nbdeltaU-1;}
581 if (linO<0) {linO=0;colO=1;}
582 else if (linO>nbdeltaU) {linO=nbdeltaU;colO=1;}
585 else if (colT>nbdeltaV) {
588 if (linO<0) {linO=0;colO=nbdeltaV-1;}
589 else if (linO>nbdeltaU) {linO=nbdeltaU;colO=nbdeltaV-1;}
593 OtherP=linO*nbdeltaVp1 + colO+1;
599 //=======================================================================
600 //function : PlaneEquation
602 //=======================================================================
603 void IntCurveSurface_Polyhedron::PlaneEquation (const Standard_Integer Triang,
604 gp_XYZ& NormalVector,
605 Standard_Real& PolarDistance) const
607 Standard_Integer i1,i2,i3;
608 Triangle(Triang,i1,i2,i3);
610 //-- gp_XYZ v1=Point(i2).XYZ()-Point(i1).XYZ();
611 //-- gp_XYZ v2=Point(i3).XYZ()-Point(i2).XYZ();
612 //-- gp_XYZ v3=Point(i1).XYZ()-Point(i3).XYZ();
614 gp_XYZ Pointi1(Point(i1).XYZ());
615 gp_XYZ Pointi2(Point(i2).XYZ());
616 gp_XYZ Pointi3(Point(i3).XYZ());
619 gp_XYZ v1= Pointi2 - Pointi1;
620 gp_XYZ v2= Pointi3 - Pointi2;
621 gp_XYZ v3= Pointi1 - Pointi3;
623 if(v1.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
624 if(v2.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
625 if(v3.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
627 NormalVector= (v1^v2)+(v2^v3)+(v3^v1);
628 NormalVector.Normalize();
629 PolarDistance = NormalVector * Point(i1).XYZ();
631 //=======================================================================
634 //=======================================================================
635 Standard_Boolean IntCurveSurface_Polyhedron::Contain (const Standard_Integer Triang,
636 const gp_Pnt& ThePnt) const
638 Standard_Integer i1,i2,i3;
639 Triangle(Triang,i1,i2,i3);
640 gp_XYZ Pointi1(Point(i1).XYZ());
641 gp_XYZ Pointi2(Point(i2).XYZ());
642 gp_XYZ Pointi3(Point(i3).XYZ());
644 gp_XYZ v1=(Pointi2-Pointi1)^(ThePnt.XYZ()-Pointi1);
645 gp_XYZ v2=(Pointi3-Pointi2)^(ThePnt.XYZ()-Pointi2);
646 gp_XYZ v3=(Pointi1-Pointi3)^(ThePnt.XYZ()-Pointi3);
647 if (v1*v2 >= 0. && v2*v3 >= 0. && v3*v1>=0.)
648 return Standard_True;
650 return Standard_False;
652 //=======================================================================
655 //=======================================================================
656 void IntCurveSurface_Polyhedron::Dump() const
660 //=======================================================================
663 //=======================================================================
664 void IntCurveSurface_Polyhedron::Size (Standard_Integer& nbdu,
665 Standard_Integer& nbdv) const
670 //=======================================================================
671 //function : Triangle
673 //=======================================================================
674 void IntCurveSurface_Polyhedron::Triangle (const Standard_Integer Index,
675 Standard_Integer& P1,
676 Standard_Integer& P2,
677 Standard_Integer& P3) const
679 Standard_Integer line=1+((Index-1)/(nbdeltaV*2));
680 Standard_Integer colon=1+((Index-1)%(nbdeltaV*2));
681 Standard_Integer colpnt=(colon+1)/2;
683 // General formula = (line-1)*(nbdeltaV+1)+colpnt
685 // Position of P1 = MesXYZ(line,colpnt);
686 P1= (line-1)*(nbdeltaV+1) + colpnt;
688 // Position of P2= MesXYZ(line+1,colpnt+((colon-1)%2));
689 P2= line*(nbdeltaV+1) + colpnt+((colon-1)%2);
691 // Position of P3= MesXYZ(line+(colon%2),colpnt+1);
692 P3= (line-1+(colon%2))*(nbdeltaV+1) + colpnt + 1;
694 //=======================================================================
696 //=======================================================================
697 const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index
699 ,Standard_Real& V) const
702 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
703 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
706 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
707 Standard_Real *CMyU = (Standard_Real *)C_MyU;
708 Standard_Real *CMyV = (Standard_Real *)C_MyV;
711 return CMyPnts[Index];
713 //=======================================================================
715 //=======================================================================
716 const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index) const {
718 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
719 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
723 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
724 return CMyPnts[Index];
726 //=======================================================================
728 //=======================================================================
729 //void IntCurveSurface_Polyhedron::Point (const gp_Pnt& p,
730 // const Standard_Integer lig,
731 // const Standard_Integer col,
732 // const Standard_Real u,
733 // const Standard_Real v)
734 void IntCurveSurface_Polyhedron::Point (const gp_Pnt& ,
735 const Standard_Integer ,
736 const Standard_Integer ,
737 const Standard_Real ,
738 const Standard_Real )
740 printf("\n IntCurveSurface_Polyhedron::Point : Ne dois pas etre appelle\n");
742 //=======================================================================
744 //=======================================================================
745 void IntCurveSurface_Polyhedron::Point (const Standard_Integer Index,gp_Pnt& P) const
748 if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
749 printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
753 gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
757 // Modified by Sergey KHROMOV - Fri Dec 7 10:12:47 2001 Begin
759 //=======================================================================
760 //function : IsOnBound
761 //purpose : This method returns true if the edge based on points with
762 // indices Index1 and Index2 represents a boundary edge.
763 //=======================================================================
765 Standard_Boolean IntCurveSurface_Polyhedron::IsOnBound
766 (const Standard_Integer Index1,
767 const Standard_Integer Index2) const
770 if(Index1<0 || Index1>((nbdeltaU+1)*(nbdeltaV+1))) {
771 printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
773 if(Index2<0 || Index2>((nbdeltaU+1)*(nbdeltaV+1))) {
774 printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
777 Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
778 Standard_Integer aDiff = Abs(Index1 - Index2);
781 // Check if points are neighbour ones.
782 if (aDiff != 1 && aDiff != nbdeltaV + 1)
783 return Standard_False;
785 for (i = 0; i <= nbdeltaU; i++) {
786 if ((Index1 == 1 + i*(nbdeltaV + 1)) && (Index2 == Index1 - 1))
787 return Standard_False;
789 if ((Index1 == (1 + i)*(nbdeltaV + 1)) && (Index2 == Index1 + 1))
790 return Standard_False;
793 return (CMyIsOnBounds[Index1] && CMyIsOnBounds[Index2]);
796 //=======================================================================
797 //function : ComputeBorderDeflection
798 //purpose : This method computes and returns a deflection of isoline
799 // of given parameter on Surface.
800 //=======================================================================
802 Standard_Real IntCurveSurface_Polyhedron::ComputeBorderDeflection
803 (const ThePSurface &Surface,
804 const Standard_Real Parameter,
805 const Standard_Real PMin,
806 const Standard_Real PMax,
807 const Standard_Boolean isUIso) const
809 Standard_Integer aNbSamples;
813 aNbSamples = nbdeltaV;
815 aNbSamples = nbdeltaU;
817 Standard_Real aDelta = (PMax - PMin)/aNbSamples;
818 Standard_Real aPar = PMin;
819 Standard_Real aDeflection = RealFirst();
825 for (i = 0; i <= aNbSamples; i++, aPar+= aDelta) {
827 aP1 = ThePSurfaceTool::Value(Surface, Parameter, aPar).XYZ();
828 aP2 = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta).XYZ();
829 aPParMid = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta/2.).XYZ();
831 aP1 = ThePSurfaceTool::Value(Surface, aPar, Parameter).XYZ();
832 aP2 = ThePSurfaceTool::Value(Surface, aPar + aDelta, Parameter).XYZ();
833 aPParMid = ThePSurfaceTool::Value(Surface, aPar + aDelta/2., Parameter).XYZ();
835 aPMid = (aP2 + aP1)/2.;
837 Standard_Real aDist = (aPMid - aPParMid).Modulus();
839 if (aDist > aDeflection)
846 // Modified by Sergey KHROMOV - Fri Dec 7 11:21:52 2001 End