0022627: Change OCCT memory management defaults
[occt.git] / src / TopOpeBRep / TopOpeBRep_FacesFiller_1.cxx
CommitLineData
7fd59977 1// File: TopOpeBRep_FacesFiller_1.cxx
2// Created: Thu Feb 17 11:02:12 1994
3// Author: Jean Yves LEBEY
4// Copyright: OPEN CASCADE 1994
5
6#include <TopOpeBRep_FacesFiller.ixx>
7
8#include <BRep_Tool.hxx>
9#include <TopoDS.hxx>
10#include <TopExp.hxx>
11#include <Standard_CString.hxx>
12#include <BRepTools.hxx>
13#include <Precision.hxx>
14#include <TColStd_ListOfInteger.hxx>
15#include <TColStd_ListIteratorOfListOfInteger.hxx>
16
17#include <TopOpeBRep_FFDumper.hxx>
18#include <TopOpeBRepTool_TOOL.hxx>
19#include <TopOpeBRepTool_defineG.hxx>
20#include <TopOpeBRepTool_EXPORT.hxx>
21#include <TopOpeBRepTool_makeTransition.hxx>
22
23#include <TopOpeBRepDS_Dumper.hxx>
24#include <TopOpeBRepDS_InterferenceTool.hxx>
25#include <TopOpeBRepDS_Curve.hxx>
26#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
27
28#include <TopOpeBRep.hxx>
29#include <TopOpeBRep_FFTransitionTool.hxx>
30#include <TopOpeBRep_GeomTool.hxx>
31#include <TopOpeBRep_PointGeomTool.hxx>
32#include <TopOpeBRep_FFDumper.hxx>
33
34#include <TopOpeBRep_define.hxx>
35
36#include <Bnd_Box.hxx>
37#include <BndLib_Add3dCurve.hxx>
38
39#ifdef DRAW
40#include <TopOpeBRep_DRAW.hxx>
41#endif
42
43#ifdef DEB
44Standard_EXPORT void debrest(const Standard_Integer i) {cout<<"+ debrest "<<i<<endl;}
45Standard_EXPORT void debrline() {cout<<"+ debrline"<<endl;}
46
47Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceCX(const Standard_Integer i);
48Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer i);
49Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE();
50Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceISTO();
51Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSP();
52Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSF();
53Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSFK();
54Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSNC();
55Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSLT();
56Standard_EXPORT Standard_Boolean TopOpeBRep_GettraceNVP(Standard_Integer a,Standard_Integer b,Standard_Integer c,Standard_Integer d,Standard_Integer e);
57Standard_IMPORT Standard_Boolean GLOBAL_bvpr;Standard_EXPORT void debvprmess(Standard_Integer f1,Standard_Integer f2,Standard_Integer il,Standard_Integer vp,Standard_Integer si);
58Standard_EXPORT Standard_Boolean TopOpeBRep_GetcontextNOPUNK();
59
60static void SSAVFF(const TopoDS_Shape& F1, const TopoDS_Shape& F2)
61{
62 TCollection_AsciiString aname_1("ffbug_1"), aname_2("ffbug_2");
63 Standard_CString name_1=aname_1.ToCString(),name_2=aname_2.ToCString();
64 cout<<"FacesFiller : "<<name_1<<","<<name_2<<endl;
65 BRepTools::Write(F1,name_1); BRepTools::Write(F2,name_2);
66}
67
68static void FUN_traceRLine(const TopOpeBRep_LineInter& L)
69{
70#ifdef DRAW
71 TCollection_AsciiString ee("Edofline"); ee.Cat(L.Index()); char* eee = ee.ToCString();
72 DBRep::Set(eee,L.Arc());
73#endif
74}
75
76static void FUN_traceGLine(const TopOpeBRep_LineInter& L)
77{
78#ifdef DRAW
79 TCollection_AsciiString ll("Glineof"); ll.Cat(L.Index()); char* lll = ll.ToCString();
80 Handle(Geom_Curve) c = L.Curve();
81 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
82 Standard_Real par1 = L.VPoint(iINON1).ParameterOnLine();
83 Standard_Real parn = L.VPoint(iINONn).ParameterOnLine();
84 Standard_Boolean isperiodic = L.IsPeriodic();
85 Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(c,par1,parn,Standard_True);
86 DrawTrSurf::Set(lll,tc);
87#endif
88}
89#endif
90
91#define M_FORWARD(o) (o == TopAbs_FORWARD)
92#define M_REVERSED(o) (o == TopAbs_REVERSED)
93
94#define FORWARD (1)
95#define REVERSED (2)
96#define INTERNAL (3)
97#define EXTERNAL (4)
98#define CLOSING (5)
99
100Standard_EXPORT void FUN_GetdgData(TopOpeBRepDS_PDataStructure& pDS,const TopOpeBRep_LineInter& L,
101 const TopoDS_Face& F1,const TopoDS_Face& F2, TopTools_DataMapOfShapeListOfShape& datamap);
102Standard_EXPORT void FUN_FillVof12(const TopOpeBRep_LineInter& L,TopOpeBRepDS_PDataStructure pDS);
103
104#define M_FINDVP (0) // only look for new vp
105#define M_MKNEWVP (1) // only make newvp
106#define M_GETVP (2) // steps (0) [+(1) if (O) fails]
107Standard_EXPORT void FUN_VPIndex(TopOpeBRep_FacesFiller& FF,
108 const TopOpeBRep_LineInter& L,
109 const TopOpeBRep_VPointInter& VP,
110 const Standard_Integer ShapeIndex,
111 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
112 const TopOpeBRepDS_ListOfInterference& DSCIL,
113 TopOpeBRepDS_Kind& PVKind, Standard_Integer& PVIndex, // out
114 Standard_Boolean& EPIfound, Handle(TopOpeBRepDS_Interference)& IEPI, // out
115 Standard_Boolean& CPIfound, Handle(TopOpeBRepDS_Interference)& ICPI, // out
116 const Standard_Integer mkVP);
117Standard_EXPORT Standard_Boolean FUN_newtransEdge(const Handle(TopOpeBRepDS_HDataStructure) HDS,
118 const TopOpeBRep_FacesFiller& FF,
119 const TopOpeBRep_LineInter& L,
120 const Standard_Boolean& Lonrest,
121 const TopOpeBRep_VPointInter& VP,
122 const TopOpeBRepDS_Kind PVKind, const Standard_Integer PVIndex,
123 const Standard_Integer& OOShapeIndex,
124 const TopoDS_Edge& edge, const TopTools_ListOfShape& ERL, TopOpeBRepDS_Transition& T);
125#define M_INTERNAL(st) (st == TopAbs_INTERNAL)
126
127
128static Standard_Boolean FUN_IwithsuppiS(const TopOpeBRepDS_ListOfInterference& loI, const Standard_Integer iS, TopOpeBRepDS_ListOfInterference& loIfound)
129{
130 TopOpeBRepDS_ListIteratorOfListOfInterference it(loI);
131 for (; it.More(); it.Next()) {const Handle(TopOpeBRepDS_Interference)& I = it.Value();
132 if (I->Support() == iS) loIfound.Append(I);}
133 Standard_Boolean ok = (loIfound.Extent() > 0);
134 return ok;
135}
136static Standard_Boolean FUN_IwithsuppkS(const TopOpeBRepDS_ListOfInterference& loI, const TopOpeBRepDS_Kind& kS, TopOpeBRepDS_ListOfInterference& loIfound)
137{
138 TopOpeBRepDS_ListIteratorOfListOfInterference it(loI);
139 for (; it.More(); it.Next()) {const Handle(TopOpeBRepDS_Interference)& I = it.Value();
140 if (I->SupportType() == kS) loIfound.Append(I);}
141 Standard_Boolean ok = (loIfound.Extent() > 0);
142 return ok;
143}
144static Standard_Boolean FUN_IwithToniS(const TopOpeBRepDS_ListOfInterference& loI, const Standard_Integer iS, TopOpeBRepDS_ListOfInterference& loIfound)
145{
146 TopOpeBRepDS_ListIteratorOfListOfInterference it(loI);
147 for (; it.More(); it.Next()) {const Handle(TopOpeBRepDS_Interference)& I = it.Value();
148 if (I->Transition().Index() == iS) loIfound.Append(I);}
149 Standard_Boolean ok = (loIfound.Extent() > 0);
150 return ok;
151}
152static Standard_Boolean FUN_supponF(const TopOpeBRepDS_PDataStructure pDS,
153 const TopOpeBRepDS_ListOfInterference& loI, const Standard_Integer iF,
154 TopOpeBRepDS_ListOfInterference& lIsupponF, TColStd_ListOfInteger& losupp)
155{
156 //<losupp> = list of support S / I in <loI> : I = (T,G,S = Edge on <F>);
157 Standard_Boolean ok = (0 < iF) && (iF <= pDS->NbShapes());
158 if (!ok) return Standard_False;
159
160 TopTools_IndexedMapOfShape MOOE; TopExp::MapShapes(pDS->Shape(iF),TopAbs_EDGE,MOOE);
161 TopOpeBRepDS_ListIteratorOfListOfInterference it(loI);
162 for (; it.More(); it.Next()){
163 const Handle(TopOpeBRepDS_Interference)& I = it.Value(); Standard_Integer iS = I->Support();
164 TopOpeBRepDS_Kind skind = I->SupportType();
165 Standard_Boolean add = Standard_False;
166 if (skind == TopOpeBRepDS_EDGE) add = MOOE.Contains(pDS->Shape(iS));
167 if (add) {losupp.Append(iS); lIsupponF.Append(I);}
168 }
169 if (losupp.Extent() < 1) return Standard_False;
170 return Standard_True;
171}
172static Standard_Boolean FUN_IoflSsuppS(const TopOpeBRepDS_PDataStructure pDS,
173 const Standard_Integer iS,const TColStd_ListOfInteger& lShape,
174 TopOpeBRepDS_ListOfInterference& IsuppiS)
175{
176 Standard_Boolean ok = Standard_False;
177 // E in <losupp> /
178 // I on E : I = (T, G, S=iS)
179
180 // looking for interferences attached to shapes of <lShape> with support <iS>
181 TColStd_ListIteratorOfListOfInteger iti(lShape);
182 for (; iti.More(); iti.Next()){
183 const TopOpeBRepDS_ListOfInterference& lI = pDS->ShapeInterferences(iti.Value());
184 ok = FUN_IwithsuppiS(lI,iS,IsuppiS);
185 }
186 return ok;
187}
188
189//=======================================================================
190// 3D
191// purpose : The compute of a transition edge/face given interferences
192// attached to the edge (stored in the DS).
193//=======================================================================
194static Standard_Boolean FUN_findTF(const TopOpeBRepDS_PDataStructure pDS,
195 const Standard_Integer iE, const Standard_Integer iF, const Standard_Integer iOOF,
196 TopOpeBRepDS_Transition& TF)
197{
198 Standard_Real factor = 0.5;
199 // ----------------------------------------------------------------------
200 // <Ifound> on <E> : Ifound = (T, S=OOF, G=POINT/VERTEX on <E>)
201 // (T, S=edge of OOF, G=POINT/VERTEX on <E>)
202 // ----------------------------------------------------------------------
203
204 // <lITonOOF>
205 TopOpeBRepDS_ListOfInterference lITonOOF;
206 Standard_Boolean ok = FUN_IwithToniS(pDS->ShapeInterferences(iE),iOOF,lITonOOF);
207 if (!ok) return Standard_False;
208 TopOpeBRepDS_ListOfInterference lITOOFskFACE;
209 Standard_Boolean found = FUN_IwithsuppkS(lITonOOF,TopOpeBRepDS_FACE,lITOOFskFACE);
210 if (found) {
211 // NYI : a deeper analysis is needed, for the moment, we make the following
212 // prequesitory : transition on E of F on point of ES is valid for
213 // all the ES (here restriction) ie :
214 // TF : transition face(F) / face(OOF) on G = ES =
215 // TE : transition edge(E) / face(OOF) at G = POINT/VERTEX
216 //Ifound on <E> : Ifound = (T(on face OOF), S=FACE, G=POINT/VERTEX on <E>)
217 const Handle(TopOpeBRepDS_Interference)& Ifound = lITOOFskFACE.First();
218 TF = Ifound->Transition();
219 }
220
221 Standard_Boolean done = Standard_False;
222 TopOpeBRepDS_ListOfInterference lITOOFskEDGE;
223 if (!found) done = FUN_IwithsuppkS(lITonOOF,TopOpeBRepDS_EDGE,lITOOFskEDGE);
224 if (done) {
225 // Ifound on <E> : Ifound = (T(on face OOF), S=FACE, G=POINT/VERTEX on <E>)
226 // if <Ifound> found : compute TE at G / <OOF>.
227 // TE ->TF.
228 const Handle(TopOpeBRepDS_Interference)& Ifound = lITOOFskEDGE.First();
229 const TopoDS_Edge& OOE = TopoDS::Edge(pDS->Shape(Ifound->Support()));
230 Standard_Real paronE; Standard_Boolean OOdone = FDS_Parameter(Ifound,paronE);
231 if (!OOdone) return Standard_False;
232
233 const TopoDS_Edge& E = TopoDS::Edge(pDS->Shape(iE));
234#ifdef DEB
235 const TopoDS_Face& F =
236#endif
237 TopoDS::Face(pDS->Shape(iF));
238 const TopoDS_Face& OOF = TopoDS::Face(pDS->Shape(iOOF));
239
240 Standard_Real f,l; FUN_tool_bounds(E,f,l);
241 TopOpeBRepTool_makeTransition MKT;
242
243 Standard_Boolean OOEboundOOF = FUN_tool_EboundF(OOE,OOF);
244 Standard_Boolean iscl = TopOpeBRepTool_TOOL::IsClosingE(OOE,OOF);
245 if (OOEboundOOF && (!iscl)) {
246 Standard_Real oopar; Standard_Boolean ok1 = FUN_tool_parE(E,paronE,OOE,oopar);
247 if (!ok1) return Standard_False;
248 gp_Pnt2d uv; ok1 = FUN_tool_paronEF(OOE,oopar,OOF,uv);
249 if (!ok1) return Standard_False;
250
251 ok = MKT.Initialize(E,f,l,paronE, OOF,uv, factor);
252 if (ok) ok = MKT.SetRest(OOE,oopar);
253 }
254 else {
255 gp_Pnt2d uv; Standard_Boolean ok1 = FUN_tool_parF(E,paronE,OOF,uv);
256 if (!ok1) return Standard_False;
257
258 ok = MKT.Initialize(E,f,l,paronE, OOF,uv, factor);
259 }
260 TopAbs_State stb,sta; ok = MKT.MkTonE(stb,sta);
261 if (!ok) return Standard_False;
262 TF.Before(stb); TF.After(sta);
263 return Standard_True;
264
265 }
266 ok = found || done;
267 return ok;
268}
269static Standard_Boolean FUN_findTOOF(const TopOpeBRepDS_PDataStructure pDS,
270 const Standard_Integer iE, const Standard_Integer iF, const Standard_Integer iOOF,
271 TopOpeBRepDS_Transition& TOOF)
272{
273 Standard_Real factor = 0.5;
274
275 // ----------------------------------------------------------------------
276 // <E> bound of <F>,
277 // <OOE> on <OOF> /
278 // <OOIfound> on <OOE> : OOIfound = (T, S=iF, G=POINT/VERTEX on <E>)
279 // ----------------------------------------------------------------------
280
281 // <lIsuppOOE> = list of interferences attached to <E> of support S = edge of <OOF>
282 // <liOOE> = list of supports of <lIsuppOOE>.
283 const TopOpeBRepDS_ListOfInterference& loIE = pDS->ShapeInterferences(iE);
284 TopOpeBRepDS_ListOfInterference lITonOOF; Standard_Boolean ok = FUN_IwithToniS(loIE,iOOF,lITonOOF);
285 TopOpeBRepDS_ListOfInterference lIsuppOOE;
286 TColStd_ListOfInteger liOOEGonE;
287 if (ok) {
288 ok = FUN_IwithsuppkS(lITonOOF,TopOpeBRepDS_EDGE,lIsuppOOE);
289 if (ok) {TopOpeBRepDS_ListIteratorOfListOfInterference it(lIsuppOOE);
290 for (; it.More(); it.Next()) liOOEGonE.Append(it.Value()->Support());}
291 }
292 else ok = FUN_supponF(pDS,loIE,iOOF,lIsuppOOE,liOOEGonE);
293 if (!ok) return Standard_False;
294
295// TopAbs_Orientation oritransOOE;
296
297 // <lOOIfound> = list of I attached to shapes of <liOOE> /
298 // I = (T, S=F, G=POINT/VERTEX on <E>)
299 TopOpeBRepDS_ListOfInterference lIOOEsuppFGonE;
300 Standard_Boolean OOfound = FUN_IoflSsuppS(pDS,iF,liOOEGonE,lIOOEsuppFGonE);
301 if (OOfound) {
302 // NYI : a deeper analysis is needed, for the moment, we make the following
303 // prequesitory : transition on OOE of OOF on point of ES is valid for
304 // all the ES (here restriction) ie :
305 // TOOF : transition face(OOF) / face(F) on (G == ES)
306 // <=> TOOE : transition edge(OOE) / face(F) at G = POINT/VERTEX
307 const Handle(TopOpeBRepDS_Interference)& OOIfound = lIOOEsuppFGonE.First();
308 TOOF = OOIfound->Transition();
309 }
310
311 Standard_Boolean OOdone = Standard_False;
312 if (!OOfound) {
313 // Ifound on <E> : Ifound = (T, S=EDGE on <OOF>, G=POINT/VERTEX on <E>)
314 // if <Ifound> found : compute TOOE at G / <F>
315 // TOOE ->TOOF.
316 const Handle(TopOpeBRepDS_Interference)& Ifound = lIsuppOOE.First();
317 const TopoDS_Edge& OOE = TopoDS::Edge(pDS->Shape(Ifound->Support()));
318 Standard_Real paronE; OOdone = FDS_Parameter(Ifound,paronE);
319 if (!OOdone) return Standard_False;
320
321 const TopoDS_Edge& E = TopoDS::Edge(pDS->Shape(iE));
322 const TopoDS_Face& F = TopoDS::Face(pDS->Shape(iF));
323
324 Standard_Real oopar; Standard_Boolean ok1 = FUN_tool_parE(E,paronE,OOE,oopar);
325 if (!ok1) return Standard_False;
326 gp_Pnt2d uv; ok1 = FUN_tool_paronEF(E,paronE,F,uv);
327 if (!ok1) return Standard_False;
328 Standard_Real f,l; FUN_tool_bounds(OOE,f,l);
329
330 TopAbs_State stb,sta;
331 TopOpeBRepTool_makeTransition MKT;
332 OOdone = MKT.Initialize(OOE,f,l,oopar,F,uv,factor);
333 if (OOdone) OOdone = MKT.SetRest(E,paronE);
334 if (OOdone) OOdone = MKT.MkTonE(stb,sta);
335 if (OOdone) {TOOF.Before(stb); TOOF.After(sta);}
336 }
337 ok = OOfound || OOdone;
338 return ok;
339}
340
341Standard_EXPORT Standard_Boolean GLOBAL_btcx = Standard_False;void debtcx(){};
342Standard_EXPORT void debtcxmess(Standard_Integer f1,Standard_Integer f2,Standard_Integer il)
343{cout<<"f1,f2,il : "<<f1<<","<<f2<<","<<il<<endl;cout.flush();debtcx();}
344
345//=======================================================================
346//function : ProcessLine
347//purpose :
348//=======================================================================
349void TopOpeBRep_FacesFiller::ProcessLine()
350{
351 Standard_Boolean reject = ( !myLineOK || myLine==NULL );
352 if (reject) return;
353 ResetDSC();
354
355#ifdef DEB
356 Standard_Integer ili = myLine->Index(),nli = myFacesIntersector->NbLines();
357 Standard_Boolean tcx = TopOpeBRepDS_GettraceCX(ili);
358 Standard_Boolean tDSF = TopOpeBRepDS_GettraceDSF();
359 Standard_Boolean traceDSNC = TopOpeBRepDS_GettraceDSNC();
360 if(tDSF)cout<<"trc tnvp 1 "<<myexF1<<" "<<myexF2<<" "<<ili<<endl;
361 if (tDSF||tcx) myHFFD->DumpLine(*myLine);
362 if (traceDSNC) cout<<"line "<<ili<<"/"<<nli<<endl;
363#endif
364
365 Standard_Boolean HasVPonR = myLine->HasVPonR();
366 if (HasVPonR) FillLineVPonR();
367 else FillLine();
368
369 Standard_Boolean inl = myLine->INL();
370 if (inl) return;
371
372 myHDS->SortOnParameter(myDSCIL);
373
374#ifdef DEB
375 TopOpeBRepDS_Dumper Dumper(myHDS);
376 if (tDSF||traceDSNC) Dumper.DumpLOI(myDSCIL,cout,"current curve : ");
377#endif
378
379 AddShapesLine();
380}
381
382//=======================================================================
383//function : ResetDSC
384//purpose :
385//=======================================================================
386void TopOpeBRep_FacesFiller::ResetDSC()
387{
388 myDSCIndex = 0;
389 myDSCIL.Clear();
390}
391
392//=======================================================================
393//function : ProcessVPInotonR
394//purpose : Same as ProcessVPnotonR.
395//=======================================================================
396void TopOpeBRep_FacesFiller::ProcessVPInotonR(TopOpeBRep_VPointInterIterator& VPI)
397{
398 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
399 ProcessVPnotonR(VP);
400}
401
402//=======================================================================
403//function : ProcessVPnotonR
404//purpose :
405//=======================================================================
406void TopOpeBRep_FacesFiller::ProcessVPnotonR(const TopOpeBRep_VPointInter& VP)
407{
408#ifdef DEB
409 Standard_Boolean traceDSF = TopOpeBRepDS_GettraceDSF();
410 Standard_Boolean traceDSP = TopOpeBRepDS_GettraceDSP();
411 Standard_Boolean traceISTO = TopOpeBRepDS_GettraceISTO();
412 if (traceDSF) cout<<endl;
413#endif
414
415 Standard_Integer ShapeIndex = 0;
416 Standard_Integer iVP = VP.Index();
417
418#ifdef DEB
419 Standard_Integer ili=myLine->Index(),ivp=iVP,isi=ShapeIndex;
420 if(traceDSF || traceDSP){
421 cout<<"trc tnvp 1 "<<myexF1<<" "<<myexF2<<" "<<ili<<" "<<ivp<<" "<<isi;
422 cout<<"; # VPonR "<<iVP<<" on "<<ShapeIndex<<endl;
423 }
424 if (traceISTO) {
425 cout<<"f1,f2,l,vp,si : ";
426 cout<<myexF1<<","<<myexF2<<","<<ili<<","<<ivp<<","<<isi<<endl;
427 }
428 GLOBAL_bvpr = TopOpeBRep_GettraceNVP(myexF1,myexF2,ili,ivp,isi);
429 if (GLOBAL_bvpr) debvprmess(myexF1,myexF2,ili,ivp,isi);
430#endif
431
432 Standard_Integer iINON1,iINONn,nINON;
433 myLine->VPBounds(iINON1,iINONn,nINON);
434 TopOpeBRepDS_ListIteratorOfListOfInterference itCPIL(myDSCIL);
435
436 TopOpeBRepDS_Kind PVKind; Standard_Integer PVIndex;
437 Standard_Boolean CPIfound = GetGeometry(itCPIL,VP,PVIndex,PVKind);
438 if ( !CPIfound ) {
439 if (iVP != iINON1 && iVP != iINONn) {
440#ifdef DEB
441 cout<<"VP "<<iVP<<" on "<<0<<" : point d'intersection anormal : rejet"<<endl;
442#endif
443 return;
444 }
445 }
446
447 if ( ! CPIfound ) {
448 Standard_Boolean found = GetFFGeometry(VP,PVKind,PVIndex);
449 if ( ! found ) PVIndex = MakeGeometry(VP,ShapeIndex,PVKind);
450 }
451
452 TopOpeBRepDS_Transition transLine;
453 if ( CPIfound ) {
454 const Handle(TopOpeBRepDS_Interference)& I = itCPIL.Value();
455 const TopOpeBRepDS_Transition& TI = I->Transition();
456 transLine = TI.Complement();
457 }
458 else {
459 if (iVP == iINON1) transLine.Set(TopAbs_FORWARD);
460 else if (iVP == iINONn) transLine.Set(TopAbs_REVERSED);
461 }
462
463 Standard_Real parline = VP.ParameterOnLine();
464 Handle(TopOpeBRepDS_Interference) CPI = TopOpeBRepDS_InterferenceTool::MakeCurveInterference
465 (transLine,TopOpeBRepDS_CURVE,0,PVKind,PVIndex,parline);
466 StoreCurveInterference(CPI);
467
468} // ProcessVPnotonR
469
470//=======================================================================
471//function : ProcessVPR
472//purpose :
473//=======================================================================
474void TopOpeBRep_FacesFiller::ProcessVPR(TopOpeBRep_FacesFiller& FF,const TopOpeBRep_VPointInter& VP)
475{
476 TopOpeBRepDS_Transition LineTonF1 = FaceFaceTransition(1);
477 TopOpeBRepDS_Transition LineTonF2 = FaceFaceTransition(2);
478 TopoDS_Face F1 = myF1;
479 TopoDS_Face F2 = myF2;
480 // --- check interiority of VPoint to the restrictions
481 Standard_Boolean tokeep = VP.Keep();
482 if ( !tokeep ) return;
483
484 Standard_Integer ShapeIndex = VP.ShapeIndex();
485
486 if (ShapeIndex == 0) {
487 FF.ProcessVPnotonR(VP);
488 }
489 else if (ShapeIndex == 1) {
490 FF.ProcessVPonR(VP,LineTonF1,F1,1);
491 }
492 else if (ShapeIndex == 2) {
493 FF.ProcessVPonR(VP,LineTonF2,F2,2);
494 }
495 else if (ShapeIndex == 3) {
496
497 Standard_Boolean isV1 = VP.IsVertexOnS1();
498 Standard_Boolean isV2 = VP.IsVertexOnS2();
499
500 Standard_Integer shin1 = 1;
501 if (isV2 && !isV1) shin1 = 2;
502
503 if (shin1 == 1) {
504 FF.ProcessVPonR(VP,LineTonF1,F1,1);
505 FF.ProcessVPonR(VP,LineTonF2,F2,2);
506 }
507 else if (shin1 == 2) {
508 FF.ProcessVPonR(VP,LineTonF2,F2,2);
509 FF.ProcessVPonR(VP,LineTonF1,F1,1);
510 }
511 }
512} // FUNvponr
513
514static Standard_Boolean FUN_brep_ONfirstP(const TopOpeBRep_VPointInter& vpf, const TopOpeBRep_VPointInter& VP)
515// prequesitory : gline is on edge
516{
517 Standard_Real parfirst = vpf.ParameterOnLine();
518 Standard_Real parcur = VP.ParameterOnLine();
519 Standard_Real d = parcur - parfirst;
520 Standard_Real tol = Precision::Confusion(); //nyixpu051098 : see lbr...
521 Standard_Boolean ONfirstP = (Abs(d) < tol);
522 return ONfirstP;
523}
524
525#ifdef DEB
526static void FUN_remove(TopOpeBRepDS_ListOfInterference& lI, const Handle(TopOpeBRepDS_Interference)& I)
527{
528 TopOpeBRepDS_ListIteratorOfListOfInterference itI(lI);
529 while (itI.More()) {
530 const Handle(TopOpeBRepDS_Interference)& Icur = itI.Value();
531 if (Icur == I) lI.Remove(itI);
532 else itI.Next();
533 }
534}
535#endif
536
537//=======================================================================
538//function : ProcessRLine
539//purpose :
540//=======================================================================
541void TopOpeBRep_FacesFiller::ProcessRLine()
542{
543#ifdef DEB
544 Standard_Boolean tDSF = TopOpeBRepDS_GettraceDSF();
545#endif
546
547 if (myLine->TypeLineCurve() != TopOpeBRep_RESTRICTION) {return;}
548
549 Standard_Boolean addIFE = Standard_True;
550 if (!addIFE) return;
551
552 const TopoDS_Edge& Erest = TopoDS::Edge(myLine->Arc());
553 Standard_Boolean FIisrest = myFacesIntersector->IsRestriction(Erest);
554 if (!FIisrest) return;
555
556 Standard_Boolean isedge1 = myLine->ArcIsEdge(1);
557 Standard_Boolean isedge2 = myLine->ArcIsEdge(2);
558 Standard_Integer EShapeIndex = (isedge1) ? 1 : (isedge2) ? 2 : 0;
559
560 Standard_Integer iErest = myDS->AddShape(Erest,EShapeIndex);
561 Standard_Integer rank = myDS->AncestorRank(iErest);
562 Standard_Integer OOrank = (rank == 1)? 2: 1;
563
564#ifdef DEB
565 if (tDSF) {cout<<"+ edge restriction "<<myDS->SectionEdge(Erest);
566 cout<<" (DS "<<iErest<<")"<<endl;}
567 Standard_Boolean trce = TopOpeBRepDS_GettraceSPSX(iErest); if(trce) debrest(iErest);
568#endif
569
570 Standard_Integer iF1 = myDS->AddShape(myF1,1);
571 Standard_Integer iF2 = myDS->AddShape(myF2,2);
572 Handle(TopOpeBRepDS_Interference) IFE;
573
574 TopOpeBRepDS_Transition T1 = FaceFaceTransition(1); T1.Index(iF2);
575 TopOpeBRepDS_Transition T2 = FaceFaceTransition(2); T2.Index(iF1);
576
577 Standard_Boolean T1unk = T1.IsUnknown();
578 Standard_Boolean T2unk = T2.IsUnknown();
579 Standard_Boolean processUNK = Standard_False;
580#ifdef DEB
581 Standard_Boolean nopunk = TopOpeBRep_GetcontextNOPUNK();
582 if (nopunk) processUNK = Standard_False;
583#endif
584 if (processUNK && (T1unk || T2unk)) {
585#ifdef DEB
586 Standard_Boolean trc = TopOpeBRepDS_GettraceSTRANGE(); trc = trc || tDSF;
587 if (trc) cout<<"T UNKNOWN FEI F"<<iF1<<" F"<<iF2<<" on Erest"<<iErest<<endl;
588#endif
589 TopoDS_Shape F = (*this).Face(rank); Standard_Integer iF = myDS->Shape(F);
590 TopoDS_Shape OOF = (*this).Face(OOrank); Standard_Integer iOOF = myDS->Shape(OOF);
591 Standard_Boolean findTOOF = (T1unk && (OOrank == 1)) || (T2unk && (OOrank == 2));
592 Standard_Boolean findTF = (T1unk && (rank == 1)) || (T2unk && (rank == 2));
593
594 if (findTOOF) {
595 // <Erest> on <F>,
596 // ?<OOE> on <OOF> /
597 // ?<OOIfound> on <OOE> : OOIfound = (T, S=iF, G=POINT/VERTEX on <Erest>)
598 TopOpeBRepDS_Transition T; Standard_Boolean OOTok = FUN_findTOOF(myDS,iErest,iF,iOOF,T);
599 if (OOTok) {
600 if (OOrank == 1) FDS_SetT(T1,T);
601 else FDS_SetT(T2,T);
602#ifdef DEB
603 if (trc) {
604 cout<<"F"<<iOOF<<" + new FEI(";TopAbs::Print(T.Before(),cout);cout<<",";
605 TopAbs::Print(T.After(),cout);cout<<" (F"<<iF<<") (E"<<iErest<<"))\n";
606 }
607#endif
608 }
609 } // !findTOOF
610 if (findTF) {
611 // ?Ifound on <Erest> : Ifound = (T on FACE=iOOF, S, G=POINT/VERTEX on <Erest>)
612 // if <Ifound> found : compute TErest at G / <OOF>
613 TopOpeBRepDS_Transition T; Standard_Boolean Tok = FUN_findTF(myDS,iErest,iF,iOOF,T);
614 if (Tok) {
615 if (rank == 1) FDS_SetT(T1,T);
616 else FDS_SetT(T2,T);
617#ifdef DEB
618 if (trc) {cout<<"F"<<iF<<" + new FEI(";TopAbs::Print(T.Before(),cout);cout<<",";
619 TopAbs::Print(T.After(),cout);cout<<" (F"<<iOOF<<") (E"<<iErest<<"))\n";}
620#endif
621 }
622 }
623 T1unk = T1.IsUnknown();
624 T2unk = T2.IsUnknown();
625 } // processUNK && (T1unk || T2unk)
626
627 IFE = TopOpeBRepDS_InterferenceTool::MakeFaceEdgeInterference
628 (T1,iF2,iErest,isedge1,TopOpeBRepDS_UNSHGEOMETRY);
629 myHDS->StoreInterference(IFE,iF1);
630
631 IFE = TopOpeBRepDS_InterferenceTool::MakeFaceEdgeInterference
632 (T2,iF1,iErest,isedge2,TopOpeBRepDS_UNSHGEOMETRY);
633 myHDS->StoreInterference(IFE,iF2);
634
635 //#################### Rline Processing ####################
636 // xpu061098
637 TopOpeBRep_VPointInterIterator VPI;
638 VPI.Init((*myLine));
639 Standard_Real tola = Precision::Angular()*1.e5;//NYIXPUTOL
640
641#ifdef DEB
642 if (tDSF) {
643 debrline();
644 cout<<endl<<"------------ Rline processing --------------------"<<endl;
645 }
646#endif
647
648 const TopOpeBRep_VPointInter& vpf = VPI.CurrentVP();
649 for (; VPI.More(); VPI.Next()) {
650 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
651#ifdef DEB
652 if (tDSF) {cout<<endl;myHFFD->DumpVP(VP);}
653#endif
654 Standard_Integer absindex = VP.ShapeIndex(); // 0,1,2,3
655 Standard_Real parRest;
656 Standard_Boolean okR = VP.ParonE(Erest,parRest);
657 if (!okR) parRest = VP.ParameterOnLine();
658 Standard_Boolean on2edges = (absindex == 3) || (absindex == OOrank);
659
660 if (!on2edges) {
661 // MSV: treat the case when an edge is touched by interior of a face
662
663// MSV: the commented code below leads to exception on 1cto 025 H3
664// (object and tool have same subshapes), so to enable it
665// the debug is needed
666
667// Standard_Boolean SIisvertex = VP.IsVertex(EShapeIndex);
668// if (SIisvertex) continue;
669// Standard_Integer ShapeIndex = EShapeIndex;
670// Standard_Integer OOShapeIndex = (ShapeIndex == 1) ? 2 : 1;
671// TopoDS_Face OOFace = (*this).Face(OOShapeIndex);
672// Standard_Integer iOOFace = myDS->Shape(OOFace);
673
674// // make PVIndex
675// TopOpeBRepDS_Kind PVKind = TopOpeBRepDS_POINT;
676// Standard_Integer PVIndex = 0;
677// Standard_Boolean EPIfound=Standard_False,CPIfound=Standard_False;
678// Handle(TopOpeBRepDS_Interference) IEPI,ICPI;
679// FUN_VPIndex((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL,
680// PVKind,PVIndex,EPIfound,IEPI,CPIfound,ICPI,
681// M_GETVP);
682// Standard_Boolean Efound = (EPIfound || CPIfound);
683// Standard_Boolean Ifound = (PVIndex != 0);
684// Standard_Boolean condmake = (!Efound && !Ifound);
685// if (condmake)
686// PVIndex = MakeGeometry(VP,ShapeIndex,PVKind);
687
688// // make transition on edge
689// TopOpeBRepDS_Transition transEdge;
690// TopOpeBRepDS_Transition Trans = FaceFaceTransition(ShapeIndex);
691// Standard_Boolean TransUNK = Trans.IsUnknown();
692// if (!TransUNK) {
693// TopAbs_Orientation oriErest = Erest.Orientation();
694// transEdge = TopOpeBRep_FFTransitionTool::ProcessLineTransition(VP,ShapeIndex,oriErest);
695// TransUNK = FDS_hasUNK(transEdge);
696// }
697// if (TransUNK) {
698// Standard_Boolean ONfirstP = ::FUN_brep_ONfirstP(vpf,VP);
699// TopAbs_Orientation OVP = ONfirstP ? TopAbs_FORWARD : TopAbs_REVERSED;
700// transEdge.Set(OVP);
701// if (ONfirstP) transEdge.StateAfter(TopAbs_ON);
702// else transEdge.StateBefore(TopAbs_ON);
703// TransUNK = FDS_hasUNK(transEdge);
704// }
705// if (TransUNK) continue;
706
707// // see if there is already such interference in DS
708// TopAbs_Orientation otransEdge = transEdge.Orientation(TopAbs_IN);
709// const TopOpeBRepDS_ListOfInterference& lIedge = myHDS->DS().ShapeInterferences(Erest);
710// TopOpeBRepDS_ListOfInterference copy; FDS_copy(lIedge,copy);
711// TopOpeBRepDS_ListOfInterference l1,l2;
712// Standard_Integer nfound = FUN_selectGIinterference(copy,PVIndex,l1);
713// if (nfound) {
714// if (iOOFace != 0) {
715// TopOpeBRepDS_ListOfInterference l3,l4;
716// nfound = FUN_selectITRASHAinterference(l2,iOOFace,l3);
717// if (nfound != 0) nfound = FUN_selectTRAORIinterference(l3,otransEdge,l4);
718// if (nfound) continue;
719// }
720// }
721
722// // make and store interference
723// Handle(TopOpeBRepDS_Interference) EPIf;
724// if (iOOFace == 0) iOOFace = myDS->AddShape(OOFace,OOShapeIndex);
725// TopOpeBRepDS_Transition T = transEdge; T.Index(iOOFace);
726// EPIf = MakeEPVInterference(T,iOOFace,PVIndex,parRest,PVKind,
727// TopOpeBRepDS_FACE,SIisvertex);
728// myHDS->StoreInterference(EPIf,Erest);
729
730 continue;
731 }
732
733 TopoDS_Edge OOE = TopoDS::Edge(VP.Edge(OOrank));
734 Standard_Integer iOO = myDS->AddShape(OOE,OOrank);
735
736 Standard_Real OOpar;
6e6cd5d9 737 VP.ParonE(OOE,OOpar);
7fd59977 738
739 // xpu091198 : 1d interf done in EdgesFiller processing (cto cylcong *)
740 Standard_Boolean sdmeds = FUN_ds_sdm((*myDS),Erest,OOE);
741 if (sdmeds) continue;
742
743 Standard_Integer obRest = TopOpeBRepTool_TOOL::OnBoundary(parRest,Erest); //vertex can be missed
744 Standard_Integer obOO = TopOpeBRepTool_TOOL::OnBoundary(OOpar,OOE); //vertex can be missed
745
746 if ((obRest == EXTERNAL)||(obOO == EXTERNAL)){
747#ifdef DEB
748 if(obRest==EXTERNAL) cout<<"***********ProcessRLine : faulty parameter on Erest"<<endl;
749 if(obOO==EXTERNAL) cout<<"***********ProcessRLine : faulty parameter on OOE"<<endl;
750#endif
751 }
752
753 Standard_Boolean tgeds = FUN_tool_EtgOOE(parRest,Erest, OOpar,OOE, tola);
754
755 TopOpeBRepDS_Kind PVKind = TopOpeBRepDS_POINT; Standard_Integer PVIndex = 0; // POINT or VERTEX index
756
757 for (Standard_Integer ShapeIndex = 1; ShapeIndex<=2; ShapeIndex++) {
758 Standard_Integer OOShapeIndex = (ShapeIndex == 1) ? 2 : 1;
759 Standard_Boolean SIErest = (ShapeIndex == rank);
760
761 Standard_Boolean SIisvertex = VP.IsVertex(ShapeIndex);
762 Standard_Boolean OOisvertex = VP.IsVertex(OOShapeIndex);
763 TopoDS_Face OOFace = (*this).Face(OOShapeIndex);
764 Standard_Integer iOOFace = myDS->Shape(OOFace);
765
766 TopoDS_Edge edge,OOedge; Standard_Integer SIedgeIndex,OOedgeIndex;
767 Standard_Real paredge,OOparedge;
768 Standard_Integer onbound;
769 if (SIErest)
770 {edge = Erest; SIedgeIndex = iErest; paredge = parRest; onbound = obRest;
771 OOedge = OOE; OOedgeIndex = iOO; OOparedge = OOpar;}
772 else
773 {OOedge = Erest;OOedgeIndex = iErest; OOparedge = parRest; onbound = obOO;
774 edge = OOE; SIedgeIndex = iOO; paredge = OOpar;}
775
776 // PVIndex :
777 // --------
778 // xpu150399 : BUC60382
779 Standard_Boolean EPIfound=Standard_False,CPIfound=Standard_False; Handle(TopOpeBRepDS_Interference) IEPI,ICPI;
780 ProcessVPondgE(VP, ShapeIndex,
781 PVKind,PVIndex, // out
782 EPIfound,IEPI, // out
783 CPIfound,ICPI); // out
784
785 if (PVIndex == 0) {
786// Standard_Boolean EPIfound=Standard_False,CPIfound=Standard_False; Handle(TopOpeBRepDS_Interference) IEPI,ICPI;
787 FUN_VPIndex((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL,
788 PVKind,PVIndex,EPIfound,IEPI,CPIfound,ICPI,
789 M_GETVP);
790 Standard_Boolean Efound = (EPIfound || CPIfound);
791 Standard_Boolean Ifound = (PVIndex != 0);
792 Standard_Boolean condmake = (!Efound && !Ifound);
793 if (condmake) {
794 if ( SIisvertex ) PVIndex = MakeGeometry(VP,ShapeIndex,PVKind);
795 else if ( OOisvertex ) PVIndex = MakeGeometry(VP,OOShapeIndex,PVKind);
796 else PVIndex = MakeGeometry(VP,ShapeIndex,PVKind);
797 }
798 }
799
800 // transEdge :
801 // ----------
802 if (OOedgeIndex == 0) OOedgeIndex = myDS->AddShape(OOedge,OOShapeIndex);
803 const TopOpeBRepDS_Transition& llt1 = FaceFaceTransition(1);
804 const TopOpeBRepDS_Transition& llt2 = FaceFaceTransition(2);
805 TopOpeBRepDS_Transition Trans = (ShapeIndex == 1)? llt1 : llt2;
806 Standard_Boolean TransUNK = Trans.IsUnknown();
807 TopAbs_Orientation Transori; if (!TransUNK) Transori = Trans.Orientation(TopAbs_IN);
808
809 TopOpeBRepDS_Transition transEdge; Standard_Boolean Tunk = Standard_True;
810 if (!TransUNK) { //xpu281098 PRO12875(edge9,OOface11)
811 if ((absindex==ShapeIndex)||(absindex==3)) {
812 if (SIErest) {
813 // transition on Erest at VP / OOface = transition at VP on Line restriction
814 TopAbs_Orientation oriErest = Erest.Orientation();
815 transEdge = TopOpeBRep_FFTransitionTool::ProcessLineTransition(VP,ShapeIndex,oriErest);
816
817 if (((onbound == 1)||(onbound == 2))&&tgeds) // xpu290399 : edge is restriction,
818 // edge15,OOedge14,OOface13
819 {transEdge.Before(TopAbs_UNKNOWN); transEdge.After(TopAbs_UNKNOWN);}
820 }
821 else {
822 // transition on edge at VP / OOface ?=
823 // TopOpeBRep_FFTransitionTool::ProcessEdgeTransition(VP,ShapeIndex,Transori);
824 // nyi
825 }
826 }
827 Tunk = FDS_hasUNK(transEdge);
828 }
829 if (Tunk) {
830 if (SIErest) {
831 // As edge=Erest is on OOFace, we only compute 2d interferences
832 Standard_Boolean ONfirstP = ::FUN_brep_ONfirstP(vpf,VP);
833 TopAbs_Orientation OVP = ONfirstP ? TopAbs_FORWARD : TopAbs_REVERSED;
834 TopAbs_Orientation oOO; Standard_Boolean ok = FUN_tool_orientEinFFORWARD(OOedge,OOFace,oOO);
835 if (!ok) continue;
836 if (M_INTERNAL(oOO)) OVP = TopAbs_INTERNAL;
837
838 // xpu240399 : cto015I2 (e15,v16)
839 // edge and OOedge are tangent, we do not keep the orientation
840 if (!tgeds) transEdge.Set(OVP);
841 }
842 else {
843 TopOpeBRepDS_Transition Tr;
844 Standard_Boolean ok = FUN_newtransEdge(myHDS,(*this),(*myLine),myLineIsonEdge,VP,PVKind,PVIndex,OOShapeIndex,
845 edge,myERL,Tr);
846 if (!ok) continue;
847 transEdge.Before(Tr.Before()); transEdge.After(Tr.After());
848 }
849#ifdef DEB
850 if (tDSF) {cout<<"*-> new transEdge (edge"<<SIedgeIndex<<",face"<<iOOFace<<")=";
851 TopAbs::Print(transEdge.Before(),cout);
852 cout<<" ";TopAbs::Print(transEdge.After(),cout);cout<<endl;}
853#endif
854 }//Tunk
855 Tunk = FDS_hasUNK(transEdge);
856 if (Tunk) continue;
857
858 TopAbs_Orientation otransEdge = transEdge.Orientation(TopAbs_IN);
859 const TopOpeBRepDS_ListOfInterference& lIedge = myHDS->DS().ShapeInterferences(edge);
860 TopOpeBRepDS_ListOfInterference copy; FDS_copy(lIedge,copy);
861 TopOpeBRepDS_ListOfInterference l1,l2; Standard_Integer nfound = FUN_selectGIinterference(copy,PVIndex,l1);
862 if (OOedgeIndex != 0) nfound = FUN_selectSIinterference(l1,OOedgeIndex,l2);
863 if (nfound) {
864 if (sdmeds) {
865 TopOpeBRepDS_ListOfInterference l3,l4; nfound = FUN_selectITRASHAinterference(l2,OOedgeIndex,l3);
866 if (nfound != 0) nfound = FUN_selectTRAORIinterference(l3,otransEdge,l4);
867 if (nfound) continue; // has I1d=(transEdge(OOedgeIndex),PVIndex,OOedgeIndex);
868 }
869 else if (iOOFace != 0) {
870 TopOpeBRepDS_ListOfInterference l3,l4; nfound = FUN_selectITRASHAinterference(l2,iOOFace,l3);
871 if (nfound != 0) nfound = FUN_selectTRAORIinterference(l3,otransEdge,l4);
872 if (nfound) continue; // has I2d=(transEdge(iOOFace),PVIndex,OOedgeIndex)
873 }
874 }// nfound
875
876 // EPI :
877 // ----
878 Handle(TopOpeBRepDS_Interference) EPI;
879 {
880 if (iOOFace == 0) iOOFace = myDS->AddShape(OOFace,OOShapeIndex);
881 TopOpeBRepDS_Transition T = transEdge; T.Index(iOOFace);
882 EPI = MakeEPVInterference(T,OOedgeIndex,PVIndex,paredge,PVKind,SIisvertex);
883 }
884 myHDS->StoreInterference(EPI,edge);
885
886 // EPIf :
887 // -----
888 if (!SIErest) {
889 Handle(TopOpeBRepDS_Interference) EPIf;
890 TopOpeBRepDS_Transition T = transEdge; T.Index(iOOFace);
891 EPIf = MakeEPVInterference(T,iOOFace,PVIndex,paredge,PVKind,
892 TopOpeBRepDS_FACE,SIisvertex);
893 myHDS->StoreInterference(EPIf,edge);
894 }
895
896 } // ShapeIndex=1..2
897 } // VPI
898 //####################
899}
900
901static Standard_Boolean FUN_haslastvpon0(const TopOpeBRep_LineInter& L)
902{
903 const Standard_Boolean wline = (L.TypeLineCurve() == TopOpeBRep_WALKING);
904 if (!wline) return Standard_False;
905
906 Standard_Integer iINON1,iINONn,nINON; L.VPBounds(iINON1,iINONn,nINON);
907
908 TopOpeBRep_VPointInterIterator VPI;
909 VPI.Init(L);
910 for (; VPI.More(); VPI.Next()) {
911 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
912 const Standard_Integer absindex = VP.ShapeIndex();
913 const Standard_Integer iVP = VP.Index();
914 if (iVP == iINONn && absindex == 0) return Standard_True;
915 }
916 return Standard_False;
917}
918
919//=======================================================================
920//function : FillLineVPonR
921//purpose :
922//=======================================================================
923void TopOpeBRep_FacesFiller::FillLineVPonR()
924{
925#ifdef DEB
926 Standard_Boolean tDSF = TopOpeBRepDS_GettraceDSF();
927 Standard_Boolean trline = Standard_False;
928#endif
929
930 // if a VP is on degenerated edge, adds the triplet
931 // (vertex, closing edge, degenerated edge) to the
932 // map as vertex for key.
933// myDataforDegenEd.Clear();
934 FUN_GetdgData(myDS,(*myLine),myF1,myF2,myDataforDegenEd);
935 FUN_FillVof12((*myLine),myDS) ;
936
937 mykeptVPnbr = 0;
938
939 if (myLine->TypeLineCurve() == TopOpeBRep_RESTRICTION) {
940#ifdef DEB
941 if (trline) FUN_traceRLine(*myLine);
942#endif
943 ProcessRLine();
944 return;
945 }
946
947 Standard_Integer iINON1,iINONn,nINON;
948 myLine->VPBounds(iINON1,iINONn,nINON);
949 if ( nINON == 0 ) {
950 return;
951 }
952
953#ifdef DEB
954 if (trline) FUN_traceGLine(*myLine);
955#endif
956
957 myLineIsonEdge = LSameDomainERL(*myLine, myERL);
958
959 // walking (case mouch1a 1 1) : line (vpfirst on 3,vplast on 0,nvpkept = 2) => kept
960 myLastVPison0 = ::FUN_haslastvpon0(*myLine);
961
962#ifdef DEB
963 if (tDSF) {
964 if (myLineIsonEdge) cout<<" geometric line is on edge"<<endl;
965 else cout <<" geometric line not on edge"<<endl;
966 }
967#endif
968
969 //----------------------------------------------------------------------
970 // IMPORTANT :
971 // Some of Curve/Point transitions for vpoints keep on RESTRICTION lines
972 // sharing same domain with the current geometric line are computed here
973 //----------------------------------------------------------------------
974
975#ifdef DEB
976 Standard_Boolean trcd = Standard_False;
977#ifdef DRAW
978 if (trcd) FUN_DrawMap(myDataforDegenEd);
979#endif
980#endif
981
982 TopOpeBRep_VPointInterIterator VPI;
983 VPI.Init((*myLine));
984 for (; VPI.More(); VPI.Next()) {
985 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
986 ProcessVPR((*this),VP);
987 }
988
989 if ( myLineIsonEdge && (!myDSCIL.IsEmpty()) ) {
990#ifdef DEB
991 if (tDSF) cout<<"myLineIsonEdge && (!myDSCIL.IsEmpty())"<<endl;
992#endif
993 myDSCIL.Clear();
994 }
995}
996
997//=======================================================================
998//function : FillLine
999//purpose :
1000//=======================================================================
1001void TopOpeBRep_FacesFiller::FillLine()
1002{
1003#ifdef DEB
1004 Standard_Boolean tDSF = TopOpeBRepDS_GettraceDSF();
1005#endif
1006
1007 Standard_Integer iINON1,iINONn,nINON;
1008 myLine->VPBounds(iINON1,iINONn,nINON);
1009 if ( nINON == 0 ) return;
1010
1011 Standard_Integer ShapeIndex = 0;
1012 Handle(TopOpeBRepDS_Interference) CPI;
1013
1014 TopOpeBRep_VPointInterIterator VPI;
1015 for (VPI.Init((*myLine)); VPI.More(); VPI.Next()) {
1016
1017 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
1018 if ( ! VP.Keep() ) continue;
1019
1020#ifdef DEB
1021 if (tDSF) cout<<endl;
1022#endif
1023
1024 Standard_Integer PVIndex;
1025 TopOpeBRepDS_Kind PVKind;
1026 TopOpeBRepDS_ListIteratorOfListOfInterference itCPIL(myDSCIL);
1027 Standard_Boolean CPIfound;
1028 CPIfound = GetGeometry(itCPIL,VP,PVIndex,PVKind);
1029 if ( ! CPIfound ) {
1030 Standard_Boolean found = GetFFGeometry(VP,PVKind,PVIndex);
1031 if ( !found ) PVIndex = MakeGeometry(VP,ShapeIndex,PVKind);
1032 }
1033
1034 TopOpeBRepDS_Transition transLine;
1035 if (! CPIfound) {
1036 Standard_Integer iVP = VPI.CurrentVPIndex();
1037 if (iVP == iINON1) transLine.Set(TopAbs_FORWARD);
1038 else if (iVP == iINONn) transLine.Set(TopAbs_REVERSED);
1039 }
1040 else transLine = itCPIL.Value()->Transition().Complement();
1041
1042 Standard_Real parline = VPI.CurrentVP().ParameterOnLine();
1043 CPI = TopOpeBRepDS_InterferenceTool::MakeCurveInterference
1044 (transLine,TopOpeBRepDS_CURVE,0,PVKind,PVIndex,parline);
1045 StoreCurveInterference(CPI);
1046
1047 } // loop on VPoints
1048
1049} // FillLine
1050
1051//=======================================================================
1052//function : AddShapesLine
1053//purpose :
1054//=======================================================================
1055void TopOpeBRep_FacesFiller::AddShapesLine()
1056{
1057 Standard_Boolean dscilemp = myDSCIL.IsEmpty();
1058 if (dscilemp) return;
1059
1060 Standard_Boolean inl = myLine->INL();
1061 if (inl) return;
1062
1063 TopOpeBRepDS_Curve& DSC = myDS->ChangeCurve(myDSCIndex);
1064
1065 Handle(Geom_Curve) C3D;
1066 Handle(Geom2d_Curve) PC1,PC2;
1067 Handle(TopOpeBRepDS_Interference) FCI1, FCI2;
1068
1069 Standard_Integer iF1 = myDS->AddShape(myF1,1);
1070 Standard_Integer iF2 = myDS->AddShape(myF2,2);
1071
1072 Standard_Real pmin,pmax;
1073 myHDS->MinMaxOnParameter(myDSCIL,pmin,pmax);
1074
1075 Standard_Real d = Abs(pmin-pmax);
1076 Standard_Boolean id = (d <= Precision::PConfusion());
1077 Standard_Boolean isper = myLine->IsPeriodic();
1078 id = (id && !isper);
1079
1080 Standard_Boolean wline = (myLine->TypeLineCurve() == TopOpeBRep_WALKING);
1081 Standard_Boolean vclosed = myLine->IsVClosed();
1082 if (wline && !isper && vclosed) {
1083 //xpu240399 : USA60298 : avoid creating curve
1084 // MSV: take into account that geometry can be of type VERTEX
1085 Standard_Integer ipf = myDSCIL.First()->Geometry();
1086 TopOpeBRepDS_Kind kpf = myDSCIL.First()->GeometryType();
1087 gp_Pnt ptf;
1088 Standard_Real tol,tolf, toll;
1089 if (kpf == TopOpeBRepDS_POINT) {
1090 TopOpeBRepDS_Point pf = myDS->Point(ipf);
1091 ptf = pf.Point();
1092 tolf = pf.Tolerance();
1093 }
1094 else { // VERTEX
1095 TopoDS_Vertex vf = TopoDS::Vertex(myDS->Shape(ipf));
1096 ptf = BRep_Tool::Pnt(vf);
1097 tolf = BRep_Tool::Tolerance(vf);
1098 }
1099
1100 Standard_Integer ipl = myDSCIL.Last()->Geometry();
1101 TopOpeBRepDS_Kind kpl = myDSCIL.Last()->GeometryType();
1102 if (kpl == TopOpeBRepDS_POINT) {
1103 TopOpeBRepDS_Point pl = myDS->Point(ipl);
1104 toll = pl.Tolerance();
1105 }
1106 else { // VERTEX
1107 TopoDS_Vertex vl = TopoDS::Vertex(myDS->Shape(ipl));
1108 toll = BRep_Tool::Tolerance(vl);
1109 }
1110
1111 tol = Max(tolf, toll);
1112 Standard_Boolean onsampt = Standard_True;
1113 for (Standard_Integer ii = 1; ii <= myLine->NbWPoint(); ii++) {
1114 TopOpeBRep_WPointInter wp = myLine->WPoint(ii);
1115 gp_Pnt pp = wp.Value();
1116 if (!pp.IsEqual(ptf,tol)) {onsampt = Standard_False;break;}
1117 }
1118 if (onsampt) id = Standard_True;
1119 }
1120
1121#ifdef DEB
1122 if (TopOpeBRepDS_GettraceDSF()) {
1123 cout<<endl<<"minmax "<<pmin<<","<<pmax;
1124 if (id) cout<<" --> rejet";
1125 cout<<endl;
1126 }
1127#endif
1128
1129 if (id) {
1130 DSC.ChangeKeep(Standard_False);
1131 return;
1132 }
1133
1134 TopOpeBRep_GeomTool::MakeCurves(pmin,pmax,(*myLine),myF1,myF2,DSC,PC1,PC2);
1135
1136 //Patch: avoid making too small edges. Made for the bug buc60926 by jgv, 14.06.01.
1137 Standard_Real fpar, lpar;
1138 DSC.Range(fpar, lpar);
1139 GeomAdaptor_Curve theCurve( DSC.Curve(), fpar, lpar );
1140 Bnd_Box theBox;
1141 BndLib_Add3dCurve::Add( theCurve, 0., theBox );
1142 Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax, MaxSide;
1143 theBox.Get( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
1144 MaxSide = Max( Max(Xmax-Xmin, Ymax-Ymin), Zmax-Zmin );
1145 Standard_Real MinTol = Min( BRep_Tool::Tolerance(myF1), BRep_Tool::Tolerance(myF2) );
1146 if (MaxSide < MinTol)
1147 {
1148 DSC.ChangeKeep(Standard_False);
1149 return;
1150 }
1151
1152 Standard_Real tolDSC = 1.e-8;
1153 DSC.Tolerance(tolDSC);
1154 const TopOpeBRepDS_Transition& lllt1 = FaceFaceTransition(1);
1155 const TopOpeBRepDS_Transition& lllt2 = FaceFaceTransition(2);
1156
1157 myDS->ChangeCurveInterferences(myDSCIndex).Append(myDSCIL);
1158 {
1159 TopOpeBRepDS_Transition T1 = lllt1; T1.Index(iF2);
1160 FCI1 = TopOpeBRepDS_InterferenceTool::MakeFaceCurveInterference
1161 (T1,iF2,myDSCIndex,PC1);
1162 myHDS->StoreInterference(FCI1,myF1);
1163 }
1164
1165 {
1166 TopOpeBRepDS_Transition T2 = lllt2; T2.Index(iF1);
1167 FCI2 = TopOpeBRepDS_InterferenceTool::MakeFaceCurveInterference
1168 (T2,iF1,myDSCIndex,PC2);
1169 myHDS->StoreInterference(FCI2,myF2);
1170 }
1171
1172 DSC.SetShapes(myF1,myF2);
1173 DSC.SetSCI(FCI1,FCI2);
1174
1175}
1176
1177//=======================================================================
1178//function : StoreCurveInterference
1179//purpose : private
1180//=======================================================================
1181void TopOpeBRep_FacesFiller::StoreCurveInterference(const Handle(TopOpeBRepDS_Interference)& I)
1182{
1183 if ( myDSCIndex == 0 ) {
1184 TopOpeBRepDS_Curve DSC;
1185 myDSCIndex = myDS->AddCurve(DSC);
1186
7fd59977 1187#ifdef DEB
1188 if (TopOpeBRepDS_GettraceDSF() || TopOpeBRepDS_GettraceDSNC())
1189 cout<<"new DSC "<<myDSCIndex<<endl;
1190 if (TopOpeBRepDS_GettraceDSLT()) myLine->DumpLineTransitions(cout);
1191#endif
1192 }
1193
1194 I->Support(myDSCIndex);
1195 myHDS->StoreInterference(I,myDSCIL);
1196}
1197
1198//=======================================================================
1199//function : GetGeometry
1200//purpose :
1201//=======================================================================
1202Standard_Boolean TopOpeBRep_FacesFiller::GetGeometry(TopOpeBRepDS_ListIteratorOfListOfInterference& IT,const TopOpeBRep_VPointInter& VP,Standard_Integer& G,TopOpeBRepDS_Kind& K)
1203{
1204 TopOpeBRepDS_Point DSP = TopOpeBRep_PointGeomTool::MakePoint(VP);
1205 Standard_Boolean b = myHDS->GetGeometry(IT,DSP,G,K);
1206#ifdef DEB
1207 Standard_Boolean trc = TopOpeBRepDS_GettraceDSF() || TopOpeBRepDS_GettraceDSP();
1208 if (b && trc) {
1209 Standard_Boolean newinDS = Standard_False; myHFFD->DumpDSP(VP,K,G,newinDS);
1210 }
1211#endif
1212 return b;
1213}
1214
1215//=======================================================================
1216//function : MakeGeometry
1217//purpose :
1218//=======================================================================
1219Standard_Integer TopOpeBRep_FacesFiller::MakeGeometry(const TopOpeBRep_VPointInter& VP,const Standard_Integer ShapeIndex,TopOpeBRepDS_Kind& K)
1220{
1221 Standard_Integer G;
1222 Standard_Boolean isvertex = VP.IsVertex(ShapeIndex);
1223 if ( isvertex ) {
1224 const TopoDS_Shape& S = VP.Vertex(ShapeIndex);
1225 G = myDS->AddShape(S,ShapeIndex);
1226 K = TopOpeBRepDS_VERTEX;
1227 }
1228 else {
1229 TopOpeBRepDS_Point P = TopOpeBRep_PointGeomTool::MakePoint(VP);
1230 G = myDS->AddPoint(P);
1231 K = TopOpeBRepDS_POINT;
1232 }
1233
1234#ifdef DEB
1235 Standard_Boolean trc = TopOpeBRepDS_GettraceDSF() || TopOpeBRepDS_GettraceDSP();
1236 if (trc) {
1237 Standard_Boolean newinDS = Standard_True; myHFFD->DumpDSP(VP,K,G,newinDS);
1238 }
1239#endif
1240
1241 return G;
1242}
1243
1244//=======================================================================
1245//function : GetFFGeometry
1246//purpose :
1247//=======================================================================
1248Standard_Boolean TopOpeBRep_FacesFiller::GetFFGeometry(const TopOpeBRepDS_Point& DSP,TopOpeBRepDS_Kind& K,Standard_Integer& G) const
1249{
1250 Standard_Boolean found = Standard_False;
1251 Standard_Integer i = myFFfirstDSP, n = myDS->NbPoints();
1252 for (; i <= n; i++) {
1253 const TopOpeBRepDS_Point& OODSP = myDS->Point(i);
1254 found = TopOpeBRep_PointGeomTool::IsEqual(DSP,OODSP);
1255 if (found) break;
1256 }
1257 if ( found ) {
1258 K = TopOpeBRepDS_POINT;
1259 G = i;
1260 }
1261 return found;
1262}
1263
1264//=======================================================================
1265//function : GetFFGeometry
1266//purpose :
1267//=======================================================================
1268Standard_Boolean TopOpeBRep_FacesFiller::GetFFGeometry(const TopOpeBRep_VPointInter& VP,TopOpeBRepDS_Kind& K,Standard_Integer& G) const
1269{
1270 TopOpeBRepDS_Point DSP = TopOpeBRep_PointGeomTool::MakePoint(VP);
1271 Standard_Integer found = GetFFGeometry(DSP,K,G);
1272 return found;
1273}
1274