0023267: cppcheck warning: Using 'memcpy' on class that contains a virtual method
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_EIR.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
7fd59977 19
20#include <TopOpeBRepDS_EIR.ixx>
21#include <BRep_Tool.hxx>
22#include <TopExp.hxx>
23#include <TopOpeBRepDS_CurvePointInterference.hxx>
24#include <TopOpeBRepDS_Dumper.hxx>
25#include <TopOpeBRepDS_Edge3dInterferenceTool.hxx>
26#include <TopOpeBRepDS_EdgeInterferenceTool.hxx>
27#include <TopOpeBRepDS_EdgeVertexInterference.hxx>
28#include <TopOpeBRepDS_Interference.hxx>
29#include <TopOpeBRepDS_TKI.hxx>
30#include <TopoDS.hxx>
31#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
32#include <TopOpeBRepTool_EXPORT.hxx>
33#include <TopOpeBRepDS_EXPORT.hxx>
34#include <TopOpeBRepDS_define.hxx>
35#include <TopOpeBRepDS_repvg.hxx>
36#include <TopOpeBRepDS_connex.hxx>
37#include <TopOpeBRepTool_TOOL.hxx>
38#ifdef DEB
39#include <TopOpeBRepDS_reDEB.hxx>
40Standard_EXPORT void debredpnc(const Standard_Integer ie){cout<<"+++ debredpnc e"<<ie<<endl;}
41Standard_IMPORT Standard_Boolean TopOpeBRepDS_GetcontextNOPNC();
42#endif
43
44#define M_FORWARD(O) (O == TopAbs_FORWARD)
45#define M_REVERSED(O) (O == TopAbs_REVERSED)
46#define M_INTERNAL(O) (O == TopAbs_INTERNAL)
47#define M_EXTERNAL(O) (O == TopAbs_EXTERNAL)
48
49// modified by NIZHNY-MKK Mon Apr 2 15:34:28 2001.BEGIN
50static Standard_Boolean CheckInterferenceIsValid(const Handle(TopOpeBRepDS_Interference)& I,
51 const TopoDS_Edge& theEdge,
52 const TopoDS_Edge& theSupportEdge,
53 const TopoDS_Vertex& theVertex);
54// modified by NIZHNY-MKK Mon Apr 2 15:34:32 2001.END
55
56//------------------------------------------------------
57static void FDS_reduceONFACEinterferences(TopOpeBRepDS_ListOfInterference& LI,
58 const TopOpeBRepDS_DataStructure& /*BDS*/,
59 const Standard_Integer
60#ifdef DEB
61 EIX
62#endif
63 )
64//------------------------------------------------------
65{
66#ifdef DEB
67 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
68 TRC = Standard_False; //MOINSTRACE
69 if (TRC) cout<<endl<<"reduceONFACEinterferences on "<<EIX<<" <- "<<LI.Extent()<<endl;
70#endif
71
72 TopOpeBRepDS_ListIteratorOfListOfInterference it1; // set hasONFACE = True if LI contains interfs with (ON,FACE) transition(s).
73 Standard_Boolean hasONFACE = Standard_False;
74 for (it1.Initialize(LI); it1.More(); it1.Next() ) {
75 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
76 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
77 if ( GT1 == TopOpeBRepDS_POINT ) {
78 hasONFACE = FUN_hasStateShape(I1->Transition(),TopAbs_ON,TopAbs_FACE);
79 if ( hasONFACE ) break;
80 }
81 }
82
83#ifdef DEB
84 if(TRC){if( hasONFACE)cout<<"egde "<<EIX<<" has (ON,FACE)"<<endl;}
85 if(TRC){if(!hasONFACE)cout<<"egde "<<EIX<<" has no (ON,FACE)"<<endl;}
86#endif
87
88 if ( hasONFACE ) {
89 // LI has (ON,FACE) : remove all other interf (POINT,(not(ON,FACE)))
90 it1.Initialize(LI);
91 while( it1.More() ) {
92 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
93 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
94 if ( GT1 == TopOpeBRepDS_POINT ) {
95 hasONFACE = FUN_hasStateShape(I1->Transition(),TopAbs_ON,TopAbs_FACE);
96 if ( ! hasONFACE ) {
97 LI.Remove(it1);
98 }
99 else it1.Next();
100 }
101 else it1.Next();
102 }
103 }
104
105#ifdef DEB
106 if (TRC) cout<<"reduceONFACEinterferences E"<<EIX<<" -> "<<LI.Extent()<<endl<<endl;
107#endif
108}
109
110//------------------------------------------------------
111static void FUN_ReducerEdge3d(const Standard_Integer SIX, TopOpeBRepDS_DataStructure& BDS,
112 TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& reducedLI)
113//------------------------------------------------------
114// <LI> = { I3d = (TonFACE, G=POINT/VERTEX, S=EDGE) }
115// {I3d} --reducing processing-> I3d' = (TonFACE, G=POINT/VERTEX, S=FACE)
116// <LI> -> <reducedLI> + <LI>
117{
118 reducedLI.Clear();
119#ifdef DEB
120 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
121 TRC = Standard_False; //MOINSTRACE
122 if(TRC) {cout<<endl; debreducer3d(SIX);}
123 if (TRC) cout<<endl<<"ReducerEdge3d E"<<SIX<<" <- "<<LI.Extent()<<endl;
124#endif
125 Standard_Integer n3d = LI.Extent();
126 if (n3d <= 1) return;
127 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(SIX));
128 Standard_Integer rankE = BDS.AncestorRank(E);
129 TopoDS_Shape OOv; Standard_Integer Gsta = 0;
130
131 TopOpeBRepDS_ListIteratorOfListOfInterference it1;
132 it1.Initialize(LI);
133
134 // <-- jyl 231198 : cts21797
135 Standard_Integer nLI = LI.Extent();
136 if (nLI >= 1) {
137 while (it1.More()) {
138 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
139 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
140 TopAbs_ShapeEnum SB1,SA1; Standard_Integer IB1,IA1; FDS_Tdata(I1,SB1,IB1,SA1,IA1);
141 Standard_Boolean torem = Standard_False;
142 if (ST1 == TopOpeBRepDS_EDGE) {
143 const TopoDS_Edge& EE = TopoDS::Edge(BDS.Shape(S1));
144 const TopoDS_Face& FF = TopoDS::Face(BDS.Shape(IB1));
145 TopAbs_Orientation o; Standard_Boolean ok = FUN_tool_orientEinFFORWARD(EE,FF,o);
146 if (ok && (o == TopAbs_EXTERNAL)) torem = Standard_True;
147 }
148 if (torem) LI.Remove(it1);
149 else it1.Next();
150 }
151 nLI = LI.Extent();
152 if (nLI <= 1) return;
153 }
154 // --> jyl 231198 : cts21797
155
156 it1.Initialize(LI);
157 while (it1.More()){
158
159 Standard_Boolean isComplex = Standard_False;
160 TopOpeBRepDS_Edge3dInterferenceTool EFITool;
161 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
162 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
163 TopAbs_ShapeEnum SB1,SA1; Standard_Integer IB1,IA1; FDS_Tdata(I1,SB1,IB1,SA1,IA1);
164
165 // modified by NIZHNY-MKK Mon Apr 2 15:35:58 2001.BEGIN
166 TopoDS_Vertex aVertex;
167
168 if((GT1 == TopOpeBRepDS_VERTEX) && G1!=0) {
169 aVertex = TopoDS::Vertex(BDS.Shape(G1));
170 }
171
172 if(!CheckInterferenceIsValid(I1, E, TopoDS::Edge(BDS.Shape(S1)), aVertex)) {
173 LI.Remove(it1);
174 continue;
175 }
176 // modified by NIZHNY-MKK Mon Apr 2 15:36:02 2001.END
177
178 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1);
179 if (it2.More()) it2.Next();
180 else return;
181
182 while ( it2.More()){
183 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
184 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
185 TopAbs_ShapeEnum SB2,SA2; Standard_Integer IB2,IA2; FDS_Tdata(I2,SB2,IB2,SA2,IA2);
186
187 // modified by NIZHNY-MKK Mon Apr 2 15:36:42 2001.BEGIN
188 aVertex.Nullify();
189
190 if((GT2 == TopOpeBRepDS_VERTEX) && G2!=0) {
191 aVertex = TopoDS::Vertex(BDS.Shape(G2));
192 }
193
194 if(!CheckInterferenceIsValid(I2, E, TopoDS::Edge(BDS.Shape(S2)), aVertex)) {
195 LI.Remove(it2);
196 continue;
197 }
198 // modified by NIZHNY-MKK Mon Apr 2 15:36:45 2001.END
199
200 Standard_Boolean sameG = (GT2 == GT1) && (G2 == G1);
201 if (!sameG) break;
202
203 // <Gsta>, <OOv>
204 if (GT1 == TopOpeBRepDS_VERTEX) {
205 TopoDS_Vertex vG1 = TopoDS::Vertex(BDS.Shape(G1));
206 Standard_Integer rankvG1 = BDS.AncestorRank(vG1);
207 Standard_Integer sdG1; Standard_Boolean G1hsd = FUN_ds_getVsdm(BDS,G1,sdG1);
208 if (rankvG1 != rankE) { // vG1 not on E
209 OOv = vG1;
210 Gsta = G1hsd? 3: 2;
211 }
212 else { // vG on E
213 if (G1hsd) OOv = BDS.Shape(sdG1);
214 Gsta = G1hsd? 3: 1;
215 }
216 }
217
218 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(IB1));
219 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(IB2)); // F2 != F1
220
221 Standard_Boolean sameS = (ST2 == ST1) && (S2 == S1);
222 if (!sameS) {
223 TopoDS_Shape Eshared; Standard_Boolean foundsh = FUN_tool_Eshared(OOv,F1,F2,Eshared);
224 if (!foundsh) return;
225
226 // modified by NIZHNY-MKK Mon Apr 2 15:37:12 2001.BEGIN
227 if(!BDS.HasShape(Eshared)) {
228 return;
229 }
230 // modified by NIZHNY-MKK Mon Apr 2 15:37:15 2001.END
231
232 S1 = S2 = BDS.Shape(Eshared);
233 }
234
235 const TopoDS_Edge& E1 = TopoDS::Edge(BDS.Shape(S1));
236 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2)); // E2 == E1
237
238 Standard_Boolean sdm = FUN_ds_sdm(BDS,E,E1);
239 if (sdm) {
240#ifdef DEB
241 if (TRC) cout<<" NO I3d : e"<<SIX<<" same domain with e"<<S1<<endl;
242#endif
243 it2.Next(); continue;
244 }
245
246 Standard_Boolean init = !isComplex;
247 Standard_Boolean isvertex = (GT1 == TopOpeBRepDS_VERTEX);
248 init = init || isvertex; // !!!KK a revoir!!!!
249
250 if (init) {
251
252 // xpu : 04-03-98 : !!!KK a revoir!!!!
253 if (isComplex) {
254 Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference();
255 EFITool.Transition(IBID);
256 I1->ChangeTransition().Set(IBID->Transition().Orientation(TopAbs_IN));
257 }
258 // !!!KK a revoir!!!!
259
260 if (!isComplex) EFITool.InitPointVertex(Gsta,OOv);
261 isComplex = Standard_True;
262 EFITool.Init(E,E1,F1,I1);
263 EFITool.Add(E,E1,F1,I1);
264#ifdef DEB
265 if(TRC){cout<<endl<<"complex T3d E"<<SIX<<endl;I1->Dump(cout,"init :","\n");}
266#endif
267 } // !isComplex
268
269#ifdef DEB
270 if(TRC) I2->Dump(cout,"add : ","\n");
271#endif
272 EFITool.Add(E,E2,F2,I2);
273 LI.Remove(it2);
274
275#ifdef DEB
276 if(TRC){cout<<"resulting : "; Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference();
277 EFITool.Transition(IBID);IBID->Transition().Dump(cout);cout<<endl;}
278#endif
279 } // it2
280
281 if (isComplex) {
282 Handle(TopOpeBRepDS_Interference) newI;
283 Handle(TopOpeBRepDS_Interference) IIBID = new TopOpeBRepDS_Interference();
284 EFITool.Transition(IIBID);
285 TopOpeBRepDS_Transition T = IIBID->Transition(); T.Index(IB1);
286
287 Standard_Boolean isevi = I1->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
288 Standard_Boolean iscpi = I1->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference));
289 if (isevi) {
290 const Handle(TopOpeBRepDS_EdgeVertexInterference)& EVI = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I1);
291 newI = new TopOpeBRepDS_EdgeVertexInterference(T,TopOpeBRepDS_FACE,IB1,G1,EVI->GBound(),
292 TopOpeBRepDS_UNSHGEOMETRY,EVI->Parameter());
293 }
294 if (iscpi) {
295 const Handle(TopOpeBRepDS_CurvePointInterference)& CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I1);
296 newI = new TopOpeBRepDS_CurvePointInterference(T,TopOpeBRepDS_FACE,IB1,TopOpeBRepDS_POINT,G1,CPI->Parameter());
297 }
298
299#ifdef DEB
300 if (TRC){cout<<"reduced T E"<<SIX<<" ";newI->Dump(cout);cout<<endl;}
301#endif
302 if (!newI.IsNull()) {
303 reducedLI.Append(newI);
304 LI.Remove(it1);
305 }
306 }
307 else
308 it1.Next();
309 } // it1
310
311#ifdef DEB
312 if (TRC) {
313 cout<<"ReducerEdge3d E"<<SIX<<" -> nIreduced "<<reducedLI.Extent();
314 cout<<" + nInonreduced "<<LI.Extent()<<endl<<endl;
315 }
316#endif
317}
318
319//------------------------------------------------------
320static void FUN_ReducerEdge(const Standard_Integer SIX,const TopOpeBRepDS_DataStructure& BDS,
321 TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& reducedLI)
322//------------------------------------------------------
323{
324#ifdef DEB
325 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
326// TRC = Standard_False; //MOINSTRACE
327 if (TRC) cout<<endl<<"ReducerEdge E"<<SIX<<" <- nI "<<LI.Extent()<<endl;
328#endif
329
330 FDS_repvg(BDS,SIX,TopOpeBRepDS_VERTEX,LI,reducedLI);
331 FDS_reduceONFACEinterferences(LI,BDS,SIX);
332 FDS_repvg(BDS,SIX,TopOpeBRepDS_POINT,LI,reducedLI);
333
334#ifdef DEB
335 if (TRC) cout<<"ReducerEdge E"<<SIX<<" -> nI "<<LI.Extent()<<endl<<endl;
336#endif
337}
338
339//------------------------------------------------------
340static void FUN_ReducerSDEdge(const Standard_Integer SIX,const TopOpeBRepDS_DataStructure& BDS,
341 TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& reducedLI)
342//------------------------------------------------------
343{
344 reducedLI.Clear();
345 Standard_Integer nI = LI.Extent();
346#ifdef DEB
347 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
348 TRC = Standard_False; //MOINSTRACE
349 if (TRC) cout<<endl<<"ReducerSDEdge E"<<SIX<<" <- nI "<<nI<<endl;
350#endif
351 if (nI <= 1) return;
352
353 TopOpeBRepDS_ListOfInterference newLI;
354 const TopoDS_Shape& EIX = BDS.Shape(SIX);
355 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
356 for (tki.Init(); tki.More(); tki.Next()) {
357 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
358 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
359
360 TopOpeBRepDS_ListIteratorOfListOfInterference it1(loi);
361 while (it1.More()) {
362 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); const TopOpeBRepDS_Transition& T1 = I1->Transition();
363 TopAbs_Orientation O1 = T1.Orientation(TopAbs_IN); Standard_Integer IB1 = T1.Index();
364 Standard_Boolean cond1 = FUN_ds_sdm(BDS,EIX,BDS.Shape(IB1));
365 if (!cond1) {newLI.Append(I1); it1.Next(); continue;}
366
367 Standard_Boolean complex1d = Standard_False;
368 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1);
369 if (it2.More()) it2.Next();
370 else break;
371
372 TopOpeBRepDS_Transition T(TopAbs_IN,TopAbs_IN,TopAbs_EDGE,TopAbs_EDGE);
373 while (it2.More()){
374 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value(); const TopOpeBRepDS_Transition& T2 = I2->Transition();
375 TopAbs_Orientation O2 = T2.Orientation(TopAbs_IN); Standard_Integer IB2 = T2.Index();
376 Standard_Boolean cond2 = FUN_ds_sdm(BDS,EIX,BDS.Shape(IB2));
377 if (!cond2) {newLI.Append(I2); it2.Next(); continue;}
378
379 complex1d = (M_FORWARD(O1) && M_REVERSED(O2));
380 complex1d = complex1d || (M_FORWARD(O2) && M_REVERSED(O1));
381 if (!complex1d) {newLI.Append(I2); it2.Next(); continue;}
382
383 if (complex1d) {
384 Standard_Integer IB = (M_REVERSED(O1)) ? IB1 : IB2; T.IndexBefore(IB);
385 Standard_Integer IA = (M_REVERSED(O1)) ? IB2 : IB1; T.IndexAfter(IA);
386 }
387 loi.Remove(it2);
388 break; // no more than 2 interferences on sdmTRASHA at same G
389 } // it2
390
391 if (complex1d) {
392 const Handle(TopOpeBRepDS_EdgeVertexInterference)& EVI = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I1);
393 TopOpeBRepDS_Config cEIX=BDS.SameDomainOri(SIX), c1=BDS.SameDomainOri(IB1);
394 TopOpeBRepDS_Config Conf = (cEIX == c1) ? TopOpeBRepDS_SAMEORIENTED : TopOpeBRepDS_DIFFORIENTED;
395 Handle(TopOpeBRepDS_Interference) newI = new TopOpeBRepDS_EdgeVertexInterference(T,TopOpeBRepDS_EDGE,IB1,G,EVI->GBound(),Conf,EVI->Parameter());
396 reducedLI.Append(newI);
397 it1.Next();
398 }
399 else {
400 newLI.Append(I1);
401 loi.Remove(it1);
402 }
403 } // it1
404 } // tki
405
406 LI.Clear(); LI.Append(newLI);
407
408#ifdef DEB
409 if (TRC) cout<<"ReducerSDEdge E"<<SIX<<" -> nI "<<LI.Extent()<<endl<<endl;
410#endif
411}
412
413//------------------------------------------------------
414static void FUN_reclSE2(const Standard_Integer SIX,const TopOpeBRepDS_DataStructure& BDS,
415 TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& reducedLI)
416//------------------------------------------------------
417// reducing LI = {I = (T(edge),G0,edge)}
418// edge <SIX> is same domain with edge <SE>
419// {I1 = (OU/IN(SE),VG,SE)
420// I2 = (IN/OU(SE),VG,SE))} -> Ir = (IN/IN(SE),VG,SE)
421{
422 reducedLI.Clear();
423 Standard_Integer nI = LI.Extent(); // DEB
424
425 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(SIX));
426
427#ifdef DEB
428 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
429 TRC = Standard_False; //MOINSTRACE
430 if (TRC) cout<<endl<<"reclSE2 E"<<SIX<<" <- nI "<<nI<<endl;
431#endif
432
433 TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);
434 while (it1.More()) {
435 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
436 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
437
438 const TopOpeBRepDS_Transition& T1 = I1->Transition(); TopAbs_Orientation O1 = T1.Orientation(TopAbs_IN);
439 if (M_INTERNAL(O1) || M_EXTERNAL(O1)) {it1.Next(); continue;}
440 TopAbs_Orientation cO1 = TopAbs::Complement(O1);
441
442 const TopoDS_Vertex& v1 = TopoDS::Vertex(BDS.Shape(G1));
443 const TopoDS_Edge& E1 = TopoDS::Edge(BDS.Shape(S1));
444 TopoDS_Vertex vclo1; Standard_Boolean iscE1 = TopOpeBRepTool_TOOL::ClosedE(E1,vclo1);
445 if (!iscE1) {it1.Next(); continue;}
446 if (!vclo1.IsSame(v1)) {it1.Next(); continue;}
447
448 Standard_Boolean sdm = FUN_ds_sdm(BDS,E,E1);
449 if (!sdm) {it1.Next(); continue;}
450
451 Standard_Boolean hascO = Standard_False;
452 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1);
453 if (it2.More()) it2.Next();
454 else {it1.Next(); continue;}
455 while ( it2.More()){
456 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
457 const TopOpeBRepDS_Transition& T2 = I2->Transition(); TopAbs_Orientation O2 = T2.Orientation(TopAbs_IN);
458 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
459
460 if (S1 != S2) {it2.Next(); continue;}
461 if (O2 != cO1) {it2.Next(); continue;}
462
463 LI.Remove(it2);
464 nI = LI.Extent(); // DEB
465 hascO = Standard_True; break;
466 } //it2
467
468 if (hascO) {
469 I1->ChangeTransition().Set(TopAbs_INTERNAL);
470 reducedLI.Append(I1); LI.Remove(it1);
471 nI = LI.Extent(); // DEB
472 }
473 else it1.Next();
474 } //it1
475
476#ifdef DEB
477 if (TRC) cout<<"reclSE2 E"<<SIX<<" -> nI "<<LI.Extent()<<endl<<endl;
478#endif
479} // FUN_reclSE2
480
481//------------------------------------------------------
482Standard_EXPORT void FUN_reclSE(const Standard_Integer EIX,const TopOpeBRepDS_DataStructure& BDS,
483 TopOpeBRepDS_ListOfInterference& LOI,TopOpeBRepDS_ListOfInterference& RLOI)
484//------------------------------------------------------
485{
486 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
487#ifdef DEB
488 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
489 TRC = Standard_False; //MOINSTRACE
490 if (TRC) cout<<endl<<"reclSE E"<<EIX<<" <- "<<LOI.Extent()<<endl;
491 if (TRC) tki.DumpTKIIterator("","\n");
492#endif
493
494 LOI.Clear();
495 for (tki.Init(); tki.More(); tki.Next()) {
496 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
497 if (K != TopOpeBRepDS_VERTEX) continue;
498
499#ifdef DEB
500 if (TRC) {tki.DumpTKI(K,G,"","\n");}
501#endif
502 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
503 Standard_Integer nloi = loi.Extent();
504 if (nloi == 0) continue;
505 else if (nloi == 1) LOI.Append(loi);
506 else {
507 FUN_reclSE2(EIX,BDS,loi,Rloi);
508 LOI.Append(loi); RLOI.Append(Rloi);
509 }
510 }
511
512#ifdef DEB
513 if (TRC) cout<<"reclSE E"<<EIX<<" -> reste "<<LOI.Extent()<<" + reduit "<<RLOI.Extent()<<endl<<endl;
514#endif
515} // FUN_reclSE
516
517//------------------------------------------------------
518static void FUN_unkeepEVIonGb1(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,TopOpeBRepDS_ListOfInterference& LI)
519//------------------------------------------------------
520// LI = {I attached to <E> = (T,G,S)}, unkeep I = EVI with G = vertex of <E>
521{
522
523#ifdef DEB
524 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
525 TRC = Standard_False; //MOINSTRACE
526 if (TRC) {cout<<endl;debreducerE(EIX);}
527#endif
528
529 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
530
531 TopOpeBRepDS_ListIteratorOfListOfInterference it(LI);
532 while (it.More()) {
533 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
534 Standard_Boolean evi = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
535 if (!evi) {it.Next(); continue;}
536 TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
537 if (GT != TopOpeBRepDS_VERTEX){it.Next(); continue;}
538
539 const TopoDS_Vertex& V = TopoDS::Vertex(BDS.Shape(G));
540 Standard_Integer o = FUN_tool_orientVinE(V,E);
541 if (o == 0){it.Next(); continue;}
542#ifdef DEB
543 if (TRC) {cout<<"-> rejet EVI on Gb 1 on "<<EIX<<" : ";I->Dump(cout);cout<<endl;}
544#endif
545 LI.Remove(it);
546 }
547}
548
549// ---------------------------------------------------------
550//unreferenced function, commented
551/*#ifdef DEB
552static void FUN_reorder(const Standard_Integer EIX, const Handle(TopOpeBRepDS_HDataStructure)& HDS,TopOpeBRepDS_ListOfInterference& LIR, TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LIend)
553// ---------------------------------------------------------
554// at same G :in <LI> I =(T, G, S)
555// in <LRI> Ir =(Tr,G,Sr)
556// I gives less information than reduced Ir
557{
558
559 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
560 TRC = Standard_False; //MOINSTRACE
561 if (TRC) cout<<endl<<"FUN_reorder :"<<endl;
562 TopOpeBRepDS_Dumper DSD(HDS);
563
564 LIend.Clear();
565
566 TopOpeBRepDS_TKI tki;
567 tki.FillOnGeometry(LI);
568
569 TopOpeBRepDS_TKI tkiR;
570 tkiR.FillOnGeometry(LIR);
571
572 for (tkiR.Init(); tkiR.More(); tkiR.Next()) {
573 TopOpeBRepDS_Kind K; Standard_Integer G; tkiR.Value(K,G);
574
575 tki.Init();
576 Standard_Boolean isbound = tki.IsBound(K,G);
577 if (!isbound) continue;
578
579 TopOpeBRepDS_ListOfInterference& loiR = tkiR.ChangeValue(K,G);
580 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
581#ifdef DEB
582 if (TRC) {TCollection_AsciiString bb("lIreduced");bb += TCollection_AsciiString(G);DSD.DumpLOI(loiR,cout,bb);
583 TCollection_AsciiString aa("lI");aa+=TCollection_AsciiString(G);DSD.DumpLOI(loi,cout,aa);}
584#endif
585 loiR.Append(loi);
586 }
587
588#ifdef DEB
589 if (TRC) cout<<"-> ordered :"<<endl;
590#endif
591 for (tkiR.Init(); tkiR.More(); tkiR.Next()) {
592 TopOpeBRepDS_Kind K; Standard_Integer G; TopOpeBRepDS_ListOfInterference& loi = tkiR.ChangeValue(K,G);
593#ifdef DEB
594 if (TRC) {TCollection_AsciiString aa("lI");aa+=TCollection_AsciiString(G);DSD.DumpLOI(loi,cout,aa);}
595#endif
596 LIend.Append(loi);
597 }
598
599#ifdef DEB
600 if (TRC) cout<<"-> residual :"<<endl;
601#endif
602 for (tki.Init(); tki.More(); tki.Next()) {
603 TopOpeBRepDS_Kind K; Standard_Integer G; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
604#ifdef DEB
605 if (TRC) {TCollection_AsciiString aa("lI");aa+=TCollection_AsciiString(G);DSD.DumpLOI(loi,cout,aa);}
606#endif
607 LIend.Append(loi);
608 }
609}
610#endif
611*/
612
613static void FUN_keepl3dF(const Standard_Integer
614#ifdef DEB
615 SIX
616#endif
617 ,const Handle(TopOpeBRepDS_HDataStructure)&
618#ifdef DEB
619 HDS
620#endif
621 ,const TopOpeBRepDS_ListOfInterference& l3dF
622 ,const TopOpeBRepDS_ListOfInterference& LR3dFE,
623 TopOpeBRepDS_ListOfInterference& l3dFkeep)
624//purpose : soit I de l3dF, on cherche IR interf dans LR3dFE de meme geometrie
625// si on n'en trouve pas, l3dFkeep += I
626{
627#ifdef DEB
628 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
629 TRC = Standard_False; //MOINSTRACE
630 if (TRC) cout<<endl<<"keepl3dF E"<<SIX<<endl;
631 TopOpeBRepDS_Dumper DSD(HDS);
632#endif
633
634 TopOpeBRepDS_TKI tki;
635 tki.FillOnGeometry(l3dF);
636
637 TopOpeBRepDS_TKI tkiR;
638 tkiR.FillOnGeometry(LR3dFE);
639
640 for (tki.Init(); tki.More(); tki.Next()) {
641 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
642 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
643 tkiR.Init();
644 Standard_Boolean isbound = tkiR.IsBound(K,G);
645 if (!isbound) {l3dFkeep.Append(loi);}
646
647#ifdef DEB
648 if (TRC) {TCollection_AsciiString bb("l3dFkeep");bb += TCollection_AsciiString(G);DSD.DumpLOI(loi,cout,bb);cout<<endl;}
649#endif
650 }
651} // FUN_keepl3dF
652
653static void FUN_reducepure2dI0(TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& RLI)
654// xpu210798 : CTS21216 (e7,G=P3,S=E9,FTRASHA=f8,f10)
655// LI attached to section edge
656// 2dI1=(REVERSED(ftrasha1),G,ES), 2dI2=(FORWARD(ftrasha2),G,ES)
657// for the compute of splitON(EIX), reduce 2dI1+2dI2 -> 2dR=(IN(ftrasha1,ftrasha2)
658// LI-> RLI + LI
659{
660 const Handle(TopOpeBRepDS_Interference)& I1 = LI.First();
661 TopAbs_Orientation O1 = I1->Transition().Orientation(TopAbs_IN);
662 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
663 FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
664
665 const Handle(TopOpeBRepDS_Interference)& I2 = LI.Last();
666 TopAbs_Orientation O2 = I2->Transition().Orientation(TopAbs_IN);
667 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2;
668 FDS_Idata(I2,tsb2,isb2,tsa2,isa2,GT2,G2,ST2,S2);
669
670 if (isb1 == isb2) return; //xpu170898 FOR+REV ->INT/EXT (cto009B1(es6,p1,f9))
671
672 // recall : G1==G2 && ST1==ST2==EDGE
673 Standard_Boolean ok = (G1==G2);
674 ok = ok && (tsb1 == TopAbs_FACE) && (tsb1==tsb2) && (isb1==isa1) && (isb2==isa2);
675 if (!ok) return;
676
677 Standard_Boolean int12 = M_REVERSED(O1) && M_FORWARD(O2);
678 Standard_Boolean int21 = M_REVERSED(O2) && M_FORWARD(O1);
679 ok = int12 || int21;
680 if (!ok) return;
681
682 TopOpeBRepDS_Transition newT(TopAbs_INTERNAL);
683 Standard_Integer bef = int12? isb1 : isb2;
684 Standard_Integer aft = int21? isb1 : isb2;
685 newT.IndexBefore(bef); newT.IndexAfter(aft);
686 I1->ChangeTransition() = newT;
687 RLI.Append(I1);
688 LI.Clear();
689} // FUN_reducepure2dI0
690
691static void FUN_reducepure2dI(TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& RLI)
692{
693 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
694 TopOpeBRepDS_ListOfInterference newLI;
695 for (tki.Init(); tki.More(); tki.Next()) {
696 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
697 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
698 Standard_Integer nloi = loi.Extent();
699 Standard_Boolean ok = (nloi == 2) && (K == TopOpeBRepDS_POINT);
700 if (ok) ::FUN_reducepure2dI0(loi,Rloi);
701 RLI.Append(Rloi);
702 newLI.Append(loi);
703 }
704 LI.Clear(); LI.Append(newLI);
705} // FUN_reducepure2dI
706
707//=======================================================================
708//function : TopOpeBRepDS_EIR
709//purpose :
710//=======================================================================
711TopOpeBRepDS_EIR::TopOpeBRepDS_EIR
712(const Handle(TopOpeBRepDS_HDataStructure)& HDS) : myHDS(HDS)
713{}
714
715//=======================================================================
716//function : ProcessEdgeInterferences
717//purpose :
718//=======================================================================
719void TopOpeBRepDS_EIR::ProcessEdgeInterferences()
720{
721 TopOpeBRepDS_DataStructure& BDS = myHDS->ChangeDS();
722 Standard_Integer i,nshape = BDS.NbShapes();
723 for (i = 1; i <= nshape; i++) {
724 const TopoDS_Shape& S = BDS.Shape(i);
725 if(S.IsNull()) continue;
726 if ( S.ShapeType() == TopAbs_EDGE ) {
727 ProcessEdgeInterferences(i);
728 }
729 }
730}
731static void FUN_ProcessEdgeInterferences(const Standard_Integer EIX
732 , const TopOpeBRepDS_Kind
733#ifdef DEB
734 K
735#endif
736 ,const Standard_Integer
737#ifdef DEB
738 G
739#endif
740 , const Handle(TopOpeBRepDS_HDataStructure)& HDS,
741 TopOpeBRepDS_ListOfInterference& LI)
742{
743 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
744 const TopoDS_Shape& E = BDS.Shape(EIX);
745#ifdef DEB
746 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
747 if (TRC) {
748 cout<<endl;debreducerE(EIX);cout<<"EIR E"<<EIX;
749 if(K==TopOpeBRepDS_POINT)cout<<",point";
750 else cout<<",vertex";
751 cout<<G<<endl;
752 }
753#endif
754
755 Standard_Integer nF = 0, nE = 0, nFE = 0;
756
757 // LI -> (lF + lFE) + lE + [LI]
758 // lF = {interference on edge <EIX> : (T(face),G=POINT/VERTEX,S)
759 // lFE = {interference on edge <EIX> : (T(face),G=POINT/VERTEX,S=EDGE)
760 // lE = {interference on edge <EIX> : (T(edge),G=POINT/VERTEX,S)
761 TopOpeBRepDS_ListOfInterference lF; nF = FUN_selectTRASHAinterference(LI,TopAbs_FACE,lF);
762 TopOpeBRepDS_ListOfInterference lFE; nFE = FUN_selectSKinterference(lF,TopOpeBRepDS_EDGE,lFE);
763 TopOpeBRepDS_ListOfInterference lE; nE = FUN_selectTRASHAinterference(LI,TopAbs_EDGE,lE);
764
765#ifdef DEB
766 TopOpeBRepDS_Dumper DSD(HDS);
767 Standard_Boolean trcl = TRC;
768// trcl = Standard_False; // MOINSTRACE
769#endif
770
771 // xpu210798 : CTS21216 (e7,G=P3,S=E9,FTRASHA=f8,f10)
772 // EIX is section edge
773 // 2dI1=(REVERSED(ftrasha1),G,ES), 2dI2=(FORWARD(ftrasha2),G,ES)
774 // for the compute of splitON(EIX), reduce 2dI1+2dI2 -> 2dR=(IN(ftrasha1,ftrasha2)
775 Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(E));
776 if (isse) {
777 TopOpeBRepDS_ListOfInterference lI2dFE,lRI2dFE;
778 // lF -> lF
779 // lFE -> lI2dFE + [lFE] / lI2dFE={FEI=(T(FTRASHA),G,SE) : no FFI=(T(FTRASHA),G,FTRASHA)}
780 FUN_selectpure2dI(lF,lFE,lI2dFE);
781#ifdef DEB
782 if (trcl) {
783 cout<<endl<<"lI2dFE -> lRI2dFE + lI2dFE"<<endl;
784 TCollection_AsciiString aa("lI2dFE :"); DSD.DumpLOI(lI2dFE,cout,aa);
785 }
786#endif
787 ::FUN_reducepure2dI(lI2dFE,lRI2dFE); // lI2dFE -> lRI2dFE + lI2dFE
788#ifdef DEB
789 if (trcl) { TCollection_AsciiString bb("lRI2dFE :"); DSD.DumpLOI(lRI2dFE,cout,bb);}
790#endif
791 lFE.Append(lI2dFE); lFE.Append(lRI2dFE);
792 }
793
794 // I -> 3dI +2dI + 1dI:
795 // -------------------
796 // lFE -> l3dFE [+l3dFEresi] +l2dFE [+lFE (+lFEresi)]
797 // : l3dFE={I3d } to reduce; for I3dFE=(T(F),G,SE) there is I3dF=(T(F),G,F)
798 // l2dFE={I2d} to reduce
799 // lFEresi to remove
800 // lF -> l3dF [+lF] : l3dF to remove
801
802 // lE -> l1dE +l1dEsd [+lE}
803 // : l1dE={I1d=(T(ETRA),G,ETRA)/same ETRA} to reduce
804 // l2dEsd={I1dsd=(T(ETRA),G,ETRA)/ E sdm ETRA}
805
806 TopOpeBRepDS_ListOfInterference lFEresi,l3dFE,l3dF,l3dFEresi,l2dFE;
807 FUN_select3dinterference(EIX,BDS,lF,l3dF,
808 lFE,lFEresi,l3dFE,l3dFEresi,
809 l2dFE);
810 TopOpeBRepDS_ListOfInterference l1dE; FUN_select2dI(EIX,BDS,TopAbs_EDGE,lE,l1dE);
811 TopOpeBRepDS_ListOfInterference l1dEsd; FUN_select1dI(EIX,BDS,lE,l1dEsd);
812
813#ifdef DEB
814 if (trcl) {
815 cout<<"lFE("<<EIX<<") -> l3dFE (S=EDGE) [+l3dFEresi] + l2dFE + [lFE +lFEresi]"<<endl;
816 TCollection_AsciiString oo("lFE :");DSD.DumpLOI(lFE,cout,oo);
817 TCollection_AsciiString pp("lFEresi :");DSD.DumpLOI(lFEresi,cout,pp);
818 TCollection_AsciiString bb("l3dFE :");DSD.DumpLOI(l3dFE,cout,bb);
819 TCollection_AsciiString bb1("l3dFEresi :");DSD.DumpLOI(l3dFEresi,cout,bb1);
820 TCollection_AsciiString ll("l2dFE :");DSD.DumpLOI(l2dFE,cout,ll);
821 cout<<"lF("<<EIX<<") -> l3dF (S=FACE) [+lF]"<<endl;
822 TCollection_AsciiString cc("lF :"); DSD.DumpLOI(lF,cout,cc);
823 TCollection_AsciiString aa("l3dF :"); DSD.DumpLOI(l3dF,cout,aa);
824 cout<<"lE("<<EIX<<") -> l1dE + lE"<<endl;
825 TCollection_AsciiString ee("lE :"); DSD.DumpLOI(lE,cout,ee);
826 TCollection_AsciiString ff("l1dE :"); DSD.DumpLOI(l1dE,cout,ff);
827 TCollection_AsciiString gg("l1dEsd :"); DSD.DumpLOI(l1dEsd,cout,gg);}
828#endif
829
830 // reducer3d :
831 // ----------
832 // l3dFE -> lR3dFE [+l3dFE (non reduced 3dI)]
833 TopOpeBRepDS_ListOfInterference lR3dFE; FUN_ReducerEdge3d(EIX,BDS,l3dFE,lR3dFE);
834#ifdef DEB
835 if (trcl) { cout<<"l3dFE("<<EIX<<") -> lR3dFE + l3dFE"<<endl;
836 TCollection_AsciiString aa("lR3dFE :");DSD.DumpLOI(lR3dFE,cout,aa);
837 TCollection_AsciiString bb("l3dFE :"); DSD.DumpLOI(l3dFE,cout,bb);}
838#endif
839
840// FUN_unkeepEVIonGb1(BDS,EIX,l1dE); // filter :
841// FUN_unkeepEVIonGb1(BDS,EIX,l2dFE); // filter :
842
843 // no reduction on G : we keep l3dF(G)
844 TopOpeBRepDS_ListOfInterference l3dFkeep; FUN_keepl3dF(EIX,HDS,l3dF,lR3dFE,l3dFkeep);
845 lF.Append(l3dFkeep);
846
847 // reducer2d :
848 // ----------
849 // l2dFE -> LR2dFE + l2dFE (non reduced 2dI)
850 TopOpeBRepDS_ListOfInterference LR2dFE; FUN_ReducerEdge(EIX,BDS,l2dFE,LR2dFE);
851
852 // reducer1d :
853 // ----------
854 // xpu210498 : reduce interferences I1(T1(esd1),VG,esd1), I2(T2(esd2),VG,esd2)
855 // if EIX sdm {esd1,esd2}
856 // - t2_2 e32 has I1(in/ou(e32),v30,e20) && I2(ou/in(e20),v30,e20) -
857 TopOpeBRepDS_ListOfInterference lR1dEsd; FUN_ReducerSDEdge(EIX,BDS,l1dEsd,lR1dEsd);
858
859 // xpu190298 : edge <EIX> same domain with closed support edge <SE>
860 // at same G = vertex <VG> = closing vertex of <SE>
861 // (I1 = (OU/IN(SE),VG,SE) && I2 = (IN/OU(SE),VG,SE)) -> Ir = (IN/IN(SE),VG,SE)
862 TopOpeBRepDS_ListOfInterference lR1dclosedSE; FUN_reclSE(EIX,BDS,l1dE,lR1dclosedSE);
863
864 // l1dE -> LR1dE + l1dE (non reduced 2dI)
865 TopOpeBRepDS_ListOfInterference LR1dE; FUN_ReducerEdge(EIX,BDS,l1dE,LR1dE);
866
867 // attached to edge <EIX>,
868 // at same G : I =(T, G,S) gives less information than
869 // Ir =(Tr,G,Sr) -reduced interference- with valid Tr
870 // -> unkeep I.
871 // using reduced I : lR3dFE, LR2dFE, LR1dE
872 TopOpeBRepDS_ListOfInterference LRI;
873 LRI.Append(lR1dEsd); LRI.Append(LR1dE); LRI.Append(lR1dclosedSE);
874 LRI.Append(LR2dFE);
875 LRI.Append(lR3dFE);
876
877 lF.Append(lFE); lF.Append(l3dFE); lF.Append(l2dFE);// lF += LFE + l3dFE + l2dFE
878 lE.Append(l1dE); // lE += l1dE
879 lE.Append(l1dEsd); // lE += l1dEsd xpu210498
880// TopOpeBRepDS_ListOfInterference LItmp; LItmp.Append(lF); LItmp.Append(lE);
881
882 // xpu : 23-01-98 : attached to edge <EIX>,
883 // at same G : I =(T, G, S) gives less information than
884 // Ir =(Tr,G,Sr) -reduced interference-
885 // -> I is added after Ir to help the edge builder.
886 LI.Clear();
887 LI.Append(LRI);LI.Append(lE);LI.Append(lF);
888// FUN_reorder(EIX,HDS,LRI, LItmp, LI);
889
890 // xpu260698 : cto902A5, spOU(e6)
891 // cto801G1, spON(se26)
892 if (isse) {
893 FUN_unkeepEVIonGb1(BDS,EIX,LI); // filter :
894 }
895//FUN_unkeepEVIonGb1(BDS,EIX,LI); // filter :
896
897#ifdef DEB
898 if (TRC){TCollection_AsciiString aa("reduced->");DSD.DumpLOI(LI,cout,aa);}
899#endif
900} // ProcessEdgeInterferences
901
902//=======================================================================
903//function : ProcessEdgeInterferences
904//purpose :
905//=======================================================================
906void TopOpeBRepDS_EIR::ProcessEdgeInterferences(const Standard_Integer EIX)
907{
908 TopOpeBRepDS_DataStructure& BDS = myHDS->ChangeDS();
909
910#ifdef DEB
911 TopOpeBRepDS_Dumper DSD(myHDS);
912 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
913 if (TRC) {cout<<endl;debreducerE(EIX);}
914#endif
915
916 // E is the edge, LI is list of interferences to compact
917 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
918 Standard_Boolean isdg = BRep_Tool::Degenerated(E);
919 if (isdg) return;
920
921 TopOpeBRepDS_ListOfInterference& LI = BDS.ChangeShapeInterferences(EIX);
922 TopOpeBRepDS_TKI newtki; newtki.FillOnGeometry(LI);
923 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
924 for (tki.Init(); tki.More(); tki.Next()) {
925 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
926 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
927 if (K==TopOpeBRepDS_POINT) continue;
928 const TopoDS_Shape& vG = BDS.Shape(G);
929 TopoDS_Shape oovG; Standard_Boolean sdm = FUN_ds_getoov(vG,BDS,oovG);
930 if (!sdm) continue;
931 Standard_Integer OOG=BDS.Shape(oovG);
932 if (OOG == 0) continue;//NYIRaise
933
934 Standard_Boolean isb = newtki.IsBound(K,OOG);
935
936 // xpu201098 : cto904F6, e10,v6
937 Standard_Boolean isbound = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(loi.First())->GBound();
938 if (isbound) { // replacing vG with oovG
939 TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); TopOpeBRepDS_ListOfInterference newloi;
940 for (; it.More(); it.Next()){
941 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
942 TopOpeBRepDS_Kind GT,ST;
943 Standard_Integer G1,S;
944 FDS_data(I,GT,G1,ST,S);
945 Standard_Real par = FDS_Parameter(I);
946 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(I->Transition(),S,OOG,par,K,ST,Standard_False);
947 newloi.Append(newI);
948#ifdef DEB
949 if (TRC) {cout<<"on e"<<EIX;I->Dump(cout);cout<<"gives ";newI->Dump(cout);cout<<endl;}
950#endif
951 }
952 newtki.ChangeInterferences(K,G).Clear();
953 if (!isb) newtki.Add(K,OOG);
954 newtki.ChangeInterferences(K,OOG).Append(newloi);
955 continue;
956 }
957
958 if (!isb) continue;
959 TopOpeBRepDS_ListOfInterference& li = newtki.ChangeInterferences(K,OOG);
960 newtki.ChangeInterferences(K,G).Append(li);
961 } // tki
962
963 TopOpeBRepDS_ListOfInterference LInew;
964 for (newtki.Init(); newtki.More(); newtki.Next()) {
965 TopOpeBRepDS_Kind K; Standard_Integer G; newtki.Value(K,G);
966 TopOpeBRepDS_ListOfInterference& loi = newtki.ChangeValue(K,G);
967 ::FUN_ProcessEdgeInterferences(EIX,K,G,myHDS,loi);
968 LInew.Append(loi);
969 }
970 LI.Clear();
971 LI.Append(LInew);
972
973 Standard_Boolean performPNC = Standard_False; // JYL 28/09/98 : temporaire
974#ifdef DEB
975 if (TopOpeBRepDS_GetcontextNOPNC()) performPNC = Standard_False;
976 if (TRC) debredpnc(EIX);
977#endif
978 if (!performPNC) return;
979
980 // suppression des I/G(I) n'est accede par aucune courbe
981 // portee par une des faces cnx a EIX.
982 Standard_Boolean isfafa = BDS.Isfafa();
983 if (!isfafa) {
984
985 tki.Clear();
986 tki.FillOnGeometry(LI);
987 LI.Clear();
988
989 for (tki.Init(); tki.More(); tki.Next()) {
990 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
991 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
992 Standard_Integer nloi = loi.Extent();
993 if (K != TopOpeBRepDS_POINT) {
994 LI.Append(loi);
995 continue;
996 }
997
998 const TopTools_ListOfShape& lfx = FDSCNX_EdgeConnexitySameShape(E,myHDS);
999#ifdef DEB
1000// Standard_Integer nlfx = lfx.Extent();
1001#endif
1002
1003 // nlfx < 2 => 0 ou 1 face accede E => pas d'autre fcx pouvant generer une courbe 3d
1004 TopTools_ListIteratorOfListOfShape itlfx(lfx);
1005 Standard_Boolean curvefound = Standard_False;
1006 for (; itlfx.More();itlfx.Next()) {
1007 const TopoDS_Face& fx = TopoDS::Face(itlfx.Value());
1008// BDS.Shape(fx);
1009 const TopOpeBRepDS_ListOfInterference& lifx = BDS.ShapeInterferences(fx); TopOpeBRepDS_ListIteratorOfListOfInterference itlifx(lifx);
1010 if (!itlifx.More()) continue;
1011
1012 Handle(TopOpeBRepDS_Interference) I1;TopOpeBRepDS_Kind GT1;Standard_Integer G1;TopOpeBRepDS_Kind ST1;Standard_Integer S1;
1013 for (; itlifx.More(); itlifx.Next()) {
1014 FDS_data(itlifx,I1,GT1,G1,ST1,S1);
1015 Standard_Boolean isfci = (GT1 == TopOpeBRepDS_CURVE);
1016 if (!isfci) continue;
1017
1018 TopOpeBRepDS_ListOfInterference& lic = BDS.ChangeCurveInterferences(G1);
1019 TopOpeBRepDS_ListIteratorOfListOfInterference itlic(lic);
1020 if (!itlic.More()) continue;
1021
1022 Handle(TopOpeBRepDS_Interference) I2;TopOpeBRepDS_Kind GT2;Standard_Integer G2;TopOpeBRepDS_Kind ST2;Standard_Integer S2;
1023 for (; itlic.More(); itlic.Next()) {
1024 FDS_data(itlic,I2,GT2,G2,ST2,S2);
1025 Standard_Boolean isp = (GT2 == TopOpeBRepDS_POINT);
1026 if (!isp) continue;
1027 if ( G2 != G ) continue;
1028 curvefound = Standard_True;
1029 break;
1030 } // itlic.More()
1031
1032 if (curvefound) break;
1033 } // itlifx.More()
1034
1035 if (curvefound) break;
1036 } // itlfx.More()
1037
1038 nloi = loi.Extent();
1039#ifdef DEB
1040// Standard_Integer nLI = LI.Extent();
1041#endif
1042 if (curvefound) {
1043 LI.Append(loi);
1044 }
1045 else {
1046#ifdef DEB
1047// if (TRC) {
1048// debredpnc(EIX);
1049 TCollection_AsciiString ss = "\n--- TopOpeBRepDS_EIR::ProcessEdgeInterferences : suppress pnc of E"; ss = ss + EIX;
1050 DSD.DumpLOI(loi,cout,ss);
1051// }
1052#endif
1053 }
1054
1055 } // tki.More()
1056 } // (!isfafa)
1057
1058} // ProcessEdgeInterferences
1059
1060// modified by NIZHNY-MKK Mon Apr 2 15:34:56 2001.BEGIN
1061static Standard_Boolean CheckInterferenceIsValid(const Handle(TopOpeBRepDS_Interference)& I,
1062 const TopoDS_Edge& theEdge,
1063 const TopoDS_Edge& theSupportEdge,
1064 const TopoDS_Vertex& theVertex) {
1065 Standard_Real pref = 0. ;
1066 Standard_Boolean ok = Standard_False;
1067 BRepAdaptor_Curve BC(theEdge);
1068
1069 Handle(TopOpeBRepDS_CurvePointInterference) CPI;
1070 CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I);
1071
1072 if(!CPI.IsNull()) {
1073 pref = CPI->Parameter();
1074 ok = Standard_True;
1075 }
1076
1077 if(!ok) {
1078 Handle(TopOpeBRepDS_EdgeVertexInterference) EVI = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I);
1079 if(!EVI.IsNull()) {
1080 pref = EVI->Parameter();
1081 ok = Standard_True;
1082 }
1083 }
1084
1085 if(!ok)
1086 return ok;
1087
1088 gp_Pnt P3d1 = BC.Value(pref);
1089 Standard_Real dist, paronSupportE;
1090 ok = FUN_tool_projPonE(P3d1,theSupportEdge,paronSupportE,dist);
1091
1092 if(!ok)
1093 return ok;
1094 BRepAdaptor_Curve BCtmp(theSupportEdge);
1095 gp_Pnt P3d2 = BCtmp.Value(paronSupportE);
1096 Standard_Real Tolerance = (BRep_Tool::Tolerance(theEdge) > BRep_Tool::Tolerance(theSupportEdge)) ? BRep_Tool::Tolerance(theEdge) : BRep_Tool::Tolerance(theSupportEdge);
1097 if(!theVertex.IsNull()) {
1098 Tolerance = (BRep_Tool::Tolerance(theVertex) > Tolerance) ? BRep_Tool::Tolerance(theVertex) : Tolerance;
1099 }
1100 if(P3d1.Distance(P3d2) > Tolerance) {
1101 ok = Standard_False;
1102 }
1103
1104 return ok;
1105}