1 // Created on: 1998-02-14
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1998-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 #include <TopOpeBRepDS_repvg.hxx>
20 #include <TopOpeBRepTool_SC.hxx>
21 #include <TopOpeBRepTool_makeTransition.hxx>
23 #include <TopOpeBRepDS_EdgeInterferenceTool.hxx>
24 #include <TopOpeBRepDS_EdgeVertexInterference.hxx>
25 #include <TopOpeBRepDS_Interference.hxx>
26 #include <TopOpeBRepDS_TKI.hxx>
27 #include <TopOpeBRepDS_EXPORT.hxx>
28 #include <TopOpeBRepDS_define.hxx>
30 #include <TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx>
31 #define MDSdmoiloi TopOpeBRepDS_DataMapOfIntegerListOfInterference
32 #define MDSdmiodmoiloi TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference
34 //------------------------------------------------------
35 Standard_EXPORT void FDS_repvg2
36 (const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,const TopOpeBRepDS_Kind GT,TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& RLI)
37 //------------------------------------------------------
39 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
40 Standard_Boolean isEd = BRep_Tool::Degenerated(E);
43 Standard_Boolean ispoint = (GT == TopOpeBRepDS_POINT);
44 Standard_Boolean isvertex = (GT == TopOpeBRepDS_VERTEX);
46 Standard_Integer nLI = LI.Extent();
48 TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);
50 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
51 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
52 FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
53 if (tsb1 != TopAbs_FACE) {it1.Next(); continue;}
54 if (tsa1 != TopAbs_FACE) {it1.Next(); continue;}
55 if (GT1 != GT) {it1.Next(); continue;}
57 // xpu121198 : raise in PRO16303, if G1 is a vertex same domain, make sure
59 Standard_Integer rkG1 = BDS.AncestorRank(G1);
60 Standard_Integer rkS1 = BDS.AncestorRank(S1);
61 if (isvertex && (rkG1 != rkS1)) {
62 TopoDS_Shape oovG; Standard_Boolean issd = FUN_ds_getoov(BDS.Shape(G1),BDS,oovG);
63 if (!issd) {it1.Next(); continue;} //!!NYIRAISE
67 const TopoDS_Edge& E1 = TopoDS::Edge(BDS.Shape(S1));
68 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(isb1));
69 TopOpeBRepDS_Point PDS; TopoDS_Shape VDS;
70 if (ispoint) PDS = BDS.Point(G1);
71 else if (isvertex) VDS = BDS.Shape(G1);
72 else throw Standard_Failure("TopOpeBRepDS FDS_repvg2 1");
74 Standard_Boolean isEd1 = BRep_Tool::Degenerated(E1); if (isEd1) {it1.Next(); continue;}
75 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); if (it2.More()) it2.Next(); else {it1.Next(); continue; }
77 TopOpeBRepDS_EdgeInterferenceTool EITool;
78 Standard_Boolean memeS = Standard_False; TopOpeBRepDS_Transition TrmemeS; Standard_Boolean isComplex = Standard_False;
80 while ( it2.More() ) {
81 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
82 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2;
83 FDS_Idata(I2,tsb2,isb2,tsa2,isa2,GT2,G2,ST2,S2);
84 if (tsb2 != TopAbs_FACE) {it2.Next(); continue;}
85 if (tsa2 != TopAbs_FACE) {it2.Next(); continue;}
87 Standard_Boolean cond = (G1 == G2); if (!cond) { it2.Next(); continue; }
89 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2));
90 Standard_Boolean isEd2 = BRep_Tool::Degenerated(E2);
91 if (isEd2) {it2.Next(); continue;}
94 memeS = memeS && (nLI == 2);
96 if (!isComplex && memeS) {
97 Standard_Real pE = FDS_Parameter(I1);
98 Standard_Boolean ok = FDS_stateEwithF2d(BDS,E,pE,GT1,G1,F1,TrmemeS); if (!ok) {it2.Next();continue;}
101 } // !isComplex && memeS
103 if (!isComplex && !memeS) {
104 isComplex = Standard_True;
106 if (ispoint) EITool.Add(E,PDS,I1);
107 else if (isvertex) EITool.Add(E1,VDS,I1);
108 } // !isComplex && !memeS
110 if (isComplex && !memeS) {
111 if (ispoint) EITool.Add(E,PDS,I2);
112 else if (isvertex) EITool.Add(E2,VDS,I2);
114 } // (isComplex && !memeS)
116 if (isComplex && memeS) {
118 } // (isComplex && memeS)
122 if (!isComplex && memeS) {
123 const TopOpeBRepDS_Transition& T1 = I1->Transition();
124 TrmemeS.Index(T1.Index()); I1->ChangeTransition() = TrmemeS;
125 RLI.Append(I1); LI.Remove(it1);
127 else if (isComplex && !memeS) {
128 EITool.Transition(I1);
129 RLI.Append(I1); LI.Remove(it1);
139 //------------------------------------------------------
140 Standard_EXPORT void FDS_repvg
141 (const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,const TopOpeBRepDS_Kind GT,TopOpeBRepDS_ListOfInterference& LOI,TopOpeBRepDS_ListOfInterference& RLOI)
142 //------------------------------------------------------
144 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
146 // xpu211098 : cto904F6 (e10,FTRA1=f14,FTRA2=f17)
147 MDSdmoiloi mapITRASHA;
148 TopOpeBRepDS_ListIteratorOfListOfInterference it(LOI);
150 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
151 Standard_Integer isa = I->Transition().Index();
152 Standard_Boolean bound = mapITRASHA.IsBound(isa);
154 TopOpeBRepDS_ListOfInterference loi; loi.Append(I);
155 mapITRASHA.Bind(isa,loi);
157 else mapITRASHA.ChangeFind(isa).Append(I);
162 MDSdmiodmoiloi itm(mapITRASHA);
163 for (; itm.More(); itm.Next()){
164 Standard_Integer isa = itm.Key();
165 TopOpeBRepDS_ListOfInterference& loi = mapITRASHA.ChangeFind(isa);
166 Standard_Integer nloi = loi.Extent();
167 if (nloi < 2) continue;
168 TopOpeBRepDS_ListOfInterference rloi; FDS_repvg2(BDS,EIX,GT,loi,rloi);
169 LOI.Append(loi); RLOI.Append(rloi);
173 for (tki.Init(); tki.More(); tki.Next()) {
174 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
175 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
176 Standard_Integer nloi = loi.Extent();
177 if (nloi == 0) continue;
178 else if (nloi == 1) LOI.Append(loi);
180 FDS_repvg2(BDS,EIX,GT,loi,Rloi);
181 LOI.Append(loi); RLOI.Append(Rloi);