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