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