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