0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_repvg.cxx
CommitLineData
b311480e 1// Created on: 1998-02-14
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <TopOpeBRepDS_repvg.hxx>
18#include <TopoDS.hxx>
19#include <BRep_Tool.hxx>
20#include <TopExp.hxx>
21
22#include <TopOpeBRepTool_EXPORT.hxx>
23#include <TopOpeBRepTool_SC.hxx>
24#include <TopOpeBRepTool_makeTransition.hxx>
25
26#include <TopOpeBRepDS_EdgeInterferenceTool.hxx>
27#include <TopOpeBRepDS_EdgeVertexInterference.hxx>
28#include <TopOpeBRepDS_Interference.hxx>
29#include <TopOpeBRepDS_TKI.hxx>
30#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
31#include <TopOpeBRepDS_EXPORT.hxx>
32#include <TopOpeBRepDS_define.hxx>
33#include <Precision.hxx>
34
35#include <TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx>
36#include <TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference.hxx>
37#define MDSdmoiloi TopOpeBRepDS_DataMapOfIntegerListOfInterference
38#define MDSdmiodmoiloi TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference
39
7fd59977 40//------------------------------------------------------
41Standard_EXPORT void FDS_repvg2
42(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,const TopOpeBRepDS_Kind GT,TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& RLI)
43//------------------------------------------------------
44{
7fd59977 45 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
46 Standard_Boolean isEd = BRep_Tool::Degenerated(E);
47 if (isEd) return;
48
7fd59977 49 Standard_Boolean ispoint = (GT == TopOpeBRepDS_POINT);
50 Standard_Boolean isvertex = (GT == TopOpeBRepDS_VERTEX);
51
dde68833 52 Standard_Integer nLI = LI.Extent();
7fd59977 53
54 TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);
55 while (it1.More()) {
56 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
57 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
58 FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
59 if (tsb1 != TopAbs_FACE) {it1.Next(); continue;}
60 if (tsa1 != TopAbs_FACE) {it1.Next(); continue;}
61 if (GT1 != GT) {it1.Next(); continue;}
62
63 // xpu121198 : raise in PRO16303, if G1 is a vertex same domain, make sure
64 // rk(G1)= rk(E1)
65 Standard_Integer rkG1 = BDS.AncestorRank(G1);
66 Standard_Integer rkS1 = BDS.AncestorRank(S1);
67 if (isvertex && (rkG1 != rkS1)) {
68 TopoDS_Shape oovG; Standard_Boolean issd = FUN_ds_getoov(BDS.Shape(G1),BDS,oovG);
69 if (!issd) {it1.Next(); continue;} //!!NYIRAISE
70 G1 = BDS.Shape(oovG);
71 }
72
73 const TopoDS_Edge& E1 = TopoDS::Edge(BDS.Shape(S1));
74 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(isb1));
75 TopOpeBRepDS_Point PDS; TopoDS_Shape VDS;
76 if (ispoint) PDS = BDS.Point(G1);
77 else if (isvertex) VDS = BDS.Shape(G1);
9775fa61 78 else throw Standard_Failure("TopOpeBRepDS FDS_repvg2 1");
7fd59977 79
80 Standard_Boolean isEd1 = BRep_Tool::Degenerated(E1); if (isEd1) {it1.Next(); continue;}
81 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); if (it2.More()) it2.Next(); else {it1.Next(); continue; }
82
83 TopOpeBRepDS_EdgeInterferenceTool EITool;
84 Standard_Boolean memeS = Standard_False; TopOpeBRepDS_Transition TrmemeS; Standard_Boolean isComplex = Standard_False;
85
86 while ( it2.More() ) {
87 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
88 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2;
89 FDS_Idata(I2,tsb2,isb2,tsa2,isa2,GT2,G2,ST2,S2);
90 if (tsb2 != TopAbs_FACE) {it2.Next(); continue;}
91 if (tsa2 != TopAbs_FACE) {it2.Next(); continue;}
92
93 Standard_Boolean cond = (G1 == G2); if (!cond) { it2.Next(); continue; }
94
7fd59977 95 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2));
96 Standard_Boolean isEd2 = BRep_Tool::Degenerated(E2);
97 if (isEd2) {it2.Next(); continue;}
98
99 memeS = (S1 == S2);
100 memeS = memeS && (nLI == 2);
101
102 if (!isComplex && memeS) {
536a3cb8 103 Standard_Real pE = FDS_Parameter(I1);
104 Standard_Boolean ok = FDS_stateEwithF2d(BDS,E,pE,GT1,G1,F1,TrmemeS); if (!ok) {it2.Next();continue;}
7fd59977 105
7fd59977 106 LI.Remove(it2);
107 } // !isComplex && memeS
108
109 if (!isComplex && !memeS) {
110 isComplex = Standard_True;
111 EITool.Init(E,I1);
112 if (ispoint) EITool.Add(E,PDS,I1);
113 else if (isvertex) EITool.Add(E1,VDS,I1);
7fd59977 114 } // !isComplex && !memeS
115
116 if (isComplex && !memeS) {
7fd59977 117 if (ispoint) EITool.Add(E,PDS,I2);
118 else if (isvertex) EITool.Add(E2,VDS,I2);
119 LI.Remove(it2);
7fd59977 120 } // (isComplex && !memeS)
121
122 if (isComplex && memeS) {
123 it2.Next();
7fd59977 124 } // (isComplex && memeS)
125
126 } // it2
127
128 if (!isComplex && memeS) {
129 const TopOpeBRepDS_Transition& T1 = I1->Transition();
130 TrmemeS.Index(T1.Index()); I1->ChangeTransition() = TrmemeS;
131 RLI.Append(I1); LI.Remove(it1);
132 }
133 else if (isComplex && !memeS) {
134 EITool.Transition(I1);
135 RLI.Append(I1); LI.Remove(it1);
136 }
137 else {
138 it1.Next();
139 }
140
141 } // it1
142
7fd59977 143} // FDS_repvg2
144
145//------------------------------------------------------
146Standard_EXPORT void FDS_repvg
147(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,const TopOpeBRepDS_Kind GT,TopOpeBRepDS_ListOfInterference& LOI,TopOpeBRepDS_ListOfInterference& RLOI)
148//------------------------------------------------------
149{
150 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
7fd59977 151
152 // xpu211098 : cto904F6 (e10,FTRA1=f14,FTRA2=f17)
153 MDSdmoiloi mapITRASHA;
154 TopOpeBRepDS_ListIteratorOfListOfInterference it(LOI);
155 while (it.More()) {
156 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
157 Standard_Integer isa = I->Transition().Index();
158 Standard_Boolean bound = mapITRASHA.IsBound(isa);
159 if (!bound) {
160 TopOpeBRepDS_ListOfInterference loi; loi.Append(I);
161 mapITRASHA.Bind(isa,loi);
162 }
163 else mapITRASHA.ChangeFind(isa).Append(I);
164 it.Next();
165 }
166
167 LOI.Clear();
168 MDSdmiodmoiloi itm(mapITRASHA);
169 for (; itm.More(); itm.Next()){
170 Standard_Integer isa = itm.Key();
171 TopOpeBRepDS_ListOfInterference& loi = mapITRASHA.ChangeFind(isa);
172 Standard_Integer nloi = loi.Extent();
173 if (nloi < 2) continue;
174 TopOpeBRepDS_ListOfInterference rloi; FDS_repvg2(BDS,EIX,GT,loi,rloi);
175 LOI.Append(loi); RLOI.Append(rloi);
176 }
177
178 /*LOI.Clear();
179 for (tki.Init(); tki.More(); tki.Next()) {
180 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
7fd59977 181 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
182 Standard_Integer nloi = loi.Extent();
183 if (nloi == 0) continue;
184 else if (nloi == 1) LOI.Append(loi);
185 else {
186 FDS_repvg2(BDS,EIX,GT,loi,Rloi);
187 LOI.Append(loi); RLOI.Append(Rloi);
188 }
189 }*/
7fd59977 190}
191