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