0025418: Debug output to be limited to OCC development environment
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_EXPORT.cxx
CommitLineData
b311480e 1// Created on: 1997-12-15
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1997-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.
b311480e 16
7fd59977 17// Modified by xpu, Wed May 20 10:47:38 1998
18
19#include <gp_Dir.hxx>
20#include <gp_Pnt.hxx>
21#include <gp_Pnt2d.hxx>
22#include <Geom_Curve.hxx>
23#include <TopoDS.hxx>
24#include <BRep_Tool.hxx>
25#include <BRepTools.hxx>
26#include <TopExp.hxx>
27#include <TopExp_Explorer.hxx>
28#include <Precision.hxx>
29#include <GeomAdaptor_Surface.hxx>
30#include <TColStd_DataMapOfIntegerInteger.hxx>
31#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
32
33#include <TopOpeBRepTool_CurveTool.hxx>
34#include <TopOpeBRepTool_ShapeTool.hxx>
35#include <TopOpeBRepTool_TOOL.hxx>
36#include <TopOpeBRepTool_EXPORT.hxx>
37#include <TopOpeBRepTool_SC.hxx>
38#include <TopOpeBRepTool_makeTransition.hxx>
39#include <Standard_ProgramError.hxx>
40
41#include <TopOpeBRepDS_InterferenceTool.hxx>
42#include <TopOpeBRepDS_BuildTool.hxx>
43#include <TopOpeBRepDS_PointIterator.hxx>
44#include <TopOpeBRepDS_BuildTool.hxx>
45#include <TopOpeBRepDS_EXPORT.hxx>
46#include <TopOpeBRepDS_connex.hxx>
47#include <TopOpeBRepDS_TKI.hxx>
48#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
49#include <TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State.hxx>
50#include <TopOpeBRepDS_TOOL.hxx>
51#include <TopOpeBRepDS_define.hxx>
52
0797d9d3 53#ifdef OCCT_DEBUG
7fd59977 54#include <TopOpeBRepDS_reDEB.hxx>
1d0a9d4d 55extern Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer);
7fd59977 56Standard_EXPORT void debse1(const Standard_Integer i) {cout<<"+ debse1 se"<<i<<endl;}
57Standard_EXPORT void debse2(const Standard_Integer i) {cout<<"+ debse2 se"<<i<<endl;}
58Standard_EXPORT void debse3(const Standard_Integer i) {cout<<"+ debse3 se"<<i<<endl;}
59Standard_EXPORT void debse4(const Standard_Integer i) {cout<<"+ debse4 se"<<i<<endl;}
60Standard_EXPORT void debse5(const Standard_Integer i) {cout<<"+ debse5 se"<<i<<endl;}
61Standard_EXPORT void debse6(const Standard_Integer i) {cout<<"+ debse6 se"<<i<<endl;}
62Standard_EXPORT void debe7(const Standard_Integer i) {cout<<"+ debe7 se"<<i<<endl;}
63Standard_EXPORT void debse8(const Standard_Integer i) {cout<<"+ debse8 se"<<i<<endl;}
64Standard_EXPORT void debe9(const Standard_Integer i) {cout<<"+ debe9 se"<<i<<endl;}
65Standard_EXPORT void debgb1(const Standard_Integer i) {cout<<"+ debgb1 se"<<i<<endl;}
66Standard_EXPORT void debse9(const Standard_Integer i) {cout<<"+ debse9 se"<<i<<endl;}
67Standard_EXPORT void debsdm1(const Standard_Integer i) {cout<<"+ debsdm1 se"<<i<<endl;}
68Standard_EXPORT void debsamsha(const Standard_Integer i) {cout<<"+ debsamsha se"<<i<<endl;}
69Standard_EXPORT void debcompletefei(const Standard_Integer i) {cout<<"+ debcompletefei f"<<i<<endl;}
70#endif
71static void FUN_Raise()
72{
0797d9d3 73#ifdef OCCT_DEBUG
7fd59977 74// cout<<"FUN_ds_completeforSE"<<endl;
75// Standard_ProgramError::Raise("FUN_ds_completeforSE");
76#endif
77}
78
79#define M_IN(st) (st == TopAbs_IN)
80#define M_ON(st) (st == TopAbs_ON)
81#define M_OUT(st) (st == TopAbs_OUT)
82#define M_FORWARD(st) (st == TopAbs_FORWARD)
83#define M_UNKNOWN(st) (st == TopAbs_UNKNOWN)
84#define M_REVERSED(st) (st == TopAbs_REVERSED)
85#define M_INTERNAL(st) (st == TopAbs_INTERNAL)
86#define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
87
88//------------------------------------------------------
89Standard_EXPORT void FDS_SetT(TopOpeBRepDS_Transition& T, const TopOpeBRepDS_Transition& T0)
90//------------------------------------------------------
91{
92 TopAbs_State stb = T0.Before(), sta = T0.After();
93 T.Before(stb); T.After(sta);
94}
95
96//------------------------------------------------------
97Standard_EXPORT Standard_Boolean FDS_hasUNK(const TopOpeBRepDS_Transition& T)
98//------------------------------------------------------
99{
100 TopAbs_State stb = T.Before(), sta = T.After();
101 Standard_Boolean hasunknown = (M_UNKNOWN(stb) || M_UNKNOWN(sta));
102 return hasunknown;
103}
104
105//------------------------------------------------------
106Standard_EXPORT void FDS_copy(const TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LII)
107//------------------------------------------------------
108{
109 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) LII.Append(it.Value());
110}
111
112//------------------------------------------------------
113Standard_EXPORT void FDS_copy(const TopTools_ListOfShape& LI, TopTools_ListOfShape& LII)
114//------------------------------------------------------
115{
116 for (TopTools_ListIteratorOfListOfShape it(LI); it.More(); it.Next()) LII.Append(it.Value());
117}
118//------------------------------------------------------
119Standard_EXPORT void FDS_assign(const TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LII)
120//------------------------------------------------------
121{
122 LII.Clear(); FDS_copy(LI,LII);
123}
124
125//------------------------------------------------------
126Standard_EXPORT void FDS_assign(const TopTools_ListOfShape& LI, TopTools_ListOfShape& LII)
127//------------------------------------------------------
128{
129 LII.Clear(); FDS_copy(LI,LII);
130}
131
132//------------------------------------------------------
133Standard_EXPORT void FUN_ds_samRk(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer Rk,
134 TopTools_ListOfShape& LI, TopTools_ListOfShape & LIsrk)
135//------------------------------------------------------
136{
137 LIsrk.Clear();
138 TopTools_ListIteratorOfListOfShape it(LI);
139 while (it.More()) {
140 const TopoDS_Shape& S = it.Value(); Standard_Integer rk = BDS.AncestorRank(S);
141 if (rk == Rk) {LIsrk.Append(S);LI.Remove(it);}
142 else it.Next();
143 }
144}
145
146//------------------------------------------------------
147Standard_EXPORT void FDS_dumpLI
148//------------------------------------------------------
0797d9d3 149#ifndef OCCT_DEBUG
7fd59977 150(const TopOpeBRepDS_ListOfInterference& ,const char* )
151{
152#else
153(const TopOpeBRepDS_ListOfInterference& LI,const char* str)
154{
155 for(TopOpeBRepDS_ListIteratorOfListOfInterference itD(LI);itD.More();itD.Next()) {
156 if(str) cout<<str; itD.Value()->Dump(cout); cout<<endl;
157 }
158#endif
159}
160
161//------------------------------------------------------
162Standard_EXPORT void FDS_Tdata
163//------------------------------------------------------
164(const Handle(TopOpeBRepDS_Interference)& I,TopAbs_ShapeEnum& SB,Standard_Integer& IB,TopAbs_ShapeEnum& SA,Standard_Integer& IA)
165{
166 if (I.IsNull()) return;
167 const TopOpeBRepDS_Transition T = I->Transition();
168 SB = T.ShapeBefore(); IB = T.IndexBefore();
169 SA = T.ShapeAfter(); IA = T.IndexAfter();
170}
171
172//------------------------------------------------------
173Standard_EXPORT void FDS_data
174//------------------------------------------------------
175(const Handle(TopOpeBRepDS_Interference)& I,TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
176{
177 if (I.IsNull()) return;
178 GT1 = I->GeometryType(); G1 = I->Geometry();
179 ST1 = I->SupportType(); S1 = I->Support();
180}
181
182// true si la transition de l'interference courante es UNKNOWN
183//------------------------------------------------------
184Standard_EXPORT Standard_Boolean FDS_data
185//------------------------------------------------------
186(const TopOpeBRepDS_ListIteratorOfListOfInterference& it1,Handle(TopOpeBRepDS_Interference)& I1,TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
187{
188 if (!it1.More()) return Standard_False;
189 I1 = it1.Value(); const TopOpeBRepDS_Transition& T1 = I1->Transition();
190 FDS_data(I1,GT1,G1,ST1,S1);
191 Standard_Boolean isunk1 = T1.IsUnknown();
192 return isunk1;
193}
194
195//------------------------------------------------------
196Standard_EXPORT void FDS_Idata
197//------------------------------------------------------
198(const Handle(TopOpeBRepDS_Interference)& I,TopAbs_ShapeEnum& SB,Standard_Integer& IB,TopAbs_ShapeEnum& SA,Standard_Integer& IA,
199 TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
200{
201 if (I.IsNull()) return;
202 FDS_Tdata(I,SB,IB,SA,IA);
203 FDS_data(I,GT1,G1,ST1,S1);
204}
205
206//------------------------------------------------------
207Standard_EXPORT Standard_Boolean FUN_ds_getVsdm
208(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer iV, Standard_Integer& iVsdm)
209//------------------------------------------------------
210{
211 iVsdm = 0;
212 Standard_Boolean found = Standard_False;
213 // getting <Vsdm> shape same domain with <V>.
214 Standard_Integer imax = BDS.NbShapes();
215 Standard_Boolean undef = (iV < 1) || (iV > imax);
216 if (undef) return Standard_False;
217 const TopoDS_Shape& V = BDS.Shape(iV);
218 TopTools_ListIteratorOfListOfShape issdm(BDS.ShapeSameDomain(V));
219 for (; issdm.More(); issdm.Next()){
220 const TopoDS_Shape& VV = issdm.Value();
221 if (V.IsSame(VV)) continue;
222 iVsdm = BDS.Shape(VV);
223 found = Standard_True; break;
224 }
225 return found;
226}
227
228//------------------------------------------------------
229Standard_EXPORT Standard_Boolean FUN_ds_sdm
230(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Shape& s1, const TopoDS_Shape& s2)
231//------------------------------------------------------
232{
233 if (!BDS.HasShape(s1) || !BDS.HasShape(s2)) return Standard_False;
234 const TopTools_ListOfShape& sdm1 = BDS.ShapeSameDomain(s1);
235 TopTools_ListIteratorOfListOfShape it1(sdm1);
236 for (; it1.More(); it1.Next())
237 if (it1.Value().IsSame(s2)) return Standard_True;
238 return Standard_False;
239}
240
241// True si les faces isb1,isb2, issues du meme shape origine, connexes par l'arete SI, sont tangentes.
242// 1/ analyse du codage SameDomain dans la DS.
243// 2/ si pas de codage SameDomain dans la DS, analyse geometrique.
244// cette deuxieme analyse est necessaire car l'info SameDomain n'est pas recherchee entre les
245// faces d'un meme shape origine.
246//------------------------------------------------------------------------------------
247Standard_EXPORT Standard_Boolean FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& ES,const TopoDS_Shape& F1,const TopoDS_Shape& F2)
248//------------------------------------------------------------------------------------
249{
250 Standard_Boolean trfa_samdom = Standard_False;
251 const TopTools_ListOfShape& ls = BDS.ShapeSameDomain(F1);
252 TopTools_ListIteratorOfListOfShape it(ls);
253 for(;it.More();it.Next()) { // NYI : syntaxe rapide de BDS IsShapeSameDomainofShape
254 const TopoDS_Shape& ss = it.Value();
255 trfa_samdom = ss.IsSame(F2);
256 if (trfa_samdom) break;
257 }
258 if ( !trfa_samdom ) {
259 Handle(Geom_Surface) su1 = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F1));
260 GeomAdaptor_Surface gs1(su1); GeomAbs_SurfaceType st1 = gs1.GetType();
261 Handle(Geom_Surface) su2 = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F2));
262 GeomAdaptor_Surface gs2(su2); GeomAbs_SurfaceType st2 = gs2.GetType();
263 Standard_Boolean plpl = (st1 == GeomAbs_Plane) && ( st2 == GeomAbs_Plane);
264 if (plpl) {
265 // NYI a arranger
266 gp_Pnt2d p2d1,p2d2; BRep_Tool::UVPoints(TopoDS::Edge(ES),TopoDS::Face(F1),p2d1,p2d2);
267 gp_Dir d1 = FUN_tool_ngS(p2d1,su1);
268 gp_Dir d2 = FUN_tool_ngS(p2d2,su2);
269 Standard_Real tola = Precision::Angular();
270 Standard_Real dot = d1.Dot(d2);
271 trfa_samdom = (Abs(1. - Abs(dot)) < tola);
272 }
273 }
274 return trfa_samdom;
275}
276
277// True si les faces isb1,isb2, issues du meme shape origine, connexes par l'arete SI, sont tangentes.
278// 1/ analyse du codage SameDomain dans la DS.
279// 2/ si pas de codage SameDomain dans la DS, analyse geometrique.
280// cette deuxieme analyse est necessaire car l'info SameDomain n'est pas recherchee entre les
281// faces d'un meme shape origine.
282//------------------------------------------------------------------------------------
283Standard_EXPORT Standard_Boolean FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Standard_Integer isb1,const Standard_Integer isb2)
284//------------------------------------------------------------------------------------
285{
286 Standard_Boolean trfa_samdom = Standard_False;
287 const TopoDS_Shape& ES = BDS.Shape(SI); // edge de F1 et F2
288 if (ES.ShapeType() != TopAbs_EDGE) return Standard_False;
289 const TopoDS_Shape& F1 = BDS.Shape(isb1);
290 if (F1.ShapeType() != TopAbs_FACE) return Standard_False;
291 const TopoDS_Shape& F2 = BDS.Shape(isb2);
292 if (F2.ShapeType() != TopAbs_FACE) return Standard_False;
293 trfa_samdom = FDS_aresamdom(BDS,ES,F1,F2);
294 return trfa_samdom;
295}
296
297//----------------------------------------------------
298Standard_EXPORT Standard_Boolean FDS_EdgeIsConnexToSameDomainFaces
299(const TopoDS_Shape& E,const Handle(TopOpeBRepDS_HDataStructure)& HDS) // not used
300//----------------------------------------------------
301{
7fd59977 302 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
303 const TopTools_ListOfShape& lf = FDSCNX_EdgeConnexitySameShape(E,HDS);
304 Standard_Integer nlf = lf.Extent();
305 if (nlf < 2) return Standard_False;
306
307 Standard_Boolean samdom = Standard_False;
308 TopTools_ListIteratorOfListOfShape i1(lf);
309 for(;i1.More();i1.Next()) {
310 const TopoDS_Shape& f1 = i1.Value();
311 TopTools_ListIteratorOfListOfShape i2(i1);
312 for(;i2.More();i2.Next()) {
313 const TopoDS_Shape& f2 = i2.Value();
7fd59977 314 samdom = FDS_aresamdom(BDS,E,f1,f2);
315 if (samdom) break;
316 }
317 if (samdom) break;
318 }
319 if (samdom) return Standard_True;
320 return Standard_False;
321} // not used
322
323
324// T si ShapeIndex SI est la GeometrieIndex d'une Interference
325// d'un Shape (Before ou After) de la Transition de I
326//----------------------------------------------------
327Standard_EXPORT Standard_Boolean FDS_SIisGIofIofSBAofTofI(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Handle(TopOpeBRepDS_Interference)& I)
328//----------------------------------------------------
329{
330 if (SI == 0) return Standard_False;
331 if (I.IsNull()) return Standard_False;
332 Standard_Boolean ya = Standard_False;
333
0797d9d3 334#ifdef OCCT_DEBUG
7fd59977 335// const TopOpeBRepDS_Transition& T1 = I->Transition();
336#endif
337 TopAbs_ShapeEnum SB1,SA1;Standard_Integer IB1,IA1;TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
338 FDS_Idata(I,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1);
339
340 if (SB1 == TopAbs_FACE) {
341 const TopOpeBRepDS_ListOfInterference& Bloi = BDS.ShapeInterferences(IB1);
342 TopOpeBRepDS_ListIteratorOfListOfInterference it(Bloi);
343 for(; it.More(); it.Next()) {
344 const Handle(TopOpeBRepDS_Interference)& IB = it.Value();
345 TopAbs_ShapeEnum SBB,SAB;Standard_Integer IBB,IAB;TopOpeBRepDS_Kind GTB,STB;Standard_Integer GB,SB;
346 FDS_Idata(IB,SBB,IBB,SAB,IAB,GTB,GB,STB,SB);
347 if (GTB == TopOpeBRepDS_EDGE && GB == SI) {
348 // la face IB1 a une interference dont la geometrie est l'arete SI.
349 ya = Standard_True;
350 break;
351 }
352 }
353 } // SB1 == FACE
354 else if (SA1 == TopAbs_FACE) {
355 const TopOpeBRepDS_ListOfInterference& Aloi = BDS.ShapeInterferences(IA1);
356 TopOpeBRepDS_ListIteratorOfListOfInterference it(Aloi);
357 for(; it.More(); it.Next()) {
358 const Handle(TopOpeBRepDS_Interference)& IA = it.Value();
359 TopAbs_ShapeEnum SBA,SAA;Standard_Integer IBA,IAA;TopOpeBRepDS_Kind GTA,STA;Standard_Integer GA,SA;
360 FDS_Idata(IA,SBA,IBA,SAA,IAA,GTA,GA,STA,SA);
361 if (GTA == TopOpeBRepDS_EDGE && GA == SI) {
362 // la face IA1 a une interference dont la geometrie est l'arete IS.
363 ya = Standard_True;
364 break;
365 }
366 }
367 } // SA1 == FACE
368
369 return ya;
370}
371
372//---------------------------------------------------------
373Standard_EXPORT Standard_Boolean FDS_Parameter(const Handle(TopOpeBRepDS_Interference)& I, Standard_Real& par)
374//---------------------------------------------------------
375{
376 Standard_Boolean isEVI = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
377 Standard_Boolean isCPI = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference));
378 if (!isEVI && !isCPI) return Standard_False;
379 par = FDS_Parameter(I);
380 return Standard_True;
381}
382
383//----------------------------------------------------
384Standard_EXPORT Standard_Real FDS_Parameter(const Handle(TopOpeBRepDS_Interference)& I)
385//----------------------------------------------------
386{
387 Standard_Real p = 0;
388 if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) )
389 p = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->Parameter();
390 else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) )
391 p = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I)->Parameter();
392 else {
0797d9d3 393#ifdef OCCT_DEBUG
7fd59977 394 cout<<"EdgeInterference : mauvais type d'interference"<<endl;
395#endif
396 Standard_Failure::Raise("FDS_Parameter");
397 }
398 return p;
399}
400
401//----------------------------------------------------------------------
402Standard_EXPORT Standard_Boolean FDS_HasSameDomain3d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,TopTools_ListOfShape* PLSD)
403//-----------------------------------------------------------------------
404{
405 const TopTools_ListOfShape& lssd = BDS.ShapeSameDomain(E);
406 Standard_Boolean hsd = (! lssd.IsEmpty());
407 if (PLSD != NULL) PLSD->Clear();
408 if (!hsd) return Standard_False;
409
410 Standard_Boolean hsd3d = Standard_False;
411 TopTools_ListIteratorOfListOfShape it(lssd);
412 for (; it.More(); it.Next()) {
413 const TopoDS_Shape& esd = it.Value();
0797d9d3 414#ifdef OCCT_DEBUG
7fd59977 415// Standard_Integer iesd = BDS.Shape(esd);
416// Standard_Integer resd = BDS.SameDomainInd(esd);
417#endif
418 TopOpeBRepDS_Config c = BDS.SameDomainOri(esd);
419 Standard_Boolean ok = Standard_True;
420 ok = ok && (c == TopOpeBRepDS_UNSHGEOMETRY);
421 if (ok) {
422 hsd3d = Standard_True;
423 if (PLSD != NULL) PLSD->Append(esd);
424 else break;
425 }
426 }
427 return hsd3d;
428}
429
430//-----------------------------------------------------------------------
431Standard_EXPORT Standard_Boolean FDS_Config3d(const TopoDS_Shape& E1,const TopoDS_Shape& E2,TopOpeBRepDS_Config& c)
432//-----------------------------------------------------------------------
433{
434 Standard_Boolean same = Standard_True;
435
436 gp_Pnt PE1;Standard_Real pE1;
437 Standard_Boolean ok1 = FUN_tool_findPinE(TopoDS::Edge(E1),PE1,pE1);
438 gp_Vec VE1; if (ok1) ok1 = TopOpeBRepTool_TOOL::TggeomE(pE1,TopoDS::Edge(E1),VE1);
439
440 Standard_Real pE2,dE2;
441 Standard_Boolean ok2 = FUN_tool_projPonE(PE1,TopoDS::Edge(E2),pE2,dE2);
442 gp_Vec VE2; if (ok2) ok2 = TopOpeBRepTool_TOOL::TggeomE(pE2,TopoDS::Edge(E2),VE2);
443
444 if (!ok1 || !ok2) return Standard_False;
445
446 gp_Dir DE1(VE1);
447 gp_Dir DE2(VE2);
448 Standard_Real dot = DE1.Dot(DE2);
449 same = (dot > 0);
450 c = (same) ? TopOpeBRepDS_SAMEORIENTED : TopOpeBRepDS_DIFFORIENTED;
451 return Standard_True;
452}
453
454//----------------------------------------------------------------------
455Standard_EXPORT Standard_Boolean FDS_HasSameDomain2d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,TopTools_ListOfShape* PLSD)
456//-----------------------------------------------------------------------
457{
458 const TopTools_ListOfShape& lssd = BDS.ShapeSameDomain(E);
459 Standard_Boolean hsd = (! lssd.IsEmpty());
460 if (PLSD != NULL) PLSD->Clear();
461 if (!hsd) return Standard_False;
462
463 Standard_Boolean hsd2d = Standard_False;
464 TopTools_ListIteratorOfListOfShape it(lssd);
465 for (; it.More(); it.Next()) {
466 const TopoDS_Shape& esd = it.Value();
0797d9d3 467#ifdef OCCT_DEBUG
7fd59977 468// Standard_Integer iesd = BDS.Shape(esd);
469// Standard_Integer resd = BDS.SameDomainInd(esd);
470#endif
471 TopOpeBRepDS_Config c = BDS.SameDomainOri(esd);
472 Standard_Boolean ok = (c == TopOpeBRepDS_SAMEORIENTED || c == TopOpeBRepDS_DIFFORIENTED);
473 if (ok) {
474 hsd2d = Standard_True;
475 if (PLSD != NULL) PLSD->Append(esd);
476 else break;
477 }
478 }
479 return hsd2d;
480}
481
482//-----------------------------------------------------------------------
483Standard_EXPORT void FDS_getupperlower
484(const Handle(TopOpeBRepDS_HDataStructure)& HDS,
485 const Standard_Integer edgeIndex,
486 const Standard_Real paredge,
487 Standard_Real& p1, Standard_Real& p2)
488//-----------------------------------------------------------------------
489{
490 TopoDS_Edge E = TopoDS::Edge(HDS->Shape(edgeIndex));
491 FUN_tool_bounds(E,p1,p2);
492
493 // get p1, p2, p1<paredge<p2 with pmin, pmax nearest parameters
494 Standard_Real par;
495 TopOpeBRepDS_PointIterator pIte = HDS->EdgePoints(E);
496 for (;pIte.More();pIte.Next()) {
497 par = pIte.Parameter();
498 Standard_Boolean parsup1 = (par > p1), parinfe = (par < paredge);
499 Standard_Boolean parinf2 = (par < p2), parsupe = (par > paredge);
500 if (parsup1 && parinfe) p1 = par;
501 if (parinf2 && parsupe) p2 = par;
502 }
503}
504
505// ----------------------------------------------------------------------
506Standard_EXPORT Standard_Boolean FUN_ds_getoov(const TopoDS_Shape& v, const TopOpeBRepDS_DataStructure& BDS, TopoDS_Shape& oov)
507//-----------------------------------------------------------------------
508{
509 // prequesitory : the DS binds at most 2 vertices same domain
510 TopoDS_Shape nullS; oov = nullS;
511 const TopTools_ListOfShape& vsd = BDS.ShapeSameDomain(v);
512 TopTools_ListIteratorOfListOfShape itlov(vsd);
513 for (; itlov.More(); itlov.Next()){
514 const TopoDS_Shape& vcur = itlov.Value();
515 if (vcur.IsSame(v)) continue;
516 oov = vcur;
517 return Standard_True;
518 }
519 return Standard_False;
520}
521
522// ----------------------------------------------------------------------
523Standard_EXPORT Standard_Boolean FUN_ds_getoov(const TopoDS_Shape& v, const Handle(TopOpeBRepDS_HDataStructure)& HDS, TopoDS_Shape& oov)
524//-----------------------------------------------------------------------
525{
526 // prequesitory : the DS binds at most 2 vertices same domain
527 TopoDS_Shape nullS; oov = nullS;
528 if (HDS->HasSameDomain(v)) {
529 TopTools_ListIteratorOfListOfShape itlov(HDS->SameDomain(v));
530 for (; itlov.More(); itlov.Next()){
531 const TopoDS_Shape& vcur = itlov.Value();
532 if (vcur.IsSame(v)) continue;
533 oov = vcur;
534 return Standard_True;
535 }
536 }
537 return Standard_False;
538}
539
540Standard_EXPORT Standard_Boolean FUN_selectTRAINTinterference(const TopOpeBRepDS_ListOfInterference& li, TopOpeBRepDS_ListOfInterference& liINTERNAL)
541{
542 liINTERNAL.Clear();
543 TopOpeBRepDS_ListIteratorOfListOfInterference it(li);
544 for (; it.More(); it.Next()){
545 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
546 const TopAbs_Orientation ori = I->Transition().Orientation(TopAbs_IN);
547 if (M_INTERNAL(ori)) liINTERNAL.Append(I);
548 }
549 Standard_Boolean hasINT = !liINTERNAL.IsEmpty();
550 return hasINT;
551}
552
553static Standard_Boolean FUN_ds_hasSDMancestorfaces
554(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const TopoDS_Edge& E1,const TopoDS_Edge& E2, TopoDS_Face& Fsd1,TopoDS_Face& Fsd2)
555{
556 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
557
558 const TopTools_ListOfShape& lFcE1 = FDSCNX_EdgeConnexitySameShape(E1,HDS);
559 const TopTools_ListOfShape& lFcE2 = FDSCNX_EdgeConnexitySameShape(E2,HDS);
560
561 TopTools_IndexedMapOfShape mapfcE2;
562 TopTools_ListIteratorOfListOfShape it2(lFcE2);
563 for (; it2.More(); it2.Next()) mapfcE2.Add(it2.Value());
564
565 TopTools_ListIteratorOfListOfShape it1(lFcE1);
566 for (; it1.More(); it1.Next()){
567 const TopoDS_Shape& fcE1 = it1.Value();
568 Standard_Boolean hsdm1 = HDS->HasSameDomain(fcE1);
569 if (!hsdm1) continue;
570 const TopTools_ListOfShape& fsdm2 = BDS.ShapeSameDomain(fcE1);
571 it2.Initialize(fsdm2);
572 for (; it2.More(); it2.Next()){
573 const TopoDS_Shape& f2 = it2.Value();
574 Standard_Boolean isb2 = mapfcE2.Contains(f2);
575 if (!isb2) continue;
576 Fsd1 = TopoDS::Face(fcE1); Fsd2 = TopoDS::Face(f2);
577 return Standard_True;
578 }
579 }
580 return Standard_False;
581}
582
583//unreferenced function, commented
0797d9d3 584/*#ifdef OCCT_DEBUG
7fd59977 585static Standard_Integer FUN_ds_FaceConnexitySameShape(const TopoDS_Vertex& V, const TopoDS_Edge& E, const Handle(TopOpeBRepDS_HDataStructure)& HDS,
586 TopTools_ListOfShape& lFcx)
587// very expensive, but found no other way (nyi : modify DS_connex.cxx)
588{
589 lFcx.Clear();
0797d9d3 590#ifdef OCCT_DEBUG
7fd59977 591// const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
592#endif
593 const TopTools_ListOfShape& lf1 = FDSCNX_EdgeConnexitySameShape(E,HDS);
594 Standard_Integer nlf1 = lf1.Extent();
595 if (nlf1 < 2) return Standard_False;
596
597 TopTools_MapOfShape mapf;
598 TopTools_ListIteratorOfListOfShape it1(lf1);
599 for (; it1.More(); it1.Next()){
600 const TopoDS_Shape& f = it1.Value();
601 mapf.Add(f);
602 TopExp_Explorer exe(f,TopAbs_EDGE);
603 for (; exe.More(); exe.Next()){
604 const TopoDS_Edge& e = TopoDS::Edge(exe.Current());
605 if (e.IsSame(E)) continue;
606 Standard_Integer iori = FUN_tool_orientVinE(V,e);
607 if (iori == 0) continue;
608 const TopTools_ListOfShape& lf2 = FDSCNX_EdgeConnexitySameShape(e,HDS);
609 TopTools_ListIteratorOfListOfShape it2(lf2);
610 for (; it2.More(); it2.Next()) mapf.Add(it2.Value());
611 } // exe
612 } // it1
613 TopTools_MapIteratorOfMapOfShape itm(mapf);
614 for (; itm.More(); itm.Next()) lFcx.Append(itm.Key());
615 return lFcx.Extent();
616}
617#endif*/
618
619// ----------------------------------------------------------------------
620Standard_EXPORT void FUN_ds_PURGEforE9(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
621// ----------------------------------------------------------------------
622{
623 // xpu040998 : line gives myLineINL=true, interference on geometry
624 // edge/face describing contact on geometry -> EPIe + EPIf = 3dI
625 // EPIf is faulty if edge is in face's geometry
626 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
627 Standard_Integer ns = BDS.NbShapes();
628 for (Standard_Integer i = 1; i <= ns; i++) {
629 const TopoDS_Shape& EE = BDS.Shape(i);
630 if (EE.ShapeType() != TopAbs_EDGE) continue;
631
632 const TopoDS_Edge& E = TopoDS::Edge(EE);
633 Standard_Boolean isdgE = BRep_Tool::Degenerated(E);
634 if (isdgE) continue;
635
636 Standard_Integer IE = BDS.Shape(E);
0797d9d3 637#ifdef OCCT_DEBUG
7fd59977 638 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
639 if (trc) debe9(IE);
640#endif
641 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
642 TopOpeBRepDS_ListOfInterference LIcopy; FDS_assign(LI,LIcopy);
643 TopOpeBRepDS_ListOfInterference l3dF; Standard_Integer n3dF = FUN_selectSKinterference(LIcopy,TopOpeBRepDS_FACE,l3dF);
644 if (n3dF == 0) continue;
645
646 const TopTools_ListOfShape& lfcxE = FDSCNX_EdgeConnexitySameShape(E,HDS);
647 Standard_Integer nlfcxE = lfcxE.Extent();
648 if (nlfcxE == 0) continue; // NYIRaise
649 TopTools_ListIteratorOfListOfShape itf(lfcxE);
650 TopTools_IndexedMapOfShape mapf; for (; itf.More(); itf.Next()) mapf.Add(itf.Value());
651
652 Standard_Boolean removed = Standard_False;
653 TopOpeBRepDS_ListIteratorOfListOfInterference it(l3dF);
654 while (it.More()) {
655 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
656 TopAbs_ShapeEnum SB,SA;Standard_Integer IB,IA;TopOpeBRepDS_Kind GT,ST;Standard_Integer G,S;
657 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
658 Standard_Boolean FhasGE = FDS_SIisGIofIofSBAofTofI(BDS,IE,I);
659 if (FhasGE) {removed = Standard_True; l3dF.Remove(it); continue;} // E has split ON F (cto904A3;e19,f14)
660 const TopoDS_Shape& F = BDS.Shape(S);
661 Standard_Boolean hsdm = HDS->HasSameDomain(F);
662 if (!hsdm) {it.Next(); continue;}
663 TopTools_ListIteratorOfListOfShape issdm(BDS.ShapeSameDomain(F));
664 Standard_Boolean foundinsdm = Standard_False;
665 for (; issdm.More(); issdm.Next())
666 if (mapf.Contains(issdm.Value())) {foundinsdm = Standard_True; break;}
667 if (!foundinsdm) {it.Next(); continue;} // E is IN geometry(F) (cto002D2;e33,f31)
668
669 // E is edge of FF sdm with F
0797d9d3 670#ifdef OCCT_DEBUG
7fd59977 671 if (trc) {cout<<"-> SE9 removing I3dF :";I->Dump(cout);cout<<endl;}
672#endif
673 removed = Standard_True; l3dF.Remove(it);
674 } //it(l3dF)
675
676 if (!removed) continue;
677 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(E);
678 LII.Clear(); LII.Append(LIcopy); LII.Append(l3dF);
679 } //i=1..ns
680} // PURGEforE9
681
682// ----------------------------------------------------------------------
683Standard_EXPORT void FUN_ds_completeforSE1(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
684// ----------------------------------------------------------------------
685{
686 // xpu160398 complement for INTERNAL transitions on section edge
687 // recall : we add geometry G on section edge SE only if
688 // SE has ISE=(T(face F),G,edge ES),
689 // && F has IF =(T,SE,S).
690 //
691 // purpose : SE has ISE=(T(face F'),G,edge),
692 // F' has no interference with support==SE
693 // => looking for F / F and F' share ES,
694 // F sdm with Fanc (one face ancestor of ES)
695 // F has I' = (T,SE,S).
696 // cto 009 D1
697
698 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
699 Standard_Integer nse = BDS.NbSectionEdges();
700
701 for (Standard_Integer i = 1; i <= nse; i++) {
702 const TopoDS_Edge& SE = BDS.SectionEdge(i);
703 Standard_Integer ISE = BDS.Shape(SE);
704 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
0797d9d3 705#ifdef OCCT_DEBUG
7fd59977 706 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
707 if (trc) debse1(ISE);
708#endif
709
710 TopOpeBRepDS_TKI tki;
711 tki.FillOnGeometry(LI);
712 for (tki.Init(); tki.More(); tki.Next()) {
713
714 // ISE = (INTERNAL(FACE),G,EDGE) :
715 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
716 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
717 TopOpeBRepDS_ListOfInterference lI1; Standard_Boolean hasINT = ::FUN_selectTRAINTinterference(loicopy,lI1);
718 if (!hasINT) continue;
719 TopOpeBRepDS_ListOfInterference lI2; Standard_Integer nI = FUN_selectTRASHAinterference(lI1,TopAbs_FACE,lI2);
720 if (nI < 1) continue;
721 TopOpeBRepDS_ListOfInterference lI3; nI = FUN_selectSKinterference(lI2,TopOpeBRepDS_EDGE,lI3);
722 if (nI < 1) continue;
723
724 Standard_Boolean keepI = Standard_False;
725// for (TopOpeBRepDS_ListIteratorOfListOfInterference it(lI3) ;it.More(); it.Next()){
726 TopOpeBRepDS_ListIteratorOfListOfInterference it(lI3) ;
727 for ( ;it.More(); it.Next()){
728 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
729 keepI = FDS_SIisGIofIofSBAofTofI(BDS,ISE,I);
730 if (keepI) break;
731 }
732 if (keepI) continue;
733
734 // ISE = (INTERNAL(F),G,ES), F has no I with G==SE
735 // find fSE / fSE (SE's ancestor face) has IfSE = (T,SE,support)
736 // - fSE sdm & fES (ES's ancestor face) -
737// for (it.Initialize(lI3) ;it.More(); it.Next()){
738 it.Initialize(lI3) ;
739 for ( ;it.More(); it.Next()){
740 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
0797d9d3 741#ifdef OCCT_DEBUG
7fd59977 742// const TopOpeBRepDS_Transition& T = I->Transition();
743#endif
744 TopOpeBRepDS_Kind GT,ST;
745 Standard_Integer G1,S;
746 FDS_data(I,GT,G1,ST,S);
747 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
748 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
749 TopoDS_Face fSE,fES; Standard_Boolean sdmf = ::FUN_ds_hasSDMancestorfaces(HDS,SE,ES, fSE,fES);
750 if (!sdmf) continue;
751 Standard_Integer IfES = BDS.Shape(fES);
752
753 const TopOpeBRepDS_ListOfInterference& LIf = BDS.ShapeInterferences(fES);
754 TopOpeBRepDS_ListOfInterference LIfcopy; FDS_copy(LIf,LIfcopy);
755 TopOpeBRepDS_ListOfInterference LIfound; Standard_Integer nfound = FUN_selectGIinterference(LIfcopy,ISE,LIfound);
756 if (nfound < 1) continue;
757
758 // cto 009 B1 : Ifor=(FORWARD(IfES),G1,S) && Irev=(REVERSED(IfES),G1,S)
759 // -> do NOT reduce to I = (INTERNAL(IfES),G1,S) (we can have EXTERNAL Tr)
760 FDS_copy(loi,loicopy);
761 TopOpeBRepDS_ListOfInterference lI4;
0797d9d3 762#ifdef OCCT_DEBUG
7fd59977 763// Standard_Integer nI4 =
764#endif
765 FUN_selectITRASHAinterference(loicopy,IfES,lI4);
766 Standard_Boolean hasFORREV=Standard_False;
767 TopOpeBRepDS_ListOfInterference lfor; Standard_Integer nFOR = FUN_selectTRAORIinterference(lI4,TopAbs_FORWARD,lfor);
768 TopOpeBRepDS_ListOfInterference lrev; Standard_Integer nREV = FUN_selectTRAORIinterference(lI4,TopAbs_REVERSED,lrev);
769 hasFORREV = (nFOR > 0) || (nREV > 0);
770 if (hasFORREV) break;
771
772 // newI :
773 // -----
774 TopOpeBRepDS_Transition newT(TopAbs_INTERNAL);
775 newT.Index(IfES);
776 Standard_Real par = FDS_Parameter(I);
777 Standard_Boolean isevi = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
778 Standard_Boolean B = Standard_False;
779 if (isevi) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
780 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,G1,par,K,TopOpeBRepDS_EDGE,B);
0797d9d3 781#ifdef OCCT_DEBUG
7fd59977 782 if (trc) {
783 cout<<"completeforSE1 on section edge "<<ISE<<" ";
784 newI->Dump(cout);
785 cout<<endl;
786 }
787#endif
788 HDS->StoreInterference(newI,SE);
789 break;
790 } // it(lI3)
791 } // tki
792 } // i=1..nse
793} // completeforSE1
794
795// ----------------------------------------------------------------------
796Standard_EXPORT void FUN_ds_completeforSE2(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
797// ----------------------------------------------------------------------
798{
799 // xpu250398 compute 3dI
800 // recall : to have spOUT(SE) / spIN(SE) with SE section edge on bound G
801 // we need IF = (T(F),G,F) with G not SE bound.
802 //
803 // purpose : Sometimes for gap's reasons we can miss such interference.
804 // attached to ES, IFE = (T(FTRA),G,ES) with G not Gbound
805 // we find no IF = (T(FTRA),G,FTRA)
806 // 1. look for FCX / FCX shares ES with FTA (recall : rkG==rkFCX)
807 // 2. compute I3d = (T2(FCX),G,FCX)
808 // !!! if SE has splits ON F near G (if we have a 2dI near G) -> do NOT add I3d
809 // PRO12696 : on se 46 (create FEI/ f50)
810
811 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
812 Standard_Integer nse = BDS.NbSectionEdges();
813
814 for (Standard_Integer i = 1; i <= nse; i++) {
815 const TopoDS_Edge& SE = TopoDS::Edge(BDS.SectionEdge(i));
816 Standard_Integer rkSE = BDS.AncestorRank(SE);
0797d9d3 817#ifdef OCCT_DEBUG
7fd59977 818 Standard_Integer ISE =
819#endif
820 BDS.Shape(SE);
821 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
0797d9d3 822#ifdef OCCT_DEBUG
7fd59977 823 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
824 if (trc) debse2(ISE);
825#endif
826
827 TopOpeBRepDS_TKI tki;
828 tki.FillOnGeometry(LI);
829 for (tki.Init(); tki.More(); tki.Next()) {
830
831 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
832 Standard_Boolean point = (K == TopOpeBRepDS_POINT);
833 Standard_Boolean vertex = (K == TopOpeBRepDS_VERTEX);
834
835 // interferences on GBound=1 not treated
836 Standard_Boolean try1 = Standard_True;
837 if (vertex) {
838 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
839 TopoDS_Vertex OOv; Standard_Boolean hasOO = FUN_ds_getoov(vG,HDS,OOv);
840 Standard_Integer ovSE = FUN_tool_orientVinE(vG,SE);
841 if ((ovSE == 0) && hasOO) ovSE = FUN_tool_orientVinE(OOv,SE);
842 if (ovSE != 0) try1 = Standard_False;
843 }
844 if (!try1) continue;
845
846 // SE has {I=(T(face), G not Gbound, edge)}
847 // has NO {I'=(T'(face'), G not Gbound, face')}
848 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
849 TopOpeBRepDS_ListOfInterference l1;
0797d9d3 850#ifdef OCCT_DEBUG
7fd59977 851// Standard_Integer nI =
852#endif
853 FUN_selectTRASHAinterference(loicopy,TopAbs_FACE,l1);
854 TopOpeBRepDS_ListOfInterference lF; Standard_Integer nF = FUN_selectSKinterference(l1,TopOpeBRepDS_FACE,lF);
855 if (nF > 1) continue;
856 TopOpeBRepDS_ListOfInterference lFE; Standard_Integer nFE = FUN_selectSKinterference(l1,TopOpeBRepDS_EDGE,lFE);
857 if (nFE == 0) continue;
858
859 // I = (T(FTRA),G not Gbound, ES)
860 const Handle(TopOpeBRepDS_Interference)& I = lFE.First();
861 Standard_Real par = FDS_Parameter(I);
0797d9d3 862#ifdef OCCT_DEBUG
7fd59977 863// const TopOpeBRepDS_Transition& T = I->Transition();
864#endif
865 TopOpeBRepDS_Kind ST; Standard_Integer S; FDS_data(I,K,G,ST,S);
866 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
867 const TopoDS_Face& FTRA= TopoDS::Face(BDS.Shape(isb));
868 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
869
870 // lfCX = {fCX / fCX shares ES with FTRA}
871 const TopTools_ListOfShape& lfCX = FDSCNX_EdgeConnexitySameShape(ES,HDS);
872 for (TopTools_ListIteratorOfListOfShape itfcx(lfCX); itfcx.More(); itfcx.Next()){
873 const TopoDS_Face& FCX = TopoDS::Face(itfcx.Value());
874 Standard_Integer IFCX = BDS.Shape(FCX);
875 if (FCX.IsSame(FTRA)) continue;
876
877 // xpu140498 : NYI check SE has part ON FCX(with bound G)
878 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectITRASHAinterference(lFE,IFCX,l2);
879 if (n2 > 0) continue;
880
881 Standard_Real OOpar = 0.;
882 if (point) {
883 gp_Pnt p3d = BDS.Point(G).Point();
884 Standard_Real t1 = BDS.Point(G).Tolerance(); Standard_Real t2 = FUN_tool_maxtol(ES);
885 Standard_Real t = (t1 > t2) ? t1 : t2;
886 Standard_Real d = 1.e1;Standard_Boolean ok = FUN_tool_projPonE(p3d,ES,OOpar,d);
887 if (!ok) {FUN_Raise(); continue;}
888 if (d > t) {FUN_Raise(); continue;}
889 }
890 if (vertex) { // rkG == rkES
891 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
892 Standard_Integer rkG = BDS.AncestorRank(G);
893
894 // modified by NIZHNY-MKK Mon Apr 2 15:38:11 2001.BEGIN
895 // if (rkG == rkSE) OOpar = BRep_Tool::Parameter(vG,ES);
896 if (rkG == rkSE) {
897 Standard_Integer hasvG = FUN_tool_orientVinE(vG,ES);
898 if(hasvG==0) {
899 continue;
900 }
901 OOpar = BRep_Tool::Parameter(vG,ES);
902 }
903 // modified by NIZHNY-MKK Mon Apr 2 15:38:30 2001.END
904 else {
905 TopoDS_Shape oov; Standard_Boolean hasoov = FUN_ds_getoov(vG,BDS,oov);
906 if (!hasoov) {
907 Standard_Real t1 = BRep_Tool::Tolerance(vG); Standard_Real t2 = FUN_tool_maxtol(ES);
908 Standard_Real t = (t1 > t2) ? t1 : t2;
909 gp_Pnt p = BRep_Tool::Pnt(vG);
910 Standard_Real parES,dd=1.e1;
911 Standard_Boolean ok = FUN_tool_projPonE(p,ES,parES,dd);
912 if (!ok) {FUN_Raise(); continue;}
913 if (dd > t) {FUN_Raise(); continue;}
914 OOpar = parES;
915 }
916 else OOpar = BRep_Tool::Parameter(TopoDS::Vertex(oov),ES);
917 }
918 }
919
920 gp_Pnt2d OOuv; Standard_Boolean ok = FUN_tool_paronEF(ES,OOpar,FCX,OOuv);
921 if (!ok) {FUN_Raise(); continue;}
922
923 TopOpeBRepDS_Transition newT;
924 // -------
925 Standard_Boolean isonper; Standard_Real par1,par2; Standard_Real factor = 1.e-4;
926 FDS_LOIinfsup(BDS,SE,par,K,G,
927 BDS.ShapeInterferences(SE),par1,par2,isonper);
928
929 TopOpeBRepTool_makeTransition MKT;
1d47d8d0 930 TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
7fd59977 931 ok = MKT.Initialize(SE,par1,par2,par, FCX,OOuv, factor);
932 if (ok) ok = MKT.SetRest(ES,OOpar);
933 if (ok) ok = MKT.MkTonE(stb,sta);
934 if (!ok) {FUN_Raise(); continue;}
935 newT.Before(stb); newT.After(sta); newT.Index(IFCX);
936
937 Handle(TopOpeBRepDS_Interference) newI;
938 // --------
939 Standard_Boolean B = Standard_False;
940 if (vertex) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
941 newI = MakeEPVInterference(newT,IFCX,G,par,K,TopOpeBRepDS_FACE,B);
0797d9d3 942#ifdef OCCT_DEBUG
7fd59977 943 if (trc) {cout<<"completeforSE2 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
944#endif
945 HDS->StoreInterference(newI,SE);
946 } // itfcx
947 } // tki
948 } // nse
949} // completeforSE2
950
951
952static Standard_Boolean FUN_ds_completeforSE3(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& SE,
953 const TopOpeBRepDS_Kind K,
954// const Standard_Integer G,
955 const Standard_Integer ,
956 const TopOpeBRepDS_ListOfInterference& loi,
957 Standard_Real& parE, Standard_Integer& IES, Standard_Integer& ITRASHA, TopOpeBRepDS_Transition& Tr)
958{
959 if (K == TopOpeBRepDS_VERTEX) return Standard_False;
960 Standard_Integer ISE = BDS.Shape(SE);
961
962 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
963 TopOpeBRepDS_ListOfInterference lINT; Standard_Integer nINT = FUN_selectTRAORIinterference(loicopy,TopAbs_INTERNAL,lINT);
964 TopOpeBRepDS_ListOfInterference lEXT; Standard_Integer nEXT = FUN_selectTRAORIinterference(loicopy,TopAbs_EXTERNAL,lEXT);
965 Standard_Integer n1 = nINT + nEXT;
966 if (n1 < 1) return Standard_False;
967 TopOpeBRepDS_ListOfInterference l1; l1.Append(lINT); l1.Append(lEXT);
968
969 // b. I = (INT/EXT(F),G,S), F has I with G==ES
970 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectTRASHAinterference(l1,TopAbs_FACE,l2);
971 if (n2 < 1) return Standard_False;
972 Standard_Boolean okb = Standard_False;
973 for (TopOpeBRepDS_ListIteratorOfListOfInterference it2(l2); it2.More(); it2.Next()){
974 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
975 okb = FDS_SIisGIofIofSBAofTofI(BDS,ISE,I2);
976 if (okb) break;
977 }
978 if (!okb) return Standard_False;
979
980 // a. I3d = IFE+IF
981 TopOpeBRepDS_ListOfInterference l2e; Standard_Integer n2e = FUN_selectSKinterference(l2,TopOpeBRepDS_EDGE,l2e);
982 TopOpeBRepDS_ListOfInterference l2f; Standard_Integer n2f = FUN_selectSKinterference(l2,TopOpeBRepDS_FACE,l2f);
983 if ((n2e == 0) || (n2f == 0)) return Standard_False;
984 Standard_Integer sI3d = l2f.First()->Support();
985 TopOpeBRepDS_ListOfInterference l3d; Standard_Integer n3d = FUN_selectITRASHAinterference(l2e,sI3d,l3d);
986 if (n3d < 1) return Standard_False;
987
988 // Tr
989 //---
990 const Handle(TopOpeBRepDS_Interference)& I3 = l3d.First();
991 TopOpeBRepDS_Kind K3,ST3; Standard_Integer G3,S3; FDS_data(I3,K3,G3,ST3,S3);
992 TopAbs_ShapeEnum tsb3,tsa3; Standard_Integer isb3,isa3; FDS_Tdata(I3,tsb3,isb3,tsa3,isa3);
993 IES = S3; ITRASHA = isb3;
994
995 const TopoDS_Edge& Eline = TopoDS::Edge(BDS.Shape(IES));
996 const TopoDS_Face& F = TopoDS::Face(BDS.Shape(ITRASHA));
997 parE = FDS_Parameter(I3);
998
999 Standard_Real parline; Standard_Boolean ok = FUN_tool_parE(SE,parE,Eline,parline);
1000 if (!ok) {FUN_Raise(); return Standard_False;}
1001 gp_Pnt2d uv; ok = FUN_tool_paronEF(Eline,parline,F,uv);
1002 if (!ok) {FUN_Raise(); return Standard_False;}
1003 Standard_Real par1,par2; FUN_tool_bounds(SE,par1,par2);
1004 Standard_Real factor = 1.e-4;
1005
1006
1d47d8d0 1007 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
7fd59977 1008 ok = MKT.Initialize(SE,par1,par2,parE, F,uv, factor);
1009 if (ok) ok = MKT.SetRest(Eline,parline);
1010 if (ok) ok = MKT.MkTonE(stb,sta);
1011 if (!ok) {FUN_Raise(); return Standard_False;}
1012 Tr.Before(stb); Tr.After(sta); Tr.Index(ITRASHA);
1013 return Standard_True;
1014}
1015
1016// ----------------------------------------------------------------------
1017Standard_EXPORT void FUN_ds_completeforSE3(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1018// ----------------------------------------------------------------------
1019{
1020 // xpu170498 : t3 (splits of e7)
1021 // prequesitory :
1022 // edge SE - a. is tangent to FTRA on ES at G, has NO SPLIT ON FTRA (near G).
1023 // - b. has splitON FCX (FCX and FTRA share ES)
1024 // a. IFE=(T(FTRA),Gpoint,ES) && IF=(T(FTRA),Gpoint,FTRA)
1025 // T describes T3d
1026 // b. IFE=(T'(FCX),Gpoint,S) / FCX has I=(T'',SE,SS)
1027 //
1028 // purpose : when T(FTRA) is INTERNAL/EXTERNAL, the compute of spIN/spOU fails,
1029 // => compute interference I3d=IFE + IF with T==FORWARD/REVERSED.
1030
1031 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1032 Standard_Integer nse = BDS.NbSectionEdges();
1033 for (Standard_Integer i = 1; i <= nse; i++) {
1034 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1035 Standard_Integer ISE = BDS.Shape(SE);
1036 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
0797d9d3 1037#ifdef OCCT_DEBUG
7fd59977 1038 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1039 if (trc) debse3(ISE);
1040#endif
1041
1042 TopOpeBRepDS_ListOfInterference newLI; Standard_Boolean hasnewLI = Standard_False;
1043 TopOpeBRepDS_TKI tki;
1044 tki.FillOnGeometry(LI);
1045 for (tki.Init(); tki.More(); tki.Next()) {
1046
1047 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1048 Standard_Real parE; Standard_Integer IES=0, ITRASHA=0; TopOpeBRepDS_Transition Tr;
1049 Standard_Boolean ok = FUN_ds_completeforSE3(BDS,SE,K,G,loi,parE,IES,ITRASHA,Tr);
1050
1051 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1052 if (!ok) {newLI.Append(loicopy); continue;}
1053
1054 // delete interferences =(T(face IF),G,S)
1055 TopOpeBRepDS_ListOfInterference lIdel;
1056 FUN_selectITRASHAinterference(loicopy,ITRASHA,lIdel);
0797d9d3 1057#ifdef OCCT_DEBUG
7fd59977 1058 if (trc) {FDS_dumpLI(lIdel,"completeforSE3, delete :");}
1059#endif
1060
1061 Handle(TopOpeBRepDS_Interference) TrFE, TrFF;
1062 //--------------
1063 hasnewLI = Standard_True;
1064 TrFE = MakeEPVInterference(Tr, ISE,G,parE,K,TopOpeBRepDS_EDGE,Standard_False);
1065 TrFF = MakeEPVInterference(Tr,ITRASHA,G,parE,K,TopOpeBRepDS_FACE,Standard_False);
0797d9d3 1066#ifdef OCCT_DEBUG
7fd59977 1067 if (trc) {cout<<"completeforSE3 on section edge "<<ISE<<" ";TrFE->Dump(cout);cout<<endl;}
1068 if (trc) {cout<<"completeforSE3 on section edge "<<ISE<<" ";TrFF->Dump(cout);cout<<endl;}
1069#endif
1070
1071 newLI.Append(TrFF); newLI.Append(TrFE); newLI.Append(loicopy);
1072 } // tki
1073
1074 if (hasnewLI) {
1075 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE); LII.Clear();
1076 LII.Append(newLI);
1077 }
1078
1079 } //i=1..nse
1080} // completeforSE3
1081
1082// ----------------------------------------------------------------------
1083Standard_EXPORT Standard_Boolean FUN_ds_shareG
1084(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const Standard_Integer iF1,const Standard_Integer iF2,
1085 const Standard_Integer iE2, const TopoDS_Edge& Esp, Standard_Boolean& shareG)
1086// ----------------------------------------------------------------------
1087// F1 sdm F2, share Esp (split of E2)
1088{
1089 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
1090 Standard_Boolean hsdm = HDS->HasSameDomain(BDS.Shape(iE2));
1091 if (!hsdm) return Standard_False;
1092
1093 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(iF1));
1094 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
1095 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(iE2));
1096
1097 Standard_Real tol = Precision::Confusion()*1.e3;
1098 Standard_Real f,l; FUN_tool_bounds(Esp,f,l);
1099 Standard_Real x = 0.45678; Standard_Real par = (1-x)*f + x*l;
1100 gp_Pnt P; Standard_Boolean ok = FUN_tool_value(par,Esp,P);
1101 if (!ok) return Standard_False;
1102
1103 Standard_Real d2,par2; ok = FUN_tool_projPonE(P,E2,par2,d2);
1104 if (!ok) return Standard_False;
1105 if (d2 > tol) return Standard_False;
1106
1107 gp_Vec nggeomF2; ok = FUN_tool_nggeomF(par2,E2,F2,nggeomF2);
1108 if (!ok) return Standard_False;
1109 gp_Dir nxx2; ok = FUN_tool_getxx(F2,E2,par2,nggeomF2,nxx2);
1110 if (!ok) return Standard_False;
1111
1112
1113 TopTools_IndexedMapOfShape mE1; TopExp::MapShapes(F1,TopAbs_EDGE,mE1);
1114 const TopTools_ListOfShape& sdmE1 = BDS.ShapeSameDomain(iE2);
1115 for (TopTools_ListIteratorOfListOfShape it(sdmE1); it.More(); it.Next()){
1116 const TopoDS_Edge& E1 = TopoDS::Edge(it.Value());
1117 Standard_Boolean isb = mE1.Contains(E1);
1118 if (!isb) continue;
1119
1120 Standard_Real d1,par1; ok = FUN_tool_projPonE(P,E1,par1,d1);
1121 if (!ok) continue;
1122 if (d1 > tol) continue;
1123
1124 // E1 on F1, E2 on F2, E1 and E2 share split Esp(nyi : check it)
1125 gp_Vec nggeomF1; ok = FUN_tool_nggeomF(par1,E1,F1,nggeomF1);
1126 if (!ok) return Standard_False;
1127 gp_Dir nxx1; ok = FUN_tool_getxx(F1,E1,par1,nggeomF1,nxx1);
1128 if (!ok) return Standard_False;
1129
7fd59977 1130 Standard_Real prod = nxx1.Dot(nxx2);
1131 shareG = (prod > 0.);
1132 return Standard_True;
1133 }
1134 return Standard_False;
1135}
1136// ----------------------------------------------------------------------
1137Standard_EXPORT Standard_Boolean FUN_ds_mkTonFsdm
1138(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const Standard_Integer iF1, const Standard_Integer iF2, const Standard_Integer iE2,
1139 const Standard_Integer iEG, const Standard_Real paronEG, const TopoDS_Edge& Esp, const Standard_Boolean pardef,
1140 TopOpeBRepDS_Transition& T)
1141// ----------------------------------------------------------------------
1142// =================================
1143// prequesitory : F1 and F2 are SDSO
1144// =================================
1145// F1 sdm F2, EG has split ON F1 shared by F2
1146//
1147// EG and E2 share geometric point G (of param paronEG)
1148// pardef = Standard_True : paronEG is defined
1149// else : use Esp to find paronEG, Esp is split of EG
1150// (!! we can have EG==E2)
1151//
1152// purpose : computes 2d transition of F1 when crossing EG relative to
1153// 2dmatter(F2) limited by E2 :
1154// -> 2d FEI attached to F1 = (T(F2), G=EG, S=F2)
1155{
1156 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
1157 Standard_Boolean hsdm = HDS->HasSameDomain(BDS.Shape(iE2));
1158 if (!hsdm) return Standard_False;
1159
1160 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(iF1));
1161 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
1162 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(iE2));
1163 const TopoDS_Edge& EG = TopoDS::Edge(BDS.Shape(iEG));
1164
1165 Standard_Boolean EGisE2 = (iEG == iE2);
1166 Standard_Real tol = Precision::Confusion()*1.e3;
1167
1168 // beafter :
1169 // ---------
1170 Standard_Boolean ok = Standard_False;
1171 gp_Pnt P; Standard_Real parEG;
1172 if (pardef) parEG = paronEG;
1173 else {
1174 Standard_Real f,l; FUN_tool_bounds(Esp,f,l);
0797d9d3 1175#ifdef OCCT_DEBUG
7fd59977 1176 // Standard_Real x = 0.45678;
1177 // Standard_Real par = (1-x)*f + x*l;
1178#endif
1179 Standard_Real dEG; ok = FUN_tool_projPonE(P,EG,parEG,dEG);
1180 if (!ok) return Standard_False;
1181 if (dEG > tol) return Standard_False;
1182 }
1183 ok = FUN_tool_value(parEG,EG,P);
1184 if (!ok) return Standard_False;
1185 gp_Vec tgtEG ; ok = TopOpeBRepTool_TOOL::TggeomE(parEG,EG,tgtEG);
1186 if (!ok) return Standard_False;
1187 gp_Vec ngF1; ok = FUN_tool_nggeomF(parEG,EG,F1,ngF1);
1188 if (!ok) return Standard_False;
1189 gp_Vec beafter = ngF1^tgtEG;
1190
1191 // nxx2 :
1192 // ------
1193 Standard_Real par2;
1194 if (EGisE2) par2 = parEG;
1195 else {
1196 Standard_Real d2; ok = FUN_tool_projPonE(P,E2,par2,d2);
1197 if (!ok) return Standard_False;
1198 if (d2 > tol) return Standard_False;
1199 }
1200 gp_Vec ngF2; ok = FUN_tool_nggeomF(par2,E2,F2,ngF2);
1201 if (!ok) return Standard_False;
1202 gp_Dir nxx2; ok = FUN_tool_getxx(F2,E2,par2,ngF2,nxx2);
1203 if (!ok) return Standard_False;
1204
1205 // T :
1206 // ---
1207 Standard_Boolean sdmEGE2 = EGisE2;
1208 if (!sdmEGE2) sdmEGE2 = FUN_ds_sdm(BDS,EG,E2);
1209 if (!sdmEGE2) return Standard_False;
1210
1211 Standard_Real prod = beafter.Dot(nxx2);
1212 Standard_Real tola = Precision::Angular()*1.e3;
1213 ok = (Abs(1- Abs(prod)) < tola);
1214 if (!ok) return Standard_False;
1215
1216 if (prod > 0.) T = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
1217 else T = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
1218 return Standard_True;
1219}
1220
1221#define UNKNOWN (0)
1222#define ONSAMESHA (1)
1223#define CLOSESAME (11)
1224#define ONOPPOSHA (2)
1225#define CLOSEOPPO (22)
1226#define FORREVOPPO (222)
1227
1228Standard_EXPORT Standard_Integer FUN_ds_oriEinF(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& E, const TopoDS_Shape& F,
1229 TopAbs_Orientation& O)
1230// purpose :
1231// * E is edge of F :returns orientation of E in F
1232// * E is edge of Fsd : Fsd sdm with F,
1233// returns orientation of E in F /E describes the same 2d area in F as in Fsd
1234// * !! if E is closing edge, returns CLOSESAME or CLOSEOPPO
1235{
1236 O = TopAbs_EXTERNAL;
1237 Standard_Integer rkF = BDS.AncestorRank(F);
1238 Standard_Integer rkE = BDS.AncestorRank(E);
1239
1240 const TopoDS_Edge& EE = TopoDS::Edge(E);
1241 const TopoDS_Face& FF = TopoDS::Face(F);
1242 Standard_Integer iF = BDS.Shape(F);
1243 TopAbs_Orientation oF = BDS.Shape(iF).Orientation();
1244
1245 if (rkF == rkE) {
1246 Standard_Boolean samsha = FUN_tool_orientEinFFORWARD(EE,FF,O);
1247 if (samsha) {
1248 Standard_Boolean iscE = BRep_Tool::IsClosed(EE,FF);
1249 if (iscE) return CLOSESAME;
1250 else return ONSAMESHA;
1251 }
1252 else return UNKNOWN;
1253 }
1254 else {
1255 const TopTools_ListOfShape& sdmFs = BDS.ShapeSameDomain(FF);
1256 Standard_Boolean hsdm = (sdmFs.Extent() > 0);
1257
1258 if (hsdm) {
1259 Standard_Boolean hasFOR=Standard_False, hasREV=Standard_False; // xpu120898 (PRO14785 : e36 shared by f34 & f39,
1260 // faces sdm with f16)
1261 TopOpeBRepDS_Config C = BDS.SameDomainOri(FF);
1262
1263 for (TopTools_ListIteratorOfListOfShape it(sdmFs); it.More(); it.Next()){
1264 const TopoDS_Face& Fsdm = TopoDS::Face(it.Value());
1265 Standard_Integer iFsdm = BDS.Shape(Fsdm);
1266 Standard_Integer rksdm = BDS.AncestorRank(Fsdm);
1267 if (rksdm == rkF) continue;
1268
1269 Standard_Boolean samsha = FUN_tool_orientEinFFORWARD(EE,Fsdm,O);
1270 if (!samsha) continue;
1271
1272 Standard_Boolean iscE = BRep_Tool::IsClosed(EE,Fsdm);
1273 if (iscE) return CLOSEOPPO;
1274 else {
1275 TopOpeBRepDS_Config Csdm = BDS.SameDomainOri(Fsdm);
1276 Standard_Boolean toreverse1 = (Csdm != C) && (!M_INTERNAL(O)) && (!M_EXTERNAL(O));
1277 if (toreverse1) O = TopAbs::Complement(O);
1278
1279 TopAbs_Orientation oFsdm = BDS.Shape(iFsdm).Orientation();
1280 Standard_Boolean toreverse2 = (oF != oFsdm) && (!M_INTERNAL(oFsdm)) && (!M_EXTERNAL(oFsdm));
1281 if (toreverse2) O = TopAbs::Complement(O);
1282 if (!hasFOR) hasFOR = M_FORWARD(O);
1283 if (!hasREV) hasREV = M_REVERSED(O);
1284 }
1285 } // it(sdmFs)
1286 if (hasFOR && hasREV) return FORREVOPPO;
1287 if (hasFOR || hasREV) {
1288 O = hasFOR ? TopAbs_FORWARD : TopAbs_REVERSED;
1289 return ONOPPOSHA;
1290 }
1291 }
1292 else return UNKNOWN;
1293 }
1294 return UNKNOWN;
1295}
1296
1297#define NONE (0)
1298#define EREFandESUP (2)
1299#define FIRST (1)
1300#define LAST (2)
1301static Standard_Integer FUN_EisSE2(const TopOpeBRepDS_DataStructure& BDS,
1302// const TopTools_MapOfShape& Fsdm,
1303 const TopTools_MapOfShape& ,
1304 const TopoDS_Edge& E,
1305 const Handle(TopOpeBRepDS_Interference)& I)
1306{
1307 const TopOpeBRepDS_Transition& T = I->Transition();
1308 const TopAbs_Orientation O = T.Orientation(TopAbs_IN);
1309 TopAbs_ShapeEnum SB,SA;Standard_Integer IB,IA;TopOpeBRepDS_Kind GT,ST;Standard_Integer G,S;
1310 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
1311 if (GT != TopOpeBRepDS_VERTEX) return NONE;
1312 if (M_EXTERNAL(O)) return NONE;
1313
1314 // E sdm ES
1315 if (SB != TopAbs_EDGE) return NONE;
1316// BDS.Shape(S);
1317
1318 Standard_Integer rkE = BDS.AncestorRank(E);
1319 Standard_Integer rkG = BDS.AncestorRank(G);
1320 const TopoDS_Vertex& VG = TopoDS::Vertex(BDS.Shape(G));
1321 Standard_Integer Gsd; Standard_Boolean Ghsd = FUN_ds_getVsdm(BDS,G,Gsd);
1322 Standard_Integer oGinE = 0;
1323 if (Ghsd) {
1324 const TopoDS_Vertex& VGsd = TopoDS::Vertex(BDS.Shape(Gsd));
1325 if (rkE == rkG) oGinE = FUN_tool_orientVinE(VG,E);
1326 else oGinE = FUN_tool_orientVinE(VGsd,E);
1327 }
1328 else oGinE = FUN_tool_orientVinE(VG,E);
1329
1330 if (oGinE == 0) return EREFandESUP; // G in IN E
1331
1332 Standard_Boolean noshare = ((oGinE == LAST) && M_FORWARD(O));
1333 noshare = noshare || ((oGinE == FIRST) && M_REVERSED(O));
1334 if (noshare) return NONE;
1335
1336 if (SB == TopAbs_EDGE) {// E sdm edge(ST)
1337 if (!Ghsd) return EREFandESUP;
1338 return EREFandESUP;
1339 }
1340
1341 return NONE;
1342}
1343Standard_EXPORT void FUN_ds_FillSDMFaces(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1344{
1345 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1346 Standard_Integer ns = BDS.NbShapes();
1347
1348 for (Standard_Integer i= 1; i <= ns; i++) {
1349 const TopoDS_Shape& S = BDS.Shape(i);
1350 if (S.ShapeType() != TopAbs_FACE) continue;
1351
1352 Standard_Integer rkS = BDS.AncestorRank(S);
1353 TopTools_MapOfShape Fsdm;
1354 TopTools_ListIteratorOfListOfShape itf(BDS.ShapeSameDomain(S));
1355 for (; itf.More(); itf.Next()){
1356 const TopoDS_Shape& f = itf.Value();
1357 Standard_Integer rkf = BDS.AncestorRank(f);
1358 if (rkf != rkS) Fsdm.Add(f);
1359 }
1360 Standard_Boolean hsd = (Fsdm.Extent() > 0);
1361 if (!hsd) continue;
1362
1363 TopExp_Explorer ex(S, TopAbs_EDGE);
1364 for (; ex.More(); ex.Next()){
1365 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
1366 Standard_Boolean hase = BDS.HasShape(E);
1367 if (!hase) continue;
1368 Standard_Boolean isse = BDS.IsSectionEdge(E);
1369 if (isse) continue;
1370 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
1371 Standard_Integer nI = LI.Extent();
1372 if (nI < 1) continue;
1373
1374 TopOpeBRepDS_ListIteratorOfListOfInterference it;
1375 for (it.Initialize(LI); it.More(); it.Next()){
1376 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
1377 Standard_Integer isSE2 = FUN_EisSE2(BDS,Fsdm,E,I);
1378 if (isSE2 == NONE) continue;
1379 BDS.AddSectionEdge(E);
1380 if (isSE2 == EREFandESUP) {
1381 Standard_Integer ST = I->Support();
1382 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(ST));
1383 BDS.AddSectionEdge(ES);
1384 }
1385 break;
1386 }
1387 } // ex(S, TopAbs_EDGE);
1388 } // i = i..ns
1389}
1390
1391Standard_EXPORT void FUN_ds_addSEsdm1d(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1392{
1393 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1394 Standard_Integer ns = BDS.NbShapes();
1395 for (Standard_Integer i= 1; i <= ns; i++) {
0797d9d3 1396#ifdef OCCT_DEBUG
7fd59977 1397 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(i);
1398 if (trc) debsdm1(i);
1399#endif
1400 const TopoDS_Shape& S = BDS.Shape(i);
1401 if (S.ShapeType() != TopAbs_EDGE) continue;
1402 const TopoDS_Edge& E = TopoDS::Edge(S);
1403 Standard_Boolean dgE = BRep_Tool::Degenerated(E);
1404 if (dgE) continue;
1405
1406 Standard_Boolean isse = BDS.IsSectionEdge(E);
1407 if (isse) continue;
1408 Standard_Integer rkE = BDS.AncestorRank(E);
1409 if (rkE != 1) continue;
1410
1411 Standard_Boolean shareG = Standard_False;
1412 TopTools_ListOfShape lsd;
1413 TopOpeBRepDS_TOOL::EShareG(HDS,E,lsd);
1414 TopTools_ListIteratorOfListOfShape itsd(lsd);
1415 if (itsd.More()) shareG = Standard_True;
1416 for (; itsd.More(); itsd.Next()) BDS.AddSectionEdge(TopoDS::Edge(itsd.Value()));
1417 if (shareG) BDS.AddSectionEdge(E);
1418 }//i=1..ns
1419}// FUN_ds_addSEsdm1d
1420
1421Standard_EXPORT Standard_Integer FUN_ds_hasI2d(
1422// const Standard_Integer EIX,
1423 const Standard_Integer ,
1424 const TopOpeBRepDS_ListOfInterference& LLI,
1425 TopOpeBRepDS_ListOfInterference& LI2d)
1426{
1427 // LI : attached to EIX at given G
1428 // recall : I3d if I1=(T(FTRA),G,FTRA) && I2=(T(FTRA),G,E)
1429 // I2d if only I=(T(FTRA),G,E) (=>EIX is on FF sdm with FTRA)
1430
1431 TopOpeBRepDS_ListOfInterference LI; FDS_assign(LLI,LI);
1432 TopOpeBRepDS_ListOfInterference L1dE; FUN_selectTRASHAinterference(LI,TopAbs_EDGE,L1dE);
1433 TopOpeBRepDS_ListOfInterference LIF;FUN_selectSKinterference(LI,TopOpeBRepDS_FACE,LIF);
1434 TopOpeBRepDS_ListOfInterference LIE;FUN_selectSKinterference(LI,TopOpeBRepDS_EDGE,LIE);
1435 LI.Append(L1dE);
1436 TopOpeBRepDS_ListIteratorOfListOfInterference itE(LIE);
1437 for (; itE.More(); itE.Next()){
1438 const Handle(TopOpeBRepDS_Interference)& IE = itE.Value();
1439 TopOpeBRepDS_Kind GTE,STE; Standard_Integer GE,SE; FDS_data(IE,GTE,GE,STE,SE);
1440 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(IE,tsb,isb,tsa,isa);
1441
1442 TopOpeBRepDS_ListIteratorOfListOfInterference itF(LIF);
1443 Standard_Boolean is3d = Standard_False;
1444 for (; itF.More(); itF.Next()){
1445 const Handle(TopOpeBRepDS_Interference)& IF = itF.Value();
1446 TopOpeBRepDS_Kind GTF,STF; Standard_Integer GF,SF; FDS_data(IF,GTF,GF,STF,SF);
1447 if (GE != GF) continue;
1448 if (SF==isb) {
1449 is3d = Standard_True;
1450 break;
1451 }
1452 } // itF
1453 if (!is3d) LI2d.Append(IE);
1454 } // itE
1455 Standard_Integer nLI2d = LI2d.Extent();
1456 return nLI2d;
1457}
1458
1459// ----------------------------------------------------------------------
1460Standard_EXPORT void FUN_ds_completeforSE4(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1461// ----------------------------------------------------------------------
1462// xpu160698 : section edge SE intersects ES at G=point
1463// ES closing edge on FTRA
1464// we need to have transitions :
1465// T1=(OU/IN(FTRA),GP,ES)
1466// T2=(IN/OU(FTRA),GP,ES), for the compute of splitON
1467// PRO6965, (SE=e13,F=f6,ES=e12)
1468{
1469 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1470 Standard_Integer nse = BDS.NbSectionEdges();
1471 for (Standard_Integer i = 1; i <= nse; i++) {
1472 const TopoDS_Edge& SE = BDS.SectionEdge(i);
0797d9d3 1473#ifdef OCCT_DEBUG
7fd59977 1474 Standard_Integer ISE =
1475#endif
1476 BDS.Shape(SE);
1477 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
0797d9d3 1478#ifdef OCCT_DEBUG
7fd59977 1479 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1480 if (trc) debse4(ISE);
1481#endif
1482
1483 TopOpeBRepDS_ListOfInterference newLI;
1484 TopOpeBRepDS_TKI tki;
1485 tki.FillOnGeometry(LI);
1486 for (tki.Init(); tki.More(); tki.Next()) {
1487 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1488 if (K != TopOpeBRepDS_POINT) continue;
1489
1490 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1491 TopOpeBRepDS_ListOfInterference l1;
1492 FUN_selectSKinterference(loicopy,TopOpeBRepDS_EDGE,l1);
1493 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectTRASHAinterference(l1,TopAbs_FACE,l2);
1494 if (n2 < 1) continue;
1495
1496 const Handle(TopOpeBRepDS_Interference)& I = l2.First();
1497 TopOpeBRepDS_Kind GT,ST; Standard_Integer S; FDS_data(I,GT,G,ST,S);
1498 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
1499 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
1500 const TopoDS_Face& FTRA = TopoDS::Face(BDS.Shape(isb));
1501
1502 Standard_Boolean closing = FUN_tool_IsClosingE(ES,FTRA,FTRA);
1503 if (!closing) continue;
1504
1505 Standard_Boolean hasFOR=Standard_False,hasREV=Standard_False;
1506 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(l2); it.More(); it.Next()){
1507 const Handle(TopOpeBRepDS_Interference)& I2 = it.Value();
1508 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
1509 TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2; FDS_Tdata(I2,tsb2,isb2,tsa2,isa2);
1510 Standard_Boolean error = (S2 != S) || (isb2 != isb);
1511 if (error) return; // nyi raise
1512 TopAbs_Orientation O2 = I2->Transition().Orientation(TopAbs_IN);
1513 if (!hasFOR) hasFOR = M_FORWARD(O2);
1514 if (!hasREV) hasREV = M_REVERSED(O2);
1515 }
1516 if (!hasFOR && !hasREV) continue;
1517 if ( hasFOR && hasREV ) continue;
1518 TopAbs_Orientation newO = hasFOR ? TopAbs_REVERSED : TopAbs_FORWARD;
1519 TopOpeBRepDS_Transition newT(newO); newT.Index(isb);
1520 Standard_Real par = FDS_Parameter(I);
1521 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,G,par,K,Standard_False);
0797d9d3 1522#ifdef OCCT_DEBUG
7fd59977 1523 if (trc) {cout<<"completeforSE4 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
1524#endif
1525 HDS->StoreInterference(newI,SE);
1526 } // tki
1527 } // i=1..nse
1528}//completeforSE4
1529
1530// ----------------------------------------------------------------------
1531Standard_EXPORT void FUN_ds_completeforSE5(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1532// ----------------------------------------------------------------------
1533// xpu190698 : section edge SE has spON face F,
1534// FCX is tangent to F at G (FCX and F are on same shape)
1535// SE has I = (T(F),G,S), T=(OUT,OUT)
1536// I' = (T'(Fsd),G,Sedge), T' FORWARD or REVERSED
1537// T describes states (ON/OUT) or (OUT/ON)
1538// PRO12695 (SE20,P1,FCX16,F29)
1539// xpu131098 : SE has I = (T(F),G,S), T=(IN,IN)
1540// I' = (T'(Fsd),G,Sedge), T' FORWARD or REVERSED
1541// T describes states (ON/IN) or (OUT/IN)
1542//
1543// recall : for the compute of spOU/IN(ES), we need to interferences
1544// TskFACE = (T(FF),G,FF) T=FORWARD/REVERSED
1545// cto 902 D9 (SE17,P4,F29,FCX4)
1546{
1547 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1548 Standard_Integer nse = BDS.NbSectionEdges();
1549 for (Standard_Integer i = 1; i <= nse; i++) {
1550 const TopoDS_Edge& SE = BDS.SectionEdge(i);
0797d9d3 1551#ifdef OCCT_DEBUG
7fd59977 1552 Standard_Integer ISE =
1553#endif
1554 BDS.Shape(SE);
1555 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(SE);
0797d9d3 1556#ifdef OCCT_DEBUG
7fd59977 1557 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1558 if (trc) debse5(ISE);
1559#endif
1560
1561 // xpu020399 : cto901A2 (e26)
1562 TopOpeBRepDS_ListOfInterference LOIc; FDS_copy(LOI,LOIc);
1563 TopOpeBRepDS_ListOfInterference LI; Standard_Integer nI = FUN_selectSKinterference(LOIc,TopOpeBRepDS_EDGE,LI);
1564 if (nI < 1) continue;
1565
1566 TopOpeBRepDS_ListOfInterference newLI; Standard_Boolean hasnewLI = Standard_False;
1567 TopOpeBRepDS_TKI tki;
1568 tki.FillOnGeometry(LI);
1569 for (tki.Init(); tki.More(); tki.Next()) {
1570 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1571 if (K != TopOpeBRepDS_POINT) {FDS_copy(loi,newLI); continue;}
1572
1573 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1574 TopOpeBRepDS_ListOfInterference lext; Standard_Integer iext = FUN_selectTRAORIinterference(loicopy,TopAbs_EXTERNAL,lext);
1575 Standard_Boolean hasext = (iext > 0);
1576 TopOpeBRepDS_ListOfInterference lint; Standard_Integer iint = FUN_selectTRAORIinterference(loicopy,TopAbs_INTERNAL,lint);
1577 Standard_Boolean hasint = (iint > 0);
1578 if (!hasext && !hasint) {FDS_copy(loi,newLI); continue;}
1579 if (hasext && hasint) {FDS_copy(loi,newLI); continue;} // nyiFUN_RAISE : incoherent data
1580 // ------------------------------
1581
1582 // NYI : only select among 2dI!!! ******************************
1583 TopOpeBRepDS_ListOfInterference lfor; Standard_Integer ifor = FUN_selectTRAORIinterference(loicopy,TopAbs_FORWARD,lfor);
1584 TopOpeBRepDS_ListOfInterference lrev; Standard_Integer irev = FUN_selectTRAORIinterference(loicopy,TopAbs_REVERSED,lrev);
1585 Standard_Boolean hasrev=(irev > 0), hasfor=(ifor > 0);
1586 if (!hasrev && !hasfor) {FDS_copy(loi,newLI); continue;}
1587 if (hasrev && hasfor) {FDS_copy(loi,newLI); continue;} // nyiFUN_RAISE : incoherent data
1588
1589 // newO :
1590 // -----
1591 Handle(TopOpeBRepDS_Interference) I2d = hasfor ? lfor.First() : lrev.First();
1592 Standard_Integer S2 = I2d->Support(); Standard_Integer iF2 = I2d->Transition().Index();
1593 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2)); Standard_Real parSE = FDS_Parameter(I2d);
1594 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
1595 Standard_Real parE2; Standard_Boolean ok = FUN_tool_parE(SE,parSE,E2,parE2);
1596 if (!ok) return;
1597 gp_Pnt2d uv2; ok = FUN_tool_paronEF(E2,parE2,F2,uv2);
1598 if (!ok) return;
1599 gp_Dir ngF2 = FUN_tool_nggeomF(uv2,F2);
1600 gp_Dir xxF2; ok = FUN_tool_getxx(F2,E2,parE2,ngF2,xxF2);
1601 if (!ok) return;
1602
1603 Handle(TopOpeBRepDS_Interference) I3d = hasext ? lext.First() : lint.First();
1604 Standard_Integer iF3 = I3d->Transition().Index();
1605 const TopoDS_Face& F3 = TopoDS::Face(BDS.Shape(iF3));
1606 // recall : G is a point => E2 = edge(S3) (I3d : {(T,G,S3),(T,G,F3)})
1607 gp_Pnt2d uv3; ok = FUN_tool_paronEF(E2,parE2,F3,uv3);
1608 if (!ok) return;
1609 gp_Dir ngF3 = FUN_tool_nggeomF(uv3,F3);
1610 gp_Dir xxF3; ok = FUN_tool_getxx(F3,E2,parE2,ngF3,xxF3);
1611 if (!ok) return;
1612
1613 Standard_Real dot = xxF2.Dot(xxF3);
1614 Standard_Boolean positive = (dot > 0); // as F and FCX are tangent, dot= +1 or -1
1615 if (positive) continue;
1616
1617 TopAbs_Orientation newO = hasfor ? TopAbs_FORWARD : TopAbs_REVERSED;
1618 if (hasint) newO = TopAbs::Complement(newO);
1619
1620 TopOpeBRepDS_ListIteratorOfListOfInterference it;
1621 if (hasint) it.Initialize(lint);
1622 else it.Initialize(lext);
1623 for (; it.More(); it.Next()){
1624 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
1625 Handle(TopOpeBRepDS_Interference) newI = I; newI->ChangeTransition().Set(newO);
0797d9d3 1626#ifdef OCCT_DEBUG
7fd59977 1627 if (trc) {cout<<"completeforSE5 se"<<ISE<<"->";newI->Dump(cout);cout<<endl;}
1628#endif
1629 newLI.Append(I);
1630 hasnewLI = Standard_True;
1631 } // it
1632 newLI.Append(lrev);
1633 newLI.Append(lfor);
1634 newLI.Append(loicopy);
1635 } // tki
1636 if (hasnewLI) {
1637 newLI.Append(LOIc);
1638 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE); LII.Clear();
1639 LII.Append(newLI);
1640 }
1641 } // i=1..nse
1642}//completeforSE5
1643
1644// ----------------------------------------------------------------------
1645Standard_EXPORT void FUN_ds_completeforSE6(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1646// ----------------------------------------------------------------------
1647// xpu280798 : - section edge E sdm3d Esd,
1648// - E has I2d(T(F),VG,E'),
1649// - VG vertex of Esd, VG not sdm
1650// - Esd edge of F
1651// => add newI1d(newT(Esd),VG,Esd)
1652// cto902B4 (e15,v22)
1653{
1654 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1655 Standard_Integer nse = BDS.NbSectionEdges();
1656 for (Standard_Integer i = 1; i <= nse; i++) {
1657 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1658 Standard_Integer ISE = BDS.Shape(SE);
0797d9d3 1659#ifdef OCCT_DEBUG
7fd59977 1660 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1661 if (trc) debse6(ISE);
1662#endif
1663
1664 TopTools_ListOfShape lEsd3d; Standard_Boolean hassd3d = FDS_HasSameDomain3d(BDS,SE,&lEsd3d);
1665 if (!hassd3d) continue;
1666
1667 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1668 TopOpeBRepDS_ListOfInterference LIcopy;
1669 TopOpeBRepDS_ListOfInterference LIa; FDS_assign(LI,LIcopy); Standard_Integer na = FUN_selectGKinterference(LIcopy,TopOpeBRepDS_VERTEX,LIa);
1670 if (na == 0) continue;
1671 TopOpeBRepDS_ListOfInterference LIb;
1672 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LIa); it.More(); it.Next()){
1673 const Handle(TopOpeBRepDS_Interference)& Ia = it.Value();
1674 Standard_Integer G = Ia->Geometry();
1675 TopoDS_Shape vGsd; Standard_Boolean hassd = FUN_ds_getoov(BDS.Shape(G), HDS, vGsd);
1676 if (!hassd) LIb.Append(Ia);
1677 }
1678
1679 TopOpeBRepDS_ListOfInterference l2dFE; FDS_assign(LIb,LIcopy);
0797d9d3 1680#ifdef OCCT_DEBUG
7fd59977 1681// Standard_Integer n2d =
1682#endif
1683 FUN_ds_hasI2d(ISE,LIcopy,l2dFE);
1684 TopOpeBRepDS_ListOfInterference l1dE; FDS_assign(LIb,LIcopy);
0797d9d3 1685#ifdef OCCT_DEBUG
7fd59977 1686// Standard_Integer n1d =
1687#endif
1688 FUN_selectTRASHAinterference(LIcopy,TopAbs_EDGE,l1dE);
1689
1690 // attached to SE : l1dE = {I1d=(T(Esd),vG,Esd) / vG !hsd}
1691 // l2dFE = {I2dF=(T(F),vG,E) / vG !hsd}
1692
1693 for (TopTools_ListIteratorOfListOfShape itsd3(lEsd3d); itsd3.More(); itsd3.Next()){
1694 const TopoDS_Edge& Esd = TopoDS::Edge(itsd3.Value());
1695 TopoDS_Vertex vf,vl; TopExp::Vertices(Esd,vf,vl);
1696 Standard_Boolean degen = BRep_Tool::Degenerated(Esd);
1697 if (degen) continue;
1698
1699 Standard_Boolean closed = vf.IsSame(vl);
1700 Standard_Integer iEsd = BDS.Shape(Esd);
1701 Standard_Integer ivf = BDS.Shape(vf);
1702 Standard_Integer ivl = BDS.Shape(vl);
1703
1704 for (Standard_Integer iv = 1; iv <= 2; iv++) {
1705 Standard_Integer G = (iv == 1)? ivf : ivl;
1706 if (G == 0) continue;
1707 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
1708 TopoDS_Shape vGsd; Standard_Boolean hassd = FUN_ds_getoov(vG, HDS, vGsd);
1709 if (hassd) continue;
1710
1711 TopOpeBRepDS_ListOfInterference l1dG;
1712 FUN_selectGIinterference(l1dE,G,l1dG);
1713 TopOpeBRepDS_ListOfInterference l2dG; Standard_Integer n2dG = FUN_selectGIinterference(l2dFE,G,l2dG);
1714 if (n2dG == 0) continue; // no 2dI at G
1715
1716 TopOpeBRepDS_ListOfInterference l1dGEsd; Standard_Integer n1dGEsd = FUN_selectITRASHAinterference(l1dG,iEsd,l1dGEsd);
1717 if (n1dGEsd != 0) continue; // 1dI(Esd) at G exists already
1718
1719 for (TopOpeBRepDS_ListIteratorOfListOfInterference it2d(l2dG); it2d.More(); it2d.Next()){
1720 const Handle(TopOpeBRepDS_Interference)& I2d = it2d.Value();
1721 Standard_Integer iTRASHA = I2d->Transition().IndexBefore();
1722 TopAbs_Orientation O = I2d->Transition().Orientation(TopAbs_IN);
1723 const TopoDS_Face& F = TopoDS::Face(BDS.Shape(iTRASHA));
1724 TopAbs_Orientation dum; Standard_Boolean EsdofF = FUN_tool_orientEinF(Esd,F,dum);
1725 if (!EsdofF) continue;
1726
1727 // we found I2d = (T(F),vG,E'), vG is vertex of Esd, vG !hsdm, Esd is edge of F
1728 // compute newI1d=(newT(Esd),vG,Esd)
1729 TopOpeBRepDS_Transition newT(TopAbs_OUT,TopAbs_OUT, TopAbs_EDGE,TopAbs_EDGE);
1730 Standard_Real parE = FDS_Parameter(I2d);
1731 if (closed) newT.Set(TopAbs_INTERNAL);
1732 else {
1733 if (M_FORWARD(O) || M_REVERSED(O)) {newT.Set(O);}
1734 else if (M_EXTERNAL(O)) {newT.Set(O);}
1735 else if (M_INTERNAL(O)) {
1736 Standard_Real parEsd = BRep_Tool::Parameter(vG,Esd);
96a95605
DB
1737 gp_Vec tgEsd; TopOpeBRepTool_TOOL::TggeomE(parEsd,Esd,tgEsd); // dir
1738 gp_Vec tgE ; TopOpeBRepTool_TOOL::TggeomE(parE,SE,tgE); // dir
7fd59977 1739 Standard_Real dot = tgEsd.Dot(tgE);
0797d9d3 1740#ifdef OCCT_DEBUG
f8814ccf 1741 Standard_Real tola = Precision::Angular();
7fd59977 1742 if (Abs(dot) < tola) Standard_Failure::Raise("completeforSE6");
1743#endif
1744 Standard_Boolean SO = (dot > 0.);
1745 Standard_Boolean isvf = (iv == 1);
1746 Standard_Boolean isforw = (SO && isvf) || (!SO && !isvf);
1747 if (isforw) {newT.Set(TopAbs_FORWARD);}
1748 else {newT.Set(TopAbs_REVERSED);}
1749 }
1750 }
1751 newT.Index(iEsd);
1752 Handle(TopOpeBRepDS_Interference) newI1d = MakeEPVInterference(newT,iEsd,G,parE,TopOpeBRepDS_VERTEX,Standard_False);
0797d9d3 1753#ifdef OCCT_DEBUG
7fd59977 1754 if (trc) {cout<<"completeforS61 on section edge "<<ISE<<" ";newI1d->Dump(cout);cout<<endl;}
1755#endif
1756 HDS->StoreInterference(newI1d,SE);
1757 } // it2d(l2dFE)
1758
1759 }
1760 } //itsd3
1761
1762 } //i=1..nse
1763}// completeforSE6
1764
1765// ----------------------------------------------------------------------
1766Standard_EXPORT void FUN_ds_completeforE7(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1767// ----------------------------------------------------------------------
1768// xpu130898 : attached to edge E, lI3d = {I=(FOR/REV(F),G,F)}
1769// reduction of lI3d if it describes INTERNAL/EXTERNAL transitions
1770// purpose : I3dFOR/REV => faulty spIN/OU of E on G
1771// CTS21199 (E6, G=v7/p3, FTR=f5)
1772{
1773 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1774 Standard_Integer ns = BDS.NbShapes();
1775 for (Standard_Integer i = 1; i <= ns; i++) {
1776 const TopoDS_Shape& EE = BDS.Shape(i);
1777 if (EE.ShapeType() != TopAbs_EDGE) continue;
1778
1779 const TopoDS_Edge& E = TopoDS::Edge(EE);
1780 Standard_Boolean isdgE = BRep_Tool::Degenerated(E);
1781 if (isdgE) continue;
1782
0797d9d3 1783#ifdef OCCT_DEBUG
7fd59977 1784 Standard_Integer IE =
1785#endif
1786 BDS.Shape(E);
0797d9d3 1787#ifdef OCCT_DEBUG
7fd59977 1788 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
1789 if (trc) debe7(IE);
1790#endif
1791 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
1792
1793 TopOpeBRepDS_TKI tki;
1794 tki.FillOnGeometry(LI);
1795 for (tki.Init(); tki.More(); tki.Next()) {
1796 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1797 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1798 TopOpeBRepDS_ListOfInterference l1;
0797d9d3 1799#ifdef OCCT_DEBUG
7fd59977 1800// Standard_Integer n1 =
1801#endif
1802 FUN_selectSKinterference(loicopy,TopOpeBRepDS_FACE,l1);
1803 TopOpeBRepDS_ListOfInterference lFOR; Standard_Integer nFOR = FUN_selectTRAORIinterference(l1,TopAbs_FORWARD,lFOR);
1804 TopOpeBRepDS_ListOfInterference lREV; Standard_Integer nREV = FUN_selectTRAORIinterference(l1,TopAbs_REVERSED,lREV);
431258f7 1805 if ((nFOR == 0) || (nREV == 0)) continue;
7fd59977 1806
1807 TopOpeBRepDS_ListOfInterference lnewI; Standard_Integer iFS=0;
1808 TopOpeBRepDS_ListIteratorOfListOfInterference it(lFOR);
1809 for (; it.More(); it.Next()){
1810 const Handle(TopOpeBRepDS_Interference)& IFOR = it.Value();
1811 Standard_Integer IFS = IFOR->Support(); const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(IFS));
1812 TopOpeBRepDS_ListOfInterference lFS; Standard_Integer nFS = FUN_selectSIinterference(loicopy,IFS,lREV);
1813 if (nFS == 0) continue;
1814
1815 TopOpeBRepDS_ListOfInterference lFSE; Standard_Integer nFSE = FUN_selectITRASHAinterference(loicopy,IFS,lFSE);
1816 Standard_Real par = FDS_Parameter(IFOR);
1817 Standard_Boolean isonper; Standard_Real par1,par2; Standard_Real factor = 1.e-4;
1818 FDS_LOIinfsup(BDS,E,par,K,G,BDS.ShapeInterferences(E),par1,par2,isonper);
1819
1820 TopOpeBRepDS_Transition newT;
1821 // -------
1822 // we have IFOR=(FORWARD(FS),G,FS) + IREV=(REVERSED(FS),G,FS)
1823 Standard_Integer IES = 0;
1824 if (nFSE == 0) {
1825 gp_Pnt2d uvFS; Standard_Boolean ok = FUN_tool_parF(E,par,FS,uvFS);
1826 if (!ok) {FUN_Raise(); continue;}
1827
1d47d8d0 1828 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
7fd59977 1829 ok = MKT.Initialize(E,par1,par2,par, FS,uvFS, factor);
1830 if (ok) ok = MKT.MkTonE(stb,sta);
1831 if (!ok) {FUN_Raise(); continue;}
1832 newT.Before(stb); newT.After(sta);
1833 }
1834 else {
1835 IES = lFSE.First()->Support();
1836 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(IES));
1837 Standard_Real parES; Standard_Boolean ok = FUN_tool_parE(E,par,ES,parES);
1838 if (!ok) {FUN_Raise(); continue;}
1839 gp_Pnt2d uvFS; ok = FUN_tool_paronEF(ES,parES,FS,uvFS);
1840 if (!ok) {FUN_Raise(); continue;}
1841
1d47d8d0 1842 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
7fd59977 1843 ok = MKT.Initialize(E,par1,par2,par, FS,uvFS, factor);
1844 if (ok) ok = MKT.SetRest(ES,parES);
1845 if (ok) ok = MKT.MkTonE(stb,sta);
1846 if (!ok) {FUN_Raise(); continue;}
1847 newT.Before(stb); newT.After(sta);
1848 }
1849
1850 // newI :
1851 //------
1852 iFS = IFS;
1853 newT.Index(IFS);
1854 Standard_Boolean B = Standard_False;
1855 if (K == TopOpeBRepDS_VERTEX) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(IFOR)->GBound();
1856 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,IFS,G,par,K,TopOpeBRepDS_FACE,B);
1857 lnewI.Append(newI);
1858 if (nFSE != 0) {
1859 Handle(TopOpeBRepDS_Interference) newIFE = MakeEPVInterference(newT,IES,G,par,K,TopOpeBRepDS_EDGE,B);
1860 lnewI.Append(newIFE);
1861 }
1862 } // it(lFOR)
1863
1864 if (iFS != 0) {
1865 TopOpeBRepDS_ListOfInterference& loii = tki.ChangeValue(K,G);
1866 TopOpeBRepDS_ListOfInterference lEFS;
0797d9d3 1867#ifdef OCCT_DEBUG
7fd59977 1868// Standard_Integer nIFS =
1869#endif
1870 FUN_selectITRASHAinterference(loii,iFS,lEFS);
1871 for (TopOpeBRepDS_ListIteratorOfListOfInterference iti(lnewI); iti.More(); iti.Next()) {
1872 Handle(TopOpeBRepDS_Interference) newI = iti.Value();
1873 loii.Append(newI);
0797d9d3 1874#ifdef OCCT_DEBUG
7fd59977 1875 if (trc) {cout<<"completeforE7 on edge "<<IE<<" ";newI->Dump(cout);cout<<endl;}
1876#endif
1877 }
1878 }
1879 } // tki
1880
1881 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(E);
1882 LII.Clear();
1883 for (tki.Init(); tki.More(); tki.Next()) {
1884 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1885 FDS_copy(loi,LII);
1886 }
1887 } //i = 1..ns
1888} //completeforE7
1889
1890// ----------------------------------------------------------------------
1891Standard_EXPORT void FUN_ds_completeforSE8(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1892// ----------------------------------------------------------------------
1893// xpu020998 : Attached to section edge SE :
1894// - {I1d=(Tr(Esd),vG,Esd), I2d=(Tr(F),vG,E)}
1895// - E and Esd are F edges
1896// I2d may be incomplete, "reduce" 2d/1d -> {I1d,newI2d}
1897// cto902A6 (ES5,Esd10,vG7,F35)
1898// prequesitory : A vertex is shared by at most 2 edges in the same face.
1899// An edge is shared by at most 2 faces of same rank.
1900{
1901 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1902 Standard_Integer nse = BDS.NbSectionEdges();
1903
1904 for (Standard_Integer i = 1; i <= nse; i++) {
1905 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1906 Standard_Integer ISE = BDS.Shape(SE);
1907 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
0797d9d3 1908#ifdef OCCT_DEBUG
7fd59977 1909 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1910 if (trc) debse8(ISE);
1911#endif
1912
1913 Standard_Boolean hasnew = Standard_False;
1914 TopOpeBRepDS_TKI tki;
1915 tki.FillOnGeometry(LI);
1916 for (tki.Init(); tki.More(); tki.Next()) {
1917 TopOpeBRepDS_Kind KK; Standard_Integer GG; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(KK,GG);
1918 Standard_Boolean isvertex = (KK == TopOpeBRepDS_VERTEX);
0797d9d3 1919#ifdef OCCT_DEBUG
7fd59977 1920// Standard_Boolean ispoint = (KK == TopOpeBRepDS_POINT);
1921#endif
1922 if (isvertex) {
1923 Standard_Boolean Ghsdm = HDS->HasSameDomain(BDS.Shape(GG));
1924 if (Ghsdm) continue;
1925 }
1926 // li -> l1dE + l2dFE + lFE(<=>l3dFE) + li(<=>lFF)
1927 TopOpeBRepDS_ListOfInterference li; FDS_assign(loi,li);
1928 TopOpeBRepDS_ListOfInterference l1dE; Standard_Integer n1d = FUN_selectTRASHAinterference(li,TopAbs_EDGE,l1dE); // li->l1dE+li(<=>lF?)
1929 TopOpeBRepDS_ListOfInterference lFE;
0797d9d3 1930#ifdef OCCT_DEBUG
7fd59977 1931// Standard_Integer nFE =
1932#endif
1933 FUN_selectSKinterference(li,TopOpeBRepDS_EDGE,lFE); // li(<=>lF?)->lFE+li(<=>lFF)
1934 TopOpeBRepDS_ListOfInterference l2dFE; Standard_Integer n2d = FUN_selectpure2dI(li,lFE,l2dFE); // lFE->l2dFE+lFE(<=>l3dFE)
0797d9d3 1935#ifdef OCCT_DEBUG
7fd59977 1936// Standard_Integer n3d = lFE.Extent();
1937#endif
1938
1939 Standard_Boolean redu2d = (n1d > 0)&&(n2d > 0);
1940 // -------------------------------
1941 if (redu2d) { // {I1d=(Tr(Esd),vG,Esd), I2d=(Tr(F),vG,E)}
1942 TopOpeBRepDS_ListIteratorOfListOfInterference it(l2dFE); TopOpeBRepDS_ListOfInterference al2dFE;
1943 while (it.More()) {
1944 Handle(TopOpeBRepDS_Interference)& I2dFE = it.Value();
1945 TopOpeBRepDS_Transition newT2d; Standard_Boolean ok = FUN_ds_redu2d1d(BDS,ISE,I2dFE,l1dE, newT2d);
1946 if (!ok) {it.Next(); continue;}
1947 I2dFE->ChangeTransition() = newT2d; al2dFE.Append(I2dFE);
0797d9d3 1948#ifdef OCCT_DEBUG
7fd59977 1949 if (trc) {cout<<"SE8 -> on SE"<<ISE<<" reducedI :";I2dFE->Dump(cout);cout<<endl;}
1950#endif
1951 l2dFE.Remove(it);
1952 }
1953 l2dFE.Append(al2dFE);
1954 } // redu2d
1955
1956 TopOpeBRepDS_ListOfInterference& loii = tki.ChangeValue(KK,GG);
1957 loii.Clear();
1958 loii.Append(l1dE); loii.Append(lFE); loii.Append(l2dFE); loii.Append(li);
1959 }// tki
1960
1961 if (!hasnew) continue;
1962 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE);
1963 LII.Clear();
1964 for (tki.Init(); tki.More(); tki.Next()) {
1965 TopOpeBRepDS_Kind KK; Standard_Integer GG; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(KK,GG);
1966 LII.Append(loi);
1967 }
1968 }// i=1..nse
1969}// completeforSE8
1970
1971// ----------------------------------------------------------------------
1972Standard_EXPORT void FUN_ds_completeforSE9(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1973// ----------------------------------------------------------------------
1974// xpu011098 : CTS21180(ES13)
1975// purpose : ES Section edge, sdm with EsdSE={Esd}, ES has no interference
1976// compute interferences for ES.
1977{
1978 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1979 Standard_Integer nse = BDS.NbSectionEdges();
1980
1981 for (Standard_Integer i = 1; i <= nse; i++) {
1982 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1983 Standard_Integer rkSE = BDS.AncestorRank(SE);
1984 Standard_Integer ISE = BDS.Shape(SE);
0797d9d3 1985#ifdef OCCT_DEBUG
7fd59977 1986 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1987 if (trc) debse9(ISE);
1988#endif
1989 Standard_Boolean hsd = HDS->HasSameDomain(SE);
1990 if (!hsd) continue;
1991 if (!BDS.ShapeInterferences(SE).IsEmpty()) continue;
1992
1993 const TopTools_ListOfShape& EsdSE = BDS.ShapeSameDomain(SE);
1994 TopTools_ListIteratorOfListOfShape ite(EsdSE);
1995 for (; ite.More(); ite.Next()){
1996 const TopoDS_Edge& Esd = TopoDS::Edge(ite.Value()); Standard_Integer iEsd = BDS.Shape(Esd);
1997 Standard_Integer rkEsd = BDS.AncestorRank(Esd);
1998 if (rkEsd == rkSE) continue;
1999 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(Esd);
2000 if (LI.IsEmpty()) continue;
2001
2002 TopOpeBRepDS_ListOfInterference LIcopy; FDS_assign(LI,LIcopy);
2003 TopOpeBRepDS_ListOfInterference LISE;
0797d9d3 2004#ifdef OCCT_DEBUG
7fd59977 2005// Standard_Integer nise =
2006#endif
2007 FUN_selectSIinterference(LIcopy,ISE,LISE);
2008
2009 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LISE);
2010 for (tki.Init(); tki.More(); tki.Next()) {
2011 TopOpeBRepDS_Kind K;
2012 Standard_Integer G;
2013// const TopOpeBRepDS_ListOfInterference& loi =
2014 tki.Value(K,G);
0797d9d3 2015#ifdef OCCT_DEBUG
7fd59977 2016// const Handle(TopOpeBRepDS_Interference)& I = loi.First();
2017// TopAbs_Orientation O = I->Transition().Orientation(TopAbs_IN);
2018#endif
2019 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
2020 Standard_Boolean hsd1 = HDS->HasSameDomain(vG);
2021 if (hsd1) continue; //nyixpu011098
2022 Standard_Integer rkG = BDS.AncestorRank(G);
2023 if (rkG != rkSE) continue; //nyixpu011098
2024
2025 // newI :
2026 // -----
2027 TopOpeBRepDS_Transition newT(TopAbs_IN,TopAbs_IN,TopAbs_EDGE,TopAbs_EDGE); newT.Index(iEsd);
2028 // modified by NIZHNY-MKK Mon Apr 2 15:39:14 2001.BEGIN
2029 Standard_Integer hasvG = FUN_tool_orientVinE(vG,SE);
2030 if(hasvG==0) {
2031 continue;
2032 }
2033 // modified by NIZHNY-MKK Mon Apr 2 15:39:17 2001.END
2034
2035 Standard_Real par = BRep_Tool::Parameter(vG,SE);
2036 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,iEsd,G,par,TopOpeBRepDS_VERTEX,TopOpeBRepDS_EDGE,Standard_True);
0797d9d3 2037#ifdef OCCT_DEBUG
7fd59977 2038 if (trc) {cout<<"completeforSE6 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
2039#endif
2040 HDS->StoreInterference(newI,SE);
2041 }
2042 }//ite(EsdSE)
2043 }//i=1..nse
2044} //completeforSE9
2045
2046// ----------------------------------------------------------------------
2047Standard_EXPORT void FUN_ds_PointToVertex(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
2048// ----------------------------------------------------------------------
2049// xpu090698 : for gap reasons, intersector IntPatch can find a intersection
2050// point POINT, whereas it should be a VERTEX,
2051// if we find edge eb / eb : EPI(T1,G,ea1),
2052// EPI(T2,G,a2) with rk(ea1) = rk(ea2),
2053// then G should be VERTEX (2 edges of same shape cannot
2054// intersect) - recall : in the DS, we do not bind twice the same closing edge-
2055// CTS20339
2056{
2057 Standard_Integer i ;
2058 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2059 Standard_Integer ns = BDS.NbShapes();
2060 TColStd_DataMapOfIntegerInteger iPiV;
2061
2062 for ( i = 1; i <= ns; i++) {
2063 const TopoDS_Shape& s = BDS.Shape(i);
2064 if (s.ShapeType() != TopAbs_EDGE) continue;
2065 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(s);
2066 if (LI.IsEmpty()) continue;
2067
2068 TopOpeBRepDS_TKI tki;
2069 tki.FillOnGeometry(LI);
2070 for (tki.Init(); tki.More(); tki.Next()) {
2071 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2072 if (K == TopOpeBRepDS_VERTEX) continue;
2073
2074 Standard_Integer Scur = 0; Standard_Boolean Gfaulty = Standard_False;
2075 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); it.More(); it.Next()){
2076 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2077 TopOpeBRepDS_Kind GT,ST;
2078 Standard_Integer G1,S;
2079 FDS_data(I,GT,G1,ST,S);
2080 if (ST != TopOpeBRepDS_EDGE) continue;
2081 if (Scur == 0) {
2082 Scur = S;
2083 }
2084 if (S != Scur) {
2085 Gfaulty = Standard_True; break;
2086 }
2087 } // it
2088 if (Gfaulty) {
2089 // in DS : pG --> vG
2090 gp_Pnt pG = BDS.Point(G).Point();
2091 Standard_Integer rkES = BDS.AncestorRank(Scur);
2092 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(Scur));
2093 TopoDS_Vertex vf,vl; TopExp::Vertices(ES,vf,vl);
2094 gp_Pnt pf = BRep_Tool::Pnt(vf); gp_Pnt pl = BRep_Tool::Pnt(vl);
2095 Standard_Real df = pf.Distance(pG); Standard_Real dl = pl.Distance(pG);
2096 TopoDS_Vertex vG;
2097 if (df < dl) vG = vf;
2098 else vG = vl;
2099
2100 Standard_Integer ivG = BDS.AddShape(vG,rkES);
2101 iPiV.Bind(G,ivG);
2102 } // Gfaulty
2103 } // tki
2104 } // i
2105
2106 if (iPiV.IsEmpty()) return;
2107 for (i = 1; i <= ns; i++) {
2108 const TopoDS_Shape& s = BDS.Shape(i);
2109 if (s.ShapeType() != TopAbs_EDGE) continue;
2110 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(s);
2111 if (LI.IsEmpty()) continue;
2112
2113 TopOpeBRepDS_ListOfInterference newLI;
2114 Standard_Integer rks = BDS.AncestorRank(s);
2115 TopOpeBRepDS_TKI tki;
2116 tki.FillOnGeometry(LI);
2117 for (tki.Init(); tki.More(); tki.Next()) {
2118 TopOpeBRepDS_Kind K;
2119 Standard_Integer G;
2120 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2121 Standard_Boolean Gisbound = iPiV.IsBound(G);
2122 if (!Gisbound) {
2123 FDS_copy(loi,newLI);
2124 continue;
2125 }
2126
2127 Standard_Integer ivG = iPiV.Find(G);
2128 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(ivG));
2129 Standard_Integer rkG = BDS.AncestorRank(ivG);
2130 Standard_Boolean Gbound = (rkG == rks);
2131
2132 for (TopOpeBRepDS_ListIteratorOfListOfInterference itl(loi); itl.More(); itl.Next()){
2133 const Handle(TopOpeBRepDS_Interference)& I = itl.Value();
2134 const Handle(TopOpeBRepDS_CurvePointInterference)& CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I);
2135 if (CPI.IsNull()) continue;
2136
2137 Standard_Real par = CPI->Parameter();
2138 TopOpeBRepDS_Kind GT,ST;
2139 Standard_Integer G1,S;
2140 FDS_data(I,GT,G1,ST,S);
2141 const TopOpeBRepDS_Transition& T = I->Transition();
2142 Standard_Real parvG; Standard_Boolean ok = FUN_tool_parVonE(vG,TopoDS::Edge(s),parvG);
2143 // modified by NIZHNY-MKK Mon Apr 2 15:39:59 2001.BEGIN
2144 // if (!ok) par = parvG;
2145 if (!ok)
2146 continue;
2147 par = parvG;
2148 // modified by NIZHNY-MKK Mon Apr 2 15:40:04 2001.END
2149 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(T,S,ivG,par,TopOpeBRepDS_VERTEX,ST,Gbound);
2150 newLI.Append(newI);
2151 }
2152 } // tki
2153 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(s);
2154 LII.Clear(); LII.Append(newLI);
2155 } // i
2156
2157 TColStd_DataMapIteratorOfDataMapOfIntegerInteger itm(iPiV);
2158 for (; itm.More(); itm.Next()){
2159 Standard_Integer G = itm.Key();
2160 BDS.RemovePoint(G);
2161 }
2162}//PointToVertex
2163
2164static Standard_Boolean FUN_redusamshaonE(const TopOpeBRepDS_DataStructure& BDS,const Handle(TopOpeBRepDS_Interference)& I,const Standard_Integer EIX, Handle(TopOpeBRepDS_Interference)& newI)
2165// attached to edge(EIX) : IFOR=(FORWARD(ES),G,ES) + IREV=(REVERSED(ES),G,ES)
2166{
2167 newI.Nullify();
2168 TopAbs_ShapeEnum SB,SA;Standard_Integer IB,IA;TopOpeBRepDS_Kind GT,ST;Standard_Integer G,S;
2169 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
2170 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
2171 Standard_Real parE = FDS_Parameter(I); Standard_Real f,l; FUN_tool_bounds(E,f,l);
2172 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
2173 const TopoDS_Face& FTRA = TopoDS::Face(BDS.Shape(IB));
2174 Standard_Real parES; Standard_Boolean ok = FUN_tool_parE(E,parE,ES,parES);
2175 if (!ok) return Standard_False;
2176 gp_Pnt2d uv; ok = FUN_tool_paronEF(ES,parES,FTRA,uv);
2177 if (!ok) return Standard_False;
2178
1d47d8d0 2179 Standard_Real factor = 1.e-2; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
7fd59977 2180 TopOpeBRepTool_makeTransition MKT;
2181 ok = MKT.Initialize(E,f,l,parE, FTRA,uv, factor);
2182 if (ok) ok = MKT.SetRest(ES,parES);
2183 if (ok) ok = MKT.MkTonE(stb,sta);
2184 if (!ok) return Standard_False;
2185 TopOpeBRepDS_Transition newT; newT.Index(IB); newT.Before(stb);newT.After(sta);
2186
2187 ok = FDS_stateEwithF2d(BDS,E,parE,GT,G,FTRA,newT);
2188 if (!ok) return Standard_False;
2189
2190 Standard_Boolean B = Standard_False; if (GT == TopOpeBRepDS_VERTEX) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
2191 newI = MakeEPVInterference(newT,S,G,parE,GT,TopOpeBRepDS_EDGE,B);
2192 return Standard_True;
2193}//FUN_redusamshaonE
2194
2195// ----------------------------------------------------------------------
2196Standard_EXPORT void FUN_ds_redusamsha(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
2197// ----------------------------------------------------------------------
2198// xpu201098 : reduce 2d interferences on same G and same S :
2199// {I1=(OU/IN(F),G,ES), I2=(IN/OU(F),G,ES)}
2200// cto009K1 (SE7,ES8,G2,FTRA27)
2201//xpu050299 (FRA60618 e13,ftrasha14)
2202{
2203 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2204 Standard_Integer ns = BDS.NbShapes();
2205
2206 for (Standard_Integer i = 1; i <= ns; i++) {
2207 if (BDS.Shape(i).ShapeType() != TopAbs_EDGE) continue;
2208
2209 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(i));
0797d9d3 2210#ifdef OCCT_DEBUG
7fd59977 2211// Standard_Boolean isse = BDS.IsSectionEdge(E);
2212// Standard_Integer rkE = BDS.AncestorRank(E);
2213#endif
2214 Standard_Integer IE = BDS.Shape(E);
0797d9d3 2215#ifdef OCCT_DEBUG
7fd59977 2216 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
2217 if (trc) debsamsha(IE);
2218#endif
2219 TopOpeBRepDS_TKI tki;
2220 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(i);
2221 tki.FillOnGeometry(LI);
2222 for (tki.Init(); tki.More(); tki.Next()) {
2223 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2224 TopOpeBRepDS_ListOfInterference loicopy; FDS_copy(loi,loicopy); // loi -> l1+l2
2225 TopOpeBRepDS_ListOfInterference l0;
0797d9d3 2226#ifdef OCCT_DEBUG
7fd59977 2227// Standard_Integer n0 =
2228#endif
2229 FUN_selectTRASHAinterference(loicopy,TopAbs_EDGE,l0);//xpu091198(cylcong)
2230 TopOpeBRepDS_ListOfInterference l1; Standard_Integer nfound = FUN_selectTRASHAinterference(loicopy,TopAbs_FACE,l1);
2231 TopOpeBRepDS_ListOfInterference l2; nfound = FUN_selectSKinterference(l1,TopOpeBRepDS_EDGE,l2);
2232 // l2 = {I=(T(faceTRASHA),G,Sedge)}
2233 if (nfound == 0) continue;
2234
2235 //***
2236 TopOpeBRepDS_TKI tkis; tkis.FillOnSupport(l2);
2237 for (tkis.Init(); tkis.More(); tkis.Next()) {
2238 TopOpeBRepDS_Kind k; Standard_Integer s; TopOpeBRepDS_ListOfInterference& li = tkis.ChangeValue(k,s);
2239 Standard_Integer nli = li.Extent();
2240 if (nli < 2) continue;
2241
2242 Handle(TopOpeBRepDS_Interference) newI;
2243 TopOpeBRepDS_ListIteratorOfListOfInterference it1(li);
2244 while (it1.More()) {
2245 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
2246 const TopOpeBRepDS_Transition& T1 = I1->Transition();
2247 TopAbs_Orientation O1 = T1.Orientation(TopAbs_IN);
2248 if (!M_FORWARD(O1) && !M_REVERSED(O1)) {it1.Next(); continue;}
2249 TopAbs_ShapeEnum SB1,SA1;Standard_Integer IB1,IA1;TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
2250 FDS_Idata(I1,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1);
2251 if (IB1 != IA1) {it1.Next(); continue;}
2252
2253 Standard_Boolean oppofound = Standard_False;
2254 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); it2.Next();
2255 while (it2.More()) {
2256 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
2257 const TopOpeBRepDS_Transition& T2 = I2->Transition();
2258 TopAbs_Orientation O2 = T2.Orientation(TopAbs_IN);
2259 TopAbs_ShapeEnum SB2,SA2;Standard_Integer IB2,IA2;TopOpeBRepDS_Kind GT2,ST2;Standard_Integer G2,S2;
2260 FDS_Idata(I2,SB2,IB2,SA2,IA2,GT2,G2,ST2,S2);
2261 if (IB2 != IA2) {it2.Next(); continue;}
2262 if (IB1 != IB2) {it2.Next(); continue;} // same fTRASHA
2263 if (S1 != S2) {it2.Next(); continue;} // same Sedge
2264
2265 if (O1 == TopAbs::Complement(O2)) {oppofound=Standard_True; break;}
2266 else {it2.Next(); continue;}
2267 } // it2(it1)
2268
2269 if (!oppofound) {it1.Next(); continue;}
2270 Standard_Boolean ok = FUN_redusamshaonE(BDS,I1,IE,newI);
2271 if (!ok) {it1.Next(); continue;}
2272 else break;
2273 } //it1(li)
2274 if (newI.IsNull()) continue;
0797d9d3 2275#ifdef OCCT_DEBUG
7fd59977 2276 if (trc) {cout<<"redusamsha se"<<IE<<"FORWARD/REVERSED ->";newI->Dump(cout);cout<<endl;}
2277#endif
2278 li.Clear(); li.Append(newI);
2279 }//tkis(l2)
2280 //***
2281
2282 TopOpeBRepDS_ListOfInterference& newloi = tki.ChangeValue(K,G); newloi.Clear();
2283 for (tkis.Init(); tkis.More(); tkis.Next()) {
2284 TopOpeBRepDS_Kind k; Standard_Integer g; TopOpeBRepDS_ListOfInterference& li = tkis.ChangeValue(k,g);
2285 newloi.Append(li);
2286 }
2287 newloi.Append(l0); newloi.Append(l1);
2288 }// tki(LI)
2289
2290 TopOpeBRepDS_ListOfInterference& newLI = BDS.ChangeShapeInterferences(E);
2291 newLI.Clear();
2292 for (tki.Init(); tki.More(); tki.Next()) {
2293 TopOpeBRepDS_Kind KK; Standard_Integer GG; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(KK,GG);
2294 newLI.Append(loi);
2295 }
2296 }// i=1..nse
2297} //FUN_ds_redusamsha
2298
2299Standard_EXPORT Standard_Boolean FUN_ds_hasFEI(const TopOpeBRepDS_PDataStructure& pDS2d, const TopoDS_Shape& F, const Standard_Integer GI, const Standard_Integer ITRA)
2300{
2301 Standard_Boolean hasF = pDS2d->HasShape(F);
2302 if (!hasF) return Standard_False;
2303
2304 const TopOpeBRepDS_ListOfInterference& LI = pDS2d->ShapeInterferences(F);
2305 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()){
2306 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2307 const TopOpeBRepDS_Transition& T = I->Transition();
2308 TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
2309 Standard_Boolean found = (G == GI) && (T.Index() == ITRA);
2310 if (found) return Standard_True;
2311 }
2312 return Standard_False;
2313} //FUN_ds_hasFEI
2314
2315Standard_EXPORT Standard_Boolean FUN_ds_ONesd(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer IE, const TopoDS_Shape& EspON, Standard_Integer& IEsd)
2316{
2317 const TopoDS_Shape& E = BDS.Shape(IE);
2318 TopTools_ListIteratorOfListOfShape it(BDS.ShapeSameDomain(E));
2319 Standard_Real f,l; FUN_tool_bounds(TopoDS::Edge(EspON),f,l);
2320 Standard_Real x = 0.456789; Standard_Real par = (1-x)*f + x*l;
2321 gp_Pnt p3d; Standard_Boolean ok = FUN_tool_value(par,TopoDS::Edge(EspON),p3d);
2322 if (!ok) return Standard_False;
2323
2324 for (; it.More(); it.Next()) {
2325 const TopoDS_Edge& esd = TopoDS::Edge(it.Value());
2326 Standard_Real d=0., parp; ok = FUN_tool_projPonE(p3d,esd,parp,d);
2327 if (!ok) continue;
2328 Standard_Real tolesd = BRep_Tool::Tolerance(esd);
2329 ok = (d < tolesd*1.e3); //nyi checktole
2330 if (!ok) continue;
2331 IEsd = BDS.Shape(esd);
2332 return Standard_True;
2333 }
2334 return Standard_False;
2335} //FUN_ds_ONesd
2336
2337/*#define FIRST (1)
2338#define LAST (2)
2339static Standard_Boolean FUN_oriTOsta(const Standard_Integer o, const TopAbs_State sta, TopAbs_Orientation& ori)
2340{
2341 Standard_Boolean ok = (sta == TopAbs_OUT) || (sta == TopAbs_IN);
2342 if (!ok) return Standard_False;
2343 ok = (o == FIRST) || (o == LAST);
2344 if (!ok) return Standard_False;
2345
2346 ori = TopAbs_EXTERNAL;
2347 if (o == FIRST) ori = TopAbs_FORWARD;
2348 if (o == LAST) ori = TopAbs_REVERSED;
2349 if (sta == TopAbs_OUT) ori = TopAbs::Complement(ori);
2350 return Standard_True;
2351} //FUN_oriTOsta
2352
2353Standard_EXPORT void FUN_ds_unkeepEVIonGb1(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const TopAbs_State sta)
2354// xpu290698 :
2355// Completing filter process for edges : delete of interferences
2356// EVI on gbound1, we keep only interferences on Gb1 describing transitions
2357// on e / e is IN the solid (if sta = IN)
2358// e is OU the solid (if sta = OU)
2359{
2360 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2361 Standard_Integer ns = BDS.NbShapes();
2362 for (Standard_Integer i = 1; i <= ns; i++) {
0797d9d3 2363#ifdef OCCT_DEBUG
7fd59977 2364 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(i);
2365 if (trc) debgb1(i);
2366#endif
2367 const TopoDS_Shape& s = BDS.Shape(i);
2368 if (s.ShapeType() != TopAbs_EDGE) continue;
2369
2370 const TopoDS_Edge& E = TopoDS::Edge(s);
2371 TopOpeBRepDS_ListOfInterference& LI = BDS.ChangeShapeInterferences(s);
2372 if (LI.IsEmpty()) continue;
2373
2374 Standard_Boolean dgE = BRep_Tool::Degenerated(E);
2375 if (dgE) continue;
2376 TopoDS_Vertex dum; Standard_Boolean closed = FUN_tool_ClosedE(E,dum);
2377 if (closed) continue;
2378
2379 TopOpeBRepDS_Kind K; Standard_Integer G; Standard_Boolean ok = Standard_False;
2380 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
2381
2382 for (tki.Init(); tki.More(); tki.Next()) {
2383 tki.Value(K,G);
2384 if (K != TopOpeBRepDS_VERTEX) break;
2385 ok = Standard_True;
2386 } // tki
2387 if (!ok) continue;
2388
2389 TopOpeBRepDS_ListOfInterference newLI;
2390 for (tki.Init(); tki.More(); tki.Next()) {
2391 tki.Value(K,G);
2392 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2393
2394 const TopoDS_Vertex& V = TopoDS::Vertex(BDS.Shape(G));
2395 Standard_Integer o = FUN_tool_orientVinE(V,E);
2396 if (o == 0) {FDS_copy(loi,newLI); continue;}
2397 TopAbs_Orientation ori; Standard_Boolean okk = FUN_oriTOsta(o,sta,ori);
2398 if (!okk) {FDS_copy(loi,newLI); continue;}
2399
2400 // attached to E at G : loi = {I} / I is EVIonGb1
2401 TopOpeBRepDS_ListOfInterference newloi;
2402 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); it.More(); it.Next()) {
2403 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2404 const TopAbs_Orientation& O = I->Transition().Orientation(TopAbs_IN);
2405 if (O == ori) {
2406 newloi.Append(I);
2407 continue;
2408 }
0797d9d3 2409#ifdef OCCT_DEBUG
7fd59977 2410 if (trc) {cout<<"unkeepEVIonGb1 on e"<<i<<" ";I->Dump(cout);cout<<endl;}
2411#endif
2412 }
2413 Standard_Integer nnewI = newloi.Extent();
2414 Standard_Integer nI = loi.Extent();
2415 Standard_Boolean ko = (nnewI > 1) && (nnewI != nI); // complex transitions at G
2416 // NYI : correcting reducing cto 001 W3 (e35)
2417 if (!ko) newLI.Append(newloi);
2418// newLI.Append(newloi); //xpu280898 : cto905J1 (e25,v8)
2419 } // tki
2420 LI.Clear(); LI.Append(newLI);
2421
2422 } // i=1..ns
2423} //FUN_ds_unkeepEVIonGb1*/
2424
2425Standard_EXPORT Standard_Boolean FDS_LOIinfsup(
2426 const TopOpeBRepDS_DataStructure&
0797d9d3 2427#ifdef OCCT_DEBUG
7fd59977 2428 BDS
2429#endif
2430 ,const TopoDS_Edge& E,
2431 const Standard_Real pE,
2432 const TopOpeBRepDS_Kind KDS,
2433 const Standard_Integer GDS,
2434 const TopOpeBRepDS_ListOfInterference& LOI,
2435 Standard_Real& pbef,
2436 Standard_Real& paft,
2437 Standard_Boolean& isonboundper)
2438{
0797d9d3 2439#ifdef OCCT_DEBUG
7fd59977 2440 Standard_Integer EIX = BDS.Shape(E);
2441 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
2442 TRC = Standard_False; // xpu170898
2443 if (TRC) cout<<endl<<"FDS_LOIinfsup.1 E"<<EIX<<" : "<<LOI.Extent()<<endl;
2444 if (TRC) debredpvg(EIX);
2445#endif
2446
2447 Standard_Real f,l; FUN_tool_bounds(E,f,l);
2448 pbef = f; paft = l;
2449 Standard_Integer n = LOI.Extent();
2450 if (n == 0) return Standard_True;
2451
2452
2453 TopOpeBRepDS_ListOfInterference LOIsansGDS;
2454 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
0797d9d3 2455#ifdef OCCT_DEBUG
7fd59977 2456 if (TRC) cout<<endl<<"FDS_LOIinfsup E"<<EIX<<" tki"<<endl;
2457 if (TRC) tki.DumpTKIIterator("","\n");
2458 if (TRC) debredpvg(EIX);
2459#endif
2460
2461 for(tki.Init();tki.More();tki.Next()) {
2462 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
2463 Standard_Boolean PV =(K==TopOpeBRepDS_POINT)||(K==TopOpeBRepDS_VERTEX);if (!PV) continue;
2464 Standard_Boolean mk = (K == KDS); Standard_Boolean mg = (G == GDS);
2465 Standard_Boolean mkg = (mk && mg); if ( mkg ) continue;
2466
0797d9d3 2467#ifdef OCCT_DEBUG
7fd59977 2468 if (TRC) {tki.DumpTKI(K,G,"","\n");debredpvg(EIX);}
2469#endif
2470
2471 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
0797d9d3 2472#ifdef OCCT_DEBUG
7fd59977 2473// Standard_Integer nloi = loi.Extent();
2474#endif
2475 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi);it.More();it.Next()) {
2476 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2477 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
2478 FDS_Idata(I,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
2479 if (tsb1 != TopAbs_FACE) continue;
2480 if (tsa1 != TopAbs_FACE) continue;
2481 const Handle(TopOpeBRepDS_CurvePointInterference)& cpi = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I);
2482 const Handle(TopOpeBRepDS_EdgeVertexInterference)& evi = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I);
2483 if (cpi.IsNull() && evi.IsNull()) continue;
2484 LOIsansGDS.Append(I);
2485 break;
2486 }
2487 }
2488
0797d9d3 2489#ifdef OCCT_DEBUG
7fd59977 2490 if (TRC) cout<<endl<<"FDS_LOIinfsup.2 E"<<EIX<<" : "<<LOIsansGDS.Extent()<<endl;
2491 if (TRC) debredpvg(EIX);
2492#endif
2493
2494 n = LOIsansGDS.Extent();
2495 if (n == 0) return Standard_True;
2496
2497 TopoDS_Vertex v; Standard_Boolean Eclosed = TopOpeBRepTool_TOOL::ClosedE(E,v);
2498 Standard_Real tole = BRep_Tool::Tolerance(E);
2499 Standard_Real tol = Precision::Parametric(tole);
2500 isonboundper = Standard_False;
2501 if (Eclosed) {
2502 Standard_Real tolv = BRep_Tool::Tolerance(v);
2503 tolv = Precision::Parametric(tolv);
2504 if (tolv > tol) tol = tolv;
2505 Standard_Boolean pEisEf = (Abs(pE-f) <= tol);
2506 Standard_Boolean pEisEl = (Abs(pE-l) <= tol);
2507 isonboundper = pEisEf || pEisEl;
2508 }
2509
2510 if (isonboundper) {
2511 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LOIsansGDS);it.More();it.Next()) {
2512 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2513 Standard_Real p = FDS_Parameter(I);
2514 // pbef > paft
2515 if (p > pbef) pbef = p;
2516 if (p < paft) paft = p;
2517 }
2518 return Standard_True;
2519 }
2520 else {
2521 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LOIsansGDS);it.More();it.Next()) {
2522 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2523 Standard_Real p = FDS_Parameter(I);
2524 if (p > pbef && p < pE) pbef = p;
2525 if (p < paft && p > pE) paft = p;
2526 }
2527 }
2528 return Standard_True;
2529} // FDS_LOIinfsup
2530
2531// sur arete E : pbef < pE < paft, calcul de p1,t2 / :
2532// p1 dans [pbef,pE[
2533// p2 dans ]pE,paft]
2534// si isonboundper = T, les bornes pbef et paft sont prises sur les bornes de E.
2535Standard_EXPORT Standard_Boolean FDS_parbefaft(
2536// const TopOpeBRepDS_DataStructure& BDS,
2537 const TopOpeBRepDS_DataStructure& ,
2538 const TopoDS_Edge& E,
2539 const Standard_Real pE,
2540 const Standard_Real& pbef,
2541 const Standard_Real& paft,
2542 const Standard_Boolean& isonboundper,
2543 Standard_Real& p1, Standard_Real& p2)
2544{
2545 Standard_Real t = 0.3178947713;
2546 Standard_Real f,l; FUN_tool_bounds(E,f,l);
2547 if (isonboundper) {
2548 p1 = (1-t)*pbef + t*l;
2549 p2 = (1-t)*f + t*paft;
2550 }
2551 else {
2552 p1 = (1-t)*pbef + t*pE;
2553 p2 = (1-t)*pE + t*paft;
2554 }
2555 return Standard_True;
2556} // FDS_parbefaft
2557
2558Standard_EXPORT Standard_Boolean FDS_stateEwithF2d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Edge& E,const Standard_Real pE,
2559 const TopOpeBRepDS_Kind KDS,const Standard_Integer GDS,
2560 const TopoDS_Face& F1,
2561 TopOpeBRepDS_Transition& TrmemeS)
2562{
2563 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(E);
2564 Standard_Real pbef,paft; Standard_Boolean isonper; Standard_Boolean ok = FDS_LOIinfsup(BDS,E,pE,KDS,GDS,LOI,pbef,paft,isonper);
2565 if (!ok) return Standard_False;
2566 Standard_Real t1,t2; ok = FDS_parbefaft(BDS,E,pE,pbef,paft,isonper,t1,t2);
2567 gp_Pnt P1; Standard_Boolean ok1 = FUN_tool_value(t1,E,P1);
2568 gp_Pnt P2; Standard_Boolean ok2 = FUN_tool_value(t2,E,P2);
2569 if (!ok1 || !ok2) return Standard_False;
2570
2571 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(F1);
2572 TopAbs_State sta1 = FSC_StatePonFace(P1,F1,PSC);
2573 TopAbs_State sta2 = FSC_StatePonFace(P2,F1,PSC);
2574
2575 // xpu190898 : cto014I2 (e5,fTRASHA14,vG7,eS10)
2576 if (sta1 == TopAbs_ON) sta1 = TopAbs_IN;
2577 if (sta2 == TopAbs_ON) sta2 = TopAbs_IN;
2578
2579 TrmemeS.Before(sta1,TopAbs_FACE);
2580 TrmemeS.After (sta2,TopAbs_FACE);
2581 return Standard_True;
2582}//FDS_stateEwithF2d
2583
2584#define SAMEORIENTED (1)
2585#define DIFFORIENTED (2)
2586Standard_EXPORT void FUN_ds_FEIGb1TO0(Handle(TopOpeBRepDS_HDataStructure)& HDS,
2587 const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& MEspON)
2588{
2589 //xpu250199 : F has FEI(Gb1, EG, FS), EG sdm Esd
2590 // -> to prevent from the loss of information, replace interference with
2591 // FEI'(Gb0, EGsd, FS)
2592 //CTS21754, f26 has FEI(Gb1,EG=e13, FS=f16), EG13 sd Esd11
2593
2594 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2595 Standard_Integer ns = BDS.NbShapes();
2596 for (Standard_Integer I=1; I<=ns; I++) {
2597
2598 const TopoDS_Shape& F = BDS.Shape(I);
2599 if (F. ShapeType() != TopAbs_FACE) continue;
2600 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(F);
0797d9d3 2601#ifdef OCCT_DEBUG
7fd59977 2602 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(I);
2603 if (trc) debgb1(I);
2604#endif
2605
2606 TopOpeBRepDS_ListOfInterference LGb1; // LI = LII + LGb1 (= {FEI with GB1})
2607 TopOpeBRepDS_ListOfInterference LII; FDS_copy(LI,LII);
2608 TopOpeBRepDS_ListIteratorOfListOfInterference it(LII);
2609 while (it.More()) {
2610 const Handle(TopOpeBRepDS_Interference)& Intf = it.Value();
2611 Handle(TopOpeBRepDS_FaceEdgeInterference) FEI =
2612 Handle(TopOpeBRepDS_FaceEdgeInterference)::DownCast(Intf);
2613 if (FEI.IsNull()) {
2614 it.Next();
2615 continue;
2616 }
2617 Standard_Boolean GB = FEI->GBound();
2618 if (GB != 1) {
2619 it.Next();
2620 continue;
2621 }
2622 LGb1.Append(Intf);
2623 LII.Remove(it);
2624 }//it(LII)
2625 Standard_Integer nGb1 = LGb1.Extent();
2626 if (nGb1 == 0) continue;
2627
2628 TopOpeBRepDS_ListOfInterference LGb0; // LGb1={FEIGb1(EG,FS)} -> LGb0={FEIGb0(Esd,FS)}
2629 it.Initialize(LGb1);
2630 while (it.More()) {
2631 Handle(TopOpeBRepDS_FaceEdgeInterference) IGb1 = Handle(TopOpeBRepDS_FaceEdgeInterference)::DownCast(it.Value());
2632 Standard_Integer S = IGb1->Support(); const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(S));
2633 Standard_Integer G = IGb1->Geometry();
2634 Standard_Integer Gsd; Standard_Boolean findSD = TopOpeBRepDS_TOOL::GetEsd(HDS,FS,G,Gsd);
2635 if (!findSD) {it.Next(); continue;}
2636
2637 // IGb0 is already stored in the list of interferences :
2638 TopOpeBRepDS_ListIteratorOfListOfInterference itt(LII); Standard_Boolean stored = Standard_False;
2639 for (; itt.More(); itt.Next()){
2640 const Handle(TopOpeBRepDS_Interference)& II = itt.Value();
2641 Standard_Boolean isfound = (II->Support() == S)&&(II->Geometry() == Gsd);
2642 if (isfound) {stored = Standard_True; break;}
2643 }//itt(LII)
2644 if (stored) {LGb1.Remove(it); continue;}
2645
2646 TopOpeBRepDS_Transition newT = IGb1->Transition();
2647 TopAbs_Orientation newO = newT.Orientation(TopAbs_IN);
2648 if (M_INTERNAL(newO) || M_EXTERNAL(newO)) {
2649 // nothing's done
2650 }
2651 else {
2652 Standard_Integer conf; Standard_Boolean ok = TopOpeBRepDS_TOOL::GetConfig(HDS,MEspON,G,Gsd,conf);
2653 if (!ok) {it.Next(); continue;}
2654 if (conf == DIFFORIENTED) newO = TopAbs::Complement(newO);
2655 }
0797d9d3 2656#ifdef OCCT_DEBUG
7fd59977 2657 if (trc) {cout<<"**FUN_ds_FEIGb1TO0 : IGb1";IGb1->Dump(cout);cout<<" ->";}
2658#endif
2659 newT.Set(newO);
2660 IGb1->SetGeometry(Gsd); IGb1->SetGBound(Standard_False); IGb1->Transition(newT);
0797d9d3 2661#ifdef OCCT_DEBUG
7fd59977 2662 if (trc) {IGb1->Dump(cout);cout<<endl;}
2663#endif
2664 LGb0.Append(IGb1); LGb1.Remove(it);
2665 }//it(LGb1)
2666
2667 if (LGb0.IsEmpty()) continue;
2668 TopOpeBRepDS_ListOfInterference& newLI = BDS.ChangeShapeInterferences(F);
2669 newLI.Clear();
2670 newLI.Append(LII); newLI.Append(LGb1); newLI.Append(LGb0);
2671 }//i=1..ns
2672}//FUN_ds_FEIGb1TO0
2673
2674// ----------------------------------------------------------------------
2675Standard_EXPORT void FUN_ds_complete1dForSESDM(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
2676// ----------------------------------------------------------------------
2677// MSV 25.03.2002 : OCC251
2678// purpose : SE Section edge, SDM with Esd, SE has no interference
2679// for one of vertices of Esd while should.
2680{
2681 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2682 Standard_Integer nse = BDS.NbSectionEdges();
2683
2684 for (Standard_Integer is = 1; is <= nse; is++) {
2685 const TopoDS_Edge& SE = BDS.SectionEdge(is);
2686 if (BRep_Tool::Degenerated(SE)) continue;
2687 Standard_Integer rkSE = BDS.AncestorRank(SE);
2688 Standard_Integer iSE = BDS.Shape(SE);
2689 Standard_Boolean hsd = HDS->HasSameDomain(SE);
2690 if (!hsd) continue;
2691 const TopTools_ListOfShape& LEsd = BDS.ShapeSameDomain(SE);
2692 if (LEsd.IsEmpty()) continue;
2693
2694 Standard_Real tolSE = BRep_Tool::Tolerance(SE);
2695 // map of vertices of SE or same domain with them
2696 TopTools_MapOfShape aGBMap;
2697 TopoDS_Vertex VSE[2];
2698 TopExp::Vertices(SE,VSE[0],VSE[1]);
2699 Standard_Integer i;
2700 for (i=0; i < 2; i++)
2701 if (!VSE[i].IsNull()) {
2702 aGBMap.Add(VSE[i]);
2703 const TopTools_ListOfShape& LV = BDS.ShapeSameDomain(VSE[i]);
2704 TopTools_ListIteratorOfListOfShape it(LV);
2705 for (; it.More(); it.Next())
2706 aGBMap.Add(it.Value());
2707 }
2708
2709 TopTools_ListIteratorOfListOfShape ite(LEsd);
2710 for (; ite.More(); ite.Next()){
2711 const TopoDS_Edge& Esd = TopoDS::Edge(ite.Value());
2712 Standard_Integer iEsd = BDS.Shape(Esd);
2713 Standard_Integer rkEsd = BDS.AncestorRank(Esd);
2714 if (rkEsd == rkSE) continue;
2715
2716 if (BRep_Tool::Degenerated(Esd)) continue;
2717 Standard_Boolean isSO;
2718 Standard_Boolean ok = FUN_tool_curvesSO(Esd,SE,isSO);
2719 if (!ok) continue;
2720
2721 Standard_Real tolEsd = Max (BRep_Tool::Tolerance(Esd), tolSE);
2722 // prepare the list of interferences of SE with Esd
2723 const TopOpeBRepDS_ListOfInterference& LIall = BDS.ShapeInterferences(iSE);
2724 TopOpeBRepDS_ListOfInterference LI,LI1;
2725 FDS_assign(LIall,LI);
2726 Standard_Integer ni = FUN_selectTRAUNKinterference(LI,LI1);
2727 LI1.Clear(); ni = FUN_selectTRASHAinterference(LI,TopAbs_EDGE,LI1);
2728 LI.Clear(); ni = FUN_selectITRASHAinterference(LI1,iEsd,LI);
2729 LI1.Clear(); ni = FUN_selectSKinterference(LI,TopOpeBRepDS_EDGE,LI1);
2730 LI.Clear(); ni = FUN_selectSIinterference(LI1,iEsd,LI);
2731 LI1.Clear(); ni = FUN_selectGKinterference(LI,TopOpeBRepDS_VERTEX,LI1);
2732 LI.Clear(); LI.Append(LI1);
2733
2734 // process vertices of Esd
2735 TopoDS_Vertex Vsd[2];
2736 TopExp::Vertices(Esd,Vsd[0],Vsd[1]);
2737 for (i=0; i < 2; i++) {
2738 const TopoDS_Vertex& aV = Vsd[i];
2739 if (aV.IsNull()) continue;
2740 // do not create interferences on GBound
2741 if (aGBMap.Contains(aV)) continue;
2742
2743 TopAbs_Orientation ori = aV.Orientation();
2744 if (!isSO) ori = TopAbs::Reverse(ori);
2745
2746 // check that SE has no yet interference with geometry aV oriented ori
2747 if (ni) {
2748 TopOpeBRepDS_ListOfInterference LI2;
2749 FDS_assign(LI,LI1);
2750 Standard_Integer nio = FUN_selectTRAORIinterference(LI1,ori,LI2);
2751 if (nio) {
2752 TopTools_MapOfShape aVGMap;
2753 aVGMap.Add(aV);
2754 const TopTools_ListOfShape& LV = BDS.ShapeSameDomain(aV);
2755 TopTools_ListIteratorOfListOfShape it(LV);
2756 for (; it.More(); it.Next())
2757 aVGMap.Add(it.Value());
2758 TopOpeBRepDS_ListIteratorOfListOfInterference iti(LI2);
2759 for (; iti.More(); iti.Next()) {
2760 const Handle(TopOpeBRepDS_Interference)& I1 = iti.Value();
2761 Standard_Integer gi = I1->Geometry();
2762 const TopoDS_Shape& aVG = BDS.Shape(gi);
2763 if (aVGMap.Contains(aVG)) break;
2764 }
2765 if (iti.More()) continue; // has already
2766 }
2767 }
2768
2769 // make new interference
2770 Standard_Real par;
2771 Standard_Real tol = Max (BRep_Tool::Tolerance(aV), tolEsd);
2772 Standard_Real parEsd = BRep_Tool::Parameter(aV,Esd);
2773 ok = FUN_tool_parE (Esd,parEsd,SE,par,tol);
2774 if (!ok) continue;
2775 TopOpeBRepDS_Transition aT(ori);
2776 aT.ShapeBefore(TopAbs_EDGE); aT.ShapeAfter(TopAbs_EDGE);
2777 aT.Index(iEsd);
2778 Standard_Integer iV = BDS.AddShape(aV,rkEsd);
2779 Standard_Boolean isGBound = Standard_False;
2780 TopOpeBRepDS_Config aConfig = (isSO
2781 ? TopOpeBRepDS_SAMEORIENTED
2782 : TopOpeBRepDS_DIFFORIENTED);
2783 Handle(TopOpeBRepDS_Interference) aI =
2784 TopOpeBRepDS_InterferenceTool::MakeEdgeVertexInterference
2785 (aT,iEsd,iV,isGBound,aConfig,par);
2786 HDS->StoreInterference(aI,SE);
2787 }
2788 }
2789 }
2790}