0024177: Eliminate CLang compiler warning -Wlogical-op-parentheses (&& within ||)
[occt.git] / src / BRepTopAdaptor / BRepTopAdaptor_FClass2d.cxx
1 // Created on: 1995-03-22
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #define AFFICHAGE 0
23
24 #define No_Standard_OutOfRange
25
26 #include <BRepTopAdaptor_FClass2d.ixx>
27
28 #include <TopoDS_Edge.hxx>
29 #include <TopoDS.hxx>
30 #include <BRep_Tool.hxx>
31 #include <TopAbs_Orientation.hxx>
32 #include <TopExp_Explorer.hxx>
33 #include <TColgp_SequenceOfPnt2d.hxx>
34 #include <BRepTools_WireExplorer.hxx>
35 #include <Geom2dInt_Geom2dCurveTool.hxx>
36 #include <BRepAdaptor_Curve2d.hxx>
37 #include <TColgp_Array1OfPnt2d.hxx>
38 #include <BRepClass_FaceClassifier.hxx>
39 #include <CSLib_Class2d.hxx>
40 #include <GeomAbs_SurfaceType.hxx>
41 #include <BRepAdaptor_HSurface.hxx>
42 #include <TopExp.hxx>
43 #include <BRepAdaptor_Curve.hxx>
44
45 #include <gp_Pnt.hxx>
46 #include <ElCLib.hxx>
47
48 #include <Precision.hxx>
49
50 #ifdef WNT
51 #include <stdio.h>
52 #endif
53
54
55 #ifdef DEB
56 #define LBRCOMPT 0
57 #else
58 #define LBRCOMPT 0
59 #endif
60
61
62 #if LBRCOMPT  
63 class StatistiquesFClass2d { 
64 public:
65   long unsigned NbConstrShape;
66   long unsigned NbPerformInfinitePoint;
67   long unsigned NbPerform;
68   long unsigned NbTestOnRestriction;
69   long unsigned NbDestroy;
70 public:
71   StatistiquesFClass2d() { 
72     NbConstrShape=NbPerform=NbPerformInfinitePoint=NbDestroy=0;
73   }
74   ~StatistiquesFClass2d() { 
75     printf("\n--- Statistiques BRepTopAdaptor:\n");
76     printf("\nConstructeur(Shape) : %10lu",NbConstrShape);
77     printf("\nPerformInfinitePoint: %10lu",NbPerformInfinitePoint);
78     printf("\nTestOnRestriction   : %10lu",NbTestOnRestriction);
79     printf("\nPerform(pnt2d)      : %10lu",NbPerform);
80     printf("\nDestroy             : %10lu",NbDestroy);
81   }
82 };
83
84 static StatistiquesFClass2d STAT;
85 #endif
86
87
88
89
90 BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace,const Standard_Real TolUV) 
91 : Toluv(TolUV), Face(aFace)  { 
92   
93 #if LBRCOMPT 
94   STAT.NbConstrShape++;
95 #endif
96
97   //-- dead end on surfaces defined on more than one period
98
99   Face.Orientation(TopAbs_FORWARD);
100   Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
101   surf->ChangeSurface().Initialize(aFace,Standard_False);
102   
103   TopoDS_Edge  edge;
104   TopAbs_Orientation Or;
105   Standard_Real u,du,Tole = 0.0,Tol=0.0;
106   BRepTools_WireExplorer WireExplorer;
107   TopExp_Explorer FaceExplorer;
108
109   Umin = Vmin = 0.0; //RealLast();
110   Umax = Vmax = -Umin;
111
112   Standard_Integer BadWire=0;
113   for( FaceExplorer.Init(Face,TopAbs_WIRE); (FaceExplorer.More() && BadWire==0); FaceExplorer.Next() )
114     {
115       Standard_Integer nbpnts = 0;
116       TColgp_SequenceOfPnt2d SeqPnt2d;
117       Standard_Integer firstpoint = 1;
118       Standard_Real FlecheU = 0.0;
119       Standard_Real FlecheV = 0.0;
120       Standard_Boolean WireIsNotEmpty = Standard_False;
121       Standard_Integer NbEdges = 0;
122
123       TopExp_Explorer Explorer;
124       for( Explorer.Init(FaceExplorer.Current(),TopAbs_EDGE); Explorer.More(); Explorer.Next() ) NbEdges++;
125         
126       gp_Pnt Ancienpnt3d(0,0,0);
127       Standard_Boolean Ancienpnt3dinitialise = Standard_False;
128
129       for( WireExplorer.Init(TopoDS::Wire(FaceExplorer.Current()),Face); WireExplorer.More(); WireExplorer.Next() )
130         {
131           
132           NbEdges--;
133           edge = WireExplorer.Current();
134           Or = edge.Orientation();
135           if(Or == TopAbs_FORWARD || Or == TopAbs_REVERSED)
136             {
137               Standard_Real pfbid,plbid;
138               if(BRep_Tool::CurveOnSurface(edge,Face,pfbid,plbid).IsNull()) return;
139               BRepAdaptor_Curve2d C(edge,Face);
140         
141               //-- ----------------------------------------
142               Standard_Boolean degenerated=Standard_False;
143               if(BRep_Tool::Degenerated(edge))   degenerated=Standard_True;
144               if(BRep_Tool::IsClosed(edge,Face)) degenerated=Standard_True;
145               TopoDS_Vertex Va,Vb;
146               TopExp::Vertices(edge,Va,Vb);
147               Standard_Real TolVertex1=0.,TolVertex=0.;
148               if (Va.IsNull()) degenerated=Standard_True;
149               else TolVertex1=BRep_Tool::Tolerance(Va);
150               if (Vb.IsNull()) degenerated=Standard_True;
151               else TolVertex=BRep_Tool::Tolerance(Vb);
152               if(TolVertex<TolVertex1) TolVertex=TolVertex1;
153               BRepAdaptor_Curve C3d;
154         
155               if(Abs(plbid-pfbid) < 1.e-9) continue;
156
157               //if(degenerated==Standard_False)
158               //  C3d.Initialize(edge,Face);
159
160               //-- Check cases when it was forgotten to code degenerated :  PRO17410 (janv 99)
161               if(degenerated == Standard_False)
162                 {
163                   C3d.Initialize(edge,Face);
164                   du=(plbid-pfbid)*0.1;
165                   u=pfbid+du;
166                   gp_Pnt P3da=C3d.Value(u);
167                   degenerated=Standard_True;
168                   u+=du;
169                   do
170                     {
171                       
172                       gp_Pnt P3db=C3d.Value(u);
173                       //                      if(P3da.SquareDistance(P3db)) { degenerated=Standard_False; break; }
174                       if(P3da.SquareDistance(P3db) > Precision::Confusion()) { degenerated=Standard_False; break; }
175                       u+=du;
176                     }
177                   while(u<plbid);
178                 }
179               
180               //-- ----------------------------------------
181
182               Tole = BRep_Tool::Tolerance(edge);
183               if(Tole>Tol) Tol=Tole;
184               
185               //Standard_Integer nbs = 1 + Geom2dInt_Geom2dCurveTool::NbSamples(C);
186               Standard_Integer nbs = Geom2dInt_Geom2dCurveTool::NbSamples(C);
187               //-- Attention to rational bsplines of degree 3. (ends of circles among others)
188               if (nbs > 2) nbs*=4;
189               du = (plbid-pfbid)/(Standard_Real)(nbs-1);
190
191               if(Or==TopAbs_FORWARD) u = pfbid;
192               else { u = plbid; du=-du; }
193         
194               //-- ------------------------------------------------------------
195               //-- Check distance uv between the start point of the edge
196               //-- and the last point registered in SeqPnt2d
197               //-- Try to remote the first point of the current edge 
198               //-- from the last saved point
199 #ifdef DEB
200               gp_Pnt2d Pnt2dDebutEdgeCourant=
201 #endif
202               C.Value(u);
203
204               //Standard_Real Baillement2dU=0;
205               //Standard_Real Baillement2dV=0;
206 #if AFFICHAGE
207               if(nbpnts>1) printf("\nTolVertex %g ",TolVertex);
208 #endif
209
210               if(firstpoint==2) u+=du;
211               Standard_Integer Avant = nbpnts;
212               for(Standard_Integer e = firstpoint; e<=nbs; e++)
213                 {
214                   gp_Pnt2d P2d = C.Value(u);
215                   if(P2d.X()<Umin) Umin = P2d.X();
216                   if(P2d.X()>Umax) Umax = P2d.X();
217                   if(P2d.Y()<Vmin) Vmin = P2d.Y();
218                   if(P2d.Y()>Vmax) Vmax = P2d.Y();
219           
220                   Standard_Real dist3dptcourant_ancienpnt=1e+20;//RealLast();
221                   gp_Pnt P3d;
222                   if(degenerated==Standard_False)
223                     {
224                       P3d=C3d.Value(u);
225                       if(nbpnts>1 && Ancienpnt3dinitialise) dist3dptcourant_ancienpnt = P3d.Distance(Ancienpnt3d);
226                     }
227                   Standard_Boolean IsRealCurve3d = Standard_True; //patch
228                   if(dist3dptcourant_ancienpnt < Precision::Confusion())
229                     {
230                       gp_Pnt MidP3d = C3d.Value( u-du/2. );
231                       if (P3d.Distance( MidP3d ) < Precision::Confusion()) IsRealCurve3d = Standard_False;
232                     }
233                   if(IsRealCurve3d)
234                     {
235                       if(degenerated==Standard_False) { Ancienpnt3d=P3d;  Ancienpnt3dinitialise=Standard_True; }
236                       nbpnts++;
237                       SeqPnt2d.Append(P2d);
238                     }
239 #if AFFICHAGE
240                   else { static int mm=0; printf("\npoint p%d  %g %g %g",++mm,P3d.X(),P3d.Y(),P3d.Z()); }
241 #endif
242                   u+=du;
243                   Standard_Integer ii = nbpnts;
244                   //-- printf("\n nbpnts:%4d  u=%7.5g   FlecheU=%7.5g  FlecheV=%7.5g  ii=%3d  Avant=%3d ",nbpnts,u,FlecheU,FlecheV,ii,Avant);
245 //                if(ii>(Avant+4))
246 //  Modified by Sergey KHROMOV - Fri Apr 19 09:46:12 2002 Begin
247                   if(ii>(Avant+4) && SeqPnt2d(ii-2).SquareDistance(SeqPnt2d(ii)))
248 //  Modified by Sergey KHROMOV - Fri Apr 19 09:46:13 2002 End
249                     {
250                       gp_Lin2d Lin(SeqPnt2d(ii-2),gp_Dir2d(gp_Vec2d(SeqPnt2d(ii-2),SeqPnt2d(ii))));
251                       Standard_Real ul = ElCLib::Parameter(Lin,SeqPnt2d(ii-1));
252                       gp_Pnt2d Pp = ElCLib::Value(ul,Lin);
253                       Standard_Real dU = Abs(Pp.X()-SeqPnt2d(ii-1).X());
254                       Standard_Real dV = Abs(Pp.Y()-SeqPnt2d(ii-1).Y());
255                       //-- printf(" (du=%7.5g   dv=%7.5g)",dU,dV);
256                       if(dU>FlecheU) FlecheU = dU;
257                       if(dV>FlecheV) FlecheV = dV;
258                     }
259                 }//for(e=firstpoint
260               if(firstpoint==1) firstpoint=2;
261               WireIsNotEmpty = Standard_True;
262             }//if(Or==FORWARD,REVERSED
263         } //-- Edges -> for(Ware.Explorer
264
265       if(NbEdges)
266         { //-- on compte ++ with a normal explorer and with the Wire Explorer
267 /*
268 #ifdef DEB  
269
270           cout << endl;
271           cout << "*** BRepTopAdaptor_Fclass2d  ** Wire Probablement FAUX **" << endl;
272           cout << "*** WireExplorer does not find all edges " << endl;
273           cout << "*** Connect old classifier" << endl;
274 #endif
275 */
276           TColgp_Array1OfPnt2d PClass(1,2);
277           //// modified by jgv, 28.04.2009 ////
278           PClass.Init(gp_Pnt2d(0.,0.));
279           /////////////////////////////////////
280           TabClass.Append((void *)new CSLib_Class2d(PClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax));
281           BadWire=1;
282           TabOrien.Append(-1);
283         }
284       else if(WireIsNotEmpty)
285         {
286           //Standard_Real anglep=0,anglem=0;
287           TColgp_Array1OfPnt2d PClass(1,nbpnts);
288           Standard_Real square = 0.0;
289
290           //-------------------------------------------------------------------
291           //-- ** The mode of calculation was somewhat changed 
292           //-- Before Oct 31 97 , the total angle of  
293           //-- rotation of the wire was evaluated on all angles except for the last 
294           //-- ** Now, exactly the angle of rotation is evaluated
295           //-- If a value remote from 2PI or -2PI is found, it means that there is 
296           //-- an uneven number of loops
297
298           if(nbpnts>3)
299             {
300 //            Standard_Integer im2=nbpnts-2;
301               Standard_Integer im1=nbpnts-1;
302               Standard_Integer im0=1;
303 //            PClass(im2)=SeqPnt2d.Value(im2);
304               PClass(im1)=SeqPnt2d.Value(im1);
305               PClass(nbpnts)=SeqPnt2d.Value(nbpnts);
306
307
308 //            for(Standard_Integer ii=1; ii<nbpnts; ii++,im0++,im1++,im2++)
309               for(Standard_Integer ii=1; ii<nbpnts; ii++,im0++,im1++)
310                 { 
311 //                if(im2>=nbpnts) im2=1;
312                   if(im1>=nbpnts) im1=1;
313                   PClass(ii)=SeqPnt2d.Value(ii);
314 //                gp_Vec2d A(PClass(im2),PClass(im1));
315 //                gp_Vec2d B(PClass(im1),PClass(im0));
316 //                Standard_Real N = A.Magnitude() * B.Magnitude();
317
318                   square += (PClass(im0).X()-PClass(im1).X())*(PClass(im0).Y()+PClass(im1).Y())*.5; 
319
320 //                if(N>1e-16){ Standard_Real a=A.Angle(B); angle+=a; }
321                 }
322
323       
324               //-- FlecheU*=10.0;
325               //-- FlecheV*=10.0;
326               if(FlecheU<Toluv) FlecheU = Toluv;
327               if(FlecheV<Toluv) FlecheV = Toluv;
328               //-- cout<<" U:"<<FlecheU<<" V:"<<FlecheV<<endl;
329               TabClass.Append((void *)new CSLib_Class2d(PClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax));
330
331 //            if((angle<2 && angle>-2)||(angle>10)||(angle<-10))
332 //              {
333 //                BadWire=1;
334 //                TabOrien.Append(-1);
335 //#ifdef DEB  
336 //                cout << endl;
337 //                cout << "*** BRepTopAdaptor_Fclass2d  ** Wire Probably FALSE **" << endl;
338 //                cout << "*** Total rotation angle of the wire : " << angle << endl;
339 //                cout << "*** Connect the old classifier" << endl;
340 //#endif
341 //              } 
342 //            else TabOrien.Append(((angle>0.0)? 1 : 0));
343               TabOrien.Append(((square < 0.0)? 1 : 0));
344             }//if(nbpoints>3
345           else
346             { 
347 #ifdef DEB  
348               cout << endl;
349               cout << "*** BRepTopAdaptor_Fclass2d  ** Wire Probably FALSE **" << endl;
350               cout << "*** The sample wire contains less than 3 points" << endl;
351               cout << "*** Connect the old classifier" << endl;
352 #endif       
353               BadWire=1;
354               TabOrien.Append(-1);
355               TColgp_Array1OfPnt2d xPClass(1,2);
356               xPClass(1) = SeqPnt2d(1); 
357               xPClass(2) = SeqPnt2d(2);
358               TabClass.Append((void *)new CSLib_Class2d(xPClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax));
359             }
360         }//else if(WareIsNotEmpty
361   }//for(FaceExplorer
362
363   Standard_Integer nbtabclass = TabClass.Length();
364
365   if(nbtabclass>0)
366     {
367       //-- If an error was detected on a wire: set all TabOrien to -1
368       if(BadWire) TabOrien(1)=-1;
369
370       if(   surf->GetType()==GeomAbs_Cone
371          || surf->GetType()==GeomAbs_Cylinder
372          || surf->GetType()==GeomAbs_Torus
373          || surf->GetType()==GeomAbs_Sphere
374          || surf->GetType()==GeomAbs_SurfaceOfRevolution)
375         
376         {
377           Standard_Real uuu=M_PI+M_PI-(Umax-Umin);
378           if(uuu<0) uuu=0;
379           U1 = 0.0;  // modified by NIZHNY-OFV  Thu May 31 14:24:10 2001 ---> //Umin-uuu*0.5;
380           U2 = 2*M_PI; // modified by NIZHNY-OFV  Thu May 31 14:24:35 2001 ---> //U1+M_PI+M_PI;
381         }
382       else { U1=U2=0.0; } 
383     
384       if(surf->GetType()==GeomAbs_Torus)
385         { 
386           Standard_Real uuu=M_PI+M_PI-(Vmax-Vmin);
387           if(uuu<0) uuu=0;
388           V1 = 0.0;  // modified by NIZHNY-OFV  Thu May 31 14:24:55 2001 ---> //Vmin-uuu*0.5;
389           V2 = 2*M_PI; // modified by NIZHNY-OFV  Thu May 31 14:24:59 2001 ---> //V1+M_PI+M_PI;
390         }
391       else { V1=V2=0.0; }   
392     }
393 }
394
395 TopAbs_State BRepTopAdaptor_FClass2d::PerformInfinitePoint() const { 
396 #if LBRCOMPT 
397   STAT.NbPerformInfinitePoint++;
398 #endif
399   
400   if(Umax==-RealLast() || Vmax==-RealLast() || Umin==RealLast() || Vmin==RealLast()) { 
401     return(TopAbs_IN);
402   }
403   gp_Pnt2d P(Umin-(Umax-Umin),Vmin-(Vmax-Vmin));
404   return(Perform(P,Standard_False));
405 }
406
407 TopAbs_State BRepTopAdaptor_FClass2d::Perform(const gp_Pnt2d& _Puv,
408                                               const Standard_Boolean RecadreOnPeriodic) const
409
410 #if LBRCOMPT 
411   STAT.NbPerform++;
412 #endif
413   
414   Standard_Integer dedans;
415   Standard_Integer nbtabclass = TabClass.Length();
416   
417   if(nbtabclass==0) { 
418     return(TopAbs_IN);
419   }
420   
421   //-- U1 is the First Param and U2 in this case is U1+Period
422   Standard_Real u=_Puv.X();
423   Standard_Real v=_Puv.Y();
424   Standard_Real uu = u, vv = v;
425
426   Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
427   surf->ChangeSurface().Initialize( Face, Standard_False );
428   const Standard_Boolean IsUPer  = surf->IsUPeriodic();
429   const Standard_Boolean IsVPer  = surf->IsVPeriodic();
430   const Standard_Real    uperiod = IsUPer ? surf->UPeriod() : 0.0;
431   const Standard_Real    vperiod = IsVPer ? surf->VPeriod() : 0.0;
432   TopAbs_State Status = TopAbs_UNKNOWN;
433   Standard_Boolean urecadre = Standard_False, vrecadre = Standard_False;
434
435   if (RecadreOnPeriodic)
436     {
437       if (IsUPer)
438         {
439           if (uu < Umin)
440             while (uu < Umin)
441               uu += uperiod;
442           else
443             {
444               while (uu >= Umin)
445                 uu -= uperiod;
446               uu += uperiod;
447             }
448         }
449       if (IsVPer)
450         {
451           if (vv < Vmin)
452             while (vv < Vmin)
453               vv += vperiod;
454           else
455             {
456               while (vv >= Vmin)
457                 vv -= vperiod;
458               vv += vperiod;
459             }
460         }
461     }
462
463   for (;;)
464     {
465       dedans = 1;
466       gp_Pnt2d Puv(u,v);
467       
468       if(TabOrien(1)!=-1) { 
469         for(Standard_Integer n=1; n<=nbtabclass; n++) { 
470           Standard_Integer cur = ((CSLib_Class2d *)TabClass(n))->SiDans(Puv);
471           if(cur==1) { 
472             if(TabOrien(n)==0) { 
473               dedans = -1; 
474               break;
475             }
476           }
477           else if(cur==-1) { 
478             if(TabOrien(n)==1) {  
479               dedans = -1; 
480               break;
481             }
482           }
483           else { 
484             dedans = 0;
485             break;
486           }
487         }
488         if(dedans==0) { 
489           BRepClass_FaceClassifier aClassifier;
490           Standard_Real m_Toluv = (Toluv > 4.0) ? 4.0 : Toluv;
491           //aClassifier.Perform(Face,Puv,Toluv);
492           aClassifier.Perform(Face,Puv,m_Toluv);
493           Status = aClassifier.State();
494         }
495         if(dedans == 1) { 
496           Status = TopAbs_IN;
497         }
498         if(dedans == -1) {
499           Status = TopAbs_OUT;
500         }
501       }
502       else {  //-- TabOrien(1)=-1    False Wire
503         BRepClass_FaceClassifier aClassifier;
504         aClassifier.Perform(Face,Puv,Toluv);
505         Status = aClassifier.State();
506       }
507
508       if (!RecadreOnPeriodic || (!IsUPer && !IsVPer))
509         return Status;
510       if (Status == TopAbs_IN || Status == TopAbs_ON)
511         return Status;
512
513       if (!urecadre)
514         {
515           u = uu;
516           urecadre = Standard_True;
517         }
518       else
519         if (IsUPer)
520           u += uperiod;
521       if (u > Umax || !IsUPer)
522         {
523           if (!vrecadre)
524             {
525               v = vv;
526               vrecadre = Standard_True;
527             }
528           else
529             if (IsVPer)
530               v += vperiod;
531
532           u = uu;
533
534           if (v > Vmax || !IsVPer)
535             return Status;
536         }
537     } //for (;;)
538 }
539
540 TopAbs_State BRepTopAdaptor_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv,
541                                                         const Standard_Real Tol,
542                                                         const Standard_Boolean RecadreOnPeriodic) const
543
544 #if LBRCOMPT 
545   STAT.NbConstrShape++;
546 #endif
547   
548   Standard_Integer dedans;
549   Standard_Integer nbtabclass = TabClass.Length();
550   
551   if(nbtabclass==0) { 
552     return(TopAbs_IN);
553   }
554   
555   //-- U1 is the First Param and U2 in this case is U1+Period
556   Standard_Real u=_Puv.X();
557   Standard_Real v=_Puv.Y();
558   Standard_Real uu = u, vv = v;
559   
560   Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
561   surf->ChangeSurface().Initialize( Face, Standard_False );
562   const Standard_Boolean IsUPer  = surf->IsUPeriodic();
563   const Standard_Boolean IsVPer  = surf->IsVPeriodic();
564   const Standard_Real    uperiod = IsUPer ? surf->UPeriod() : 0.0;
565   const Standard_Real    vperiod = IsVPer ? surf->VPeriod() : 0.0;
566   TopAbs_State Status = TopAbs_UNKNOWN;
567   Standard_Boolean urecadre = Standard_False, vrecadre = Standard_False;
568   
569   if (RecadreOnPeriodic)
570     {
571       if (IsUPer)
572         {
573           if (uu < Umin)
574             while (uu < Umin)
575               uu += uperiod;
576           else
577             {
578               while (uu >= Umin)
579                 uu -= uperiod;
580               uu += uperiod;
581             }
582         }
583       if (IsVPer)
584         {
585           if (vv < Vmin)
586             while (vv < Vmin)
587               vv += vperiod;
588           else
589             {
590               while (vv >= Vmin)
591                 vv -= vperiod;
592               vv += vperiod;
593             }
594         }
595     }
596   
597   for (;;)
598     {
599       dedans = 1;
600       gp_Pnt2d Puv(u,v);
601       
602       if(TabOrien(1)!=-1) { 
603         for(Standard_Integer n=1; n<=nbtabclass; n++) { 
604           Standard_Integer cur = ((CSLib_Class2d *)TabClass(n))->SiDans_OnMode(Puv,Tol);
605           if(cur==1) { 
606             if(TabOrien(n)==0) { 
607               dedans = -1; 
608               break;
609             }
610           }
611           else if(cur==-1) { 
612             if(TabOrien(n)==1) {  
613               dedans = -1; 
614               break;
615             }
616           }
617           else { 
618             dedans = 0;
619             break;
620           }
621         }
622         if(dedans==0) {
623           Status = TopAbs_ON;
624         }
625         if(dedans == 1) {
626           Status = TopAbs_IN;
627         }
628         if(dedans == -1) {
629           Status = TopAbs_OUT;
630         }
631       }
632       else {  //-- TabOrien(1)=-1    False Wire
633         BRepClass_FaceClassifier aClassifier;
634         aClassifier.Perform(Face,Puv,Tol);
635         Status = aClassifier.State();
636       }
637       
638       if (!RecadreOnPeriodic || (!IsUPer && !IsVPer))
639         return Status;
640       if (Status == TopAbs_IN || Status == TopAbs_ON)
641         return Status;
642       
643       if (!urecadre)
644         {
645           u = uu;
646           urecadre = Standard_True;
647         }
648       else
649         if (IsUPer)
650           u += uperiod;
651       if (u > Umax || !IsUPer)
652         {
653           if (!vrecadre)
654             {
655               v = vv;
656               vrecadre = Standard_True;
657             }
658           else
659             if (IsVPer)
660               v += vperiod;
661           
662           u = uu;
663           
664           if (v > Vmax || !IsVPer)
665             return Status;
666         }
667     } //for (;;)
668 }
669
670
671 void BRepTopAdaptor_FClass2d::Destroy() { 
672 #if LBRCOMPT
673   STAT.NbDestroy++;
674 #endif
675   
676   Standard_Integer nbtabclass = TabClass.Length(); 
677   for(Standard_Integer d=1; d<=nbtabclass;d++) {
678     if(TabClass(d)) { 
679       delete ((CSLib_Class2d *)TabClass(d));
680       TabClass(d)=NULL;
681     }
682   }
683 }
684
685
686
687 #include <Standard_ConstructionError.hxx>
688
689
690 //const BRepTopAdaptor_FClass2d &  BRepTopAdaptor_FClass2d::Copy(const BRepTopAdaptor_FClass2d& Other) const { 
691 const BRepTopAdaptor_FClass2d &  BRepTopAdaptor_FClass2d::Copy(const BRepTopAdaptor_FClass2d& ) const { 
692   cerr<<"Copy not allowed in BRepTopAdaptor_FClass2d"<<endl;
693   Standard_ConstructionError::Raise();
694   return(*this);
695 }