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