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