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
19 #include <gp_Pnt2d.hxx>
21 #include <BRepTools.hxx>
23 #include <TopExp_Explorer.hxx>
24 #include <Precision.hxx>
25 #include <GeomAdaptor_Surface.hxx>
26 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
28 #include <TopOpeBRepTool_ShapeTool.hxx>
29 #include <TopOpeBRepTool_TOOL.hxx>
30 #include <TopOpeBRepTool_EXPORT.hxx>
31 #include <TopOpeBRepTool_SC.hxx>
32 #include <TopOpeBRepTool_makeTransition.hxx>
33 #include <Standard_ProgramError.hxx>
35 #include <TopOpeBRepDS_InterferenceTool.hxx>
36 #include <TopOpeBRepDS_PointIterator.hxx>
37 #include <TopOpeBRepDS_BuildTool.hxx>
38 #include <TopOpeBRepDS_EXPORT.hxx>
39 #include <TopOpeBRepDS_connex.hxx>
40 #include <TopOpeBRepDS_TKI.hxx>
41 #include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
42 #include <TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State.hxx>
43 #include <TopOpeBRepDS_TOOL.hxx>
44 #include <TopOpeBRepDS_define.hxx>
46 #define M_IN(st) (st == TopAbs_IN)
47 #define M_ON(st) (st == TopAbs_ON)
48 #define M_OUT(st) (st == TopAbs_OUT)
49 #define M_FORWARD(st) (st == TopAbs_FORWARD)
50 #define M_UNKNOWN(st) (st == TopAbs_UNKNOWN)
51 #define M_REVERSED(st) (st == TopAbs_REVERSED)
52 #define M_INTERNAL(st) (st == TopAbs_INTERNAL)
53 #define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
55 //------------------------------------------------------
56 Standard_EXPORT void FDS_SetT(TopOpeBRepDS_Transition& T, const TopOpeBRepDS_Transition& T0)
57 //------------------------------------------------------
59 TopAbs_State stb = T0.Before(), sta = T0.After();
60 T.Before(stb); T.After(sta);
63 //------------------------------------------------------
64 Standard_EXPORT Standard_Boolean FDS_hasUNK(const TopOpeBRepDS_Transition& T)
65 //------------------------------------------------------
67 TopAbs_State stb = T.Before(), sta = T.After();
68 Standard_Boolean hasunknown = (M_UNKNOWN(stb) || M_UNKNOWN(sta));
72 //------------------------------------------------------
73 Standard_EXPORT void FDS_copy(const TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LII)
74 //------------------------------------------------------
76 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) LII.Append(it.Value());
79 //------------------------------------------------------
80 Standard_EXPORT void FDS_copy(const TopTools_ListOfShape& LI, TopTools_ListOfShape& LII)
81 //------------------------------------------------------
83 for (TopTools_ListIteratorOfListOfShape it(LI); it.More(); it.Next()) LII.Append(it.Value());
85 //------------------------------------------------------
86 Standard_EXPORT void FDS_assign(const TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LII)
87 //------------------------------------------------------
89 LII.Clear(); FDS_copy(LI,LII);
92 //------------------------------------------------------
93 Standard_EXPORT void FDS_assign(const TopTools_ListOfShape& LI, TopTools_ListOfShape& LII)
94 //------------------------------------------------------
96 LII.Clear(); FDS_copy(LI,LII);
99 //------------------------------------------------------
100 Standard_EXPORT void FUN_ds_samRk(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer Rk,
101 TopTools_ListOfShape& LI, TopTools_ListOfShape & LIsrk)
102 //------------------------------------------------------
105 TopTools_ListIteratorOfListOfShape it(LI);
107 const TopoDS_Shape& S = it.Value(); Standard_Integer rk = BDS.AncestorRank(S);
108 if (rk == Rk) {LIsrk.Append(S);LI.Remove(it);}
113 //------------------------------------------------------
114 Standard_EXPORT void FDS_Tdata
115 //------------------------------------------------------
116 (const Handle(TopOpeBRepDS_Interference)& I,TopAbs_ShapeEnum& SB,Standard_Integer& IB,TopAbs_ShapeEnum& SA,Standard_Integer& IA)
118 if (I.IsNull()) return;
119 const TopOpeBRepDS_Transition T = I->Transition();
120 SB = T.ShapeBefore(); IB = T.IndexBefore();
121 SA = T.ShapeAfter(); IA = T.IndexAfter();
124 //------------------------------------------------------
125 Standard_EXPORT void FDS_data
126 //------------------------------------------------------
127 (const Handle(TopOpeBRepDS_Interference)& I,TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
129 if (I.IsNull()) return;
130 GT1 = I->GeometryType(); G1 = I->Geometry();
131 ST1 = I->SupportType(); S1 = I->Support();
134 // true si la transition de l'interference courante es UNKNOWN
135 //------------------------------------------------------
136 Standard_EXPORT Standard_Boolean FDS_data
137 //------------------------------------------------------
138 (const TopOpeBRepDS_ListIteratorOfListOfInterference& it1,Handle(TopOpeBRepDS_Interference)& I1,TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
140 if (!it1.More()) return Standard_False;
141 I1 = it1.Value(); const TopOpeBRepDS_Transition& T1 = I1->Transition();
142 FDS_data(I1,GT1,G1,ST1,S1);
143 Standard_Boolean isunk1 = T1.IsUnknown();
147 //------------------------------------------------------
148 Standard_EXPORT void FDS_Idata
149 //------------------------------------------------------
150 (const Handle(TopOpeBRepDS_Interference)& I,TopAbs_ShapeEnum& SB,Standard_Integer& IB,TopAbs_ShapeEnum& SA,Standard_Integer& IA,
151 TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
153 if (I.IsNull()) return;
154 FDS_Tdata(I,SB,IB,SA,IA);
155 FDS_data(I,GT1,G1,ST1,S1);
158 //------------------------------------------------------
159 Standard_EXPORT Standard_Boolean FUN_ds_getVsdm
160 (const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer iV, Standard_Integer& iVsdm)
161 //------------------------------------------------------
164 Standard_Boolean found = Standard_False;
165 // getting <Vsdm> shape same domain with <V>.
166 Standard_Integer imax = BDS.NbShapes();
167 Standard_Boolean undef = (iV < 1) || (iV > imax);
168 if (undef) return Standard_False;
169 const TopoDS_Shape& V = BDS.Shape(iV);
170 TopTools_ListIteratorOfListOfShape issdm(BDS.ShapeSameDomain(V));
171 for (; issdm.More(); issdm.Next()){
172 const TopoDS_Shape& VV = issdm.Value();
173 if (V.IsSame(VV)) continue;
174 iVsdm = BDS.Shape(VV);
175 found = Standard_True; break;
180 //------------------------------------------------------
181 Standard_EXPORT Standard_Boolean FUN_ds_sdm
182 (const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Shape& s1, const TopoDS_Shape& s2)
183 //------------------------------------------------------
185 if (!BDS.HasShape(s1) || !BDS.HasShape(s2)) return Standard_False;
186 const TopTools_ListOfShape& sdm1 = BDS.ShapeSameDomain(s1);
187 TopTools_ListIteratorOfListOfShape it1(sdm1);
188 for (; it1.More(); it1.Next())
189 if (it1.Value().IsSame(s2)) return Standard_True;
190 return Standard_False;
193 // True si les faces isb1,isb2, issues du meme shape origine, connexes par l'arete SI, sont tangentes.
194 // 1/ analyse du codage SameDomain dans la DS.
195 // 2/ si pas de codage SameDomain dans la DS, analyse geometrique.
196 // cette deuxieme analyse est necessaire car l'info SameDomain n'est pas recherchee entre les
197 // faces d'un meme shape origine.
198 //------------------------------------------------------------------------------------
199 Standard_EXPORT Standard_Boolean FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& ES,const TopoDS_Shape& F1,const TopoDS_Shape& F2)
200 //------------------------------------------------------------------------------------
202 Standard_Boolean trfa_samdom = Standard_False;
203 const TopTools_ListOfShape& ls = BDS.ShapeSameDomain(F1);
204 TopTools_ListIteratorOfListOfShape it(ls);
205 for(;it.More();it.Next()) { // NYI : syntaxe rapide de BDS IsShapeSameDomainofShape
206 const TopoDS_Shape& ss = it.Value();
207 trfa_samdom = ss.IsSame(F2);
208 if (trfa_samdom) break;
210 if ( !trfa_samdom ) {
211 Handle(Geom_Surface) su1 = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F1));
212 GeomAdaptor_Surface gs1(su1); GeomAbs_SurfaceType st1 = gs1.GetType();
213 Handle(Geom_Surface) su2 = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F2));
214 GeomAdaptor_Surface gs2(su2); GeomAbs_SurfaceType st2 = gs2.GetType();
215 Standard_Boolean plpl = (st1 == GeomAbs_Plane) && ( st2 == GeomAbs_Plane);
218 gp_Pnt2d p2d1,p2d2; BRep_Tool::UVPoints(TopoDS::Edge(ES),TopoDS::Face(F1),p2d1,p2d2);
219 gp_Dir d1 = FUN_tool_ngS(p2d1,su1);
220 gp_Dir d2 = FUN_tool_ngS(p2d2,su2);
221 Standard_Real tola = Precision::Angular();
222 Standard_Real dot = d1.Dot(d2);
223 trfa_samdom = (Abs(1. - Abs(dot)) < tola);
229 // True si les faces isb1,isb2, issues du meme shape origine, connexes par l'arete SI, sont tangentes.
230 // 1/ analyse du codage SameDomain dans la DS.
231 // 2/ si pas de codage SameDomain dans la DS, analyse geometrique.
232 // cette deuxieme analyse est necessaire car l'info SameDomain n'est pas recherchee entre les
233 // faces d'un meme shape origine.
234 //------------------------------------------------------------------------------------
235 Standard_EXPORT Standard_Boolean FDS_aresamdom(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Standard_Integer isb1,const Standard_Integer isb2)
236 //------------------------------------------------------------------------------------
238 Standard_Boolean trfa_samdom = Standard_False;
239 const TopoDS_Shape& ES = BDS.Shape(SI); // edge de F1 et F2
240 if (ES.ShapeType() != TopAbs_EDGE) return Standard_False;
241 const TopoDS_Shape& F1 = BDS.Shape(isb1);
242 if (F1.ShapeType() != TopAbs_FACE) return Standard_False;
243 const TopoDS_Shape& F2 = BDS.Shape(isb2);
244 if (F2.ShapeType() != TopAbs_FACE) return Standard_False;
245 trfa_samdom = FDS_aresamdom(BDS,ES,F1,F2);
249 //----------------------------------------------------
250 Standard_EXPORT Standard_Boolean FDS_EdgeIsConnexToSameDomainFaces
251 (const TopoDS_Shape& E,const Handle(TopOpeBRepDS_HDataStructure)& HDS) // not used
252 //----------------------------------------------------
254 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
255 const TopTools_ListOfShape& lf = FDSCNX_EdgeConnexitySameShape(E,HDS);
256 Standard_Integer nlf = lf.Extent();
257 if (nlf < 2) return Standard_False;
259 Standard_Boolean samdom = Standard_False;
260 TopTools_ListIteratorOfListOfShape i1(lf);
261 for(;i1.More();i1.Next()) {
262 const TopoDS_Shape& f1 = i1.Value();
263 TopTools_ListIteratorOfListOfShape i2(i1);
264 for(;i2.More();i2.Next()) {
265 const TopoDS_Shape& f2 = i2.Value();
266 samdom = FDS_aresamdom(BDS,E,f1,f2);
271 if (samdom) return Standard_True;
272 return Standard_False;
276 // T si ShapeIndex SI est la GeometrieIndex d'une Interference
277 // d'un Shape (Before ou After) de la Transition de I
278 //----------------------------------------------------
279 Standard_EXPORT Standard_Boolean FDS_SIisGIofIofSBAofTofI(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Handle(TopOpeBRepDS_Interference)& I)
280 //----------------------------------------------------
282 if (SI == 0) return Standard_False;
283 if (I.IsNull()) return Standard_False;
284 Standard_Boolean ya = Standard_False;
286 TopAbs_ShapeEnum SB1 = TopAbs_SHAPE, SA1 = TopAbs_SHAPE; Standard_Integer IB1 = 0, IA1 = 0; TopOpeBRepDS_Kind GT1 = TopOpeBRepDS_UNKNOWN, ST1 = TopOpeBRepDS_UNKNOWN; Standard_Integer G1 = 0, S1 = 0;
287 FDS_Idata(I,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1);
289 if (SB1 == TopAbs_FACE) {
290 const TopOpeBRepDS_ListOfInterference& Bloi = BDS.ShapeInterferences(IB1);
291 TopOpeBRepDS_ListIteratorOfListOfInterference it(Bloi);
292 for(; it.More(); it.Next()) {
293 const Handle(TopOpeBRepDS_Interference)& IB = it.Value();
294 TopAbs_ShapeEnum SBB = TopAbs_SHAPE, SAB = TopAbs_SHAPE; Standard_Integer IBB = 0, IAB = 0; TopOpeBRepDS_Kind GTB = TopOpeBRepDS_UNKNOWN, STB = TopOpeBRepDS_UNKNOWN; Standard_Integer GB = 0, SB = 0;
295 FDS_Idata(IB,SBB,IBB,SAB,IAB,GTB,GB,STB,SB);
296 if (GTB == TopOpeBRepDS_EDGE && GB == SI) {
297 // la face IB1 a une interference dont la geometrie est l'arete SI.
303 else if (SA1 == TopAbs_FACE) {
304 const TopOpeBRepDS_ListOfInterference& Aloi = BDS.ShapeInterferences(IA1);
305 TopOpeBRepDS_ListIteratorOfListOfInterference it(Aloi);
306 for(; it.More(); it.Next()) {
307 const Handle(TopOpeBRepDS_Interference)& IA = it.Value();
308 TopAbs_ShapeEnum SBA = TopAbs_SHAPE, SAA = TopAbs_SHAPE;Standard_Integer IBA = 0, IAA = 0; TopOpeBRepDS_Kind GTA = TopOpeBRepDS_UNKNOWN, STA = TopOpeBRepDS_UNKNOWN; Standard_Integer GA = 0, SA = 0;
309 FDS_Idata(IA,SBA,IBA,SAA,IAA,GTA,GA,STA,SA);
310 if (GTA == TopOpeBRepDS_EDGE && GA == SI) {
311 // la face IA1 a une interference dont la geometrie est l'arete IS.
321 //---------------------------------------------------------
322 Standard_EXPORT Standard_Boolean FDS_Parameter(const Handle(TopOpeBRepDS_Interference)& I, Standard_Real& par)
323 //---------------------------------------------------------
325 Standard_Boolean isEVI = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
326 Standard_Boolean isCPI = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference));
327 if (!isEVI && !isCPI) return Standard_False;
328 par = FDS_Parameter(I);
329 return Standard_True;
332 //----------------------------------------------------
333 Standard_EXPORT Standard_Real FDS_Parameter(const Handle(TopOpeBRepDS_Interference)& I)
334 //----------------------------------------------------
337 if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) )
338 p = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->Parameter();
339 else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) )
340 p = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I)->Parameter();
342 throw Standard_Failure("FDS_Parameter");
347 //----------------------------------------------------------------------
348 Standard_EXPORT Standard_Boolean FDS_HasSameDomain3d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,TopTools_ListOfShape* PLSD)
349 //-----------------------------------------------------------------------
351 const TopTools_ListOfShape& lssd = BDS.ShapeSameDomain(E);
352 Standard_Boolean hsd = (! lssd.IsEmpty());
353 if (PLSD != NULL) PLSD->Clear();
354 if (!hsd) return Standard_False;
356 Standard_Boolean hsd3d = Standard_False;
357 TopTools_ListIteratorOfListOfShape it(lssd);
358 for (; it.More(); it.Next()) {
359 const TopoDS_Shape& esd = it.Value();
360 TopOpeBRepDS_Config c = BDS.SameDomainOri(esd);
361 Standard_Boolean ok = Standard_True;
362 ok = ok && (c == TopOpeBRepDS_UNSHGEOMETRY);
364 hsd3d = Standard_True;
365 if (PLSD != NULL) PLSD->Append(esd);
372 //-----------------------------------------------------------------------
373 Standard_EXPORT Standard_Boolean FDS_Config3d(const TopoDS_Shape& E1,const TopoDS_Shape& E2,TopOpeBRepDS_Config& c)
374 //-----------------------------------------------------------------------
376 Standard_Boolean same = Standard_True;
378 gp_Pnt PE1;Standard_Real pE1;
379 Standard_Boolean ok1 = FUN_tool_findPinE(TopoDS::Edge(E1),PE1,pE1);
380 gp_Vec VE1; if (ok1) ok1 = TopOpeBRepTool_TOOL::TggeomE(pE1,TopoDS::Edge(E1),VE1);
382 Standard_Real pE2,dE2;
383 Standard_Boolean ok2 = FUN_tool_projPonE(PE1,TopoDS::Edge(E2),pE2,dE2);
384 gp_Vec VE2; if (ok2) ok2 = TopOpeBRepTool_TOOL::TggeomE(pE2,TopoDS::Edge(E2),VE2);
386 if (!ok1 || !ok2) return Standard_False;
390 Standard_Real dot = DE1.Dot(DE2);
392 c = (same) ? TopOpeBRepDS_SAMEORIENTED : TopOpeBRepDS_DIFFORIENTED;
393 return Standard_True;
396 //----------------------------------------------------------------------
397 Standard_EXPORT Standard_Boolean FDS_HasSameDomain2d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,TopTools_ListOfShape* PLSD)
398 //-----------------------------------------------------------------------
400 const TopTools_ListOfShape& lssd = BDS.ShapeSameDomain(E);
401 Standard_Boolean hsd = (! lssd.IsEmpty());
402 if (PLSD != NULL) PLSD->Clear();
403 if (!hsd) return Standard_False;
405 Standard_Boolean hsd2d = Standard_False;
406 TopTools_ListIteratorOfListOfShape it(lssd);
407 for (; it.More(); it.Next()) {
408 const TopoDS_Shape& esd = it.Value();
409 TopOpeBRepDS_Config c = BDS.SameDomainOri(esd);
410 Standard_Boolean ok = (c == TopOpeBRepDS_SAMEORIENTED || c == TopOpeBRepDS_DIFFORIENTED);
412 hsd2d = Standard_True;
413 if (PLSD != NULL) PLSD->Append(esd);
420 //-----------------------------------------------------------------------
421 Standard_EXPORT void FDS_getupperlower
422 (const Handle(TopOpeBRepDS_HDataStructure)& HDS,
423 const Standard_Integer edgeIndex,
424 const Standard_Real paredge,
425 Standard_Real& p1, Standard_Real& p2)
426 //-----------------------------------------------------------------------
428 TopoDS_Edge E = TopoDS::Edge(HDS->Shape(edgeIndex));
429 FUN_tool_bounds(E,p1,p2);
431 // get p1, p2, p1<paredge<p2 with pmin, pmax nearest parameters
433 TopOpeBRepDS_PointIterator pIte = HDS->EdgePoints(E);
434 for (;pIte.More();pIte.Next()) {
435 par = pIte.Parameter();
436 Standard_Boolean parsup1 = (par > p1), parinfe = (par < paredge);
437 Standard_Boolean parinf2 = (par < p2), parsupe = (par > paredge);
438 if (parsup1 && parinfe) p1 = par;
439 if (parinf2 && parsupe) p2 = par;
443 // ----------------------------------------------------------------------
444 Standard_EXPORT Standard_Boolean FUN_ds_getoov(const TopoDS_Shape& v, const TopOpeBRepDS_DataStructure& BDS, TopoDS_Shape& oov)
445 //-----------------------------------------------------------------------
447 // prequesitory : the DS binds at most 2 vertices same domain
448 TopoDS_Shape nullS; oov = nullS;
449 const TopTools_ListOfShape& vsd = BDS.ShapeSameDomain(v);
450 TopTools_ListIteratorOfListOfShape itlov(vsd);
451 for (; itlov.More(); itlov.Next()){
452 const TopoDS_Shape& vcur = itlov.Value();
453 if (vcur.IsSame(v)) continue;
455 return Standard_True;
457 return Standard_False;
460 // ----------------------------------------------------------------------
461 Standard_EXPORT Standard_Boolean FUN_ds_getoov(const TopoDS_Shape& v, const Handle(TopOpeBRepDS_HDataStructure)& HDS, TopoDS_Shape& oov)
462 //-----------------------------------------------------------------------
464 // prequesitory : the DS binds at most 2 vertices same domain
465 TopoDS_Shape nullS; oov = nullS;
466 if (HDS->HasSameDomain(v)) {
467 TopTools_ListIteratorOfListOfShape itlov(HDS->SameDomain(v));
468 for (; itlov.More(); itlov.Next()){
469 const TopoDS_Shape& vcur = itlov.Value();
470 if (vcur.IsSame(v)) continue;
472 return Standard_True;
475 return Standard_False;
478 Standard_EXPORT Standard_Boolean FUN_selectTRAINTinterference(const TopOpeBRepDS_ListOfInterference& li, TopOpeBRepDS_ListOfInterference& liINTERNAL)
481 TopOpeBRepDS_ListIteratorOfListOfInterference it(li);
482 for (; it.More(); it.Next()){
483 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
484 const TopAbs_Orientation ori = I->Transition().Orientation(TopAbs_IN);
485 if (M_INTERNAL(ori)) liINTERNAL.Append(I);
487 Standard_Boolean hasINT = !liINTERNAL.IsEmpty();
491 static Standard_Boolean FUN_ds_hasSDMancestorfaces
492 (const Handle(TopOpeBRepDS_HDataStructure)& HDS, const TopoDS_Edge& E1,const TopoDS_Edge& E2, TopoDS_Face& Fsd1,TopoDS_Face& Fsd2)
494 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
496 const TopTools_ListOfShape& lFcE1 = FDSCNX_EdgeConnexitySameShape(E1,HDS);
497 const TopTools_ListOfShape& lFcE2 = FDSCNX_EdgeConnexitySameShape(E2,HDS);
499 TopTools_IndexedMapOfShape mapfcE2;
500 TopTools_ListIteratorOfListOfShape it2(lFcE2);
501 for (; it2.More(); it2.Next()) mapfcE2.Add(it2.Value());
503 TopTools_ListIteratorOfListOfShape it1(lFcE1);
504 for (; it1.More(); it1.Next()){
505 const TopoDS_Shape& fcE1 = it1.Value();
506 Standard_Boolean hsdm1 = HDS->HasSameDomain(fcE1);
507 if (!hsdm1) continue;
508 const TopTools_ListOfShape& fsdm2 = BDS.ShapeSameDomain(fcE1);
509 it2.Initialize(fsdm2);
510 for (; it2.More(); it2.Next()){
511 const TopoDS_Shape& f2 = it2.Value();
512 Standard_Boolean isb2 = mapfcE2.Contains(f2);
514 Fsd1 = TopoDS::Face(fcE1); Fsd2 = TopoDS::Face(f2);
515 return Standard_True;
518 return Standard_False;
521 // ----------------------------------------------------------------------
522 Standard_EXPORT void FUN_ds_PURGEforE9(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
523 // ----------------------------------------------------------------------
525 // xpu040998 : line gives myLineINL=true, interference on geometry
526 // edge/face describing contact on geometry -> EPIe + EPIf = 3dI
527 // EPIf is faulty if edge is in face's geometry
528 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
529 Standard_Integer ns = BDS.NbShapes();
530 for (Standard_Integer i = 1; i <= ns; i++) {
531 const TopoDS_Shape& EE = BDS.Shape(i);
532 if (EE.ShapeType() != TopAbs_EDGE) continue;
534 const TopoDS_Edge& E = TopoDS::Edge(EE);
535 Standard_Boolean isdgE = BRep_Tool::Degenerated(E);
538 Standard_Integer IE = BDS.Shape(E);
539 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
540 TopOpeBRepDS_ListOfInterference LIcopy; FDS_assign(LI,LIcopy);
541 TopOpeBRepDS_ListOfInterference l3dF; Standard_Integer n3dF = FUN_selectSKinterference(LIcopy,TopOpeBRepDS_FACE,l3dF);
542 if (n3dF == 0) continue;
544 const TopTools_ListOfShape& lfcxE = FDSCNX_EdgeConnexitySameShape(E,HDS);
545 Standard_Integer nlfcxE = lfcxE.Extent();
546 if (nlfcxE == 0) continue; // NYIRaise
547 TopTools_ListIteratorOfListOfShape itf(lfcxE);
548 TopTools_IndexedMapOfShape mapf; for (; itf.More(); itf.Next()) mapf.Add(itf.Value());
550 Standard_Boolean removed = Standard_False;
551 TopOpeBRepDS_ListIteratorOfListOfInterference it(l3dF);
553 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
554 TopAbs_ShapeEnum SB = TopAbs_SHAPE, SA = TopAbs_SHAPE;Standard_Integer IB = 0, IA = 0;TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0, S = 0;
555 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
556 Standard_Boolean FhasGE = FDS_SIisGIofIofSBAofTofI(BDS,IE,I);
557 if (FhasGE) {removed = Standard_True; l3dF.Remove(it); continue;} // E has split ON F (cto904A3;e19,f14)
558 const TopoDS_Shape& F = BDS.Shape(S);
559 Standard_Boolean hsdm = HDS->HasSameDomain(F);
560 if (!hsdm) {it.Next(); continue;}
561 TopTools_ListIteratorOfListOfShape issdm(BDS.ShapeSameDomain(F));
562 Standard_Boolean foundinsdm = Standard_False;
563 for (; issdm.More(); issdm.Next())
564 if (mapf.Contains(issdm.Value())) {foundinsdm = Standard_True; break;}
565 if (!foundinsdm) {it.Next(); continue;} // E is IN geometry(F) (cto002D2;e33,f31)
567 // E is edge of FF sdm with F
568 removed = Standard_True; l3dF.Remove(it);
571 if (!removed) continue;
572 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(E);
573 LII.Clear(); LII.Append(LIcopy); LII.Append(l3dF);
577 // ----------------------------------------------------------------------
578 Standard_EXPORT void FUN_ds_completeforSE1(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
579 // ----------------------------------------------------------------------
581 // xpu160398 complement for INTERNAL transitions on section edge
582 // recall : we add geometry G on section edge SE only if
583 // SE has ISE=(T(face F),G,edge ES),
584 // && F has IF =(T,SE,S).
586 // purpose : SE has ISE=(T(face F'),G,edge),
587 // F' has no interference with support==SE
588 // => looking for F / F and F' share ES,
589 // F sdm with Fanc (one face ancestor of ES)
590 // F has I' = (T,SE,S).
593 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
594 Standard_Integer nse = BDS.NbSectionEdges();
596 for (Standard_Integer i = 1; i <= nse; i++) {
597 const TopoDS_Edge& SE = BDS.SectionEdge(i);
598 Standard_Integer ISE = BDS.Shape(SE);
599 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
601 TopOpeBRepDS_TKI tki;
602 tki.FillOnGeometry(LI);
603 for (tki.Init(); tki.More(); tki.Next()) {
605 // ISE = (INTERNAL(FACE),G,EDGE) :
606 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
607 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
608 TopOpeBRepDS_ListOfInterference lI1; Standard_Boolean hasINT = ::FUN_selectTRAINTinterference(loicopy,lI1);
609 if (!hasINT) continue;
610 TopOpeBRepDS_ListOfInterference lI2; Standard_Integer nI = FUN_selectTRASHAinterference(lI1,TopAbs_FACE,lI2);
611 if (nI < 1) continue;
612 TopOpeBRepDS_ListOfInterference lI3; nI = FUN_selectSKinterference(lI2,TopOpeBRepDS_EDGE,lI3);
613 if (nI < 1) continue;
615 Standard_Boolean keepI = Standard_False;
616 // for (TopOpeBRepDS_ListIteratorOfListOfInterference it(lI3) ;it.More(); it.Next()){
617 TopOpeBRepDS_ListIteratorOfListOfInterference it(lI3) ;
618 for ( ;it.More(); it.Next()){
619 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
620 keepI = FDS_SIisGIofIofSBAofTofI(BDS,ISE,I);
625 // ISE = (INTERNAL(F),G,ES), F has no I with G==SE
626 // find fSE / fSE (SE's ancestor face) has IfSE = (T,SE,support)
627 // - fSE sdm & fES (ES's ancestor face) -
628 // for (it.Initialize(lI3) ;it.More(); it.Next()){
630 for ( ;it.More(); it.Next()){
631 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
632 TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN;
633 Standard_Integer G1 = 0, S = 0;
634 FDS_data(I,GT,G1,ST,S);
635 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
636 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
637 TopoDS_Face fSE,fES; Standard_Boolean sdmf = ::FUN_ds_hasSDMancestorfaces(HDS,SE,ES, fSE,fES);
639 Standard_Integer IfES = BDS.Shape(fES);
641 const TopOpeBRepDS_ListOfInterference& LIf = BDS.ShapeInterferences(fES);
642 TopOpeBRepDS_ListOfInterference LIfcopy; FDS_copy(LIf,LIfcopy);
643 TopOpeBRepDS_ListOfInterference LIfound; Standard_Integer nfound = FUN_selectGIinterference(LIfcopy,ISE,LIfound);
644 if (nfound < 1) continue;
646 // cto 009 B1 : Ifor=(FORWARD(IfES),G1,S) && Irev=(REVERSED(IfES),G1,S)
647 // -> do NOT reduce to I = (INTERNAL(IfES),G1,S) (we can have EXTERNAL Tr)
648 FDS_copy(loi,loicopy);
649 TopOpeBRepDS_ListOfInterference lI4;
650 FUN_selectITRASHAinterference(loicopy,IfES,lI4);
651 Standard_Boolean hasFORREV=Standard_False;
652 TopOpeBRepDS_ListOfInterference lfor; Standard_Integer nFOR = FUN_selectTRAORIinterference(lI4,TopAbs_FORWARD,lfor);
653 TopOpeBRepDS_ListOfInterference lrev; Standard_Integer nREV = FUN_selectTRAORIinterference(lI4,TopAbs_REVERSED,lrev);
654 hasFORREV = (nFOR > 0) || (nREV > 0);
655 if (hasFORREV) break;
659 TopOpeBRepDS_Transition newT(TopAbs_INTERNAL);
661 Standard_Real par = FDS_Parameter(I);
662 Standard_Boolean isevi = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
663 Standard_Boolean B = Standard_False;
664 if (isevi) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
665 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,G1,par,K,TopOpeBRepDS_EDGE,B);
666 HDS->StoreInterference(newI,SE);
673 // ----------------------------------------------------------------------
674 Standard_EXPORT void FUN_ds_completeforSE2(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
675 // ----------------------------------------------------------------------
677 // xpu250398 compute 3dI
678 // recall : to have spOUT(SE) / spIN(SE) with SE section edge on bound G
679 // we need IF = (T(F),G,F) with G not SE bound.
681 // purpose : Sometimes for gap's reasons we can miss such interference.
682 // attached to ES, IFE = (T(FTRA),G,ES) with G not Gbound
683 // we find no IF = (T(FTRA),G,FTRA)
684 // 1. look for FCX / FCX shares ES with FTA (recall : rkG==rkFCX)
685 // 2. compute I3d = (T2(FCX),G,FCX)
686 // !!! if SE has splits ON F near G (if we have a 2dI near G) -> do NOT add I3d
687 // PRO12696 : on se 46 (create FEI/ f50)
689 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
690 Standard_Integer nse = BDS.NbSectionEdges();
692 for (Standard_Integer i = 1; i <= nse; i++) {
693 const TopoDS_Edge& SE = TopoDS::Edge(BDS.SectionEdge(i));
694 Standard_Integer rkSE = BDS.AncestorRank(SE);
696 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
698 TopOpeBRepDS_TKI tki;
699 tki.FillOnGeometry(LI);
700 for (tki.Init(); tki.More(); tki.Next()) {
702 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
703 Standard_Boolean point = (K == TopOpeBRepDS_POINT);
704 Standard_Boolean vertex = (K == TopOpeBRepDS_VERTEX);
706 // interferences on GBound=1 not treated
707 Standard_Boolean try1 = Standard_True;
709 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
710 TopoDS_Vertex OOv; Standard_Boolean hasOO = FUN_ds_getoov(vG,HDS,OOv);
711 Standard_Integer ovSE = FUN_tool_orientVinE(vG,SE);
712 if ((ovSE == 0) && hasOO) ovSE = FUN_tool_orientVinE(OOv,SE);
713 if (ovSE != 0) try1 = Standard_False;
717 // SE has {I=(T(face), G not Gbound, edge)}
718 // has NO {I'=(T'(face'), G not Gbound, face')}
719 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
720 TopOpeBRepDS_ListOfInterference l1;
721 FUN_selectTRASHAinterference(loicopy,TopAbs_FACE,l1);
722 TopOpeBRepDS_ListOfInterference lF; Standard_Integer nF = FUN_selectSKinterference(l1,TopOpeBRepDS_FACE,lF);
723 if (nF > 1) continue;
724 TopOpeBRepDS_ListOfInterference lFE; Standard_Integer nFE = FUN_selectSKinterference(l1,TopOpeBRepDS_EDGE,lFE);
725 if (nFE == 0) continue;
727 // I = (T(FTRA),G not Gbound, ES)
728 const Handle(TopOpeBRepDS_Interference)& I = lFE.First();
729 Standard_Real par = FDS_Parameter(I);
731 TopOpeBRepDS_Kind ST = TopOpeBRepDS_UNKNOWN; Standard_Integer S = 0; FDS_data(I,K,G,ST,S);
732 TopAbs_ShapeEnum tsb = TopAbs_SHAPE, tsa = TopAbs_SHAPE; Standard_Integer isb = 0, isa = 0; FDS_Tdata(I,tsb,isb,tsa,isa);
733 const TopoDS_Face& FTRA= TopoDS::Face(BDS.Shape(isb));
734 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
736 // lfCX = {fCX / fCX shares ES with FTRA}
737 const TopTools_ListOfShape& lfCX = FDSCNX_EdgeConnexitySameShape(ES,HDS);
738 for (TopTools_ListIteratorOfListOfShape itfcx(lfCX); itfcx.More(); itfcx.Next()){
739 const TopoDS_Face& FCX = TopoDS::Face(itfcx.Value());
740 Standard_Integer IFCX = BDS.Shape(FCX);
741 if (FCX.IsSame(FTRA)) continue;
743 // xpu140498 : NYI check SE has part ON FCX(with bound G)
744 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectITRASHAinterference(lFE,IFCX,l2);
745 if (n2 > 0) continue;
747 Standard_Real OOpar = 0.;
749 gp_Pnt p3d = BDS.Point(G).Point();
750 Standard_Real t1 = BDS.Point(G).Tolerance(); Standard_Real t2 = FUN_tool_maxtol(ES);
751 Standard_Real t = (t1 > t2) ? t1 : t2;
752 Standard_Real d = 1.e1;Standard_Boolean ok = FUN_tool_projPonE(p3d,ES,OOpar,d);
754 if (d > t) {continue;}
756 if (vertex) { // rkG == rkES
757 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
758 Standard_Integer rkG = BDS.AncestorRank(G);
760 // modified by NIZHNY-MKK Mon Apr 2 15:38:11 2001.BEGIN
761 // if (rkG == rkSE) OOpar = BRep_Tool::Parameter(vG,ES);
763 Standard_Integer hasvG = FUN_tool_orientVinE(vG,ES);
767 OOpar = BRep_Tool::Parameter(vG,ES);
769 // modified by NIZHNY-MKK Mon Apr 2 15:38:30 2001.END
771 TopoDS_Shape oov; Standard_Boolean hasoov = FUN_ds_getoov(vG,BDS,oov);
773 Standard_Real t1 = BRep_Tool::Tolerance(vG); Standard_Real t2 = FUN_tool_maxtol(ES);
774 Standard_Real t = (t1 > t2) ? t1 : t2;
775 gp_Pnt p = BRep_Tool::Pnt(vG);
776 Standard_Real parES,dd=1.e1;
777 Standard_Boolean ok = FUN_tool_projPonE(p,ES,parES,dd);
779 if (dd > t) {continue;}
782 else OOpar = BRep_Tool::Parameter(TopoDS::Vertex(oov),ES);
786 gp_Pnt2d OOuv; Standard_Boolean ok = FUN_tool_paronEF(ES,OOpar,FCX,OOuv);
789 TopOpeBRepDS_Transition newT;
791 Standard_Boolean isonper = false; Standard_Real par1 = 0.0, par2 = 0.0; Standard_Real factor = 1.e-4;
792 FDS_LOIinfsup(BDS,SE,par,K,G,
793 BDS.ShapeInterferences(SE),par1,par2,isonper);
795 TopOpeBRepTool_makeTransition MKT;
796 TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
797 ok = MKT.Initialize(SE,par1,par2,par, FCX,OOuv, factor);
798 if (ok) ok = MKT.SetRest(ES,OOpar);
799 if (ok) ok = MKT.MkTonE(stb,sta);
801 newT.Before(stb); newT.After(sta); newT.Index(IFCX);
803 Handle(TopOpeBRepDS_Interference) newI;
805 Standard_Boolean B = Standard_False;
806 if (vertex) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
807 newI = MakeEPVInterference(newT,IFCX,G,par,K,TopOpeBRepDS_FACE,B);
808 HDS->StoreInterference(newI,SE);
815 static Standard_Boolean FUN_ds_completeforSE3(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& SE,
816 const TopOpeBRepDS_Kind K,
817 // const Standard_Integer G,
818 const Standard_Integer ,
819 const TopOpeBRepDS_ListOfInterference& loi,
820 Standard_Real& parE, Standard_Integer& IES, Standard_Integer& ITRASHA, TopOpeBRepDS_Transition& Tr)
822 if (K == TopOpeBRepDS_VERTEX) return Standard_False;
823 Standard_Integer ISE = BDS.Shape(SE);
825 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
826 TopOpeBRepDS_ListOfInterference lINT; Standard_Integer nINT = FUN_selectTRAORIinterference(loicopy,TopAbs_INTERNAL,lINT);
827 TopOpeBRepDS_ListOfInterference lEXT; Standard_Integer nEXT = FUN_selectTRAORIinterference(loicopy,TopAbs_EXTERNAL,lEXT);
828 Standard_Integer n1 = nINT + nEXT;
829 if (n1 < 1) return Standard_False;
830 TopOpeBRepDS_ListOfInterference l1; l1.Append(lINT); l1.Append(lEXT);
832 // b. I = (INT/EXT(F),G,S), F has I with G==ES
833 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectTRASHAinterference(l1,TopAbs_FACE,l2);
834 if (n2 < 1) return Standard_False;
835 Standard_Boolean okb = Standard_False;
836 for (TopOpeBRepDS_ListIteratorOfListOfInterference it2(l2); it2.More(); it2.Next()){
837 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
838 okb = FDS_SIisGIofIofSBAofTofI(BDS,ISE,I2);
841 if (!okb) return Standard_False;
844 TopOpeBRepDS_ListOfInterference l2e; Standard_Integer n2e = FUN_selectSKinterference(l2,TopOpeBRepDS_EDGE,l2e);
845 TopOpeBRepDS_ListOfInterference l2f; Standard_Integer n2f = FUN_selectSKinterference(l2,TopOpeBRepDS_FACE,l2f);
846 if ((n2e == 0) || (n2f == 0)) return Standard_False;
847 Standard_Integer sI3d = l2f.First()->Support();
848 TopOpeBRepDS_ListOfInterference l3d; Standard_Integer n3d = FUN_selectITRASHAinterference(l2e,sI3d,l3d);
849 if (n3d < 1) return Standard_False;
853 const Handle(TopOpeBRepDS_Interference)& I3 = l3d.First();
854 TopOpeBRepDS_Kind K3 = TopOpeBRepDS_UNKNOWN, ST3 = TopOpeBRepDS_UNKNOWN; Standard_Integer G3 = 0, S3 = 0; FDS_data(I3,K3,G3,ST3,S3);
855 TopAbs_ShapeEnum tsb3 = TopAbs_SHAPE, tsa3 = TopAbs_SHAPE; Standard_Integer isb3 = 0, isa3 = 0; FDS_Tdata(I3,tsb3,isb3,tsa3,isa3);
856 IES = S3; ITRASHA = isb3;
858 const TopoDS_Edge& Eline = TopoDS::Edge(BDS.Shape(IES));
859 const TopoDS_Face& F = TopoDS::Face(BDS.Shape(ITRASHA));
860 parE = FDS_Parameter(I3);
862 Standard_Real parline = 0.0; Standard_Boolean ok = FUN_tool_parE(SE,parE,Eline,parline);
863 if (!ok) {return Standard_False;}
864 gp_Pnt2d uv; ok = FUN_tool_paronEF(Eline,parline,F,uv);
865 if (!ok) {return Standard_False;}
866 Standard_Real par1 = 0.0, par2 = 0.0; FUN_tool_bounds(SE,par1,par2);
867 Standard_Real factor = 1.e-4;
870 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
871 ok = MKT.Initialize(SE,par1,par2,parE, F,uv, factor);
872 if (ok) ok = MKT.SetRest(Eline,parline);
873 if (ok) ok = MKT.MkTonE(stb,sta);
874 if (!ok) {return Standard_False;}
875 Tr.Before(stb); Tr.After(sta); Tr.Index(ITRASHA);
876 return Standard_True;
879 // ----------------------------------------------------------------------
880 Standard_EXPORT void FUN_ds_completeforSE3(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
881 // ----------------------------------------------------------------------
883 // xpu170498 : t3 (splits of e7)
885 // edge SE - a. is tangent to FTRA on ES at G, has NO SPLIT ON FTRA (near G).
886 // - b. has splitON FCX (FCX and FTRA share ES)
887 // a. IFE=(T(FTRA),Gpoint,ES) && IF=(T(FTRA),Gpoint,FTRA)
889 // b. IFE=(T'(FCX),Gpoint,S) / FCX has I=(T'',SE,SS)
891 // purpose : when T(FTRA) is INTERNAL/EXTERNAL, the compute of spIN/spOU fails,
892 // => compute interference I3d=IFE + IF with T==FORWARD/REVERSED.
894 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
895 Standard_Integer nse = BDS.NbSectionEdges();
896 for (Standard_Integer i = 1; i <= nse; i++) {
897 const TopoDS_Edge& SE = BDS.SectionEdge(i);
898 Standard_Integer ISE = BDS.Shape(SE);
899 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
901 TopOpeBRepDS_ListOfInterference newLI; Standard_Boolean hasnewLI = Standard_False;
902 TopOpeBRepDS_TKI tki;
903 tki.FillOnGeometry(LI);
904 for (tki.Init(); tki.More(); tki.Next()) {
906 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
907 Standard_Real parE = 0.0; Standard_Integer IES=0, ITRASHA=0; TopOpeBRepDS_Transition Tr;
908 Standard_Boolean ok = FUN_ds_completeforSE3(BDS,SE,K,G,loi,parE,IES,ITRASHA,Tr);
910 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
911 if (!ok) {newLI.Append(loicopy); continue;}
913 // delete interferences =(T(face IF),G,S)
914 TopOpeBRepDS_ListOfInterference lIdel;
915 FUN_selectITRASHAinterference(loicopy,ITRASHA,lIdel);
917 Handle(TopOpeBRepDS_Interference) TrFE, TrFF;
919 hasnewLI = Standard_True;
920 TrFE = MakeEPVInterference(Tr, ISE,G,parE,K,TopOpeBRepDS_EDGE,Standard_False);
921 TrFF = MakeEPVInterference(Tr,ITRASHA,G,parE,K,TopOpeBRepDS_FACE,Standard_False);
922 newLI.Append(TrFF); newLI.Append(TrFE); newLI.Append(loicopy);
926 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE); LII.Clear();
933 // ----------------------------------------------------------------------
934 Standard_EXPORT Standard_Boolean FUN_ds_shareG
935 (const Handle(TopOpeBRepDS_HDataStructure)& HDS, const Standard_Integer iF1,const Standard_Integer iF2,
936 const Standard_Integer iE2, const TopoDS_Edge& Esp, Standard_Boolean& shareG)
937 // ----------------------------------------------------------------------
938 // F1 sdm F2, share Esp (split of E2)
940 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
941 Standard_Boolean hsdm = HDS->HasSameDomain(BDS.Shape(iE2));
942 if (!hsdm) return Standard_False;
944 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(iF1));
945 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
946 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(iE2));
948 Standard_Real tol = Precision::Confusion()*1.e3;
949 Standard_Real f = 0.0, l = 0.0; FUN_tool_bounds(Esp,f,l);
950 Standard_Real x = 0.45678; Standard_Real par = (1-x)*f + x*l;
951 gp_Pnt P; Standard_Boolean ok = FUN_tool_value(par,Esp,P);
952 if (!ok) return Standard_False;
954 Standard_Real d2 = 0.0, par2 = 0.0; ok = FUN_tool_projPonE(P,E2,par2,d2);
955 if (!ok) return Standard_False;
956 if (d2 > tol) return Standard_False;
958 gp_Vec nggeomF2; ok = FUN_tool_nggeomF(par2,E2,F2,nggeomF2);
959 if (!ok) return Standard_False;
960 gp_Dir nxx2; ok = FUN_tool_getxx(F2,E2,par2,nggeomF2,nxx2);
961 if (!ok) return Standard_False;
964 TopTools_IndexedMapOfShape mE1; TopExp::MapShapes(F1,TopAbs_EDGE,mE1);
965 const TopTools_ListOfShape& sdmE1 = BDS.ShapeSameDomain(iE2);
966 for (TopTools_ListIteratorOfListOfShape it(sdmE1); it.More(); it.Next()){
967 const TopoDS_Edge& E1 = TopoDS::Edge(it.Value());
968 Standard_Boolean isb = mE1.Contains(E1);
971 Standard_Real d1 = 0.0, par1 = 0.0; ok = FUN_tool_projPonE(P,E1,par1,d1);
973 if (d1 > tol) continue;
975 // E1 on F1, E2 on F2, E1 and E2 share split Esp(nyi : check it)
976 gp_Vec nggeomF1; ok = FUN_tool_nggeomF(par1,E1,F1,nggeomF1);
977 if (!ok) return Standard_False;
978 gp_Dir nxx1; ok = FUN_tool_getxx(F1,E1,par1,nggeomF1,nxx1);
979 if (!ok) return Standard_False;
981 Standard_Real prod = nxx1.Dot(nxx2);
982 shareG = (prod > 0.);
983 return Standard_True;
985 return Standard_False;
987 // ----------------------------------------------------------------------
988 Standard_EXPORT Standard_Boolean FUN_ds_mkTonFsdm
989 (const Handle(TopOpeBRepDS_HDataStructure)& HDS, const Standard_Integer iF1, const Standard_Integer iF2, const Standard_Integer iE2,
990 const Standard_Integer iEG, const Standard_Real paronEG, const TopoDS_Edge& Esp, const Standard_Boolean pardef,
991 TopOpeBRepDS_Transition& T)
992 // ----------------------------------------------------------------------
993 // =================================
994 // prequesitory : F1 and F2 are SDSO
995 // =================================
996 // F1 sdm F2, EG has split ON F1 shared by F2
998 // EG and E2 share geometric point G (of param paronEG)
999 // pardef = Standard_True : paronEG is defined
1000 // else : use Esp to find paronEG, Esp is split of EG
1001 // (!! we can have EG==E2)
1003 // purpose : computes 2d transition of F1 when crossing EG relative to
1004 // 2dmatter(F2) limited by E2 :
1005 // -> 2d FEI attached to F1 = (T(F2), G=EG, S=F2)
1007 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
1008 Standard_Boolean hsdm = HDS->HasSameDomain(BDS.Shape(iE2));
1009 if (!hsdm) return Standard_False;
1011 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(iF1));
1012 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
1013 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(iE2));
1014 const TopoDS_Edge& EG = TopoDS::Edge(BDS.Shape(iEG));
1016 Standard_Boolean EGisE2 = (iEG == iE2);
1017 Standard_Real tol = Precision::Confusion()*1.e3;
1021 Standard_Boolean ok = Standard_False;
1022 gp_Pnt P; Standard_Real parEG = 0.0;
1023 if (pardef) parEG = paronEG;
1025 Standard_Real f = 0.0, l = 0.0; FUN_tool_bounds(Esp,f,l);
1026 Standard_Real dEG = 0.0; ok = FUN_tool_projPonE(P,EG,parEG,dEG);
1027 if (!ok) return Standard_False;
1028 if (dEG > tol) return Standard_False;
1030 ok = FUN_tool_value(parEG,EG,P);
1031 if (!ok) return Standard_False;
1032 gp_Vec tgtEG ; ok = TopOpeBRepTool_TOOL::TggeomE(parEG,EG,tgtEG);
1033 if (!ok) return Standard_False;
1034 gp_Vec ngF1; ok = FUN_tool_nggeomF(parEG,EG,F1,ngF1);
1035 if (!ok) return Standard_False;
1036 gp_Vec beafter = ngF1^tgtEG;
1040 Standard_Real par2 = 0.0;
1041 if (EGisE2) par2 = parEG;
1043 Standard_Real d2 = 0.0; ok = FUN_tool_projPonE(P,E2,par2,d2);
1044 if (!ok) return Standard_False;
1045 if (d2 > tol) return Standard_False;
1047 gp_Vec ngF2; ok = FUN_tool_nggeomF(par2,E2,F2,ngF2);
1048 if (!ok) return Standard_False;
1049 gp_Dir nxx2; ok = FUN_tool_getxx(F2,E2,par2,ngF2,nxx2);
1050 if (!ok) return Standard_False;
1054 Standard_Boolean sdmEGE2 = EGisE2;
1055 if (!sdmEGE2) sdmEGE2 = FUN_ds_sdm(BDS,EG,E2);
1056 if (!sdmEGE2) return Standard_False;
1058 Standard_Real prod = beafter.Dot(nxx2);
1059 Standard_Real tola = Precision::Angular()*1.e3;
1060 ok = (Abs(1- Abs(prod)) < tola);
1061 if (!ok) return Standard_False;
1063 if (prod > 0.) T = TopOpeBRepDS_Transition(TopAbs_OUT,TopAbs_IN);
1064 else T = TopOpeBRepDS_Transition(TopAbs_IN,TopAbs_OUT);
1065 return Standard_True;
1069 #define ONSAMESHA (1)
1070 #define CLOSESAME (11)
1071 #define ONOPPOSHA (2)
1072 #define CLOSEOPPO (22)
1073 #define FORREVOPPO (222)
1075 Standard_EXPORT Standard_Integer FUN_ds_oriEinF(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& E, const TopoDS_Shape& F,
1076 TopAbs_Orientation& O)
1078 // * E is edge of F :returns orientation of E in F
1079 // * E is edge of Fsd : Fsd sdm with F,
1080 // returns orientation of E in F /E describes the same 2d area in F as in Fsd
1081 // * !! if E is closing edge, returns CLOSESAME or CLOSEOPPO
1083 O = TopAbs_EXTERNAL;
1084 Standard_Integer rkF = BDS.AncestorRank(F);
1085 Standard_Integer rkE = BDS.AncestorRank(E);
1087 const TopoDS_Edge& EE = TopoDS::Edge(E);
1088 const TopoDS_Face& FF = TopoDS::Face(F);
1089 Standard_Integer iF = BDS.Shape(F);
1090 TopAbs_Orientation oF = BDS.Shape(iF).Orientation();
1093 Standard_Boolean samsha = FUN_tool_orientEinFFORWARD(EE,FF,O);
1095 Standard_Boolean iscE = BRep_Tool::IsClosed(EE,FF);
1096 if (iscE) return CLOSESAME;
1097 else return ONSAMESHA;
1099 else return UNKNOWN;
1102 const TopTools_ListOfShape& sdmFs = BDS.ShapeSameDomain(FF);
1103 Standard_Boolean hsdm = (sdmFs.Extent() > 0);
1106 Standard_Boolean hasFOR=Standard_False, hasREV=Standard_False; // xpu120898 (PRO14785 : e36 shared by f34 & f39,
1107 // faces sdm with f16)
1108 TopOpeBRepDS_Config C = BDS.SameDomainOri(FF);
1110 for (TopTools_ListIteratorOfListOfShape it(sdmFs); it.More(); it.Next()){
1111 const TopoDS_Face& Fsdm = TopoDS::Face(it.Value());
1112 Standard_Integer iFsdm = BDS.Shape(Fsdm);
1113 Standard_Integer rksdm = BDS.AncestorRank(Fsdm);
1114 if (rksdm == rkF) continue;
1116 Standard_Boolean samsha = FUN_tool_orientEinFFORWARD(EE,Fsdm,O);
1117 if (!samsha) continue;
1119 Standard_Boolean iscE = BRep_Tool::IsClosed(EE,Fsdm);
1120 if (iscE) return CLOSEOPPO;
1122 TopOpeBRepDS_Config Csdm = BDS.SameDomainOri(Fsdm);
1123 Standard_Boolean toreverse1 = (Csdm != C) && (!M_INTERNAL(O)) && (!M_EXTERNAL(O));
1124 if (toreverse1) O = TopAbs::Complement(O);
1126 TopAbs_Orientation oFsdm = BDS.Shape(iFsdm).Orientation();
1127 Standard_Boolean toreverse2 = (oF != oFsdm) && (!M_INTERNAL(oFsdm)) && (!M_EXTERNAL(oFsdm));
1128 if (toreverse2) O = TopAbs::Complement(O);
1129 if (!hasFOR) hasFOR = M_FORWARD(O);
1130 if (!hasREV) hasREV = M_REVERSED(O);
1133 if (hasFOR && hasREV) return FORREVOPPO;
1134 if (hasFOR || hasREV) {
1135 O = hasFOR ? TopAbs_FORWARD : TopAbs_REVERSED;
1139 else return UNKNOWN;
1145 #define EREFandESUP (2)
1148 static Standard_Integer FUN_EisSE2(const TopOpeBRepDS_DataStructure& BDS,
1149 // const TopTools_MapOfShape& Fsdm,
1150 const TopTools_MapOfShape& ,
1151 const TopoDS_Edge& E,
1152 const Handle(TopOpeBRepDS_Interference)& I)
1154 const TopOpeBRepDS_Transition& T = I->Transition();
1155 const TopAbs_Orientation O = T.Orientation(TopAbs_IN);
1156 TopAbs_ShapeEnum SB = TopAbs_SHAPE, SA = TopAbs_SHAPE;Standard_Integer IB = 0, IA = 0;TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0, S = 0;
1157 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
1158 if (GT != TopOpeBRepDS_VERTEX) return NONE;
1159 if (M_EXTERNAL(O)) return NONE;
1162 if (SB != TopAbs_EDGE) return NONE;
1165 Standard_Integer rkE = BDS.AncestorRank(E);
1166 Standard_Integer rkG = BDS.AncestorRank(G);
1167 const TopoDS_Vertex& VG = TopoDS::Vertex(BDS.Shape(G));
1168 Standard_Integer Gsd = 0; Standard_Boolean Ghsd = FUN_ds_getVsdm(BDS,G,Gsd);
1169 Standard_Integer oGinE = 0;
1171 const TopoDS_Vertex& VGsd = TopoDS::Vertex(BDS.Shape(Gsd));
1172 if (rkE == rkG) oGinE = FUN_tool_orientVinE(VG,E);
1173 else oGinE = FUN_tool_orientVinE(VGsd,E);
1175 else oGinE = FUN_tool_orientVinE(VG,E);
1177 if (oGinE == 0) return EREFandESUP; // G in IN E
1179 Standard_Boolean noshare = ((oGinE == LAST) && M_FORWARD(O));
1180 noshare = noshare || ((oGinE == FIRST) && M_REVERSED(O));
1181 if (noshare) return NONE;
1183 if (SB == TopAbs_EDGE) {// E sdm edge(ST)
1184 if (!Ghsd) return EREFandESUP;
1190 Standard_EXPORT void FUN_ds_FillSDMFaces(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1192 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1193 Standard_Integer ns = BDS.NbShapes();
1195 for (Standard_Integer i= 1; i <= ns; i++) {
1196 const TopoDS_Shape& S = BDS.Shape(i);
1197 if (S.ShapeType() != TopAbs_FACE) continue;
1199 Standard_Integer rkS = BDS.AncestorRank(S);
1200 TopTools_MapOfShape Fsdm;
1201 TopTools_ListIteratorOfListOfShape itf(BDS.ShapeSameDomain(S));
1202 for (; itf.More(); itf.Next()){
1203 const TopoDS_Shape& f = itf.Value();
1204 Standard_Integer rkf = BDS.AncestorRank(f);
1205 if (rkf != rkS) Fsdm.Add(f);
1207 Standard_Boolean hsd = (Fsdm.Extent() > 0);
1210 TopExp_Explorer ex(S, TopAbs_EDGE);
1211 for (; ex.More(); ex.Next()){
1212 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
1213 Standard_Boolean hase = BDS.HasShape(E);
1214 if (!hase) continue;
1215 Standard_Boolean isse = BDS.IsSectionEdge(E);
1217 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
1218 Standard_Integer nI = LI.Extent();
1219 if (nI < 1) continue;
1221 TopOpeBRepDS_ListIteratorOfListOfInterference it;
1222 for (it.Initialize(LI); it.More(); it.Next()){
1223 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
1224 Standard_Integer isSE2 = FUN_EisSE2(BDS,Fsdm,E,I);
1225 if (isSE2 == NONE) continue;
1226 BDS.AddSectionEdge(E);
1227 if (isSE2 == EREFandESUP) {
1228 Standard_Integer ST = I->Support();
1229 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(ST));
1230 BDS.AddSectionEdge(ES);
1234 } // ex(S, TopAbs_EDGE);
1238 Standard_EXPORT void FUN_ds_addSEsdm1d(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1240 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1241 Standard_Integer ns = BDS.NbShapes();
1242 for (Standard_Integer i= 1; i <= ns; i++) {
1243 const TopoDS_Shape& S = BDS.Shape(i);
1244 if (S.ShapeType() != TopAbs_EDGE) continue;
1245 const TopoDS_Edge& E = TopoDS::Edge(S);
1246 Standard_Boolean dgE = BRep_Tool::Degenerated(E);
1249 Standard_Boolean isse = BDS.IsSectionEdge(E);
1251 Standard_Integer rkE = BDS.AncestorRank(E);
1252 if (rkE != 1) continue;
1254 Standard_Boolean shareG = Standard_False;
1255 TopTools_ListOfShape lsd;
1256 TopOpeBRepDS_TOOL::EShareG(HDS,E,lsd);
1257 TopTools_ListIteratorOfListOfShape itsd(lsd);
1258 if (itsd.More()) shareG = Standard_True;
1259 for (; itsd.More(); itsd.Next()) BDS.AddSectionEdge(TopoDS::Edge(itsd.Value()));
1260 if (shareG) BDS.AddSectionEdge(E);
1262 }// FUN_ds_addSEsdm1d
1264 Standard_EXPORT Standard_Integer FUN_ds_hasI2d(
1265 // const Standard_Integer EIX,
1266 const Standard_Integer ,
1267 const TopOpeBRepDS_ListOfInterference& LLI,
1268 TopOpeBRepDS_ListOfInterference& LI2d)
1270 // LI : attached to EIX at given G
1271 // recall : I3d if I1=(T(FTRA),G,FTRA) && I2=(T(FTRA),G,E)
1272 // I2d if only I=(T(FTRA),G,E) (=>EIX is on FF sdm with FTRA)
1274 TopOpeBRepDS_ListOfInterference LI; FDS_assign(LLI,LI);
1275 TopOpeBRepDS_ListOfInterference L1dE; FUN_selectTRASHAinterference(LI,TopAbs_EDGE,L1dE);
1276 TopOpeBRepDS_ListOfInterference LIF;FUN_selectSKinterference(LI,TopOpeBRepDS_FACE,LIF);
1277 TopOpeBRepDS_ListOfInterference LIE;FUN_selectSKinterference(LI,TopOpeBRepDS_EDGE,LIE);
1279 TopOpeBRepDS_ListIteratorOfListOfInterference itE(LIE);
1280 for (; itE.More(); itE.Next()){
1281 const Handle(TopOpeBRepDS_Interference)& IE = itE.Value();
1282 TopOpeBRepDS_Kind GTE = TopOpeBRepDS_UNKNOWN, STE = TopOpeBRepDS_UNKNOWN; Standard_Integer GE = 0, SE = 0; FDS_data(IE,GTE,GE,STE,SE);
1283 TopAbs_ShapeEnum tsb = TopAbs_SHAPE, tsa = TopAbs_SHAPE; Standard_Integer isb = 0, isa = 0; FDS_Tdata(IE,tsb,isb,tsa,isa);
1285 TopOpeBRepDS_ListIteratorOfListOfInterference itF(LIF);
1286 Standard_Boolean is3d = Standard_False;
1287 for (; itF.More(); itF.Next()){
1288 const Handle(TopOpeBRepDS_Interference)& IF = itF.Value();
1289 TopOpeBRepDS_Kind GTF = TopOpeBRepDS_UNKNOWN, STF = TopOpeBRepDS_UNKNOWN;
1290 Standard_Integer GF=0,SF=0;
1291 FDS_data(IF,GTF,GF,STF,SF);
1292 if (GE != GF) continue;
1294 is3d = Standard_True;
1298 if (!is3d) LI2d.Append(IE);
1300 Standard_Integer nLI2d = LI2d.Extent();
1304 // ----------------------------------------------------------------------
1305 Standard_EXPORT void FUN_ds_completeforSE4(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1306 // ----------------------------------------------------------------------
1307 // xpu160698 : section edge SE intersects ES at G=point
1308 // ES closing edge on FTRA
1309 // we need to have transitions :
1310 // T1=(OU/IN(FTRA),GP,ES)
1311 // T2=(IN/OU(FTRA),GP,ES), for the compute of splitON
1312 // PRO6965, (SE=e13,F=f6,ES=e12)
1314 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1315 Standard_Integer nse = BDS.NbSectionEdges();
1316 for (Standard_Integer i = 1; i <= nse; i++) {
1317 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1319 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1321 TopOpeBRepDS_ListOfInterference newLI;
1322 TopOpeBRepDS_TKI tki;
1323 tki.FillOnGeometry(LI);
1324 for (tki.Init(); tki.More(); tki.Next()) {
1325 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1326 if (K != TopOpeBRepDS_POINT) continue;
1328 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1329 TopOpeBRepDS_ListOfInterference l1;
1330 FUN_selectSKinterference(loicopy,TopOpeBRepDS_EDGE,l1);
1331 TopOpeBRepDS_ListOfInterference l2; Standard_Integer n2 = FUN_selectTRASHAinterference(l1,TopAbs_FACE,l2);
1332 if (n2 < 1) continue;
1334 const Handle(TopOpeBRepDS_Interference)& I = l2.First();
1335 TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN; Standard_Integer S = 0; FDS_data(I,GT,G,ST,S);
1336 TopAbs_ShapeEnum tsb = TopAbs_SHAPE, tsa = TopAbs_SHAPE; Standard_Integer isb = 0, isa = 0; FDS_Tdata(I,tsb,isb,tsa,isa);
1337 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
1338 const TopoDS_Face& FTRA = TopoDS::Face(BDS.Shape(isb));
1340 Standard_Boolean closing = FUN_tool_IsClosingE(ES,FTRA,FTRA);
1341 if (!closing) continue;
1343 Standard_Boolean hasFOR=Standard_False,hasREV=Standard_False;
1344 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(l2); it.More(); it.Next()){
1345 const Handle(TopOpeBRepDS_Interference)& I2 = it.Value();
1346 TopOpeBRepDS_Kind GT2 = TopOpeBRepDS_UNKNOWN, ST2 = TopOpeBRepDS_UNKNOWN; Standard_Integer G2 = 0, S2 = 0; FDS_data(I2,GT2,G2,ST2,S2);
1347 TopAbs_ShapeEnum tsb2 = TopAbs_SHAPE, tsa2 = TopAbs_SHAPE; Standard_Integer isb2 = 0, isa2 = 0; FDS_Tdata(I2,tsb2,isb2,tsa2,isa2);
1348 Standard_Boolean error = (S2 != S) || (isb2 != isb);
1349 if (error) return; // nyi raise
1350 TopAbs_Orientation O2 = I2->Transition().Orientation(TopAbs_IN);
1351 if (!hasFOR) hasFOR = M_FORWARD(O2);
1352 if (!hasREV) hasREV = M_REVERSED(O2);
1354 if (!hasFOR && !hasREV) continue;
1355 if ( hasFOR && hasREV ) continue;
1356 TopAbs_Orientation newO = hasFOR ? TopAbs_REVERSED : TopAbs_FORWARD;
1357 TopOpeBRepDS_Transition newT(newO); newT.Index(isb);
1358 Standard_Real par = FDS_Parameter(I);
1359 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,G,par,K,Standard_False);
1360 HDS->StoreInterference(newI,SE);
1365 // ----------------------------------------------------------------------
1366 Standard_EXPORT void FUN_ds_completeforSE5(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1367 // ----------------------------------------------------------------------
1368 // xpu190698 : section edge SE has spON face F,
1369 // FCX is tangent to F at G (FCX and F are on same shape)
1370 // SE has I = (T(F),G,S), T=(OUT,OUT)
1371 // I' = (T'(Fsd),G,Sedge), T' FORWARD or REVERSED
1372 // T describes states (ON/OUT) or (OUT/ON)
1373 // PRO12695 (SE20,P1,FCX16,F29)
1374 // xpu131098 : SE has I = (T(F),G,S), T=(IN,IN)
1375 // I' = (T'(Fsd),G,Sedge), T' FORWARD or REVERSED
1376 // T describes states (ON/IN) or (OUT/IN)
1378 // recall : for the compute of spOU/IN(ES), we need to interferences
1379 // TskFACE = (T(FF),G,FF) T=FORWARD/REVERSED
1380 // cto 902 D9 (SE17,P4,F29,FCX4)
1382 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1383 Standard_Integer nse = BDS.NbSectionEdges();
1384 for (Standard_Integer i = 1; i <= nse; i++) {
1385 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1387 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(SE);
1389 // xpu020399 : cto901A2 (e26)
1390 TopOpeBRepDS_ListOfInterference LOIc; FDS_copy(LOI,LOIc);
1391 TopOpeBRepDS_ListOfInterference LI; Standard_Integer nI = FUN_selectSKinterference(LOIc,TopOpeBRepDS_EDGE,LI);
1392 if (nI < 1) continue;
1394 TopOpeBRepDS_ListOfInterference newLI; Standard_Boolean hasnewLI = Standard_False;
1395 TopOpeBRepDS_TKI tki;
1396 tki.FillOnGeometry(LI);
1397 for (tki.Init(); tki.More(); tki.Next()) {
1398 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1399 if (K != TopOpeBRepDS_POINT) {FDS_copy(loi,newLI); continue;}
1401 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1402 TopOpeBRepDS_ListOfInterference lext; Standard_Integer iext = FUN_selectTRAORIinterference(loicopy,TopAbs_EXTERNAL,lext);
1403 Standard_Boolean hasext = (iext > 0);
1404 TopOpeBRepDS_ListOfInterference lint; Standard_Integer iint = FUN_selectTRAORIinterference(loicopy,TopAbs_INTERNAL,lint);
1405 Standard_Boolean hasint = (iint > 0);
1406 if (!hasext && !hasint) {FDS_copy(loi,newLI); continue;}
1407 if (hasext && hasint) {FDS_copy(loi,newLI); continue;} // nyiFUN_RAISE : incoherent data
1408 // ------------------------------
1410 // NYI : only select among 2dI!!! ******************************
1411 TopOpeBRepDS_ListOfInterference lfor; Standard_Integer ifor = FUN_selectTRAORIinterference(loicopy,TopAbs_FORWARD,lfor);
1412 TopOpeBRepDS_ListOfInterference lrev; Standard_Integer irev = FUN_selectTRAORIinterference(loicopy,TopAbs_REVERSED,lrev);
1413 Standard_Boolean hasrev=(irev > 0), hasfor=(ifor > 0);
1414 if (!hasrev && !hasfor) {FDS_copy(loi,newLI); continue;}
1415 if (hasrev && hasfor) {FDS_copy(loi,newLI); continue;} // nyiFUN_RAISE : incoherent data
1419 Handle(TopOpeBRepDS_Interference) I2d = hasfor ? lfor.First() : lrev.First();
1420 Standard_Integer S2 = I2d->Support(); Standard_Integer iF2 = I2d->Transition().Index();
1421 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2)); Standard_Real parSE = FDS_Parameter(I2d);
1422 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(iF2));
1423 Standard_Real parE2; Standard_Boolean ok = FUN_tool_parE(SE,parSE,E2,parE2);
1425 gp_Pnt2d uv2; ok = FUN_tool_paronEF(E2,parE2,F2,uv2);
1427 gp_Dir ngF2 = FUN_tool_nggeomF(uv2,F2);
1428 gp_Dir xxF2; ok = FUN_tool_getxx(F2,E2,parE2,ngF2,xxF2);
1431 Handle(TopOpeBRepDS_Interference) I3d = hasext ? lext.First() : lint.First();
1432 Standard_Integer iF3 = I3d->Transition().Index();
1433 const TopoDS_Face& F3 = TopoDS::Face(BDS.Shape(iF3));
1434 // recall : G is a point => E2 = edge(S3) (I3d : {(T,G,S3),(T,G,F3)})
1435 gp_Pnt2d uv3; ok = FUN_tool_paronEF(E2,parE2,F3,uv3);
1437 gp_Dir ngF3 = FUN_tool_nggeomF(uv3,F3);
1438 gp_Dir xxF3; ok = FUN_tool_getxx(F3,E2,parE2,ngF3,xxF3);
1441 Standard_Real dot = xxF2.Dot(xxF3);
1442 Standard_Boolean positive = (dot > 0); // as F and FCX are tangent, dot= +1 or -1
1443 if (positive) continue;
1445 TopAbs_Orientation newO = hasfor ? TopAbs_FORWARD : TopAbs_REVERSED;
1446 if (hasint) newO = TopAbs::Complement(newO);
1448 TopOpeBRepDS_ListIteratorOfListOfInterference it;
1449 if (hasint) it.Initialize(lint);
1450 else it.Initialize(lext);
1451 for (; it.More(); it.Next()){
1452 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
1453 Handle(TopOpeBRepDS_Interference) newI = I; newI->ChangeTransition().Set(newO);
1455 hasnewLI = Standard_True;
1459 newLI.Append(loicopy);
1463 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE); LII.Clear();
1469 // ----------------------------------------------------------------------
1470 Standard_EXPORT void FUN_ds_completeforSE6(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1471 // ----------------------------------------------------------------------
1472 // xpu280798 : - section edge E sdm3d Esd,
1473 // - E has I2d(T(F),VG,E'),
1474 // - VG vertex of Esd, VG not sdm
1476 // => add newI1d(newT(Esd),VG,Esd)
1477 // cto902B4 (e15,v22)
1479 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1480 Standard_Integer nse = BDS.NbSectionEdges();
1481 for (Standard_Integer i = 1; i <= nse; i++) {
1482 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1483 Standard_Integer ISE = BDS.Shape(SE);
1484 TopTools_ListOfShape lEsd3d; Standard_Boolean hassd3d = FDS_HasSameDomain3d(BDS,SE,&lEsd3d);
1485 if (!hassd3d) continue;
1487 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1488 TopOpeBRepDS_ListOfInterference LIcopy;
1489 TopOpeBRepDS_ListOfInterference LIa; FDS_assign(LI,LIcopy); Standard_Integer na = FUN_selectGKinterference(LIcopy,TopOpeBRepDS_VERTEX,LIa);
1490 if (na == 0) continue;
1491 TopOpeBRepDS_ListOfInterference LIb;
1492 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LIa); it.More(); it.Next()){
1493 const Handle(TopOpeBRepDS_Interference)& Ia = it.Value();
1494 Standard_Integer G = Ia->Geometry();
1495 TopoDS_Shape vGsd; Standard_Boolean hassd = FUN_ds_getoov(BDS.Shape(G), HDS, vGsd);
1496 if (!hassd) LIb.Append(Ia);
1499 TopOpeBRepDS_ListOfInterference l2dFE; FDS_assign(LIb,LIcopy);
1500 FUN_ds_hasI2d(ISE,LIcopy,l2dFE);
1501 TopOpeBRepDS_ListOfInterference l1dE; FDS_assign(LIb,LIcopy);
1502 FUN_selectTRASHAinterference(LIcopy,TopAbs_EDGE,l1dE);
1504 // attached to SE : l1dE = {I1d=(T(Esd),vG,Esd) / vG !hsd}
1505 // l2dFE = {I2dF=(T(F),vG,E) / vG !hsd}
1507 for (TopTools_ListIteratorOfListOfShape itsd3(lEsd3d); itsd3.More(); itsd3.Next()){
1508 const TopoDS_Edge& Esd = TopoDS::Edge(itsd3.Value());
1509 TopoDS_Vertex vf,vl; TopExp::Vertices(Esd,vf,vl);
1510 Standard_Boolean degen = BRep_Tool::Degenerated(Esd);
1511 if (degen) continue;
1513 Standard_Boolean closed = vf.IsSame(vl);
1514 Standard_Integer iEsd = BDS.Shape(Esd);
1515 Standard_Integer ivf = BDS.Shape(vf);
1516 Standard_Integer ivl = BDS.Shape(vl);
1518 for (Standard_Integer iv = 1; iv <= 2; iv++) {
1519 Standard_Integer G = (iv == 1)? ivf : ivl;
1520 if (G == 0) continue;
1521 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
1522 TopoDS_Shape vGsd; Standard_Boolean hassd = FUN_ds_getoov(vG, HDS, vGsd);
1523 if (hassd) continue;
1525 TopOpeBRepDS_ListOfInterference l1dG;
1526 FUN_selectGIinterference(l1dE,G,l1dG);
1527 TopOpeBRepDS_ListOfInterference l2dG; Standard_Integer n2dG = FUN_selectGIinterference(l2dFE,G,l2dG);
1528 if (n2dG == 0) continue; // no 2dI at G
1530 TopOpeBRepDS_ListOfInterference l1dGEsd; Standard_Integer n1dGEsd = FUN_selectITRASHAinterference(l1dG,iEsd,l1dGEsd);
1531 if (n1dGEsd != 0) continue; // 1dI(Esd) at G exists already
1533 for (TopOpeBRepDS_ListIteratorOfListOfInterference it2d(l2dG); it2d.More(); it2d.Next()){
1534 const Handle(TopOpeBRepDS_Interference)& I2d = it2d.Value();
1535 Standard_Integer iTRASHA = I2d->Transition().IndexBefore();
1536 TopAbs_Orientation O = I2d->Transition().Orientation(TopAbs_IN);
1537 const TopoDS_Face& F = TopoDS::Face(BDS.Shape(iTRASHA));
1538 TopAbs_Orientation dum; Standard_Boolean EsdofF = FUN_tool_orientEinF(Esd,F,dum);
1539 if (!EsdofF) continue;
1541 // we found I2d = (T(F),vG,E'), vG is vertex of Esd, vG !hsdm, Esd is edge of F
1542 // compute newI1d=(newT(Esd),vG,Esd)
1543 TopOpeBRepDS_Transition newT(TopAbs_OUT,TopAbs_OUT, TopAbs_EDGE,TopAbs_EDGE);
1544 Standard_Real parE = FDS_Parameter(I2d);
1545 if (closed) newT.Set(TopAbs_INTERNAL);
1547 if (M_FORWARD(O) || M_REVERSED(O)) {newT.Set(O);}
1548 else if (M_EXTERNAL(O)) {newT.Set(O);}
1549 else if (M_INTERNAL(O)) {
1550 Standard_Real parEsd = BRep_Tool::Parameter(vG,Esd);
1551 gp_Vec tgEsd; TopOpeBRepTool_TOOL::TggeomE(parEsd,Esd,tgEsd); // dir
1552 gp_Vec tgE ; TopOpeBRepTool_TOOL::TggeomE(parE,SE,tgE); // dir
1553 Standard_Real dot = tgEsd.Dot(tgE);
1554 Standard_Boolean SO = (dot > 0.);
1555 Standard_Boolean isvf = (iv == 1);
1556 Standard_Boolean isforw = (SO && isvf) || (!SO && !isvf);
1557 if (isforw) {newT.Set(TopAbs_FORWARD);}
1558 else {newT.Set(TopAbs_REVERSED);}
1562 Handle(TopOpeBRepDS_Interference) newI1d = MakeEPVInterference(newT,iEsd,G,parE,TopOpeBRepDS_VERTEX,Standard_False);
1563 HDS->StoreInterference(newI1d,SE);
1572 // ----------------------------------------------------------------------
1573 Standard_EXPORT void FUN_ds_completeforE7(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1574 // ----------------------------------------------------------------------
1575 // xpu130898 : attached to edge E, lI3d = {I=(FOR/REV(F),G,F)}
1576 // reduction of lI3d if it describes INTERNAL/EXTERNAL transitions
1577 // purpose : I3dFOR/REV => faulty spIN/OU of E on G
1578 // CTS21199 (E6, G=v7/p3, FTR=f5)
1580 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1581 Standard_Integer ns = BDS.NbShapes();
1582 for (Standard_Integer i = 1; i <= ns; i++) {
1583 const TopoDS_Shape& EE = BDS.Shape(i);
1584 if (EE.ShapeType() != TopAbs_EDGE) continue;
1586 const TopoDS_Edge& E = TopoDS::Edge(EE);
1587 Standard_Boolean isdgE = BRep_Tool::Degenerated(E);
1588 if (isdgE) continue;
1590 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E);
1592 TopOpeBRepDS_TKI tki;
1593 tki.FillOnGeometry(LI);
1594 for (tki.Init(); tki.More(); tki.Next()) {
1595 TopOpeBRepDS_Kind K; Standard_Integer G; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1596 TopOpeBRepDS_ListOfInterference loicopy; FDS_assign(loi,loicopy);
1597 TopOpeBRepDS_ListOfInterference l1;
1598 FUN_selectSKinterference(loicopy,TopOpeBRepDS_FACE,l1);
1599 TopOpeBRepDS_ListOfInterference lFOR; Standard_Integer nFOR = FUN_selectTRAORIinterference(l1,TopAbs_FORWARD,lFOR);
1600 TopOpeBRepDS_ListOfInterference lREV; Standard_Integer nREV = FUN_selectTRAORIinterference(l1,TopAbs_REVERSED,lREV);
1601 if ((nFOR == 0) || (nREV == 0)) continue;
1603 TopOpeBRepDS_ListOfInterference lnewI; Standard_Integer iFS=0;
1604 TopOpeBRepDS_ListIteratorOfListOfInterference it(lFOR);
1605 for (; it.More(); it.Next()){
1606 const Handle(TopOpeBRepDS_Interference)& IFOR = it.Value();
1607 Standard_Integer IFS = IFOR->Support(); const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(IFS));
1608 TopOpeBRepDS_ListOfInterference lFS; Standard_Integer nFS = FUN_selectSIinterference(loicopy,IFS,lREV);
1609 if (nFS == 0) continue;
1611 TopOpeBRepDS_ListOfInterference lFSE; Standard_Integer nFSE = FUN_selectITRASHAinterference(loicopy,IFS,lFSE);
1612 Standard_Real par = FDS_Parameter(IFOR);
1613 Standard_Boolean isonper = false; Standard_Real par1 = 0.0, par2 = 0.0; Standard_Real factor = 1.e-4;
1614 FDS_LOIinfsup(BDS,E,par,K,G,BDS.ShapeInterferences(E),par1,par2,isonper);
1616 TopOpeBRepDS_Transition newT;
1618 // we have IFOR=(FORWARD(FS),G,FS) + IREV=(REVERSED(FS),G,FS)
1619 Standard_Integer IES = 0;
1621 gp_Pnt2d uvFS; Standard_Boolean ok = FUN_tool_parF(E,par,FS,uvFS);
1622 if (!ok) {continue;}
1624 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
1625 ok = MKT.Initialize(E,par1,par2,par, FS,uvFS, factor);
1626 if (ok) ok = MKT.MkTonE(stb,sta);
1627 if (!ok) {continue;}
1628 newT.Before(stb); newT.After(sta);
1631 IES = lFSE.First()->Support();
1632 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(IES));
1633 Standard_Real parES; Standard_Boolean ok = FUN_tool_parE(E,par,ES,parES);
1634 if (!ok) {continue;}
1635 gp_Pnt2d uvFS; ok = FUN_tool_paronEF(ES,parES,FS,uvFS);
1636 if (!ok) {continue;}
1638 TopOpeBRepTool_makeTransition MKT; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
1639 ok = MKT.Initialize(E,par1,par2,par, FS,uvFS, factor);
1640 if (ok) ok = MKT.SetRest(ES,parES);
1641 if (ok) ok = MKT.MkTonE(stb,sta);
1642 if (!ok) {continue;}
1643 newT.Before(stb); newT.After(sta);
1650 Standard_Boolean B = Standard_False;
1651 if (K == TopOpeBRepDS_VERTEX) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(IFOR)->GBound();
1652 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,IFS,G,par,K,TopOpeBRepDS_FACE,B);
1655 Handle(TopOpeBRepDS_Interference) newIFE = MakeEPVInterference(newT,IES,G,par,K,TopOpeBRepDS_EDGE,B);
1656 lnewI.Append(newIFE);
1661 TopOpeBRepDS_ListOfInterference& loii = tki.ChangeValue(K,G);
1662 TopOpeBRepDS_ListOfInterference lEFS;
1663 FUN_selectITRASHAinterference(loii,iFS,lEFS);
1664 for (TopOpeBRepDS_ListIteratorOfListOfInterference iti(lnewI); iti.More(); iti.Next()) {
1665 Handle(TopOpeBRepDS_Interference) newI = iti.Value();
1671 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(E);
1673 for (tki.Init(); tki.More(); tki.Next()) {
1674 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1680 // ----------------------------------------------------------------------
1681 Standard_EXPORT void FUN_ds_completeforSE8(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1682 // ----------------------------------------------------------------------
1683 // xpu020998 : Attached to section edge SE :
1684 // - {I1d=(Tr(Esd),vG,Esd), I2d=(Tr(F),vG,E)}
1685 // - E and Esd are F edges
1686 // I2d may be incomplete, "reduce" 2d/1d -> {I1d,newI2d}
1687 // cto902A6 (ES5,Esd10,vG7,F35)
1688 // prequesitory : A vertex is shared by at most 2 edges in the same face.
1689 // An edge is shared by at most 2 faces of same rank.
1691 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1692 Standard_Integer nse = BDS.NbSectionEdges();
1694 for (Standard_Integer i = 1; i <= nse; i++) {
1695 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1696 Standard_Integer ISE = BDS.Shape(SE);
1697 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(SE);
1699 Standard_Boolean hasnew = Standard_False;
1700 TopOpeBRepDS_TKI tki;
1701 tki.FillOnGeometry(LI);
1702 for (tki.Init(); tki.More(); tki.Next()) {
1703 TopOpeBRepDS_Kind KK; Standard_Integer GG; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(KK,GG);
1704 Standard_Boolean isvertex = (KK == TopOpeBRepDS_VERTEX);
1707 Standard_Boolean Ghsdm = HDS->HasSameDomain(BDS.Shape(GG));
1708 if (Ghsdm) continue;
1710 // li -> l1dE + l2dFE + lFE(<=>l3dFE) + li(<=>lFF)
1711 TopOpeBRepDS_ListOfInterference li; FDS_assign(loi,li);
1712 TopOpeBRepDS_ListOfInterference l1dE; Standard_Integer n1d = FUN_selectTRASHAinterference(li,TopAbs_EDGE,l1dE); // li->l1dE+li(<=>lF?)
1713 TopOpeBRepDS_ListOfInterference lFE;
1714 FUN_selectSKinterference(li,TopOpeBRepDS_EDGE,lFE); // li(<=>lF?)->lFE+li(<=>lFF)
1715 TopOpeBRepDS_ListOfInterference l2dFE; Standard_Integer n2d = FUN_selectpure2dI(li,lFE,l2dFE); // lFE->l2dFE+lFE(<=>l3dFE)
1716 Standard_Boolean redu2d = (n1d > 0)&&(n2d > 0);
1717 // -------------------------------
1718 if (redu2d) { // {I1d=(Tr(Esd),vG,Esd), I2d=(Tr(F),vG,E)}
1719 TopOpeBRepDS_ListIteratorOfListOfInterference it(l2dFE); TopOpeBRepDS_ListOfInterference al2dFE;
1721 Handle(TopOpeBRepDS_Interference)& I2dFE = it.Value();
1722 TopOpeBRepDS_Transition newT2d; Standard_Boolean ok = FUN_ds_redu2d1d(BDS,ISE,I2dFE,l1dE, newT2d);
1723 if (!ok) {it.Next(); continue;}
1724 I2dFE->ChangeTransition() = newT2d; al2dFE.Append(I2dFE);
1727 l2dFE.Append(al2dFE);
1730 TopOpeBRepDS_ListOfInterference& loii = tki.ChangeValue(KK,GG);
1732 loii.Append(l1dE); loii.Append(lFE); loii.Append(l2dFE); loii.Append(li);
1735 if (!hasnew) continue;
1736 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(SE);
1738 for (tki.Init(); tki.More(); tki.Next()) {
1739 TopOpeBRepDS_Kind KK = TopOpeBRepDS_UNKNOWN; Standard_Integer GG = 0; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(KK,GG);
1745 // ----------------------------------------------------------------------
1746 Standard_EXPORT void FUN_ds_completeforSE9(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1747 // ----------------------------------------------------------------------
1748 // xpu011098 : CTS21180(ES13)
1749 // purpose : ES Section edge, sdm with EsdSE={Esd}, ES has no interference
1750 // compute interferences for ES.
1752 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1753 Standard_Integer nse = BDS.NbSectionEdges();
1755 for (Standard_Integer i = 1; i <= nse; i++) {
1756 const TopoDS_Edge& SE = BDS.SectionEdge(i);
1757 Standard_Integer rkSE = BDS.AncestorRank(SE);
1758 Standard_Integer ISE = BDS.Shape(SE);
1759 Standard_Boolean hsd = HDS->HasSameDomain(SE);
1761 if (!BDS.ShapeInterferences(SE).IsEmpty()) continue;
1763 const TopTools_ListOfShape& EsdSE = BDS.ShapeSameDomain(SE);
1764 TopTools_ListIteratorOfListOfShape ite(EsdSE);
1765 for (; ite.More(); ite.Next()){
1766 const TopoDS_Edge& Esd = TopoDS::Edge(ite.Value()); Standard_Integer iEsd = BDS.Shape(Esd);
1767 Standard_Integer rkEsd = BDS.AncestorRank(Esd);
1768 if (rkEsd == rkSE) continue;
1769 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(Esd);
1770 if (LI.IsEmpty()) continue;
1772 TopOpeBRepDS_ListOfInterference LIcopy; FDS_assign(LI,LIcopy);
1773 TopOpeBRepDS_ListOfInterference LISE;
1774 FUN_selectSIinterference(LIcopy,ISE,LISE);
1776 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LISE);
1777 for (tki.Init(); tki.More(); tki.Next()) {
1778 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN;
1779 Standard_Integer G = 0;
1780 // const TopOpeBRepDS_ListOfInterference& loi =
1782 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(G));
1783 Standard_Boolean hsd1 = HDS->HasSameDomain(vG);
1784 if (hsd1) continue; //nyixpu011098
1785 Standard_Integer rkG = BDS.AncestorRank(G);
1786 if (rkG != rkSE) continue; //nyixpu011098
1790 TopOpeBRepDS_Transition newT(TopAbs_IN,TopAbs_IN,TopAbs_EDGE,TopAbs_EDGE); newT.Index(iEsd);
1791 // modified by NIZHNY-MKK Mon Apr 2 15:39:14 2001.BEGIN
1792 Standard_Integer hasvG = FUN_tool_orientVinE(vG,SE);
1796 // modified by NIZHNY-MKK Mon Apr 2 15:39:17 2001.END
1798 Standard_Real par = BRep_Tool::Parameter(vG,SE);
1799 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,iEsd,G,par,TopOpeBRepDS_VERTEX,TopOpeBRepDS_EDGE,Standard_True);
1800 HDS->StoreInterference(newI,SE);
1806 // ----------------------------------------------------------------------
1807 Standard_EXPORT void FUN_ds_PointToVertex(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1808 // ----------------------------------------------------------------------
1809 // xpu090698 : for gap reasons, intersector IntPatch can find a intersection
1810 // point POINT, whereas it should be a VERTEX,
1811 // if we find edge eb / eb : EPI(T1,G,ea1),
1812 // EPI(T2,G,a2) with rk(ea1) = rk(ea2),
1813 // then G should be VERTEX (2 edges of same shape cannot
1814 // intersect) - recall : in the DS, we do not bind twice the same closing edge-
1817 Standard_Integer i ;
1818 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1819 Standard_Integer ns = BDS.NbShapes();
1820 TColStd_DataMapOfIntegerInteger iPiV;
1822 for ( i = 1; i <= ns; i++) {
1823 const TopoDS_Shape& s = BDS.Shape(i);
1824 if (s.ShapeType() != TopAbs_EDGE) continue;
1825 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(s);
1826 if (LI.IsEmpty()) continue;
1828 TopOpeBRepDS_TKI tki;
1829 tki.FillOnGeometry(LI);
1830 for (tki.Init(); tki.More(); tki.Next()) {
1831 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1832 if (K == TopOpeBRepDS_VERTEX) continue;
1834 Standard_Integer Scur = 0; Standard_Boolean Gfaulty = Standard_False;
1835 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); it.More(); it.Next()){
1836 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
1837 TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN;
1838 Standard_Integer G1 = 0, S = 0;
1839 FDS_data(I,GT,G1,ST,S);
1840 if (ST != TopOpeBRepDS_EDGE) continue;
1845 Gfaulty = Standard_True; break;
1849 // in DS : pG --> vG
1850 gp_Pnt pG = BDS.Point(G).Point();
1851 Standard_Integer rkES = BDS.AncestorRank(Scur);
1852 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(Scur));
1853 TopoDS_Vertex vf,vl; TopExp::Vertices(ES,vf,vl);
1854 gp_Pnt pf = BRep_Tool::Pnt(vf); gp_Pnt pl = BRep_Tool::Pnt(vl);
1855 Standard_Real df = pf.Distance(pG); Standard_Real dl = pl.Distance(pG);
1857 if (df < dl) vG = vf;
1860 Standard_Integer ivG = BDS.AddShape(vG,rkES);
1866 if (iPiV.IsEmpty()) return;
1867 for (i = 1; i <= ns; i++) {
1868 const TopoDS_Shape& s = BDS.Shape(i);
1869 if (s.ShapeType() != TopAbs_EDGE) continue;
1870 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(s);
1871 if (LI.IsEmpty()) continue;
1873 TopOpeBRepDS_ListOfInterference newLI;
1874 Standard_Integer rks = BDS.AncestorRank(s);
1875 TopOpeBRepDS_TKI tki;
1876 tki.FillOnGeometry(LI);
1877 for (tki.Init(); tki.More(); tki.Next()) {
1878 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN;
1879 Standard_Integer G = 0;
1880 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1881 Standard_Boolean Gisbound = iPiV.IsBound(G);
1883 FDS_copy(loi,newLI);
1887 Standard_Integer ivG = iPiV.Find(G);
1888 const TopoDS_Vertex& vG = TopoDS::Vertex(BDS.Shape(ivG));
1889 Standard_Integer rkG = BDS.AncestorRank(ivG);
1890 Standard_Boolean Gbound = (rkG == rks);
1892 for (TopOpeBRepDS_ListIteratorOfListOfInterference itl(loi); itl.More(); itl.Next()){
1893 const Handle(TopOpeBRepDS_Interference)& I = itl.Value();
1894 Handle(TopOpeBRepDS_CurvePointInterference) CPI (Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I));
1895 if (CPI.IsNull()) continue;
1897 Standard_Real par = CPI->Parameter();
1898 TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN;
1899 Standard_Integer G1 = 0, S = 0;
1900 FDS_data(I,GT,G1,ST,S);
1901 const TopOpeBRepDS_Transition& T = I->Transition();
1902 Standard_Real parvG = 0.0; Standard_Boolean ok = FUN_tool_parVonE(vG,TopoDS::Edge(s),parvG);
1903 // modified by NIZHNY-MKK Mon Apr 2 15:39:59 2001.BEGIN
1904 // if (!ok) par = parvG;
1908 // modified by NIZHNY-MKK Mon Apr 2 15:40:04 2001.END
1909 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(T,S,ivG,par,TopOpeBRepDS_VERTEX,ST,Gbound);
1913 TopOpeBRepDS_ListOfInterference& LII = BDS.ChangeShapeInterferences(s);
1914 LII.Clear(); LII.Append(newLI);
1917 TColStd_DataMapIteratorOfDataMapOfIntegerInteger itm(iPiV);
1918 for (; itm.More(); itm.Next()){
1919 Standard_Integer G = itm.Key();
1924 static Standard_Boolean FUN_redusamshaonE(const TopOpeBRepDS_DataStructure& BDS,const Handle(TopOpeBRepDS_Interference)& I,const Standard_Integer EIX, Handle(TopOpeBRepDS_Interference)& newI)
1925 // attached to edge(EIX) : IFOR=(FORWARD(ES),G,ES) + IREV=(REVERSED(ES),G,ES)
1928 TopAbs_ShapeEnum SB = TopAbs_SHAPE, SA = TopAbs_SHAPE;Standard_Integer IB = 0, IA = 0; TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0, S = 0;
1929 FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S);
1930 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
1931 Standard_Real parE = FDS_Parameter(I); Standard_Real f,l; FUN_tool_bounds(E,f,l);
1932 const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S));
1933 const TopoDS_Face& FTRA = TopoDS::Face(BDS.Shape(IB));
1934 Standard_Real parES = 0.0; Standard_Boolean ok = FUN_tool_parE(E,parE,ES,parES);
1935 if (!ok) return Standard_False;
1936 gp_Pnt2d uv; ok = FUN_tool_paronEF(ES,parES,FTRA,uv);
1937 if (!ok) return Standard_False;
1939 Standard_Real factor = 1.e-2; TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
1940 TopOpeBRepTool_makeTransition MKT;
1941 ok = MKT.Initialize(E,f,l,parE, FTRA,uv, factor);
1942 if (ok) ok = MKT.SetRest(ES,parES);
1943 if (ok) ok = MKT.MkTonE(stb,sta);
1944 if (!ok) return Standard_False;
1945 TopOpeBRepDS_Transition newT; newT.Index(IB); newT.Before(stb);newT.After(sta);
1947 ok = FDS_stateEwithF2d(BDS,E,parE,GT,G,FTRA,newT);
1948 if (!ok) return Standard_False;
1950 Standard_Boolean B = Standard_False; if (GT == TopOpeBRepDS_VERTEX) B = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound();
1951 newI = MakeEPVInterference(newT,S,G,parE,GT,TopOpeBRepDS_EDGE,B);
1952 return Standard_True;
1953 }//FUN_redusamshaonE
1955 // ----------------------------------------------------------------------
1956 Standard_EXPORT void FUN_ds_redusamsha(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
1957 // ----------------------------------------------------------------------
1958 // xpu201098 : reduce 2d interferences on same G and same S :
1959 // {I1=(OU/IN(F),G,ES), I2=(IN/OU(F),G,ES)}
1960 // cto009K1 (SE7,ES8,G2,FTRA27)
1961 //xpu050299 (FRA60618 e13,ftrasha14)
1963 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1964 Standard_Integer ns = BDS.NbShapes();
1966 for (Standard_Integer i = 1; i <= ns; i++) {
1967 if (BDS.Shape(i).ShapeType() != TopAbs_EDGE) continue;
1969 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(i));
1970 Standard_Integer IE = BDS.Shape(E);
1971 TopOpeBRepDS_TKI tki;
1972 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(i);
1973 tki.FillOnGeometry(LI);
1974 for (tki.Init(); tki.More(); tki.Next()) {
1975 TopOpeBRepDS_Kind K = TopOpeBRepDS_UNKNOWN; Standard_Integer G = 0; const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
1976 TopOpeBRepDS_ListOfInterference loicopy; FDS_copy(loi,loicopy); // loi -> l1+l2
1977 TopOpeBRepDS_ListOfInterference l0;
1978 FUN_selectTRASHAinterference(loicopy,TopAbs_EDGE,l0);//xpu091198(cylcong)
1979 TopOpeBRepDS_ListOfInterference l1; Standard_Integer nfound = FUN_selectTRASHAinterference(loicopy,TopAbs_FACE,l1);
1980 TopOpeBRepDS_ListOfInterference l2; nfound = FUN_selectSKinterference(l1,TopOpeBRepDS_EDGE,l2);
1981 // l2 = {I=(T(faceTRASHA),G,Sedge)}
1982 if (nfound == 0) continue;
1985 TopOpeBRepDS_TKI tkis; tkis.FillOnSupport(l2);
1986 for (tkis.Init(); tkis.More(); tkis.Next()) {
1987 TopOpeBRepDS_Kind k = TopOpeBRepDS_UNKNOWN; Standard_Integer s = 0; TopOpeBRepDS_ListOfInterference& li = tkis.ChangeValue(k,s);
1988 Standard_Integer nli = li.Extent();
1989 if (nli < 2) continue;
1991 Handle(TopOpeBRepDS_Interference) newI;
1992 TopOpeBRepDS_ListIteratorOfListOfInterference it1(li);
1993 while (it1.More()) {
1994 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
1995 const TopOpeBRepDS_Transition& T1 = I1->Transition();
1996 TopAbs_Orientation O1 = T1.Orientation(TopAbs_IN);
1997 if (!M_FORWARD(O1) && !M_REVERSED(O1)) {it1.Next(); continue;}
1998 TopAbs_ShapeEnum SB1 = TopAbs_SHAPE, SA1 = TopAbs_SHAPE; Standard_Integer IB1 = 0, IA1 = 0; TopOpeBRepDS_Kind GT1 = TopOpeBRepDS_UNKNOWN, ST1 = TopOpeBRepDS_UNKNOWN; Standard_Integer G1 = 0, S1 = 0;
1999 FDS_Idata(I1,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1);
2000 if (IB1 != IA1) {it1.Next(); continue;}
2002 Standard_Boolean oppofound = Standard_False;
2003 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); it2.Next();
2004 while (it2.More()) {
2005 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
2006 const TopOpeBRepDS_Transition& T2 = I2->Transition();
2007 TopAbs_Orientation O2 = T2.Orientation(TopAbs_IN);
2008 TopAbs_ShapeEnum SB2 = TopAbs_SHAPE, SA2 = TopAbs_SHAPE; Standard_Integer IB2 = 0, IA2 = 0; TopOpeBRepDS_Kind GT2 = TopOpeBRepDS_UNKNOWN, ST2 = TopOpeBRepDS_UNKNOWN; Standard_Integer G2 = 0, S2 = 0;
2009 FDS_Idata(I2,SB2,IB2,SA2,IA2,GT2,G2,ST2,S2);
2010 if (IB2 != IA2) {it2.Next(); continue;}
2011 if (IB1 != IB2) {it2.Next(); continue;} // same fTRASHA
2012 if (S1 != S2) {it2.Next(); continue;} // same Sedge
2014 if (O1 == TopAbs::Complement(O2)) {oppofound=Standard_True; break;}
2015 else {it2.Next(); continue;}
2018 if (!oppofound) {it1.Next(); continue;}
2019 Standard_Boolean ok = FUN_redusamshaonE(BDS,I1,IE,newI);
2020 if (!ok) {it1.Next(); continue;}
2023 if (newI.IsNull()) continue;
2024 li.Clear(); li.Append(newI);
2028 TopOpeBRepDS_ListOfInterference& newloi = tki.ChangeValue(K,G); newloi.Clear();
2029 for (tkis.Init(); tkis.More(); tkis.Next()) {
2030 TopOpeBRepDS_Kind k = TopOpeBRepDS_UNKNOWN; Standard_Integer g = 0; TopOpeBRepDS_ListOfInterference& li = tkis.ChangeValue(k,g);
2033 newloi.Append(l0); newloi.Append(l1);
2036 TopOpeBRepDS_ListOfInterference& newLI = BDS.ChangeShapeInterferences(E);
2038 for (tki.Init(); tki.More(); tki.Next()) {
2039 TopOpeBRepDS_Kind KK = TopOpeBRepDS_UNKNOWN; Standard_Integer GG = 0; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(KK,GG);
2043 } //FUN_ds_redusamsha
2045 Standard_EXPORT Standard_Boolean FUN_ds_hasFEI(const TopOpeBRepDS_PDataStructure& pDS2d, const TopoDS_Shape& F, const Standard_Integer GI, const Standard_Integer ITRA)
2047 Standard_Boolean hasF = pDS2d->HasShape(F);
2048 if (!hasF) return Standard_False;
2050 const TopOpeBRepDS_ListOfInterference& LI = pDS2d->ShapeInterferences(F);
2051 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()){
2052 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2053 const TopOpeBRepDS_Transition& T = I->Transition();
2054 TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
2055 Standard_Boolean found = (G == GI) && (T.Index() == ITRA);
2056 if (found) return Standard_True;
2058 return Standard_False;
2061 Standard_EXPORT Standard_Boolean FUN_ds_ONesd(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer IE, const TopoDS_Shape& EspON, Standard_Integer& IEsd)
2063 const TopoDS_Shape& E = BDS.Shape(IE);
2064 TopTools_ListIteratorOfListOfShape it(BDS.ShapeSameDomain(E));
2065 Standard_Real f = 0.0, l = 0.0; FUN_tool_bounds(TopoDS::Edge(EspON),f,l);
2066 Standard_Real x = 0.456789; Standard_Real par = (1-x)*f + x*l;
2067 gp_Pnt p3d; Standard_Boolean ok = FUN_tool_value(par,TopoDS::Edge(EspON),p3d);
2068 if (!ok) return Standard_False;
2070 for (; it.More(); it.Next()) {
2071 const TopoDS_Edge& esd = TopoDS::Edge(it.Value());
2072 Standard_Real d=0., parp; ok = FUN_tool_projPonE(p3d,esd,parp,d);
2074 Standard_Real tolesd = BRep_Tool::Tolerance(esd);
2075 ok = (d < tolesd*1.e3); //nyi checktole
2077 IEsd = BDS.Shape(esd);
2078 return Standard_True;
2080 return Standard_False;
2085 static Standard_Boolean FUN_oriTOsta(const Standard_Integer o, const TopAbs_State sta, TopAbs_Orientation& ori)
2087 Standard_Boolean ok = (sta == TopAbs_OUT) || (sta == TopAbs_IN);
2088 if (!ok) return Standard_False;
2089 ok = (o == FIRST) || (o == LAST);
2090 if (!ok) return Standard_False;
2092 ori = TopAbs_EXTERNAL;
2093 if (o == FIRST) ori = TopAbs_FORWARD;
2094 if (o == LAST) ori = TopAbs_REVERSED;
2095 if (sta == TopAbs_OUT) ori = TopAbs::Complement(ori);
2096 return Standard_True;
2099 Standard_EXPORT void FUN_ds_unkeepEVIonGb1(const Handle(TopOpeBRepDS_HDataStructure)& HDS, const TopAbs_State sta)
2101 // Completing filter process for edges : delete of interferences
2102 // EVI on gbound1, we keep only interferences on Gb1 describing transitions
2103 // on e / e is IN the solid (if sta = IN)
2104 // e is OU the solid (if sta = OU)
2106 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2107 Standard_Integer ns = BDS.NbShapes();
2108 for (Standard_Integer i = 1; i <= ns; i++) {
2109 const TopoDS_Shape& s = BDS.Shape(i);
2110 if (s.ShapeType() != TopAbs_EDGE) continue;
2112 const TopoDS_Edge& E = TopoDS::Edge(s);
2113 TopOpeBRepDS_ListOfInterference& LI = BDS.ChangeShapeInterferences(s);
2114 if (LI.IsEmpty()) continue;
2116 Standard_Boolean dgE = BRep_Tool::Degenerated(E);
2118 TopoDS_Vertex dum; Standard_Boolean closed = FUN_tool_ClosedE(E,dum);
2119 if (closed) continue;
2121 TopOpeBRepDS_Kind K; Standard_Integer G; Standard_Boolean ok = Standard_False;
2122 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
2124 for (tki.Init(); tki.More(); tki.Next()) {
2126 if (K != TopOpeBRepDS_VERTEX) break;
2131 TopOpeBRepDS_ListOfInterference newLI;
2132 for (tki.Init(); tki.More(); tki.Next()) {
2134 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
2136 const TopoDS_Vertex& V = TopoDS::Vertex(BDS.Shape(G));
2137 Standard_Integer o = FUN_tool_orientVinE(V,E);
2138 if (o == 0) {FDS_copy(loi,newLI); continue;}
2139 TopAbs_Orientation ori; Standard_Boolean okk = FUN_oriTOsta(o,sta,ori);
2140 if (!okk) {FDS_copy(loi,newLI); continue;}
2142 // attached to E at G : loi = {I} / I is EVIonGb1
2143 TopOpeBRepDS_ListOfInterference newloi;
2144 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); it.More(); it.Next()) {
2145 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2146 const TopAbs_Orientation& O = I->Transition().Orientation(TopAbs_IN);
2152 Standard_Integer nnewI = newloi.Extent();
2153 Standard_Integer nI = loi.Extent();
2154 Standard_Boolean ko = (nnewI > 1) && (nnewI != nI); // complex transitions at G
2155 // NYI : correcting reducing cto 001 W3 (e35)
2156 if (!ko) newLI.Append(newloi);
2157 // newLI.Append(newloi); //xpu280898 : cto905J1 (e25,v8)
2159 LI.Clear(); LI.Append(newLI);
2162 } //FUN_ds_unkeepEVIonGb1*/
2164 Standard_EXPORT Standard_Boolean FDS_LOIinfsup(
2165 const TopOpeBRepDS_DataStructure&,
2166 const TopoDS_Edge& E,
2167 const Standard_Real pE,
2168 const TopOpeBRepDS_Kind KDS,
2169 const Standard_Integer GDS,
2170 const TopOpeBRepDS_ListOfInterference& LOI,
2171 Standard_Real& pbef,
2172 Standard_Real& paft,
2173 Standard_Boolean& isonboundper)
2175 Standard_Real f = 0.0, l = 0.0; FUN_tool_bounds(E,f,l);
2177 Standard_Integer n = LOI.Extent();
2178 if (n == 0) return Standard_True;
2181 TopOpeBRepDS_ListOfInterference LOIsansGDS;
2182 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
2184 for(tki.Init();tki.More();tki.Next()) {
2185 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
2186 Standard_Boolean PV =(K==TopOpeBRepDS_POINT)||(K==TopOpeBRepDS_VERTEX);if (!PV) continue;
2187 Standard_Boolean mk = (K == KDS); Standard_Boolean mg = (G == GDS);
2188 Standard_Boolean mkg = (mk && mg); if ( mkg ) continue;
2190 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
2192 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(loi);it.More();it.Next()) {
2193 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2194 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
2195 FDS_Idata(I,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
2196 if (tsb1 != TopAbs_FACE) continue;
2197 if (tsa1 != TopAbs_FACE) continue;
2198 Handle(TopOpeBRepDS_CurvePointInterference) cpi (Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I));
2199 Handle(TopOpeBRepDS_EdgeVertexInterference) evi (Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I));
2200 if (cpi.IsNull() && evi.IsNull()) continue;
2201 LOIsansGDS.Append(I);
2206 n = LOIsansGDS.Extent();
2207 if (n == 0) return Standard_True;
2209 TopoDS_Vertex v; Standard_Boolean Eclosed = TopOpeBRepTool_TOOL::ClosedE(E,v);
2210 Standard_Real tole = BRep_Tool::Tolerance(E);
2211 Standard_Real tol = Precision::Parametric(tole);
2212 isonboundper = Standard_False;
2214 Standard_Real tolv = BRep_Tool::Tolerance(v);
2215 tolv = Precision::Parametric(tolv);
2216 if (tolv > tol) tol = tolv;
2217 Standard_Boolean pEisEf = (Abs(pE-f) <= tol);
2218 Standard_Boolean pEisEl = (Abs(pE-l) <= tol);
2219 isonboundper = pEisEf || pEisEl;
2223 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LOIsansGDS);it.More();it.Next()) {
2224 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2225 Standard_Real p = FDS_Parameter(I);
2227 if (p > pbef) pbef = p;
2228 if (p < paft) paft = p;
2230 return Standard_True;
2233 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LOIsansGDS);it.More();it.Next()) {
2234 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
2235 Standard_Real p = FDS_Parameter(I);
2236 if (p > pbef && p < pE) pbef = p;
2237 if (p < paft && p > pE) paft = p;
2240 return Standard_True;
2243 // sur arete E : pbef < pE < paft, calcul de p1,t2 / :
2244 // p1 dans [pbef,pE[
2245 // p2 dans ]pE,paft]
2246 // si isonboundper = T, les bornes pbef et paft sont prises sur les bornes de E.
2247 Standard_EXPORT Standard_Boolean FDS_parbefaft(
2248 // const TopOpeBRepDS_DataStructure& BDS,
2249 const TopOpeBRepDS_DataStructure& ,
2250 const TopoDS_Edge& E,
2251 const Standard_Real pE,
2252 const Standard_Real& pbef,
2253 const Standard_Real& paft,
2254 const Standard_Boolean& isonboundper,
2255 Standard_Real& p1, Standard_Real& p2)
2257 Standard_Real t = 0.3178947713;
2258 Standard_Real f,l; FUN_tool_bounds(E,f,l);
2260 p1 = (1-t)*pbef + t*l;
2261 p2 = (1-t)*f + t*paft;
2264 p1 = (1-t)*pbef + t*pE;
2265 p2 = (1-t)*pE + t*paft;
2267 return Standard_True;
2270 Standard_EXPORT Standard_Boolean FDS_stateEwithF2d(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Edge& E,const Standard_Real pE,
2271 const TopOpeBRepDS_Kind KDS,const Standard_Integer GDS,
2272 const TopoDS_Face& F1,
2273 TopOpeBRepDS_Transition& TrmemeS)
2275 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(E);
2276 Standard_Real pbef = 0.0, paft = 0.0; Standard_Boolean isonper = false; Standard_Boolean ok = FDS_LOIinfsup(BDS,E,pE,KDS,GDS,LOI,pbef,paft,isonper);
2277 if (!ok) return Standard_False;
2278 Standard_Real t1 = 0.0, t2 = 0.0; ok = FDS_parbefaft(BDS,E,pE,pbef,paft,isonper,t1,t2);
2279 gp_Pnt P1; Standard_Boolean ok1 = FUN_tool_value(t1,E,P1);
2280 gp_Pnt P2; Standard_Boolean ok2 = FUN_tool_value(t2,E,P2);
2281 if (!ok1 || !ok2) return Standard_False;
2283 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(F1);
2284 TopAbs_State sta1 = FSC_StatePonFace(P1,F1,PSC);
2285 TopAbs_State sta2 = FSC_StatePonFace(P2,F1,PSC);
2287 // xpu190898 : cto014I2 (e5,fTRASHA14,vG7,eS10)
2288 if (sta1 == TopAbs_ON) sta1 = TopAbs_IN;
2289 if (sta2 == TopAbs_ON) sta2 = TopAbs_IN;
2291 TrmemeS.Before(sta1,TopAbs_FACE);
2292 TrmemeS.After (sta2,TopAbs_FACE);
2293 return Standard_True;
2294 }//FDS_stateEwithF2d
2296 #define SAMEORIENTED (1)
2297 #define DIFFORIENTED (2)
2298 Standard_EXPORT void FUN_ds_FEIGb1TO0(Handle(TopOpeBRepDS_HDataStructure)& HDS,
2299 const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& MEspON)
2301 //xpu250199 : F has FEI(Gb1, EG, FS), EG sdm Esd
2302 // -> to prevent from the loss of information, replace interference with
2303 // FEI'(Gb0, EGsd, FS)
2304 //CTS21754, f26 has FEI(Gb1,EG=e13, FS=f16), EG13 sd Esd11
2306 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2307 Standard_Integer ns = BDS.NbShapes();
2308 for (Standard_Integer I=1; I<=ns; I++) {
2310 const TopoDS_Shape& F = BDS.Shape(I);
2311 if (F. ShapeType() != TopAbs_FACE) continue;
2312 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(F);
2313 TopOpeBRepDS_ListOfInterference LGb1; // LI = LII + LGb1 (= {FEI with GB1})
2314 TopOpeBRepDS_ListOfInterference LII; FDS_copy(LI,LII);
2315 TopOpeBRepDS_ListIteratorOfListOfInterference it(LII);
2317 const Handle(TopOpeBRepDS_Interference)& Intf = it.Value();
2318 Handle(TopOpeBRepDS_FaceEdgeInterference) FEI =
2319 Handle(TopOpeBRepDS_FaceEdgeInterference)::DownCast(Intf);
2324 Standard_Boolean GB = FEI->GBound();
2332 Standard_Integer nGb1 = LGb1.Extent();
2333 if (nGb1 == 0) continue;
2335 TopOpeBRepDS_ListOfInterference LGb0; // LGb1={FEIGb1(EG,FS)} -> LGb0={FEIGb0(Esd,FS)}
2336 it.Initialize(LGb1);
2338 Handle(TopOpeBRepDS_FaceEdgeInterference) IGb1 = Handle(TopOpeBRepDS_FaceEdgeInterference)::DownCast(it.Value());
2339 Standard_Integer S = IGb1->Support(); const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(S));
2340 Standard_Integer G = IGb1->Geometry();
2341 Standard_Integer Gsd; Standard_Boolean findSD = TopOpeBRepDS_TOOL::GetEsd(HDS,FS,G,Gsd);
2342 if (!findSD) {it.Next(); continue;}
2344 // IGb0 is already stored in the list of interferences :
2345 TopOpeBRepDS_ListIteratorOfListOfInterference itt(LII); Standard_Boolean stored = Standard_False;
2346 for (; itt.More(); itt.Next()){
2347 const Handle(TopOpeBRepDS_Interference)& II = itt.Value();
2348 Standard_Boolean isfound = (II->Support() == S)&&(II->Geometry() == Gsd);
2349 if (isfound) {stored = Standard_True; break;}
2351 if (stored) {LGb1.Remove(it); continue;}
2353 TopOpeBRepDS_Transition newT = IGb1->Transition();
2354 TopAbs_Orientation newO = newT.Orientation(TopAbs_IN);
2355 if (M_INTERNAL(newO) || M_EXTERNAL(newO)) {
2359 Standard_Integer conf = 0; Standard_Boolean ok = TopOpeBRepDS_TOOL::GetConfig(HDS,MEspON,G,Gsd,conf);
2360 if (!ok) {it.Next(); continue;}
2361 if (conf == DIFFORIENTED) newO = TopAbs::Complement(newO);
2364 IGb1->SetGeometry(Gsd); IGb1->SetGBound(Standard_False); IGb1->Transition(newT);
2365 LGb0.Append(IGb1); LGb1.Remove(it);
2368 if (LGb0.IsEmpty()) continue;
2369 TopOpeBRepDS_ListOfInterference& newLI = BDS.ChangeShapeInterferences(F);
2371 newLI.Append(LII); newLI.Append(LGb1); newLI.Append(LGb0);
2375 // ----------------------------------------------------------------------
2376 Standard_EXPORT void FUN_ds_complete1dForSESDM(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
2377 // ----------------------------------------------------------------------
2378 // MSV 25.03.2002 : OCC251
2379 // purpose : SE Section edge, SDM with Esd, SE has no interference
2380 // for one of vertices of Esd while should.
2382 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
2383 Standard_Integer nse = BDS.NbSectionEdges();
2385 for (Standard_Integer is = 1; is <= nse; is++) {
2386 const TopoDS_Edge& SE = BDS.SectionEdge(is);
2387 if (BRep_Tool::Degenerated(SE)) continue;
2388 Standard_Integer rkSE = BDS.AncestorRank(SE);
2389 Standard_Integer iSE = BDS.Shape(SE);
2390 Standard_Boolean hsd = HDS->HasSameDomain(SE);
2392 const TopTools_ListOfShape& LEsd = BDS.ShapeSameDomain(SE);
2393 if (LEsd.IsEmpty()) continue;
2395 Standard_Real tolSE = BRep_Tool::Tolerance(SE);
2396 // map of vertices of SE or same domain with them
2397 TopTools_MapOfShape aGBMap;
2398 TopoDS_Vertex VSE[2];
2399 TopExp::Vertices(SE,VSE[0],VSE[1]);
2401 for (i=0; i < 2; i++)
2402 if (!VSE[i].IsNull()) {
2404 const TopTools_ListOfShape& LV = BDS.ShapeSameDomain(VSE[i]);
2405 TopTools_ListIteratorOfListOfShape it(LV);
2406 for (; it.More(); it.Next())
2407 aGBMap.Add(it.Value());
2410 TopTools_ListIteratorOfListOfShape ite(LEsd);
2411 for (; ite.More(); ite.Next()){
2412 const TopoDS_Edge& Esd = TopoDS::Edge(ite.Value());
2413 Standard_Integer iEsd = BDS.Shape(Esd);
2414 Standard_Integer rkEsd = BDS.AncestorRank(Esd);
2415 if (rkEsd == rkSE) continue;
2417 if (BRep_Tool::Degenerated(Esd)) continue;
2418 Standard_Boolean isSO = false;
2419 Standard_Boolean ok = FUN_tool_curvesSO(Esd,SE,isSO);
2422 Standard_Real tolEsd = Max (BRep_Tool::Tolerance(Esd), tolSE);
2423 // prepare the list of interferences of SE with Esd
2424 const TopOpeBRepDS_ListOfInterference& LIall = BDS.ShapeInterferences(iSE);
2425 TopOpeBRepDS_ListOfInterference LI,LI1;
2426 FDS_assign(LIall,LI);
2427 Standard_Integer ni = FUN_selectTRAUNKinterference(LI,LI1);
2428 LI1.Clear(); ni = FUN_selectTRASHAinterference(LI,TopAbs_EDGE,LI1);
2429 LI.Clear(); ni = FUN_selectITRASHAinterference(LI1,iEsd,LI);
2430 LI1.Clear(); ni = FUN_selectSKinterference(LI,TopOpeBRepDS_EDGE,LI1);
2431 LI.Clear(); ni = FUN_selectSIinterference(LI1,iEsd,LI);
2432 LI1.Clear(); ni = FUN_selectGKinterference(LI,TopOpeBRepDS_VERTEX,LI1);
2433 LI.Clear(); LI.Append(LI1);
2435 // process vertices of Esd
2436 TopoDS_Vertex Vsd[2];
2437 TopExp::Vertices(Esd,Vsd[0],Vsd[1]);
2438 for (i=0; i < 2; i++) {
2439 const TopoDS_Vertex& aV = Vsd[i];
2440 if (aV.IsNull()) continue;
2441 // do not create interferences on GBound
2442 if (aGBMap.Contains(aV)) continue;
2444 TopAbs_Orientation ori = aV.Orientation();
2445 if (!isSO) ori = TopAbs::Reverse(ori);
2447 // check that SE has no yet interference with geometry aV oriented ori
2449 TopOpeBRepDS_ListOfInterference LI2;
2451 Standard_Integer nio = FUN_selectTRAORIinterference(LI1,ori,LI2);
2453 TopTools_MapOfShape aVGMap;
2455 const TopTools_ListOfShape& LV = BDS.ShapeSameDomain(aV);
2456 TopTools_ListIteratorOfListOfShape it(LV);
2457 for (; it.More(); it.Next())
2458 aVGMap.Add(it.Value());
2459 TopOpeBRepDS_ListIteratorOfListOfInterference iti(LI2);
2460 for (; iti.More(); iti.Next()) {
2461 const Handle(TopOpeBRepDS_Interference)& I1 = iti.Value();
2462 Standard_Integer gi = I1->Geometry();
2463 const TopoDS_Shape& aVG = BDS.Shape(gi);
2464 if (aVGMap.Contains(aVG)) break;
2466 if (iti.More()) continue; // has already
2470 // make new interference
2471 Standard_Real par = 0.0;
2472 Standard_Real tol = Max (BRep_Tool::Tolerance(aV), tolEsd);
2473 Standard_Real parEsd = BRep_Tool::Parameter(aV,Esd);
2474 ok = FUN_tool_parE (Esd,parEsd,SE,par,tol);
2476 TopOpeBRepDS_Transition aT(ori);
2477 aT.ShapeBefore(TopAbs_EDGE); aT.ShapeAfter(TopAbs_EDGE);
2479 Standard_Integer iV = BDS.AddShape(aV,rkEsd);
2480 Standard_Boolean isGBound = Standard_False;
2481 TopOpeBRepDS_Config aConfig = (isSO
2482 ? TopOpeBRepDS_SAMEORIENTED
2483 : TopOpeBRepDS_DIFFORIENTED);
2484 Handle(TopOpeBRepDS_Interference) aI =
2485 TopOpeBRepDS_InterferenceTool::MakeEdgeVertexInterference
2486 (aT,iEsd,iV,isGBound,aConfig,par);
2487 HDS->StoreInterference(aI,SE);