0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / TopOpeBRep / TopOpeBRep_vprclo.cxx
CommitLineData
7fd59977 1// File: TopOpeBRep_FacesFiller_VPonR.cxx
2// Created: Fri Aug 4 10:57:30 1995
3// Author: Jean Yves LEBEY
4// <jyl@meteox>
5
6#include <TopOpeBRep_FacesFiller.ixx>
7
8#include <TopOpeBRepTool_ShapeTool.hxx>
9#include <TopOpeBRepTool_EXPORT.hxx>
10#include <TopOpeBRepTool_makeTransition.hxx>
11
12#include <TopOpeBRepDS_PointIterator.hxx>
13#include <TopOpeBRepDS_define.hxx>
14#include <TopOpeBRepDS_repvg.hxx> // LOIinfsup
15#include <TopOpeBRepDS_EXPORT.hxx>
16
17#include <TopOpeBRep_define.hxx>
18
19#include <Precision.hxx>
20#include <TopoDS.hxx>
21#include <TopExp.hxx>
22#include <BRep_Tool.hxx>
23#include <BRepAdaptor_Curve.hxx>
24#include <gp_Vec.hxx>
25
26
27#define M_ON(st) (st == TopAbs_ON)
28#define M_REVERSED(st) (st == TopAbs_REVERSED)
29
30#ifdef DEB
31Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSF();
32Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer i1);
33Standard_EXPORT void debarc(const Standard_Integer i);
34Standard_EXPORT void debooarc(const Standard_Integer i);
35#endif
36
37Standard_EXPORT Handle(TopOpeBRepDS_Interference) MakeEPVInterference
38(const TopOpeBRepDS_Transition& T, // transition
39 const Standard_Integer S, // curve/edge index
40 const Standard_Integer G, // point/vertex index
41 const Standard_Real P, // parameter of G on S
42 const TopOpeBRepDS_Kind GK,
43 const Standard_Boolean B); // G is a vertex (or not) of the interference master
44Standard_EXPORT Handle(TopOpeBRepDS_Interference) MakeEPVInterference
45(const TopOpeBRepDS_Transition& T, // transition
46 const Standard_Integer S, // curve/edge index
47 const Standard_Integer G, // point/vertex index
48 const Standard_Real P, // parameter of G on S
49 const TopOpeBRepDS_Kind GK, // POINT/VERTEX
50 const TopOpeBRepDS_Kind SK,
51 const Standard_Boolean B); // G is a vertex (or not) of the interference master
52
53
54static Standard_Boolean FUN_INlos(const TopoDS_Shape& S, const TopTools_ListOfShape& loS)
55{
56 TopTools_ListIteratorOfListOfShape it(loS);
57 for (; it.More(); it.Next())
58 if (it.Value().IsSame(S)) return Standard_True;
59 return Standard_False;
60}
61
62//=======================================================================
63//function : GetEdgeTrans
64//purpose : Computes E<Sind> transition on <F> at point <VP>
65// Computes FORWARD or REVERSED transitions,
66// returns transition UNKNOWN elsewhere.
67//=======================================================================
68TopOpeBRepDS_Transition TopOpeBRep_FacesFiller::GetEdgeTrans(const TopOpeBRep_VPointInter& VP,const TopOpeBRepDS_Kind PVKind,
69 const Standard_Integer PVIndex,const Standard_Integer ShapeIndex,const TopoDS_Face& F)
70{
71 // VP is on couture <Ec> of rank <sind>
72 // on face <F> of rank <oosind>.
73 Standard_Integer OOShapeIndex = (ShapeIndex == 1) ? 2 : 1;
74 Standard_Integer vpsind = VP.ShapeIndex();
75 Standard_Boolean on2edges = (vpsind == 3);
76 Standard_Boolean isvalid = on2edges || (vpsind == ShapeIndex);
77 if (!isvalid) Standard_Failure::Raise("TopOpeBRep_FacesFiller::GetEdgeTrans");
78
79 const TopoDS_Edge& edge = TopoDS::Edge(VP.Edge(ShapeIndex));
80 Standard_Real paredge = VP.EdgeParameter(ShapeIndex);
81
82 TopoDS_Edge OOedge;
83#ifdef DEB
84 Standard_Real OOparedge;
85#else
86 Standard_Real OOparedge=0;
87#endif
88 Standard_Boolean hasONedge = (VP.State(OOShapeIndex) == TopAbs_ON);
89 Standard_Boolean hasOOedge = (on2edges) ? Standard_True : hasONedge;
90 if ( hasOOedge ) {
91 if (on2edges) OOparedge = VP.EdgeParameter(OOShapeIndex);
92 else OOparedge = VP.EdgeONParameter(OOShapeIndex);
93 TopoDS_Shape OOe;
94 if (on2edges) OOe = VP.Edge(OOShapeIndex);
95 else OOe = VP.EdgeON(OOShapeIndex);
96 OOedge = TopoDS::Edge(OOe);
97 }
98 gp_Pnt2d OOuv = VP.SurfaceParameters(OOShapeIndex);
99
100 Standard_Real par1,par2;
101 Standard_Integer SIedgeIndex = (myHDS->HasShape(edge)) ? myHDS->Shape(edge) : 0;
102// if (SIedgeIndex != 0) FDS_getupperlower(myHDS,SIedgeIndex,paredge,par1,par2);
103 if (SIedgeIndex != 0) {
104 Standard_Boolean isonboundper;
105 FDS_LOIinfsup(myHDS->DS(),edge,paredge,PVKind,PVIndex,
106 myHDS->DS().ShapeInterferences(edge),par1,par2,isonboundper);
107 }
108 else
109 FUN_tool_bounds(edge,par1,par2);
110
111 TopOpeBRepDS_Transition T;
112 // xpu : 16-01-98
113 // <Tr> relative to 3d <OOface> matter,
114 // we take into account <Tr> / 2d <OOface> only if <edge> is normal to <OOface>
115 Standard_Real tola = Precision::Angular()*1.e+2; //dealing with tolerances
116 Standard_Boolean EtgF = FUN_tool_EtgF(paredge,edge,OOuv,F,tola);
117 Standard_Boolean rest = FUN_INlos(edge,myERL);
118 Standard_Boolean isse = myHDS->DS().IsSectionEdge(edge);
119 rest = rest || isse;
120 Standard_Boolean interf2d = EtgF && hasOOedge && rest;
121
122 Standard_Real factor = 1.e-4;
123 TopOpeBRepTool_makeTransition MKT;
124 Standard_Boolean ok = MKT.Initialize(edge,par1,par2,paredge, F,OOuv, factor);
125 if (!ok) return T;
126 Standard_Boolean isT2d = MKT.IsT2d();
127 interf2d = interf2d && isT2d;
128 if (interf2d) ok = MKT.SetRest(OOedge,OOparedge);
129 if (!ok) return T;
130
131 TopAbs_State stb,sta; ok = MKT.MkTonE(stb,sta);
132 if (!ok) return T;
133 T.Before(stb); T.After(sta);
134 return T;
135}
136
137//=======================================================================
138//function : ProcessVPonclosingR
139//purpose : SUPPLYING INTPATCH when <VP> is on closing arc.
140//=======================================================================
141void TopOpeBRep_FacesFiller::ProcessVPonclosingR(const TopOpeBRep_VPointInter& VP,
142// const TopoDS_Shape& GFace,
143 const TopoDS_Shape& ,
144 const Standard_Integer ShapeIndex,
145 const TopOpeBRepDS_Transition& transEdge,const TopOpeBRepDS_Kind PVKind, const Standard_Integer PVIndex,
146// const Standard_Boolean EPIfound,
147 const Standard_Boolean ,
148// const Handle(TopOpeBRepDS_Interference)& IEPI)
149 const Handle(TopOpeBRepDS_Interference)& )
150{
151// Standard_Boolean isvertex = VP.IsVertex(ShapeIndex);
152 Standard_Boolean isvertex = (PVKind == TopOpeBRepDS_VERTEX);
153 Standard_Integer absindex = VP.ShapeIndex(); // 0,1,2,3
7fd59977 154 Standard_Boolean OOShapeIndex = (ShapeIndex == 1) ? 2 : 1;
155 Standard_Boolean on2edges = (absindex == 3);
156 Standard_Boolean hasONedge = (VP.State(OOShapeIndex) == TopAbs_ON);
157 Standard_Boolean hasOOedge = (on2edges) ? Standard_True : hasONedge;
158
159 TopoDS_Face Face = (*this).Face(ShapeIndex);
7fd59977 160 TopoDS_Face OOFace = (*this).Face(OOShapeIndex);
161 Standard_Integer iOOFace = myDS->Shape(OOFace);
162 if (iOOFace == 0) iOOFace = myDS->AddShape(OOFace,OOShapeIndex);
163
164 // current VPoint is on <edge>
165 Standard_Integer SIedgeIndex = 0;
166 const TopoDS_Edge& edge = TopoDS::Edge(VP.Edge(ShapeIndex));
167 if (myDS->HasShape(edge)) SIedgeIndex = myDS->Shape(edge);
168 else myDS->AddShape(edge,ShapeIndex);
6e6cd5d9 169
7fd59977 170 Standard_Real paredge = VP.EdgeParameter(ShapeIndex);
171
172 // dummy if !<hasOOedge>
173 Standard_Integer OOedgeIndex = 0;
174 Standard_Boolean OOclosing,OOisrest; OOclosing = OOisrest = Standard_False;
175 TopoDS_Edge OOedge;
176 if ( hasOOedge ) {
177 TopoDS_Shape OOe;
178 if (on2edges) OOe = VP.Edge(OOShapeIndex);
179 else OOe = VP.EdgeON(OOShapeIndex);
180 OOedge = TopoDS::Edge(OOe);
181 OOisrest = myDS->IsSectionEdge(OOedge);
182 OOclosing = TopOpeBRepTool_ShapeTool::Closed(OOedge,OOFace);
183 if (myDS->HasShape(OOedge)) OOedgeIndex = myDS->Shape(OOedge);
184 else OOedgeIndex = myDS->AddShape(OOedge,OOShapeIndex);
185 }
186
187#ifdef DEB
188 Standard_Boolean traceDSF = TopOpeBRepDS_GettraceDSF();
189 Standard_Boolean trce = TopOpeBRepDS_GettraceSPSX(SIedgeIndex); if(trce) debarc(SIedgeIndex);
190 Standard_Boolean trcooe = TopOpeBRepDS_GettraceSPSX(OOedgeIndex); if(trcooe) debooarc(OOedgeIndex);
191#endif
192
193 // ===================================================================
194 // --- Edge/(POINT,VERTEX) Interference (EPI) creation ---
195 // ===================================================================
196
197 // 1. <edge> enters or outers myF<OOShapeIndex> at <VP>,
198 // transition <transEdge> returned by IntPatch is valid (FORWARD/REVERSED).
199 // 2. <edge> is tangent to myF<OOShapeIndex> :
200 // transEdge should be INTERNAL/EXTERNAL.
201
202 Standard_Boolean Tunk = transEdge.IsUnknown();
203#ifdef DEB
204 if (!Tunk && traceDSF) cout<<"-> on closing : transAdd = "<<endl;
205#endif
206 TopOpeBRepDS_Transition transAdd;
207 Standard_Boolean newtransEdge = Tunk;
208 if (newtransEdge) transAdd = GetEdgeTrans(VP,PVKind,PVIndex,ShapeIndex,OOFace);
209 else transAdd = transEdge;
210
211 // !!! if the compute of <transAdd> fails, we add transEdge.
212 // hasOOedge : <VP> is ON edge <edge> and ON <OOFace>
213 // !hasOOedge : <VP> is ON edge <edge> and IN <OOFace>
214 {
215 TopOpeBRepDS_Transition T = transAdd; T.Index(iOOFace);
216 Handle(TopOpeBRepDS_Interference) EPI = ::MakeEPVInterference
217 (T,iOOFace,PVIndex,paredge,PVKind,TopOpeBRepDS_FACE,isvertex);
218 myHDS->StoreInterference(EPI,edge);
219 }
220 if (hasOOedge) {
221 TopOpeBRepDS_Transition T = transAdd; T.Index(iOOFace);
222 Handle(TopOpeBRepDS_Interference) EPI = ::MakeEPVInterference
223 (T,OOedgeIndex,PVIndex,paredge,PVKind,isvertex);
224 myHDS->StoreInterference(EPI,edge);
225 }
226
227} // ProcessVPonclosingR