0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / TopOpeBRep / TopOpeBRep_FacesFiller.cxx
1 // File:        TopOpeBRep_FacesFiller.cxx
2 // Created:     Mon Oct 10 17:31:13 1994
3 // Author:      Jean Yves LEBEY
4 //              <jyl@bravox>
5
6 #include <TopOpeBRep_FacesFiller.ixx>
7
8 #include <Standard_ProgramError.hxx>
9 //#include <BRepAdaptor_Curve2d.hxx>
10 #include <TopOpeBRep_FFTransitionTool.hxx>
11 #include <TopOpeBRep.hxx>
12 #include <Precision.hxx>
13 #include <TopoDS.hxx>
14 #include <BRep_Tool.hxx>
15 #include <Geom_Surface.hxx>
16 #include <GeomProjLib.hxx>
17 #include <Geom_Circle.hxx>
18 #include <Geom_Line.hxx>
19 #include <gp_Pnt.hxx>
20 #include <gp_Pnt2d.hxx>
21 #include <TopOpeBRepTool_EXPORT.hxx>
22 #include <TopOpeBRepTool_2d.hxx>
23 #include <TopOpeBRep_define.hxx>
24 #include <TopOpeBRepTool_defineG.hxx>
25 #include <TopOpeBRepTool_SC.hxx>
26
27 Standard_EXPORT Standard_Boolean FUN_projPonL(const gp_Pnt& P,const TopOpeBRep_LineInter L,const TopOpeBRep_FacesFiller& FF,
28                                  Standard_Real& paramL)
29 {
30   Standard_Boolean paramLdef = Standard_False;
31   Standard_Integer Esi = (L.ArcIsEdge(1)) ? 1:2;
32   const TopoDS_Edge& E = TopoDS::Edge(L.Arc());
33   Standard_Boolean hasC3D = FC2D_HasC3D(E);
34   Standard_Real dist;
35   if (hasC3D) {
36     BRepAdaptor_Curve BAC(E);
37     paramLdef = FUN_tool_projPonC(P,BAC,paramL,dist);
38   }
39   else {
40     BRepAdaptor_Curve2d BAC2D;
41     if      (Esi == 1)  BAC2D.Initialize(E,FF.Face(1));
42     else if (Esi == 2)  BAC2D.Initialize(E,FF.Face(2));
43     paramLdef = FUN_tool_projPonC2D(P,BAC2D,paramL,dist);
44   }
45   return paramLdef;
46 }
47
48 #ifdef DEB
49 Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceDSF(); 
50 Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceDSFK(); 
51 Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceDSNC(); 
52 void debffsamdom(void){}
53 #endif
54
55 static void FUN_MakeERL(TopOpeBRep_FacesIntersector& FI,TopTools_ListOfShape& ERL)
56 {
57   ERL.Clear();
58   const TopTools_IndexedMapOfShape& mer = FI.Restrictions();
59   for ( Standard_Integer ie = 1, ne = mer.Extent(); ie <= ne; ie++) {
60     const TopoDS_Edge& E = TopoDS::Edge(mer.FindKey(ie));
61     ERL.Append(E);
62   }
63 }
64
65 // Unused :
66 #ifdef DEB
67 static void FUN_MakeERL(const TopTools_MapOfShape& mapES,TopTools_ListOfShape& ERL)
68 {
69   ERL.Clear();
70   TopTools_MapIteratorOfMapOfShape itES;
71   for (itES.Initialize(mapES);itES.More();itES.Next()) {
72     const TopoDS_Shape& E = itES.Key();
73     ERL.Append(E);
74   }
75 }
76 #endif
77
78 //=======================================================================
79 //function : TopOpeBRep_FacesFiller
80 //purpose  : 
81 //=======================================================================
82 TopOpeBRep_FacesFiller::TopOpeBRep_FacesFiller() : myPShapeClassifier(NULL)
83
84   myexF1 = myexF2 = 0;
85 #ifdef DEB
86   myHFFD = new TopOpeBRep_FFDumper(this);
87 #endif
88 }
89
90 //=======================================================================
91 //function : PShapeClassifier
92 //purpose  : 
93 //=======================================================================
94 TopOpeBRepTool_PShapeClassifier TopOpeBRep_FacesFiller::PShapeClassifier() const
95 {
96   return myPShapeClassifier;
97 }
98
99 //=======================================================================
100 //function : SetPShapeClassifier
101 //purpose  : 
102 //=======================================================================
103 void TopOpeBRep_FacesFiller::SetPShapeClassifier(const TopOpeBRepTool_PShapeClassifier& PSC) 
104 {
105   myPShapeClassifier = PSC;
106 }
107
108 //=======================================================================
109 //function : Insert
110 //purpose  : 
111 //=======================================================================
112 void TopOpeBRep_FacesFiller::Insert(const TopoDS_Shape& S1,const TopoDS_Shape& S2,TopOpeBRep_FacesIntersector& FACINT,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
113 {
114   myF1 = TopoDS::Face(S1); myF1ori = S1.Orientation();
115   myF2 = TopoDS::Face(S2); myF2ori = S2.Orientation(); 
116   myFacesIntersector = &FACINT;
117   myHDS = HDS;
118   myDS = &(HDS->ChangeDS());
119   if (myPShapeClassifier == NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
120
121 #ifdef DEB
122   Standard_Integer exF1,exF2; GetTraceIndex(exF1,exF2);
123   myFacesIntersector->InitLine();
124   for (; myFacesIntersector->MoreLine(); myFacesIntersector->NextLine()) myFacesIntersector->CurrentLine().SetTraceIndex(exF1,exF2);
125   myHFFD->Init(this);
126 #endif
127   
128   Standard_Boolean samdom = myFacesIntersector->SameDomain();
129   if ( samdom ) {
130     myDS->FillShapesSameDomain(S1,S2);
131     return;
132   }
133   
134   myFacesIntersector->InitLine();
135   for (; myFacesIntersector->MoreLine(); myFacesIntersector->NextLine()) {
136     TopOpeBRep_LineInter& L = myFacesIntersector->CurrentLine();
137     L.SetFaces(TopoDS::Face(S1),TopoDS::Face(S2));
138   }
139   
140   VP_Position(FACINT);
141
142   myFacesIntersector->InitLine();
143   for (; myFacesIntersector->MoreLine(); myFacesIntersector->NextLine()) {
144     TopOpeBRep_LineInter& L = myFacesIntersector->CurrentLine();
145     L.SetHasVPonR();
146     L.SetINL();
147     L.SetIsVClosed();
148   }
149
150   ProcessSectionEdges();
151   myFFfirstDSP = myDS->NbPoints() + 1;
152
153   FUN_MakeERL((*myFacesIntersector), myERL); // BUG
154
155   myFacesIntersector->InitLine();
156   for (; myFacesIntersector->MoreLine(); myFacesIntersector->NextLine()) {
157     TopOpeBRep_LineInter& L = myFacesIntersector->CurrentLine();
158     LoadLine(L);
159     ProcessLine();
160   }
161   
162 }
163
164 //=======================================================================
165 //function : ChangePointClassifier
166 //purpose  : 
167 //=======================================================================
168 TopOpeBRep_PointClassifier& TopOpeBRep_FacesFiller::ChangePointClassifier()
169 {  
170   return myPointClassifier;
171 }
172
173
174 //=======================================================================
175 //function : LoadLine
176 //purpose  : 
177 //=======================================================================
178 void TopOpeBRep_FacesFiller::LoadLine(TopOpeBRep_LineInter& L)
179 {
180   myLine = &L;
181   Standard_Boolean bchk = CheckLine(L);
182   Standard_Boolean binl = L.INL();
183   myLineINL = binl;
184   {
185     TopOpeBRep_TypeLineCurve t = L.TypeLineCurve();
186     if ( !bchk && binl && t == TopOpeBRep_LINE ) {
187       bchk = Standard_True;
188     }
189   }
190   L.SetOK(bchk);
191   myLineOK = bchk;
192   if (!myLineOK) return;
193   
194   L.ComputeFaceFaceTransition();
195 } // LoadLine
196
197 //=======================================================================
198 //function : CheckLine
199 //purpose  : private
200 //           returns False if L is WALKING line with a number of VPoints < 2
201 //           else returns True 
202 //=======================================================================
203 Standard_Boolean TopOpeBRep_FacesFiller::CheckLine(TopOpeBRep_LineInter& L) const
204 {
205   Standard_Real tol1,tol2;
206   myFacesIntersector->GetTolerances(tol1,tol2);
207   
208   Standard_Boolean check = Standard_True;
209   TopOpeBRep_TypeLineCurve t = L.TypeLineCurve();
210   Standard_Integer nbvp = L.NbVPoint();
211   
212 #ifdef DEB
213   Standard_Boolean TDSF = TopOpeBRepDS_GettraceDSF();
214   if (TDSF) { cout<<"CheckLine ";TopOpeBRep::Print(t,cout);cout<<" "<<nbvp<<" points"<<endl; }
215 #endif
216   
217   if ( t == TopOpeBRep_WALKING ) {
218     if ( nbvp < 2 ) {
219 #ifdef DEB
220       cout<<"\n=== Nb de IntPatch_Point sur WL incorrect : "<<nbvp<<" ===\n";
221 #endif
222       check = Standard_False;
223     }
224   }
225   else if (t == TopOpeBRep_LINE) {
226     Standard_Integer np = 0;
227     TopOpeBRep_VPointInterIterator VPI;
228     
229     for ( VPI.Init(L); VPI.More(); VPI.Next()) {
230       const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
231       if ( VP.Keep() ) np++;
232     }
233     if ( np != 2 ) {
234       return Standard_True;
235     }
236     
237     TopOpeBRep_VPointInter A,B;
238     np = 0;
239     for ( VPI.Init(L); VPI.More(); VPI.Next()) {
240       const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
241       if ( !VP.Keep() ) continue;
242       np++;
243       if ( np == 1 ) A = VP;
244       if ( np == 2 ) B = VP;
245     }
246     
247     Standard_Boolean isAV1 = A.IsVertexOnS1();
248     Standard_Boolean isAV2 = A.IsVertexOnS2();
249     TopoDS_Shape V1;
250     if (isAV1) V1 = A.VertexOnS1();
251     if (isAV2) V1 = A.VertexOnS2();
252     Standard_Boolean isBV1 = B.IsVertexOnS1();
253     Standard_Boolean isBV2 = B.IsVertexOnS2();
254     TopoDS_Shape V2;
255     if (isBV1) V2 = B.VertexOnS1();
256     if (isBV2) V2 = B.VertexOnS2();
257     
258 #ifdef DEB
259     if (TDSF) {
260       cout<<"CheckLine : isAV1 isAV2 isBV1 isBV2 ";
261       cout<<isAV1<<" "<<isAV2<<" "<<isBV1<<" "<<isBV2<<endl;
262     }
263 #endif
264     
265     if ( !V1.IsNull() && ( V1.IsSame(V2) ) ) {
266 #ifdef DEB
267       Standard_Real parA = A.ParameterOnLine();    
268       Standard_Real parB = B.ParameterOnLine();    
269       if (TDSF) {
270         cout<<"kpart : parA parB delta "<<parA<<" "<<parB<<" "<<parA-parB<<endl;
271         cout<<"kpart : rejet de ligne"<<endl;
272       }
273 #endif
274       return Standard_False;      
275     }
276   } // LINE
277   else {
278     Standard_Boolean notrnotw = (t != TopOpeBRep_RESTRICTION && t != TopOpeBRep_WALKING);
279     if (notrnotw) {
280       if (t == TopOpeBRep_CIRCLE) { 
281         // cto 012 D2, faces 6 et 1, line 3 incorrecte.
282         
283         Standard_Integer iINON1,iINONn,nINON;
284         myLine->VPBounds(iINON1,iINONn,nINON);
285         if ( nINON >= 2) {
286           
287           const TopOpeBRep_VPointInter& A = myLine->VPoint(iINON1);
288           const TopOpeBRep_VPointInter& B = myLine->VPoint(iINONn);
289           Standard_Real parA = A.ParameterOnLine();    
290           Standard_Real parB = B.ParameterOnLine();    
291           Standard_Boolean conf = (fabs(parA-parB) < tol1);
292           if (conf) {
293             //modified by NIZHNY-MZV  Wed Dec  1 09:53:08 1999
294             check = Msf;
295 //modified by NIZHNY-MZV  Wed Dec  1 09:53:18 1999          Standard_Boolean isp = L.IsPeriodic();
296 //modified by NIZHNY-MZV  Wed Dec  1 09:53:20 1999          if (isp) {
297 //modified by NIZHNY-MZV  Wed Dec  1 09:53:21 1999            Handle(Geom_Circle) C = Handle(Geom_Circle)::DownCast(L.Curve());
298 //modified by NIZHNY-MZV  Wed Dec  1 09:53:22 1999            Standard_Real per = C->Period();
299 //modified by NIZHNY-MZV  Wed Dec  1 09:53:23 1999            parB = parA + per;
300 //modified by NIZHNY-MZV  Wed Dec  1 09:53:25 1999          }
301           }
302           
303 //modified by NIZHNY-MZV  Wed Dec  1 09:53:32 1999        Standard_Real t = 0.2567899311;
304 //modified by NIZHNY-MZV  Wed Dec  1 09:53:33 1999        Standard_Real p = (1-t)*parA + t*parB;
305 //modified by NIZHNY-MZV  Wed Dec  1 09:53:34 1999        Handle(Geom_Curve) GC = myLine->Curve();
306 //modified by NIZHNY-MZV  Wed Dec  1 09:53:34 1999        const TopoDS_Face& F1 = TopoDS::Face(myF1);
307 //modified by NIZHNY-MZV  Wed Dec  1 09:53:35 1999        const TopoDS_Face& F2 = TopoDS::Face(myF2);
308 //modified by NIZHNY-MZV  Wed Dec  1 09:53:36 1999        Handle(Geom_Surface) GS1 = BRep_Tool::Surface(F1);
309 //modified by NIZHNY-MZV  Wed Dec  1 09:53:36 1999        Handle(Geom_Surface) GS2 = BRep_Tool::Surface(F2);
310 //modified by NIZHNY-MZV  Wed Dec  1 09:53:37 1999        Handle(Geom2d_Curve) C1 = GeomProjLib::Curve2d(GC,parA,parB,GS1);
311 //modified by NIZHNY-MZV  Wed Dec  1 09:53:38 1999        Handle(Geom2d_Curve) C2 = GeomProjLib::Curve2d(GC,parA,parB,GS2);       
312           
313 //modified by NIZHNY-MZV  Wed Dec  1 09:53:39 1999        gp_Pnt2d P1 = C1->Value(p);
314 //modified by NIZHNY-MZV  Wed Dec  1 09:53:44 1999        gp_Pnt2d P2 = C2->Value(p);
315 //modified by NIZHNY-MZV  Wed Dec  1 09:53:45 1999        TopOpeBRep_PointClassifier* pcl = (TopOpeBRep_PointClassifier*)((void*)&myPointClassifier);
316 //modified by NIZHNY-MZV  Wed Dec  1 09:53:46 1999        TopAbs_State staP1 = pcl->Classify(F1,P1,tol1);
317 //modified by NIZHNY-MZV  Wed Dec  1 09:53:47 1999        TopAbs_State staP2 = pcl->Classify(F2,P2,tol1);
318 //modified by NIZHNY-MZV  Wed Dec  1 09:53:48 1999Standard_Boolean ok1 = (staP1 == TopAbs_IN || staP1 == TopAbs_ON);
319 //modified by NIZHNY-MZV  Wed Dec  1 09:53:49 1999        Standard_Boolean ok2 = (staP2 == TopAbs_IN || staP2 == TopAbs_ON);
320 //modified by NIZHNY-MZV  Wed Dec  1 09:53:50 1999        check = (ok1 && ok2);
321           
322         }
323       } // CIRCLE
324       else if (t == TopOpeBRep_HYPERBOLA) {
325         Standard_Integer iINON1,iINONn,nINON;
326         myLine->VPBounds(iINON1,iINONn,nINON);
327         if ( nINON < 2 ) {
328           check = Standard_False;
329         }
330       }
331       else if (t == TopOpeBRep_ELLIPSE) {
332         Standard_Integer iINON1,iINONn,nINON;
333         myLine->VPBounds(iINON1,iINONn,nINON);
334         if ( nINON < 2 ) {
335           check = Standard_False;
336         }
337         else {
338           const TopOpeBRep_VPointInter& A = myLine->VPoint(iINON1);
339           const TopOpeBRep_VPointInter& B = myLine->VPoint(iINONn);
340           Standard_Real parA = A.ParameterOnLine();    
341           Standard_Real parB = B.ParameterOnLine();    
342           Standard_Boolean conf = (fabs(parA-parB) < tol1);
343           if (conf) {
344             check = Standard_False;
345           }
346         }
347       }
348     }
349   }
350   
351 #ifdef DEB
352   if (!check) { cout<<"# DEB CheckLine : rejet de ";TopOpeBRep::Print(t,cout);cout<<" a "<<nbvp<<" points"<<endl; }
353 #endif
354
355   return check;
356 }
357
358 //=======================================================================
359 //function : VP_Position
360 //purpose  : 
361 //=======================================================================
362 //void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_FacesIntersector& FACINT)
363 void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_FacesIntersector& )
364 {
365   for (myFacesIntersector->InitLine(); 
366        myFacesIntersector->MoreLine();
367        myFacesIntersector->NextLine()) {
368     TopOpeBRep_LineInter& L = myFacesIntersector->CurrentLine();
369     const TopOpeBRep_TypeLineCurve tl = L.TypeLineCurve();
370     Standard_Boolean ok = (tl == TopOpeBRep_RESTRICTION) ;
371     if ( ok ) VP_Position(L);
372   }
373   
374   for (myFacesIntersector->InitLine(); 
375        myFacesIntersector->MoreLine(); 
376        myFacesIntersector->NextLine()) {
377     TopOpeBRep_LineInter& L = myFacesIntersector->CurrentLine();
378     const TopOpeBRep_TypeLineCurve tl = L.TypeLineCurve();
379     Standard_Boolean ok = (tl != TopOpeBRep_RESTRICTION) ;
380     if ( ok ) VP_Position(L);
381   }
382 }
383
384 //=======================================================================
385 //function : VP_Position
386 //purpose  : 
387 //=======================================================================
388 void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_LineInter& L)
389 {
390   myLine = &L;
391 #ifdef DEB
392   if (TopOpeBRepDS_GettraceDSFK()) {
393     cout<<endl<<"VP_Position on line "<<L.Index()<<" ";L.DumpType();cout<<endl;
394   }
395 #endif
396   Standard_Boolean isrest = (L.TypeLineCurve() == TopOpeBRep_RESTRICTION) ;
397   
398   if (!isrest) VP_PositionOnL(L);
399   else         VP_PositionOnR(L);
400   
401   L.SetVPBounds();
402   
403 #ifdef DEB
404   if (TopOpeBRepDS_GettraceDSFK()) {
405     Standard_Integer VPF,VPL,VPN; L.VPBounds(VPF,VPL,VPN);
406     cout<<"SetVPBounds : VPF,VPL,VPN = "<<VPF<<","<<VPL<<","<<VPN;
407     if (VPN != 0) cout<<" : VP(s) kept"<<endl;
408     else          cout<<" : NO VP kept"<<endl;
409   }
410 #endif
411 }
412
413 //=======================================================================
414 //function : VP_PositionOnL
415 //purpose  : 
416 //=======================================================================
417 void TopOpeBRep_FacesFiller::VP_PositionOnL(TopOpeBRep_LineInter& L)
418 {
419   TopOpeBRep_VPointInterIterator VPI(L);
420   Standard_Integer Lindex = L.Index();
421   TopOpeBRep_VPointInterClassifier VPC;
422   
423   for (; VPI.More(); VPI.Next()) {
424     TopOpeBRep_VPointInter& VP = VPI.ChangeCurrentVP();
425     Standard_Integer VPsi = VP.ShapeIndex();
426     const gp_Pnt& P3D = VP.Value();
427     
428     Standard_Boolean VPequalVPONRESTRICTION = Standard_False;
429     TopOpeBRep_FacesIntersector& FI = *((TopOpeBRep_FacesIntersector*)((void*)myFacesIntersector));
430     Standard_Integer iOL = 1,n = FI.NbLines(); 
431     for (iOL=1; iOL<=n; iOL++ ) { 
432       if (iOL == Lindex ) continue; 
433       TopOpeBRep_LineInter& OL = FI.ChangeLine(iOL);
434       VPequalVPONRESTRICTION = PequalVPonR(P3D,VPsi,VP,OL);
435       if ( VPequalVPONRESTRICTION ) break;
436     }
437     
438     if ( !VPequalVPONRESTRICTION ) {
439       VP_Position(VP,VPC);
440     }    
441   }
442 }
443
444 //=======================================================================
445 //function : VP_PositionOnR
446 //purpose  : 
447 //=======================================================================
448 void TopOpeBRep_FacesFiller::VP_PositionOnR(TopOpeBRep_LineInter& L)
449 {
450   TopOpeBRep_VPointInterClassifier VPC;
451   
452   TopOpeBRep_VPointInterIterator VPI(L);
453   Standard_Integer Esi   = (L.ArcIsEdge(1)) ? 1:2;
454   Standard_Integer OOEsi = (L.ArcIsEdge(1)) ? 2:1;
455   
456   Standard_Boolean isline = Standard_False;
457   const TopoDS_Edge& earc = TopoDS::Edge(L.Arc());
458   Standard_Boolean hasc3d = FC2D_HasC3D(earc);
459   if (hasc3d) isline = FUN_tool_line(earc);
460   else {
461     BRepAdaptor_Curve2d BAC2D;
462     if      (Esi == 1)  BAC2D.Initialize(earc,myF1);
463     else if (Esi == 2)  BAC2D.Initialize(earc,myF2);
464     GeomAbs_CurveType t = BAC2D.GetType();
465     isline = (t == GeomAbs_Line);
466   }
467   
468   for (; VPI.More(); VPI.Next()) {
469     TopOpeBRep_VPointInter& VP = VPI.ChangeCurrentVP();
470     
471     Standard_Boolean isvertex = VP.IsVertex(Esi);
472     if ( isvertex ) {
473       if (!isline) VP_Position(VP,VPC);
474       continue;
475     }
476     Standard_Boolean OOisvertex = VP.IsVertex(OOEsi);
477     if ( OOisvertex ) {
478       if (!isline) VP_Position(VP,VPC);
479       continue;
480     }
481     
482     const gp_Pnt& P = VP.Value();
483     Standard_Boolean arcisE = L.ArcIsEdge(Esi);
484     Standard_Boolean arcisOOE = L.ArcIsEdge(OOEsi);
485     
486     if (arcisE) {
487       Standard_Real paramC;Standard_Boolean paramCdef = FUN_projPonL(P,L,(*this),paramC);
488       if ( paramCdef ) {
489         const TopoDS_Edge& E = TopoDS::Edge(L.Arc());
490         VP.State(TopAbs_ON,Esi);
491         VP.EdgeON(E,paramC,Esi);
492       }
493       else {
494 //      Standard_ProgramError::Raise("VP_Position projection failed on E");
495         VP.ChangeKeep(Standard_False); // xpu051198
496       }
497     }
498     
499     if (arcisOOE) {
500       Standard_Real paramC;Standard_Boolean paramCdef = FUN_projPonL(P,L,(*this),paramC);
501       if ( paramCdef ) {
502         const TopoDS_Edge& OOE = TopoDS::Edge(L.Arc());
503         VP.State(TopAbs_ON,OOEsi);
504         VP.EdgeON(OOE,paramC,OOEsi);
505       }
506       else {
507 //      Standard_ProgramError::Raise("VP_Position projection failed on OOE");
508         VP.ChangeKeep(Standard_False); // xpu051198
509       }
510     }
511     
512 #ifdef DEB
513     if (TopOpeBRepDS_GettraceDSFK()) {
514       cout<<"VP "<<VP.Index()<<" on "<<Esi<<" : ";
515       TopAbs::Print(VP.State(Esi),cout);
516       cout<<"/"<<Esi<<" ";
517       if (VP.Keep()) { cout<<"kept"<<endl; }
518       else           { cout<<"NOT kept"<<endl; }
519     }
520 #endif
521   }
522 }
523
524 //=======================================================================
525 //function : VP_Position
526 //purpose  : 
527 //=======================================================================
528 void TopOpeBRep_FacesFiller::VP_Position(TopOpeBRep_VPointInter& VP,TopOpeBRep_VPointInterClassifier& VPC)
529 {
530   Standard_Integer si = VP.ShapeIndex();
531   Standard_Boolean c1=Standard_False,c2=Standard_False;
532
533   if      (si == 0) { c1 = Standard_True; c2 = Standard_True; }
534   else if (si == 1) { c1 = Standard_False; c2 = Standard_True; }
535   else if (si == 2) { c1 = Standard_True; c2 = Standard_False; }
536   else if (si == 3) { c1 = Standard_True; c2 = Standard_True; }
537   
538   Standard_Boolean AssumeINON = Standard_False;
539   if (myLine) AssumeINON = (myLine->TypeLineCurve() != TopOpeBRep_RESTRICTION);
540
541   // modified by NIZHNY-MKK  Fri Oct 27 14:50:28 2000.BEGIN
542   //   Standard_Real tol = Precision::Confusion();
543   Standard_Real tol1, tol2;
544   tol1 = tol2 = Precision::Confusion();
545   myFacesIntersector->GetTolerances(tol1, tol2);
546   Standard_Real tol = (tol1 > tol2) ? tol1 : tol2;
547   // modified by NIZHNY-MKK  Fri Oct 27 14:50:36 2000.END
548
549   if (c1) VPC.VPointPosition(myF1,VP,1,myPointClassifier,AssumeINON,tol);
550   if (c2) VPC.VPointPosition(myF2,VP,2,myPointClassifier,AssumeINON,tol);
551   
552 #ifdef DEB
553   if (TopOpeBRepDS_GettraceDSFK()) {
554     cout<<"VP "<<VP.Index()<<" on "<<si<<" : ";
555     if (c1) { TopAbs::Print(VP.State(1),cout);cout<<"/1 "; }
556     if (c2) { TopAbs::Print(VP.State(2),cout);cout<<"/2 "; }
557     if (VP.Keep()) { cout<<"kept"<<endl; }
558     else           { cout<<"NOT kept"<<endl; }
559   }
560 #endif
561 }
562
563 //=======================================================================
564 //function : PequalVPonR
565 //purpose  : 
566 //=======================================================================
567 Standard_Boolean TopOpeBRep_FacesFiller::PequalVPonR(const gp_Pnt& P3D,const Standard_Integer VPsi,TopOpeBRep_VPointInter& VP,TopOpeBRep_LineInter& Lrest) const 
568 {
569   const TopOpeBRep_TypeLineCurve tOL = Lrest.TypeLineCurve();
570   Standard_Boolean OLok = (tOL == TopOpeBRep_RESTRICTION) ;
571   if ( !OLok ) return Standard_False;
572   
573   Standard_Boolean VPequalVPONRESTRICTION = Standard_False;
574   const TopoDS_Edge& EOL = TopoDS::Edge(Lrest.Arc());
575   Standard_Integer EOLsi = (Lrest.ArcIsEdge(1)) ? 1:2;
576   
577   TopOpeBRep_VPointInterIterator VPIOL(Lrest);
578   for (; VPIOL.More(); VPIOL.Next()) {
579     TopOpeBRep_VPointInter& VPOL = VPIOL.ChangeCurrentVP();
580     Standard_Integer VPOLsi = VPOL.ShapeIndex();
581     
582     Standard_Boolean VPOLisvertex = Standard_False;
583     VPOLisvertex = VPOL.IsVertex(1);
584     if (VPOLisvertex) continue;
585     
586     Standard_Boolean diffsi = (VPOLsi != VPsi);
587     if ( diffsi ) continue;
588     
589     TopAbs_State stateEsi = VPOL.State(EOLsi);
590     if (stateEsi != TopAbs_ON) continue; 
591     
592     const gp_Pnt& P3DOL = VPOL.Value();
593     Standard_Real tolE = BRep_Tool::Tolerance(EOL);
594     VPequalVPONRESTRICTION = P3DOL.IsEqual(P3D,tolE);
595     
596     if ( VPequalVPONRESTRICTION ) {
597       Standard_Real paramCOL = VPOL.EdgeONParameter(EOLsi);
598       VP.State(TopAbs_ON,EOLsi);
599       VP.EdgeON(EOL,paramCOL,EOLsi);
600       break;
601     }
602   }
603   return VPequalVPONRESTRICTION;
604 }
605
606 //=======================================================================
607 //function : FacesIntersector
608 //purpose  : 
609 //=======================================================================
610 TopOpeBRep_FacesIntersector& TopOpeBRep_FacesFiller::ChangeFacesIntersector()
611 {
612   return (*myFacesIntersector);
613 }
614
615 //=======================================================================
616 //function : HDataStructure
617 //purpose  : 
618 //=======================================================================
619 Handle(TopOpeBRepDS_HDataStructure) TopOpeBRep_FacesFiller::HDataStructure()
620 {
621   return myHDS;
622 }
623
624 //=======================================================================
625 //function : DataStructure
626 //purpose  : 
627 //=======================================================================
628 TopOpeBRepDS_DataStructure& TopOpeBRep_FacesFiller::ChangeDataStructure()
629 {
630   return (*myDS);
631 }
632
633 //=======================================================================
634 //function : Face
635 //purpose  : 
636 //=======================================================================
637 const TopoDS_Face& TopOpeBRep_FacesFiller::Face(const Standard_Integer I) const
638 {
639   if      (I == 1) return myF1;
640   else if (I == 2) return myF2;
641   Standard_ProgramError::Raise("FacesFiller::Face");
642   return myF1;
643 }
644
645 //=======================================================================
646 //function : FaceFaceTransition
647 //purpose  : 
648 //=======================================================================
649 const TopOpeBRepDS_Transition& TopOpeBRep_FacesFiller::FaceFaceTransition(const TopOpeBRep_LineInter& L,const Standard_Integer I) const
650 {
651   const TopOpeBRepDS_Transition& T = L.FaceFaceTransition(I);
652   return T;
653 }
654
655 //=======================================================================
656 //function : FaceFaceTransition
657 //purpose  : 
658 //=======================================================================
659 const TopOpeBRepDS_Transition& TopOpeBRep_FacesFiller::FaceFaceTransition(const Standard_Integer I) const
660 {
661   const TopOpeBRepDS_Transition& T = myLine->FaceFaceTransition(I);
662   return T;
663 }
664
665 TopOpeBRep_PFacesIntersector TopOpeBRep_FacesFiller::PFacesIntersectorDummy() const 
666 {return myFacesIntersector;}
667 TopOpeBRepDS_PDataStructure TopOpeBRep_FacesFiller::PDataStructureDummy() const 
668 {return myDS;}
669 TopOpeBRep_PLineInter TopOpeBRep_FacesFiller::PLineInterDummy() const 
670 {return myLine;}
671
672 //=======================================================================
673 //function : SetTraceIndex
674 //purpose  : 
675 //=======================================================================
676 void TopOpeBRep_FacesFiller::SetTraceIndex(const Standard_Integer exF1,const Standard_Integer exF2)
677
678   myexF1 = exF1;
679   myexF2 = exF2;
680 }
681
682 //=======================================================================
683 //function : GetTraceIndex
684 //purpose  : 
685 //=======================================================================
686 void TopOpeBRep_FacesFiller::GetTraceIndex(Standard_Integer& exF1,Standard_Integer& exF2)const 
687
688   exF1 = myexF1;
689   exF2 = myexF2;
690 }