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