7fd59977 |
1 | // File: TopOpeBRepDS_repvg.cxx |
2 | // Created: Sat Feb 14 15:53:06 1998 |
3 | // Author: Jean Yves LEBEY |
4 | // <jyl@langdox.paris1.matra-dtv.fr> |
5 | |
6 | #include <TopOpeBRepDS_repvg.hxx> |
7 | #include <TopoDS.hxx> |
8 | #include <BRep_Tool.hxx> |
9 | #include <TopExp.hxx> |
10 | |
11 | #include <TopOpeBRepTool_EXPORT.hxx> |
12 | #include <TopOpeBRepTool_SC.hxx> |
13 | #include <TopOpeBRepTool_makeTransition.hxx> |
14 | |
15 | #include <TopOpeBRepDS_EdgeInterferenceTool.hxx> |
16 | #include <TopOpeBRepDS_EdgeVertexInterference.hxx> |
17 | #include <TopOpeBRepDS_Interference.hxx> |
18 | #include <TopOpeBRepDS_TKI.hxx> |
19 | #include <TopOpeBRepDS_ProcessInterferencesTool.hxx> |
20 | #include <TopOpeBRepDS_EXPORT.hxx> |
21 | #include <TopOpeBRepDS_define.hxx> |
22 | #include <Precision.hxx> |
23 | |
24 | #include <TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx> |
25 | #include <TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference.hxx> |
26 | #define MDSdmoiloi TopOpeBRepDS_DataMapOfIntegerListOfInterference |
27 | #define MDSdmiodmoiloi TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference |
28 | |
29 | #ifdef DEB |
30 | #include <TopOpeBRepDS_reDEB.hxx> |
31 | Standard_IMPORT Standard_Boolean TopOpeBRepDS_GetcontextMKTONREG(); |
32 | #endif |
33 | |
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 | //------------------------------------------------------ |
38 | { |
39 | #ifdef DEB |
40 | Standard_Boolean TRC=DSREDUEDGETRCE(EIX); |
41 | TRC = Standard_False; //xpu170898 |
42 | #endif |
43 | const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX)); |
44 | Standard_Boolean isEd = BRep_Tool::Degenerated(E); |
45 | if (isEd) return; |
46 | |
47 | #ifdef DEB |
48 | if (TRC) cout<<endl<<"repvg1 E"<<EIX<<" <- "<<LI.Extent()<<endl; |
49 | if (TRC) debredpvg(EIX); |
50 | #endif |
51 | |
52 | Standard_Boolean ispoint = (GT == TopOpeBRepDS_POINT); |
53 | Standard_Boolean isvertex = (GT == TopOpeBRepDS_VERTEX); |
54 | |
55 | Standard_Boolean nLI = LI.Extent(); |
56 | |
57 | TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI); |
58 | while (it1.More()) { |
59 | const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); |
60 | TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1; |
61 | FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1); |
62 | if (tsb1 != TopAbs_FACE) {it1.Next(); continue;} |
63 | if (tsa1 != TopAbs_FACE) {it1.Next(); continue;} |
64 | if (GT1 != GT) {it1.Next(); continue;} |
65 | |
66 | // xpu121198 : raise in PRO16303, if G1 is a vertex same domain, make sure |
67 | // rk(G1)= rk(E1) |
68 | Standard_Integer rkG1 = BDS.AncestorRank(G1); |
69 | Standard_Integer rkS1 = BDS.AncestorRank(S1); |
70 | if (isvertex && (rkG1 != rkS1)) { |
71 | TopoDS_Shape oovG; Standard_Boolean issd = FUN_ds_getoov(BDS.Shape(G1),BDS,oovG); |
72 | if (!issd) {it1.Next(); continue;} //!!NYIRAISE |
73 | G1 = BDS.Shape(oovG); |
74 | } |
75 | |
76 | const TopoDS_Edge& E1 = TopoDS::Edge(BDS.Shape(S1)); |
77 | const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(isb1)); |
78 | TopOpeBRepDS_Point PDS; TopoDS_Shape VDS; |
79 | if (ispoint) PDS = BDS.Point(G1); |
80 | else if (isvertex) VDS = BDS.Shape(G1); |
81 | else Standard_Failure::Raise("TopOpeBRepDS FDS_repvg2 1"); |
82 | |
83 | Standard_Boolean isEd1 = BRep_Tool::Degenerated(E1); if (isEd1) {it1.Next(); continue;} |
84 | TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); if (it2.More()) it2.Next(); else {it1.Next(); continue; } |
85 | |
86 | TopOpeBRepDS_EdgeInterferenceTool EITool; |
87 | Standard_Boolean memeS = Standard_False; TopOpeBRepDS_Transition TrmemeS; Standard_Boolean isComplex = Standard_False; |
88 | |
89 | while ( it2.More() ) { |
90 | const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value(); |
91 | TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2; |
92 | FDS_Idata(I2,tsb2,isb2,tsa2,isa2,GT2,G2,ST2,S2); |
93 | if (tsb2 != TopAbs_FACE) {it2.Next(); continue;} |
94 | if (tsa2 != TopAbs_FACE) {it2.Next(); continue;} |
95 | |
96 | Standard_Boolean cond = (G1 == G2); if (!cond) { it2.Next(); continue; } |
97 | |
98 | #ifdef DEB |
99 | if (TRC && isvertex && DSREDUEDGETRCE(BDS.Shape(VDS))) debreducerEV(EIX,BDS.Shape(VDS)); |
100 | #endif |
101 | |
102 | const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2)); |
103 | Standard_Boolean isEd2 = BRep_Tool::Degenerated(E2); |
104 | if (isEd2) {it2.Next(); continue;} |
105 | |
106 | memeS = (S1 == S2); |
107 | memeS = memeS && (nLI == 2); |
108 | |
109 | if (!isComplex && memeS) { |
110 | Standard_Boolean mktone = Standard_False; |
111 | #ifdef DEB |
112 | // NYI XPU : corriger la sequence suivante (avec mkTonE) qui produit une |
113 | // NYI transition (ON,ON) dans le cas cto 009 B4 pour l'arete 6* / face *21 |
114 | // NYI aux PDS 1 et 5, au lieu de (IN,IN). |
115 | mktone = TopOpeBRepDS_GetcontextMKTONREG(); |
116 | if (mktone) { |
117 | const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(E); |
118 | Standard_Real pbef,paft; Standard_Boolean isonper; |
119 | Standard_Real pE = FDS_Parameter(I1); |
120 | Standard_Boolean ok = FDS_LOIinfsup(BDS,E,pE,GT1,G1,LOI,pbef,paft,isonper); |
121 | if (!ok) {it2.Next();continue;} |
122 | Standard_Real pE1; ok = FUN_tool_parE(E,pE,E1,pE1); if (!ok) {it2.Next();continue;} |
123 | gp_Pnt2d uv; ok = FUN_tool_paronEF(E,pE,F1,uv); if (!ok) {it2.Next();continue;} |
124 | Standard_Real factor = 0.789; |
125 | TopOpeBRepTool_makeTransition MKT; |
126 | TopAbs_State stb,sta; |
127 | ok = MKT.Initialize(E,pbef,paft,pE, F1,uv, factor); |
128 | if (ok) ok = MKT.SetRest(E1,pE1); |
129 | if (ok) ok = MKT.MkTonE(stb,sta); |
130 | if (!ok) {it2.Next();continue;} |
131 | TrmemeS.Before(stb); TrmemeS.After(sta); |
132 | } |
133 | #endif |
134 | if (!mktone) { |
135 | Standard_Real pE = FDS_Parameter(I1); |
136 | Standard_Boolean ok = FDS_stateEwithF2d(BDS,E,pE,GT1,G1,F1,TrmemeS); if (!ok) {it2.Next();continue;} |
137 | } |
138 | |
139 | #ifdef DEB |
140 | if(TRC){cout<<"memeS result ";TrmemeS.Dump(cout);cout<<endl;} |
141 | #endif |
142 | LI.Remove(it2); |
143 | } // !isComplex && memeS |
144 | |
145 | if (!isComplex && !memeS) { |
146 | isComplex = Standard_True; |
147 | EITool.Init(E,I1); |
148 | if (ispoint) EITool.Add(E,PDS,I1); |
149 | else if (isvertex) EITool.Add(E1,VDS,I1); |
150 | #ifdef DEB |
151 | if (TRC){cout<<endl<<"complex T2d E"<<EIX<<endl;I1->Dump(cout);cout<<endl;} |
152 | if (TRC){cout<<"init ";Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference(); |
153 | EITool.Transition(IBID);IBID->Transition().Dump(cout);cout<<endl;} |
154 | #endif |
155 | } // !isComplex && !memeS |
156 | |
157 | if (isComplex && !memeS) { |
158 | #ifdef DEB |
159 | if(TRC) I2->Dump(cout,"add ","\n"); |
160 | #endif |
161 | if (ispoint) EITool.Add(E,PDS,I2); |
162 | else if (isvertex) EITool.Add(E2,VDS,I2); |
163 | LI.Remove(it2); |
164 | #ifdef DEB |
165 | if(TRC){cout<<"result ";Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference(); |
166 | EITool.Transition(IBID);IBID->Transition().Dump(cout);cout<<endl;} |
167 | #endif |
168 | } // (isComplex && !memeS) |
169 | |
170 | if (isComplex && memeS) { |
171 | it2.Next(); |
172 | #ifdef DEB |
173 | #endif |
174 | } // (isComplex && memeS) |
175 | |
176 | } // it2 |
177 | |
178 | if (!isComplex && memeS) { |
179 | const TopOpeBRepDS_Transition& T1 = I1->Transition(); |
180 | TrmemeS.Index(T1.Index()); I1->ChangeTransition() = TrmemeS; |
181 | RLI.Append(I1); LI.Remove(it1); |
182 | } |
183 | else if (isComplex && !memeS) { |
184 | EITool.Transition(I1); |
185 | RLI.Append(I1); LI.Remove(it1); |
186 | } |
187 | else { |
188 | it1.Next(); |
189 | } |
190 | |
191 | } // it1 |
192 | |
193 | #ifdef DEB |
194 | if (TRC) cout<<"repvg2 E"<<EIX<<" -> reste "<<LI.Extent()<<" + reduit "<<RLI.Extent()<<endl<<endl; |
195 | #endif |
196 | } // FDS_repvg2 |
197 | |
198 | //------------------------------------------------------ |
199 | Standard_EXPORT void FDS_repvg |
200 | (const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,const TopOpeBRepDS_Kind GT,TopOpeBRepDS_ListOfInterference& LOI,TopOpeBRepDS_ListOfInterference& RLOI) |
201 | //------------------------------------------------------ |
202 | { |
203 | TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI); |
204 | #ifdef DEB |
205 | Standard_Boolean TRC=DSREDUEDGETRCE(EIX); |
206 | TRC = Standard_False; //xpu170898 |
207 | if (TRC) cout<<endl<<"repvg E"<<EIX<<" <- "<<LOI.Extent()<<endl; |
208 | if (TRC) tki.DumpTKIIterator("","\n"); |
209 | if (TRC) debredpvg(EIX); |
210 | #endif |
211 | |
212 | // xpu211098 : cto904F6 (e10,FTRA1=f14,FTRA2=f17) |
213 | MDSdmoiloi mapITRASHA; |
214 | TopOpeBRepDS_ListIteratorOfListOfInterference it(LOI); |
215 | while (it.More()) { |
216 | const Handle(TopOpeBRepDS_Interference)& I = it.Value(); |
217 | Standard_Integer isa = I->Transition().Index(); |
218 | Standard_Boolean bound = mapITRASHA.IsBound(isa); |
219 | if (!bound) { |
220 | TopOpeBRepDS_ListOfInterference loi; loi.Append(I); |
221 | mapITRASHA.Bind(isa,loi); |
222 | } |
223 | else mapITRASHA.ChangeFind(isa).Append(I); |
224 | it.Next(); |
225 | } |
226 | |
227 | LOI.Clear(); |
228 | MDSdmiodmoiloi itm(mapITRASHA); |
229 | for (; itm.More(); itm.Next()){ |
230 | Standard_Integer isa = itm.Key(); |
231 | TopOpeBRepDS_ListOfInterference& loi = mapITRASHA.ChangeFind(isa); |
232 | Standard_Integer nloi = loi.Extent(); |
233 | if (nloi < 2) continue; |
234 | TopOpeBRepDS_ListOfInterference rloi; FDS_repvg2(BDS,EIX,GT,loi,rloi); |
235 | LOI.Append(loi); RLOI.Append(rloi); |
236 | } |
237 | |
238 | /*LOI.Clear(); |
239 | for (tki.Init(); tki.More(); tki.Next()) { |
240 | TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G); |
241 | #ifdef DEB |
242 | if (TRC) {tki.DumpTKI(K,G,"","\n");debredpvg(EIX);} |
243 | #endif |
244 | TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi; |
245 | Standard_Integer nloi = loi.Extent(); |
246 | if (nloi == 0) continue; |
247 | else if (nloi == 1) LOI.Append(loi); |
248 | else { |
249 | FDS_repvg2(BDS,EIX,GT,loi,Rloi); |
250 | LOI.Append(loi); RLOI.Append(Rloi); |
251 | } |
252 | }*/ |
253 | |
254 | #ifdef DEB |
255 | if (TRC) cout<<"repvg E"<<EIX<<" -> reste "<<LOI.Extent()<<" + reduit "<<RLOI.Extent()<<endl<<endl; |
256 | #endif |
257 | } |
258 | |