1 // Created on: 1998-02-14
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <TopOpeBRepDS_repvg.hxx>
24 #include <BRep_Tool.hxx>
27 #include <TopOpeBRepTool_EXPORT.hxx>
28 #include <TopOpeBRepTool_SC.hxx>
29 #include <TopOpeBRepTool_makeTransition.hxx>
31 #include <TopOpeBRepDS_EdgeInterferenceTool.hxx>
32 #include <TopOpeBRepDS_EdgeVertexInterference.hxx>
33 #include <TopOpeBRepDS_Interference.hxx>
34 #include <TopOpeBRepDS_TKI.hxx>
35 #include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
36 #include <TopOpeBRepDS_EXPORT.hxx>
37 #include <TopOpeBRepDS_define.hxx>
38 #include <Precision.hxx>
40 #include <TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx>
41 #include <TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference.hxx>
42 #define MDSdmoiloi TopOpeBRepDS_DataMapOfIntegerListOfInterference
43 #define MDSdmiodmoiloi TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference
46 #include <TopOpeBRepDS_reDEB.hxx>
47 extern Standard_Boolean TopOpeBRepDS_GetcontextMKTONREG();
50 //------------------------------------------------------
51 Standard_EXPORT void FDS_repvg2
52 (const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,const TopOpeBRepDS_Kind GT,TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& RLI)
53 //------------------------------------------------------
56 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
57 TRC = Standard_False; //xpu170898
59 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
60 Standard_Boolean isEd = BRep_Tool::Degenerated(E);
64 if (TRC) cout<<endl<<"repvg1 E"<<EIX<<" <- "<<LI.Extent()<<endl;
65 if (TRC) debredpvg(EIX);
68 Standard_Boolean ispoint = (GT == TopOpeBRepDS_POINT);
69 Standard_Boolean isvertex = (GT == TopOpeBRepDS_VERTEX);
71 Standard_Boolean nLI = LI.Extent();
73 TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);
75 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
76 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
77 FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
78 if (tsb1 != TopAbs_FACE) {it1.Next(); continue;}
79 if (tsa1 != TopAbs_FACE) {it1.Next(); continue;}
80 if (GT1 != GT) {it1.Next(); continue;}
82 // xpu121198 : raise in PRO16303, if G1 is a vertex same domain, make sure
84 Standard_Integer rkG1 = BDS.AncestorRank(G1);
85 Standard_Integer rkS1 = BDS.AncestorRank(S1);
86 if (isvertex && (rkG1 != rkS1)) {
87 TopoDS_Shape oovG; Standard_Boolean issd = FUN_ds_getoov(BDS.Shape(G1),BDS,oovG);
88 if (!issd) {it1.Next(); continue;} //!!NYIRAISE
92 const TopoDS_Edge& E1 = TopoDS::Edge(BDS.Shape(S1));
93 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(isb1));
94 TopOpeBRepDS_Point PDS; TopoDS_Shape VDS;
95 if (ispoint) PDS = BDS.Point(G1);
96 else if (isvertex) VDS = BDS.Shape(G1);
97 else Standard_Failure::Raise("TopOpeBRepDS FDS_repvg2 1");
99 Standard_Boolean isEd1 = BRep_Tool::Degenerated(E1); if (isEd1) {it1.Next(); continue;}
100 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); if (it2.More()) it2.Next(); else {it1.Next(); continue; }
102 TopOpeBRepDS_EdgeInterferenceTool EITool;
103 Standard_Boolean memeS = Standard_False; TopOpeBRepDS_Transition TrmemeS; Standard_Boolean isComplex = Standard_False;
105 while ( it2.More() ) {
106 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
107 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2;
108 FDS_Idata(I2,tsb2,isb2,tsa2,isa2,GT2,G2,ST2,S2);
109 if (tsb2 != TopAbs_FACE) {it2.Next(); continue;}
110 if (tsa2 != TopAbs_FACE) {it2.Next(); continue;}
112 Standard_Boolean cond = (G1 == G2); if (!cond) { it2.Next(); continue; }
115 if (TRC && isvertex && DSREDUEDGETRCE(BDS.Shape(VDS))) debreducerEV(EIX,BDS.Shape(VDS));
118 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2));
119 Standard_Boolean isEd2 = BRep_Tool::Degenerated(E2);
120 if (isEd2) {it2.Next(); continue;}
123 memeS = memeS && (nLI == 2);
125 if (!isComplex && memeS) {
126 Standard_Boolean mktone = Standard_False;
128 // NYI XPU : corriger la sequence suivante (avec mkTonE) qui produit une
129 // NYI transition (ON,ON) dans le cas cto 009 B4 pour l'arete 6* / face *21
130 // NYI aux PDS 1 et 5, au lieu de (IN,IN).
131 mktone = TopOpeBRepDS_GetcontextMKTONREG();
133 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(E);
134 Standard_Real pbef,paft; Standard_Boolean isonper;
135 Standard_Real pE = FDS_Parameter(I1);
136 Standard_Boolean ok = FDS_LOIinfsup(BDS,E,pE,GT1,G1,LOI,pbef,paft,isonper);
137 if (!ok) {it2.Next();continue;}
138 Standard_Real pE1; ok = FUN_tool_parE(E,pE,E1,pE1); if (!ok) {it2.Next();continue;}
139 gp_Pnt2d uv; ok = FUN_tool_paronEF(E,pE,F1,uv); if (!ok) {it2.Next();continue;}
140 Standard_Real factor = 0.789;
141 TopOpeBRepTool_makeTransition MKT;
142 TopAbs_State stb = TopAbs_UNKNOWN,sta = TopAbs_UNKNOWN;
143 ok = MKT.Initialize(E,pbef,paft,pE, F1,uv, factor);
144 if (ok) ok = MKT.SetRest(E1,pE1);
145 if (ok) ok = MKT.MkTonE(stb,sta);
146 if (!ok) {it2.Next();continue;}
147 TrmemeS.Before(stb); TrmemeS.After(sta);
151 Standard_Real pE = FDS_Parameter(I1);
152 Standard_Boolean ok = FDS_stateEwithF2d(BDS,E,pE,GT1,G1,F1,TrmemeS); if (!ok) {it2.Next();continue;}
156 if(TRC){cout<<"memeS result ";TrmemeS.Dump(cout);cout<<endl;}
159 } // !isComplex && memeS
161 if (!isComplex && !memeS) {
162 isComplex = Standard_True;
164 if (ispoint) EITool.Add(E,PDS,I1);
165 else if (isvertex) EITool.Add(E1,VDS,I1);
167 if (TRC){cout<<endl<<"complex T2d E"<<EIX<<endl;I1->Dump(cout);cout<<endl;}
168 if (TRC){cout<<"init ";Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference();
169 EITool.Transition(IBID);IBID->Transition().Dump(cout);cout<<endl;}
171 } // !isComplex && !memeS
173 if (isComplex && !memeS) {
175 if(TRC) I2->Dump(cout,"add ","\n");
177 if (ispoint) EITool.Add(E,PDS,I2);
178 else if (isvertex) EITool.Add(E2,VDS,I2);
181 if(TRC){cout<<"result ";Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference();
182 EITool.Transition(IBID);IBID->Transition().Dump(cout);cout<<endl;}
184 } // (isComplex && !memeS)
186 if (isComplex && memeS) {
190 } // (isComplex && memeS)
194 if (!isComplex && memeS) {
195 const TopOpeBRepDS_Transition& T1 = I1->Transition();
196 TrmemeS.Index(T1.Index()); I1->ChangeTransition() = TrmemeS;
197 RLI.Append(I1); LI.Remove(it1);
199 else if (isComplex && !memeS) {
200 EITool.Transition(I1);
201 RLI.Append(I1); LI.Remove(it1);
210 if (TRC) cout<<"repvg2 E"<<EIX<<" -> reste "<<LI.Extent()<<" + reduit "<<RLI.Extent()<<endl<<endl;
214 //------------------------------------------------------
215 Standard_EXPORT void FDS_repvg
216 (const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,const TopOpeBRepDS_Kind GT,TopOpeBRepDS_ListOfInterference& LOI,TopOpeBRepDS_ListOfInterference& RLOI)
217 //------------------------------------------------------
219 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
221 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
222 TRC = Standard_False; //xpu170898
223 if (TRC) cout<<endl<<"repvg E"<<EIX<<" <- "<<LOI.Extent()<<endl;
224 if (TRC) tki.DumpTKIIterator("","\n");
225 if (TRC) debredpvg(EIX);
228 // xpu211098 : cto904F6 (e10,FTRA1=f14,FTRA2=f17)
229 MDSdmoiloi mapITRASHA;
230 TopOpeBRepDS_ListIteratorOfListOfInterference it(LOI);
232 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
233 Standard_Integer isa = I->Transition().Index();
234 Standard_Boolean bound = mapITRASHA.IsBound(isa);
236 TopOpeBRepDS_ListOfInterference loi; loi.Append(I);
237 mapITRASHA.Bind(isa,loi);
239 else mapITRASHA.ChangeFind(isa).Append(I);
244 MDSdmiodmoiloi itm(mapITRASHA);
245 for (; itm.More(); itm.Next()){
246 Standard_Integer isa = itm.Key();
247 TopOpeBRepDS_ListOfInterference& loi = mapITRASHA.ChangeFind(isa);
248 Standard_Integer nloi = loi.Extent();
249 if (nloi < 2) continue;
250 TopOpeBRepDS_ListOfInterference rloi; FDS_repvg2(BDS,EIX,GT,loi,rloi);
251 LOI.Append(loi); RLOI.Append(rloi);
255 for (tki.Init(); tki.More(); tki.Next()) {
256 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
258 if (TRC) {tki.DumpTKI(K,G,"","\n");debredpvg(EIX);}
260 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
261 Standard_Integer nloi = loi.Extent();
262 if (nloi == 0) continue;
263 else if (nloi == 1) LOI.Append(loi);
265 FDS_repvg2(BDS,EIX,GT,loi,Rloi);
266 LOI.Append(loi); RLOI.Append(Rloi);
271 if (TRC) cout<<"repvg E"<<EIX<<" -> reste "<<LOI.Extent()<<" + reduit "<<RLOI.Extent()<<endl<<endl;