1 // Created on: 1997-12-15
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by xpu, Wed May 20 10:47:38 1998
21 #include <gp_Pnt2d.hxx>
22 #include <Geom_Curve.hxx>
24 #include <BRep_Tool.hxx>
25 #include <BRepTools.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>
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>
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>
54 #include <TopOpeBRepDS_reDEB.hxx>
55 extern Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer);
56 Standard_EXPORT void debse1(const Standard_Integer i) {cout<<"+ debse1 se"<<i<<endl;}
57 Standard_EXPORT void debse2(const Standard_Integer i) {cout<<"+ debse2 se"<<i<<endl;}
58 Standard_EXPORT void debse3(const Standard_Integer i) {cout<<"+ debse3 se"<<i<<endl;}
59 Standard_EXPORT void debse4(const Standard_Integer i) {cout<<"+ debse4 se"<<i<<endl;}
60 Standard_EXPORT void debse5(const Standard_Integer i) {cout<<"+ debse5 se"<<i<<endl;}
61 Standard_EXPORT void debse6(const Standard_Integer i) {cout<<"+ debse6 se"<<i<<endl;}
62 Standard_EXPORT void debe7(const Standard_Integer i) {cout<<"+ debe7 se"<<i<<endl;}
63 Standard_EXPORT void debse8(const Standard_Integer i) {cout<<"+ debse8 se"<<i<<endl;}
64 Standard_EXPORT void debe9(const Standard_Integer i) {cout<<"+ debe9 se"<<i<<endl;}
65 Standard_EXPORT void debgb1(const Standard_Integer i) {cout<<"+ debgb1 se"<<i<<endl;}
66 Standard_EXPORT void debse9(const Standard_Integer i) {cout<<"+ debse9 se"<<i<<endl;}
67 Standard_EXPORT void debsdm1(const Standard_Integer i) {cout<<"+ debsdm1 se"<<i<<endl;}
68 Standard_EXPORT void debsamsha(const Standard_Integer i) {cout<<"+ debsamsha se"<<i<<endl;}
69 Standard_EXPORT void debcompletefei(const Standard_Integer i) {cout<<"+ debcompletefei f"<<i<<endl;}
71 static void FUN_Raise()
74 // cout<<"FUN_ds_completeforSE"<<endl;
75 // Standard_ProgramError::Raise("FUN_ds_completeforSE");
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)
88 //------------------------------------------------------
89 Standard_EXPORT void FDS_SetT(TopOpeBRepDS_Transition& T, const TopOpeBRepDS_Transition& T0)
90 //------------------------------------------------------
92 TopAbs_State stb = T0.Before(), sta = T0.After();
93 T.Before(stb); T.After(sta);
96 //------------------------------------------------------
97 Standard_EXPORT Standard_Boolean FDS_hasUNK(const TopOpeBRepDS_Transition& T)
98 //------------------------------------------------------
100 TopAbs_State stb = T.Before(), sta = T.After();
101 Standard_Boolean hasunknown = (M_UNKNOWN(stb) || M_UNKNOWN(sta));
105 //------------------------------------------------------
106 Standard_EXPORT void FDS_copy(const TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LII)
107 //------------------------------------------------------
109 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) LII.Append(it.Value());
112 //------------------------------------------------------
113 Standard_EXPORT void FDS_copy(const TopTools_ListOfShape& LI, TopTools_ListOfShape& LII)
114 //------------------------------------------------------
116 for (TopTools_ListIteratorOfListOfShape it(LI); it.More(); it.Next()) LII.Append(it.Value());
118 //------------------------------------------------------
119 Standard_EXPORT void FDS_assign(const TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LII)
120 //------------------------------------------------------
122 LII.Clear(); FDS_copy(LI,LII);
125 //------------------------------------------------------
126 Standard_EXPORT void FDS_assign(const TopTools_ListOfShape& LI, TopTools_ListOfShape& LII)
127 //------------------------------------------------------
129 LII.Clear(); FDS_copy(LI,LII);
132 //------------------------------------------------------
133 Standard_EXPORT void FUN_ds_samRk(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer Rk,
134 TopTools_ListOfShape& LI, TopTools_ListOfShape & LIsrk)
135 //------------------------------------------------------
138 TopTools_ListIteratorOfListOfShape it(LI);
140 const TopoDS_Shape& S = it.Value(); Standard_Integer rk = BDS.AncestorRank(S);
141 if (rk == Rk) {LIsrk.Append(S);LI.Remove(it);}
146 //------------------------------------------------------
147 Standard_EXPORT void FDS_dumpLI
148 //------------------------------------------------------
150 (const TopOpeBRepDS_ListOfInterference& ,const char* )
153 (const TopOpeBRepDS_ListOfInterference& LI,const char* str)
155 for(TopOpeBRepDS_ListIteratorOfListOfInterference itD(LI);itD.More();itD.Next()) {
156 if(str) cout<<str; itD.Value()->Dump(cout); cout<<endl;
161 //------------------------------------------------------
162 Standard_EXPORT void FDS_Tdata
163 //------------------------------------------------------
164 (const Handle(TopOpeBRepDS_Interference)& I,TopAbs_ShapeEnum& SB,Standard_Integer& IB,TopAbs_ShapeEnum& SA,Standard_Integer& IA)
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();
172 //------------------------------------------------------
173 Standard_EXPORT void FDS_data
174 //------------------------------------------------------
175 (const Handle(TopOpeBRepDS_Interference)& I,TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
177 if (I.IsNull()) return;
178 GT1 = I->GeometryType(); G1 = I->Geometry();
179 ST1 = I->SupportType(); S1 = I->Support();
182 // true si la transition de l'interference courante es UNKNOWN
183 //------------------------------------------------------
184 Standard_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)
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();
195 //------------------------------------------------------
196 Standard_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)
201 if (I.IsNull()) return;
202 FDS_Tdata(I,SB,IB,SA,IA);
203 FDS_data(I,GT1,G1,ST1,S1);
206 //------------------------------------------------------
207 Standard_EXPORT Standard_Boolean FUN_ds_getVsdm
208 (const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer iV, Standard_Integer& iVsdm)
209 //------------------------------------------------------
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;
228 //------------------------------------------------------
229 Standard_EXPORT Standard_Boolean FUN_ds_sdm
230 (const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Shape& s1, const TopoDS_Shape& s2)
231 //------------------------------------------------------
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;
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 //------------------------------------------------------------------------------------
247 Standard_EXPORT Standard_Boolean FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& ES,const TopoDS_Shape& F1,const TopoDS_Shape& F2)
248 //------------------------------------------------------------------------------------
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;
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);
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);
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 //------------------------------------------------------------------------------------
283 Standard_EXPORT Standard_Boolean FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Standard_Integer isb1,const Standard_Integer isb2)
284 //------------------------------------------------------------------------------------
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);
297 //----------------------------------------------------
298 Standard_EXPORT Standard_Boolean FDS_EdgeIsConnexToSameDomainFaces
299 (const TopoDS_Shape& E,const Handle(TopOpeBRepDS_HDataStructure)& HDS) // not used
300 //----------------------------------------------------
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;
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();
314 samdom = FDS_aresamdom(BDS,E,f1,f2);
319 if (samdom) return Standard_True;
320 return Standard_False;
324 // T si ShapeIndex SI est la GeometrieIndex d'une Interference
325 // d'un Shape (Before ou After) de la Transition de I
326 //----------------------------------------------------
327 Standard_EXPORT Standard_Boolean FDS_SIisGIofIofSBAofTofI(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Handle(TopOpeBRepDS_Interference)& I)
328 //----------------------------------------------------
330 if (SI == 0) return Standard_False;
331 if (I.IsNull()) return Standard_False;
332 Standard_Boolean ya = Standard_False;
335 // const TopOpeBRepDS_Transition& T1 = I->Transition();
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);
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.
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.
372 //---------------------------------------------------------
373 Standard_EXPORT Standard_Boolean FDS_Parameter(const Handle(TopOpeBRepDS_Interference)& I, Standard_Real& par)
374 //---------------------------------------------------------
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;
383 //----------------------------------------------------
384 Standard_EXPORT Standard_Real FDS_Parameter(const Handle(TopOpeBRepDS_Interference)& I)
385 //----------------------------------------------------
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();
394 cout<<"EdgeInterference : mauvais type d'interference"<<endl;
396 Standard_Failure::Raise("FDS_Parameter");
401 //----------------------------------------------------------------------
402 Standard_EXPORT Standard_Boolean FDS_HasSameDomain3d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,TopTools_ListOfShape* PLSD)
403 //-----------------------------------------------------------------------
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;
410 Standard_Boolean hsd3d = Standard_False;
411 TopTools_ListIteratorOfListOfShape it(lssd);
412 for (; it.More(); it.Next()) {
413 const TopoDS_Shape& esd = it.Value();
415 // Standard_Integer iesd = BDS.Shape(esd);
416 // Standard_Integer resd = BDS.SameDomainInd(esd);
418 TopOpeBRepDS_Config c = BDS.SameDomainOri(esd);
419 Standard_Boolean ok = Standard_True;
420 ok = ok && (c == TopOpeBRepDS_UNSHGEOMETRY);
422 hsd3d = Standard_True;
423 if (PLSD != NULL) PLSD->Append(esd);
430 //-----------------------------------------------------------------------
431 Standard_EXPORT Standard_Boolean FDS_Config3d(const TopoDS_Shape& E1,const TopoDS_Shape& E2,TopOpeBRepDS_Config& c)
432 //-----------------------------------------------------------------------
434 Standard_Boolean same = Standard_True;
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);
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);
444 if (!ok1 || !ok2) return Standard_False;
448 Standard_Real dot = DE1.Dot(DE2);
450 c = (same) ? TopOpeBRepDS_SAMEORIENTED : TopOpeBRepDS_DIFFORIENTED;
451 return Standard_True;
454 //----------------------------------------------------------------------
455 Standard_EXPORT Standard_Boolean FDS_HasSameDomain2d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,TopTools_ListOfShape* PLSD)
456 //-----------------------------------------------------------------------
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;
463 Standard_Boolean hsd2d = Standard_False;
464 TopTools_ListIteratorOfListOfShape it(lssd);
465 for (; it.More(); it.Next()) {
466 const TopoDS_Shape& esd = it.Value();
468 // Standard_Integer iesd = BDS.Shape(esd);
469 // Standard_Integer resd = BDS.SameDomainInd(esd);
471 TopOpeBRepDS_Config c = BDS.SameDomainOri(esd);
472 Standard_Boolean ok = (c == TopOpeBRepDS_SAMEORIENTED || c == TopOpeBRepDS_DIFFORIENTED);
474 hsd2d = Standard_True;
475 if (PLSD != NULL) PLSD->Append(esd);
482 //-----------------------------------------------------------------------
483 Standard_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 //-----------------------------------------------------------------------
490 TopoDS_Edge E = TopoDS::Edge(HDS->Shape(edgeIndex));
491 FUN_tool_bounds(E,p1,p2);
493 // get p1, p2, p1<paredge<p2 with pmin, pmax nearest parameters
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;
505 // ----------------------------------------------------------------------
506 Standard_EXPORT Standard_Boolean FUN_ds_getoov(const TopoDS_Shape& v, const TopOpeBRepDS_DataStructure& BDS, TopoDS_Shape& oov)
507 //-----------------------------------------------------------------------
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;
517 return Standard_True;
519 return Standard_False;
522 // ----------------------------------------------------------------------
523 Standard_EXPORT Standard_Boolean FUN_ds_getoov(const TopoDS_Shape& v, const Handle(TopOpeBRepDS_HDataStructure)& HDS, TopoDS_Shape& oov)
524 //-----------------------------------------------------------------------
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;
534 return Standard_True;
537 return Standard_False;
540 Standard_EXPORT Standard_Boolean FUN_selectTRAINTinterference(const TopOpeBRepDS_ListOfInterference& li, TopOpeBRepDS_ListOfInterference& liINTERNAL)
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);
549 Standard_Boolean hasINT = !liINTERNAL.IsEmpty();
553 static 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)
556 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
558 const TopTools_ListOfShape& lFcE1 = FDSCNX_EdgeConnexitySameShape(E1,HDS);
559 const TopTools_ListOfShape& lFcE2 = FDSCNX_EdgeConnexitySameShape(E2,HDS);
561 TopTools_IndexedMapOfShape mapfcE2;
562 TopTools_ListIteratorOfListOfShape it2(lFcE2);
563 for (; it2.More(); it2.Next()) mapfcE2.Add(it2.Value());
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);
576 Fsd1 = TopoDS::Face(fcE1); Fsd2 = TopoDS::Face(f2);
577 return Standard_True;
580 return Standard_False;
583 //unreferenced function, commented
585 static 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)
591 // const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
593 const TopTools_ListOfShape& lf1 = FDSCNX_EdgeConnexitySameShape(E,HDS);
594 Standard_Integer nlf1 = lf1.Extent();
595 if (nlf1 < 2) return Standard_False;
597 TopTools_MapOfShape mapf;
598 TopTools_ListIteratorOfListOfShape it1(lf1);
599 for (; it1.More(); it1.Next()){
600 const TopoDS_Shape& f = it1.Value();
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());
613 TopTools_MapIteratorOfMapOfShape itm(mapf);
614 for (; itm.More(); itm.Next()) lFcx.Append(itm.Key());
615 return lFcx.Extent();
619 // ----------------------------------------------------------------------
620 Standard_EXPORT void FUN_ds_PURGEforE9(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
621 // ----------------------------------------------------------------------
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;
632 const TopoDS_Edge& E = TopoDS::Edge(EE);
633 Standard_Boolean isdgE = BRep_Tool::Degenerated(E);
636 Standard_Integer IE = BDS.Shape(E);
638 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
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;
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());
652 Standard_Boolean removed = Standard_False;
653 TopOpeBRepDS_ListIteratorOfListOfInterference it(l3dF);
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)
669 // E is edge of FF sdm with F
671 if (trc) {cout<<"-> SE9 removing I3dF :";I->Dump(cout);cout<<endl;}
673 removed = Standard_True; l3dF.Remove(it);
676 if (!removed) continue;
677 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(E);
678 LII.Clear(); LII.Append(LIcopy); LII.Append(l3dF);
682 // ----------------------------------------------------------------------
683 Standard_EXPORT void FUN_ds_completeforSE1(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
684 // ----------------------------------------------------------------------
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).
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).
698 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
699 Standard_Integer nse = BDS.NbSectionEdges();
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);
706 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
707 if (trc) debse1(ISE);
710 TopOpeBRepDS_TKI tki;
711 tki.FillOnGeometry(LI);
712 for (tki.Init(); tki.More(); tki.Next()) {
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;
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);
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()){
739 for ( ;it.More(); it.Next()){
740 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
742 // const TopOpeBRepDS_Transition& T = I->Transition();
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);
751 Standard_Integer IfES = BDS.Shape(fES);
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;
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;
763 // Standard_Integer nI4 =
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;
774 TopOpeBRepDS_Transition newT(TopAbs_INTERNAL);
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);
783 cout<<"completeforSE1 on section edge "<<ISE<<" ";
788 HDS->StoreInterference(newI,SE);
795 // ----------------------------------------------------------------------
796 Standard_EXPORT void FUN_ds_completeforSE2(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
797 // ----------------------------------------------------------------------
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.
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)
811 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
812 Standard_Integer nse = BDS.NbSectionEdges();
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);
818 Standard_Integer ISE =
821 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
823 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
824 if (trc) debse2(ISE);
827 TopOpeBRepDS_TKI tki;
828 tki.FillOnGeometry(LI);
829 for (tki.Init(); tki.More(); tki.Next()) {
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);
835 // interferences on GBound=1 not treated
836 Standard_Boolean try1 = Standard_True;
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;
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;
851 // Standard_Integer nI =
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;
859 // I = (T(FTRA),G not Gbound, ES)
860 const Handle(TopOpeBRepDS_Interference)& I = lFE.First();
861 Standard_Real par = FDS_Parameter(I);
863 // const TopOpeBRepDS_Transition& T = I->Transition();
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));
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;
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;
881 Standard_Real OOpar = 0.;
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;}
890 if (vertex) { // rkG == rkES
891 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
892 Standard_Integer rkG = BDS.AncestorRank(G);
894 // modified by NIZHNY-MKK Mon Apr 2 15:38:11 2001.BEGIN
895 // if (rkG == rkSE) OOpar = BRep_Tool::Parameter(vG,ES);
897 Standard_Integer hasvG = FUN_tool_orientVinE(vG,ES);
901 OOpar = BRep_Tool::Parameter(vG,ES);
903 // modified by NIZHNY-MKK Mon Apr 2 15:38:30 2001.END
905 TopoDS_Shape oov; Standard_Boolean hasoov = FUN_ds_getoov(vG,BDS,oov);
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;}
916 else OOpar = BRep_Tool::Parameter(TopoDS::Vertex(oov),ES);
920 gp_Pnt2d OOuv; Standard_Boolean ok = FUN_tool_paronEF(ES,OOpar,FCX,OOuv);
921 if (!ok) {FUN_Raise(); continue;}
923 TopOpeBRepDS_Transition newT;
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);
929 TopOpeBRepTool_makeTransition MKT;
930 TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
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);
937 Handle(TopOpeBRepDS_Interference) newI;
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);
943 if (trc) {cout<<"completeforSE2 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
945 HDS->StoreInterference(newI,SE);
952 static 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)
959 if (K == TopOpeBRepDS_VERTEX) return Standard_False;
960 Standard_Integer ISE = BDS.Shape(SE);
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);
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);
978 if (!okb) return Standard_False;
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;
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;
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);
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;
1007 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
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;
1016 // ----------------------------------------------------------------------
1017 Standard_EXPORT void FUN_ds_completeforSE3(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1018 // ----------------------------------------------------------------------
1020 // xpu170498 : t3 (splits of e7)
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)
1026 // b. IFE=(T'(FCX),Gpoint,S) / FCX has I=(T'',SE,SS)
1028 // purpose : when T(FTRA) is INTERNAL/EXTERNAL, the compute of spIN/spOU fails,
1029 // => compute interference I3d=IFE + IF with T==FORWARD/REVERSED.
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);
1038 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1039 if (trc) debse3(ISE);
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()) {
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);
1051 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1052 if (!ok) {newLI.Append(loicopy); continue;}
1054 // delete interferences =(T(face IF),G,S)
1055 TopOpeBRepDS_ListOfInterference lIdel;
1056 FUN_selectITRASHAinterference(loicopy,ITRASHA,lIdel);
1058 if (trc) {FDS_dumpLI(lIdel,"completeforSE3, delete :");}
1061 Handle(TopOpeBRepDS_Interference) TrFE, TrFF;
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);
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;}
1071 newLI.Append(TrFF); newLI.Append(TrFE); newLI.Append(loicopy);
1075 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE); LII.Clear();
1082 // ----------------------------------------------------------------------
1083 Standard_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)
1089 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
1090 Standard_Boolean hsdm = HDS->HasSameDomain(BDS.Shape(iE2));
1091 if (!hsdm) return Standard_False;
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));
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;
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;
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;
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);
1120 Standard_Real d1,par1; ok = FUN_tool_projPonE(P,E1,par1,d1);
1122 if (d1 > tol) continue;
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;
1130 Standard_Real prod = nxx1.Dot(nxx2);
1131 shareG = (prod > 0.);
1132 return Standard_True;
1134 return Standard_False;
1136 // ----------------------------------------------------------------------
1137 Standard_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
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)
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)
1156 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
1157 Standard_Boolean hsdm = HDS->HasSameDomain(BDS.Shape(iE2));
1158 if (!hsdm) return Standard_False;
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));
1165 Standard_Boolean EGisE2 = (iEG == iE2);
1166 Standard_Real tol = Precision::Confusion()*1.e3;
1170 Standard_Boolean ok = Standard_False;
1171 gp_Pnt P; Standard_Real parEG;
1172 if (pardef) parEG = paronEG;
1174 Standard_Real f,l; FUN_tool_bounds(Esp,f,l);
1176 // Standard_Real x = 0.45678;
1177 // Standard_Real par = (1-x)*f + x*l;
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;
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;
1194 if (EGisE2) par2 = parEG;
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;
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;
1207 Standard_Boolean sdmEGE2 = EGisE2;
1208 if (!sdmEGE2) sdmEGE2 = FUN_ds_sdm(BDS,EG,E2);
1209 if (!sdmEGE2) return Standard_False;
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;
1216 if (prod > 0.) T = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
1217 else T = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
1218 return Standard_True;
1222 #define ONSAMESHA (1)
1223 #define CLOSESAME (11)
1224 #define ONOPPOSHA (2)
1225 #define CLOSEOPPO (22)
1226 #define FORREVOPPO (222)
1228 Standard_EXPORT Standard_Integer FUN_ds_oriEinF(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& E, const TopoDS_Shape& F,
1229 TopAbs_Orientation& O)
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
1236 O = TopAbs_EXTERNAL;
1237 Standard_Integer rkF = BDS.AncestorRank(F);
1238 Standard_Integer rkE = BDS.AncestorRank(E);
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();
1246 Standard_Boolean samsha = FUN_tool_orientEinFFORWARD(EE,FF,O);
1248 Standard_Boolean iscE = BRep_Tool::IsClosed(EE,FF);
1249 if (iscE) return CLOSESAME;
1250 else return ONSAMESHA;
1252 else return UNKNOWN;
1255 const TopTools_ListOfShape& sdmFs = BDS.ShapeSameDomain(FF);
1256 Standard_Boolean hsdm = (sdmFs.Extent() > 0);
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);
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;
1269 Standard_Boolean samsha = FUN_tool_orientEinFFORWARD(EE,Fsdm,O);
1270 if (!samsha) continue;
1272 Standard_Boolean iscE = BRep_Tool::IsClosed(EE,Fsdm);
1273 if (iscE) return CLOSEOPPO;
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);
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);
1286 if (hasFOR && hasREV) return FORREVOPPO;
1287 if (hasFOR || hasREV) {
1288 O = hasFOR ? TopAbs_FORWARD : TopAbs_REVERSED;
1292 else return UNKNOWN;
1298 #define EREFandESUP (2)
1301 static 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)
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;
1315 if (SB != TopAbs_EDGE) return NONE;
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;
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);
1328 else oGinE = FUN_tool_orientVinE(VG,E);
1330 if (oGinE == 0) return EREFandESUP; // G in IN E
1332 Standard_Boolean noshare = ((oGinE == LAST) && M_FORWARD(O));
1333 noshare = noshare || ((oGinE == FIRST) && M_REVERSED(O));
1334 if (noshare) return NONE;
1336 if (SB == TopAbs_EDGE) {// E sdm edge(ST)
1337 if (!Ghsd) return EREFandESUP;
1343 Standard_EXPORT void FUN_ds_FillSDMFaces(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1345 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1346 Standard_Integer ns = BDS.NbShapes();
1348 for (Standard_Integer i= 1; i <= ns; i++) {
1349 const TopoDS_Shape& S = BDS.Shape(i);
1350 if (S.ShapeType() != TopAbs_FACE) continue;
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);
1360 Standard_Boolean hsd = (Fsdm.Extent() > 0);
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);
1370 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
1371 Standard_Integer nI = LI.Extent();
1372 if (nI < 1) continue;
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);
1387 } // ex(S, TopAbs_EDGE);
1391 Standard_EXPORT void FUN_ds_addSEsdm1d(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1393 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1394 Standard_Integer ns = BDS.NbShapes();
1395 for (Standard_Integer i= 1; i <= ns; i++) {
1397 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(i);
1398 if (trc) debsdm1(i);
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);
1406 Standard_Boolean isse = BDS.IsSectionEdge(E);
1408 Standard_Integer rkE = BDS.AncestorRank(E);
1409 if (rkE != 1) continue;
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);
1419 }// FUN_ds_addSEsdm1d
1421 Standard_EXPORT Standard_Integer FUN_ds_hasI2d(
1422 // const Standard_Integer EIX,
1423 const Standard_Integer ,
1424 const TopOpeBRepDS_ListOfInterference& LLI,
1425 TopOpeBRepDS_ListOfInterference& LI2d)
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)
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);
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);
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;
1449 is3d = Standard_True;
1453 if (!is3d) LI2d.Append(IE);
1455 Standard_Integer nLI2d = LI2d.Extent();
1459 // ----------------------------------------------------------------------
1460 Standard_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)
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);
1474 Standard_Integer ISE =
1477 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1479 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1480 if (trc) debse4(ISE);
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;
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;
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));
1502 Standard_Boolean closing = FUN_tool_IsClosingE(ES,FTRA,FTRA);
1503 if (!closing) continue;
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);
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);
1523 if (trc) {cout<<"completeforSE4 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
1525 HDS->StoreInterference(newI,SE);
1530 // ----------------------------------------------------------------------
1531 Standard_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)
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)
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);
1552 Standard_Integer ISE =
1555 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(SE);
1557 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1558 if (trc) debse5(ISE);
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;
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;}
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 // ------------------------------
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
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);
1597 gp_Pnt2d uv2; ok = FUN_tool_paronEF(E2,parE2,F2,uv2);
1599 gp_Dir ngF2 = FUN_tool_nggeomF(uv2,F2);
1600 gp_Dir xxF2; ok = FUN_tool_getxx(F2,E2,parE2,ngF2,xxF2);
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);
1609 gp_Dir ngF3 = FUN_tool_nggeomF(uv3,F3);
1610 gp_Dir xxF3; ok = FUN_tool_getxx(F3,E2,parE2,ngF3,xxF3);
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;
1617 TopAbs_Orientation newO = hasfor ? TopAbs_FORWARD : TopAbs_REVERSED;
1618 if (hasint) newO = TopAbs::Complement(newO);
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);
1627 if (trc) {cout<<"completeforSE5 se"<<ISE<<"->";newI->Dump(cout);cout<<endl;}
1630 hasnewLI = Standard_True;
1634 newLI.Append(loicopy);
1638 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE); LII.Clear();
1644 // ----------------------------------------------------------------------
1645 Standard_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
1651 // => add newI1d(newT(Esd),VG,Esd)
1652 // cto902B4 (e15,v22)
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);
1660 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1661 if (trc) debse6(ISE);
1664 TopTools_ListOfShape lEsd3d; Standard_Boolean hassd3d = FDS_HasSameDomain3d(BDS,SE,&lEsd3d);
1665 if (!hassd3d) continue;
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);
1679 TopOpeBRepDS_ListOfInterference l2dFE; FDS_assign(LIb,LIcopy);
1681 // Standard_Integer n2d =
1683 FUN_ds_hasI2d(ISE,LIcopy,l2dFE);
1684 TopOpeBRepDS_ListOfInterference l1dE; FDS_assign(LIb,LIcopy);
1686 // Standard_Integer n1d =
1688 FUN_selectTRASHAinterference(LIcopy,TopAbs_EDGE,l1dE);
1690 // attached to SE : l1dE = {I1d=(T(Esd),vG,Esd) / vG !hsd}
1691 // l2dFE = {I2dF=(T(F),vG,E) / vG !hsd}
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;
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);
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;
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
1716 TopOpeBRepDS_ListOfInterference l1dGEsd; Standard_Integer n1dGEsd = FUN_selectITRASHAinterference(l1dG,iEsd,l1dGEsd);
1717 if (n1dGEsd != 0) continue; // 1dI(Esd) at G exists already
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;
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);
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);
1737 gp_Vec tgEsd; TopOpeBRepTool_TOOL::TggeomE(parEsd,Esd,tgEsd); // dir
1738 gp_Vec tgE ; TopOpeBRepTool_TOOL::TggeomE(parE,SE,tgE); // dir
1739 Standard_Real dot = tgEsd.Dot(tgE);
1741 Standard_Real tola = Precision::Angular();
1742 if (Abs(dot) < tola) Standard_Failure::Raise("completeforSE6");
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);}
1752 Handle(TopOpeBRepDS_Interference) newI1d = MakeEPVInterference(newT,iEsd,G,parE,TopOpeBRepDS_VERTEX,Standard_False);
1754 if (trc) {cout<<"completeforS61 on section edge "<<ISE<<" ";newI1d->Dump(cout);cout<<endl;}
1756 HDS->StoreInterference(newI1d,SE);
1765 // ----------------------------------------------------------------------
1766 Standard_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)
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;
1779 const TopoDS_Edge& E = TopoDS::Edge(EE);
1780 Standard_Boolean isdgE = BRep_Tool::Degenerated(E);
1781 if (isdgE) continue;
1784 Standard_Integer IE =
1788 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
1791 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
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;
1800 // Standard_Integer n1 =
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);
1805 if ((nFOR == 0) || (nREV == 0)) continue;
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;
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);
1820 TopOpeBRepDS_Transition newT;
1822 // we have IFOR=(FORWARD(FS),G,FS) + IREV=(REVERSED(FS),G,FS)
1823 Standard_Integer IES = 0;
1825 gp_Pnt2d uvFS; Standard_Boolean ok = FUN_tool_parF(E,par,FS,uvFS);
1826 if (!ok) {FUN_Raise(); continue;}
1828 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
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);
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;}
1842 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
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);
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);
1859 Handle(TopOpeBRepDS_Interference) newIFE = MakeEPVInterference(newT,IES,G,par,K,TopOpeBRepDS_EDGE,B);
1860 lnewI.Append(newIFE);
1865 TopOpeBRepDS_ListOfInterference& loii = tki.ChangeValue(K,G);
1866 TopOpeBRepDS_ListOfInterference lEFS;
1868 // Standard_Integer nIFS =
1870 FUN_selectITRASHAinterference(loii,iFS,lEFS);
1871 for (TopOpeBRepDS_ListIteratorOfListOfInterference iti(lnewI); iti.More(); iti.Next()) {
1872 Handle(TopOpeBRepDS_Interference) newI = iti.Value();
1875 if (trc) {cout<<"completeforE7 on edge "<<IE<<" ";newI->Dump(cout);cout<<endl;}
1881 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(E);
1883 for (tki.Init(); tki.More(); tki.Next()) {
1884 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1890 // ----------------------------------------------------------------------
1891 Standard_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.
1901 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1902 Standard_Integer nse = BDS.NbSectionEdges();
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);
1909 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1910 if (trc) debse8(ISE);
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);
1920 // Standard_Boolean ispoint = (KK == TopOpeBRepDS_POINT);
1923 Standard_Boolean Ghsdm = HDS->HasSameDomain(BDS.Shape(GG));
1924 if (Ghsdm) continue;
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;
1931 // Standard_Integer nFE =
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)
1936 // Standard_Integer n3d = lFE.Extent();
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;
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);
1949 if (trc) {cout<<"SE8 -> on SE"<<ISE<<" reducedI :";I2dFE->Dump(cout);cout<<endl;}
1953 l2dFE.Append(al2dFE);
1956 TopOpeBRepDS_ListOfInterference& loii = tki.ChangeValue(KK,GG);
1958 loii.Append(l1dE); loii.Append(lFE); loii.Append(l2dFE); loii.Append(li);
1961 if (!hasnew) continue;
1962 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE);
1964 for (tki.Init(); tki.More(); tki.Next()) {
1965 TopOpeBRepDS_Kind KK; Standard_Integer GG; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(KK,GG);
1971 // ----------------------------------------------------------------------
1972 Standard_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.
1978 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1979 Standard_Integer nse = BDS.NbSectionEdges();
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);
1986 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(ISE);
1987 if (trc) debse9(ISE);
1989 Standard_Boolean hsd = HDS->HasSameDomain(SE);
1991 if (!BDS.ShapeInterferences(SE).IsEmpty()) continue;
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;
2002 TopOpeBRepDS_ListOfInterference LIcopy; FDS_assign(LI,LIcopy);
2003 TopOpeBRepDS_ListOfInterference LISE;
2005 // Standard_Integer nise =
2007 FUN_selectSIinterference(LIcopy,ISE,LISE);
2009 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LISE);
2010 for (tki.Init(); tki.More(); tki.Next()) {
2011 TopOpeBRepDS_Kind K;
2013 // const TopOpeBRepDS_ListOfInterference& loi =
2016 // const Handle(TopOpeBRepDS_Interference)& I = loi.First();
2017 // TopAbs_Orientation O = I->Transition().Orientation(TopAbs_IN);
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
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);
2033 // modified by NIZHNY-MKK Mon Apr 2 15:39:17 2001.END
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);
2038 if (trc) {cout<<"completeforSE6 on section edge "<<ISE<<" ";newI->Dump(cout);cout<<endl;}
2040 HDS->StoreInterference(newI,SE);
2046 // ----------------------------------------------------------------------
2047 Standard_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-
2057 Standard_Integer i ;
2058 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2059 Standard_Integer ns = BDS.NbShapes();
2060 TColStd_DataMapOfIntegerInteger iPiV;
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;
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;
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;
2085 Gfaulty = Standard_True; break;
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);
2097 if (df < dl) vG = vf;
2100 Standard_Integer ivG = BDS.AddShape(vG,rkES);
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;
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;
2120 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2121 Standard_Boolean Gisbound = iPiV.IsBound(G);
2123 FDS_copy(loi,newLI);
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);
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;
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;
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);
2153 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(s);
2154 LII.Clear(); LII.Append(newLI);
2157 TColStd_DataMapIteratorOfDataMapOfIntegerInteger itm(iPiV);
2158 for (; itm.More(); itm.Next()){
2159 Standard_Integer G = itm.Key();
2164 static 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)
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;
2179 Standard_Real factor = 1.e-2; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
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);
2187 ok = FDS_stateEwithF2d(BDS,E,parE,GT,G,FTRA,newT);
2188 if (!ok) return Standard_False;
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
2195 // ----------------------------------------------------------------------
2196 Standard_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)
2203 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2204 Standard_Integer ns = BDS.NbShapes();
2206 for (Standard_Integer i = 1; i <= ns; i++) {
2207 if (BDS.Shape(i).ShapeType() != TopAbs_EDGE) continue;
2209 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(i));
2211 // Standard_Boolean isse = BDS.IsSectionEdge(E);
2212 // Standard_Integer rkE = BDS.AncestorRank(E);
2214 Standard_Integer IE = BDS.Shape(E);
2216 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(IE);
2217 if (trc) debsamsha(IE);
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;
2227 // Standard_Integer n0 =
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;
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;
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;}
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
2265 if (O1 == TopAbs::Complement(O2)) {oppofound=Standard_True; break;}
2266 else {it2.Next(); continue;}
2269 if (!oppofound) {it1.Next(); continue;}
2270 Standard_Boolean ok = FUN_redusamshaonE(BDS,I1,IE,newI);
2271 if (!ok) {it1.Next(); continue;}
2274 if (newI.IsNull()) continue;
2276 if (trc) {cout<<"redusamsha se"<<IE<<"FORWARD/REVERSED ->";newI->Dump(cout);cout<<endl;}
2278 li.Clear(); li.Append(newI);
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);
2287 newloi.Append(l0); newloi.Append(l1);
2290 TopOpeBRepDS_ListOfInterference& newLI = BDS.ChangeShapeInterferences(E);
2292 for (tki.Init(); tki.More(); tki.Next()) {
2293 TopOpeBRepDS_Kind KK; Standard_Integer GG; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(KK,GG);
2297 } //FUN_ds_redusamsha
2299 Standard_EXPORT Standard_Boolean FUN_ds_hasFEI(const TopOpeBRepDS_PDataStructure& pDS2d, const TopoDS_Shape& F, const Standard_Integer GI, const Standard_Integer ITRA)
2301 Standard_Boolean hasF = pDS2d->HasShape(F);
2302 if (!hasF) return Standard_False;
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;
2312 return Standard_False;
2315 Standard_EXPORT Standard_Boolean FUN_ds_ONesd(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer IE, const TopoDS_Shape& EspON, Standard_Integer& IEsd)
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;
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);
2328 Standard_Real tolesd = BRep_Tool::Tolerance(esd);
2329 ok = (d < tolesd*1.e3); //nyi checktole
2331 IEsd = BDS.Shape(esd);
2332 return Standard_True;
2334 return Standard_False;
2339 static Standard_Boolean FUN_oriTOsta(const Standard_Integer o, const TopAbs_State sta, TopAbs_Orientation& ori)
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;
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;
2353 Standard_EXPORT void FUN_ds_unkeepEVIonGb1(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const TopAbs_State sta)
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)
2360 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2361 Standard_Integer ns = BDS.NbShapes();
2362 for (Standard_Integer i = 1; i <= ns; i++) {
2364 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(i);
2367 const TopoDS_Shape& s = BDS.Shape(i);
2368 if (s.ShapeType() != TopAbs_EDGE) continue;
2370 const TopoDS_Edge& E = TopoDS::Edge(s);
2371 TopOpeBRepDS_ListOfInterference& LI = BDS.ChangeShapeInterferences(s);
2372 if (LI.IsEmpty()) continue;
2374 Standard_Boolean dgE = BRep_Tool::Degenerated(E);
2376 TopoDS_Vertex dum; Standard_Boolean closed = FUN_tool_ClosedE(E,dum);
2377 if (closed) continue;
2379 TopOpeBRepDS_Kind K; Standard_Integer G; Standard_Boolean ok = Standard_False;
2380 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
2382 for (tki.Init(); tki.More(); tki.Next()) {
2384 if (K != TopOpeBRepDS_VERTEX) break;
2389 TopOpeBRepDS_ListOfInterference newLI;
2390 for (tki.Init(); tki.More(); tki.Next()) {
2392 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
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;}
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);
2410 if (trc) {cout<<"unkeepEVIonGb1 on e"<<i<<" ";I->Dump(cout);cout<<endl;}
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)
2420 LI.Clear(); LI.Append(newLI);
2423 } //FUN_ds_unkeepEVIonGb1*/
2425 Standard_EXPORT Standard_Boolean FDS_LOIinfsup(
2426 const TopOpeBRepDS_DataStructure&
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)
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);
2447 Standard_Real f,l; FUN_tool_bounds(E,f,l);
2449 Standard_Integer n = LOI.Extent();
2450 if (n == 0) return Standard_True;
2453 TopOpeBRepDS_ListOfInterference LOIsansGDS;
2454 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
2456 if (TRC) cout<<endl<<"FDS_LOIinfsup E"<<EIX<<" tki"<<endl;
2457 if (TRC) tki.DumpTKIIterator("","\n");
2458 if (TRC) debredpvg(EIX);
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;
2468 if (TRC) {tki.DumpTKI(K,G,"","\n");debredpvg(EIX);}
2471 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
2473 // Standard_Integer nloi = loi.Extent();
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);
2490 if (TRC) cout<<endl<<"FDS_LOIinfsup.2 E"<<EIX<<" : "<<LOIsansGDS.Extent()<<endl;
2491 if (TRC) debredpvg(EIX);
2494 n = LOIsansGDS.Extent();
2495 if (n == 0) return Standard_True;
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;
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;
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);
2515 if (p > pbef) pbef = p;
2516 if (p < paft) paft = p;
2518 return Standard_True;
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;
2528 return Standard_True;
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.
2535 Standard_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)
2545 Standard_Real t = 0.3178947713;
2546 Standard_Real f,l; FUN_tool_bounds(E,f,l);
2548 p1 = (1-t)*pbef + t*l;
2549 p2 = (1-t)*f + t*paft;
2552 p1 = (1-t)*pbef + t*pE;
2553 p2 = (1-t)*pE + t*paft;
2555 return Standard_True;
2558 Standard_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)
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;
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);
2575 // xpu190898 : cto014I2 (e5,fTRASHA14,vG7,eS10)
2576 if (sta1 == TopAbs_ON) sta1 = TopAbs_IN;
2577 if (sta2 == TopAbs_ON) sta2 = TopAbs_IN;
2579 TrmemeS.Before(sta1,TopAbs_FACE);
2580 TrmemeS.After (sta2,TopAbs_FACE);
2581 return Standard_True;
2582 }//FDS_stateEwithF2d
2584 #define SAMEORIENTED (1)
2585 #define DIFFORIENTED (2)
2586 Standard_EXPORT void FUN_ds_FEIGb1TO0(Handle(TopOpeBRepDS_HDataStructure)& HDS,
2587 const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& MEspON)
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
2594 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2595 Standard_Integer ns = BDS.NbShapes();
2596 for (Standard_Integer I=1; I<=ns; I++) {
2598 const TopoDS_Shape& F = BDS.Shape(I);
2599 if (F. ShapeType() != TopAbs_FACE) continue;
2600 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(F);
2602 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(I);
2606 TopOpeBRepDS_ListOfInterference LGb1; // LI = LII + LGb1 (= {FEI with GB1})
2607 TopOpeBRepDS_ListOfInterference LII; FDS_copy(LI,LII);
2608 TopOpeBRepDS_ListIteratorOfListOfInterference it(LII);
2610 const Handle(TopOpeBRepDS_Interference)& Intf = it.Value();
2611 Handle(TopOpeBRepDS_FaceEdgeInterference) FEI =
2612 Handle(TopOpeBRepDS_FaceEdgeInterference)::DownCast(Intf);
2617 Standard_Boolean GB = FEI->GBound();
2625 Standard_Integer nGb1 = LGb1.Extent();
2626 if (nGb1 == 0) continue;
2628 TopOpeBRepDS_ListOfInterference LGb0; // LGb1={FEIGb1(EG,FS)} -> LGb0={FEIGb0(Esd,FS)}
2629 it.Initialize(LGb1);
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;}
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;}
2644 if (stored) {LGb1.Remove(it); continue;}
2646 TopOpeBRepDS_Transition newT = IGb1->Transition();
2647 TopAbs_Orientation newO = newT.Orientation(TopAbs_IN);
2648 if (M_INTERNAL(newO) || M_EXTERNAL(newO)) {
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);
2657 if (trc) {cout<<"**FUN_ds_FEIGb1TO0 : IGb1";IGb1->Dump(cout);cout<<" ->";}
2660 IGb1->SetGeometry(Gsd); IGb1->SetGBound(Standard_False); IGb1->Transition(newT);
2662 if (trc) {IGb1->Dump(cout);cout<<endl;}
2664 LGb0.Append(IGb1); LGb1.Remove(it);
2667 if (LGb0.IsEmpty()) continue;
2668 TopOpeBRepDS_ListOfInterference& newLI = BDS.ChangeShapeInterferences(F);
2670 newLI.Append(LII); newLI.Append(LGb1); newLI.Append(LGb0);
2674 // ----------------------------------------------------------------------
2675 Standard_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.
2681 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2682 Standard_Integer nse = BDS.NbSectionEdges();
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);
2691 const TopTools_ListOfShape& LEsd = BDS.ShapeSameDomain(SE);
2692 if (LEsd.IsEmpty()) continue;
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]);
2700 for (i=0; i < 2; i++)
2701 if (!VSE[i].IsNull()) {
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());
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;
2716 if (BRep_Tool::Degenerated(Esd)) continue;
2717 Standard_Boolean isSO;
2718 Standard_Boolean ok = FUN_tool_curvesSO(Esd,SE,isSO);
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);
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;
2743 TopAbs_Orientation ori = aV.Orientation();
2744 if (!isSO) ori = TopAbs::Reverse(ori);
2746 // check that SE has no yet interference with geometry aV oriented ori
2748 TopOpeBRepDS_ListOfInterference LI2;
2750 Standard_Integer nio = FUN_selectTRAORIinterference(LI1,ori,LI2);
2752 TopTools_MapOfShape aVGMap;
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;
2765 if (iti.More()) continue; // has already
2769 // make new interference
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);
2775 TopOpeBRepDS_Transition aT(ori);
2776 aT.ShapeBefore(TopAbs_EDGE); aT.ShapeAfter(TopAbs_EDGE);
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);