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