0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / TopOpeBRep / TopOpeBRep_FaceEdgeFiller.cxx
CommitLineData
7fd59977 1// File: TopOpeBRep_FaceEdgeFiller.cxx
2// Created: Wed Jun 14 16:54:03 1995
3// Author: Jean Yves LEBEY
4// <jyl@meteox>
5
6#include <TopOpeBRep_FaceEdgeFiller.ixx>
7
8#include <TopOpeBRep_PointGeomTool.hxx>
9#include <TopOpeBRepDS_InterferenceTool.hxx>
10#include <TopOpeBRepDS_DataStructure.hxx>
11#include <TopOpeBRepDS_Point.hxx>
12#include <TopOpeBRepDS_CurvePointInterference.hxx>
13
14#include <TopoDS.hxx>
15#include <TopoDS_Face.hxx>
16#include <TopoDS_Edge.hxx>
17#include <gp_Pnt2d.hxx>
18
19#ifdef DEB
20Standard_IMPORT void FEINT_DUMPPOINTS(TopOpeBRep_FaceEdgeIntersector& FEINT,
21 const TopOpeBRepDS_DataStructure& BDS);
22Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceDSF();
23#endif
24
25//=======================================================================
26//function : TopOpeBRep_FaceEdgeFiller
27//purpose :
28//=======================================================================
29
30TopOpeBRep_FaceEdgeFiller::TopOpeBRep_FaceEdgeFiller()
31{
32}
33
34
35//=======================================================================
36//function : Insert
37//purpose :
38//=======================================================================
39
40void TopOpeBRep_FaceEdgeFiller::Insert
41(const TopoDS_Shape& F,
42 const TopoDS_Shape& E,
43 TopOpeBRep_FaceEdgeIntersector& FEINT,
44 const Handle(TopOpeBRepDS_HDataStructure)& HDS)
45{
46 const TopoDS_Face& FF = TopoDS::Face(F);
47 const TopoDS_Edge& EE = TopoDS::Edge(E);
48
49#ifdef DEB
50 if (TopOpeBRepDS_GettraceDSF()) {
51 FEINT_DUMPPOINTS(FEINT,HDS->DS());
52 }
53#endif
54
55 // exit if no point.
56 FEINT.InitPoint();
57 if ( ! FEINT.MorePoint() ) return;
58
59 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
60
61 TopAbs_Orientation FFori = FF.Orientation();
62 TopAbs_Orientation EEori = EE.Orientation();
63
64 // --- Add <FF,EE> in BDS
65 Standard_Integer FFindex = BDS.AddShape(FF,1);
66#ifdef DEB
67 Standard_Integer EEindex =
68#endif
69 BDS.AddShape(EE,2);
70
71 // --- get list of interferences connected to edges <FF>,<EE>
72 TopOpeBRepDS_ListOfInterference& EIL1 = BDS.ChangeShapeInterferences(FF);
73 TopOpeBRepDS_ListOfInterference& EIL2 = BDS.ChangeShapeInterferences(EE);
74
75 Handle(TopOpeBRepDS_Interference) EPI; //edge/point interference
76 Handle(TopOpeBRepDS_Interference) EVI; //edge/vertex interference
77
78 for (; FEINT.MorePoint(); FEINT.NextPoint() ) {
79 gp_Pnt2d pUV; FEINT.UVPoint(pUV);
7fd59977 80 Standard_Real parE = FEINT.Parameter();
81
82#ifdef DEB
83 TopOpeBRepDS_Transition TFF =
84#endif
85 FEINT.Transition(1,EEori); // EEori bidon = EXTERNAL
86 TopOpeBRepDS_Transition TEE = FEINT.Transition(2,FFori);
87 TEE.Index(FFindex);
88
89 TopoDS_Vertex V1;
90 Standard_Boolean isvertexF = FEINT.IsVertex(1,V1);
91 TopoDS_Vertex V2;
92 Standard_Boolean isvertexE = FEINT.IsVertex(2,V2);
93 Standard_Boolean isvertex = isvertexF || isvertexE;
94
95 Standard_Integer DSPindex;
96 Standard_Boolean EPIfound;
97
98 if ( ! isvertex ) {
99 // create a new geometry in DS ( and get its index <DSPindex> )
100 // or get the index <DSPindex> of an equal geometry
101 // among those of Edge/Point interferences connected to <FF> (or <EE>).
102
103 TopOpeBRepDS_ListIteratorOfListOfInterference itEIL1(EIL1);
104 EPIfound = GetGeometry(itEIL1,FEINT,DSPindex,BDS);
105 if ( ! EPIfound ) DSPindex = MakeGeometry(FEINT,BDS);
106
107 // sur FF
108 // NYI : FacePointInterference : on ajoute un point INTERNAL a F
109// FPI = new TopOpeBRepDS_FacePointInterference(TopAbs_INTERNAL,
110// TopOpeBRepDS_FACE,FFindex,
111// TopOpeBRepDS_POINT,DSPindex,
112// pUV);
113// StoreInterference(FPI,EIL1,BDS);
114
115 // sur EE
116 EPI = TopOpeBRepDS_InterferenceTool::MakeCurveInterference
117 (TEE,TopOpeBRepDS_FACE,FFindex,TopOpeBRepDS_POINT,DSPindex,parE);
118 StoreInterference(EPI,EIL2,BDS);
119 }
120
121 else if ( isvertexF ) {
122 // si aussi vertex de E, in privilegie le vertex de la face
123 Standard_Integer Vindex = BDS.AddShape(V1,1);
124
125 // sur FF
126 // NYI pour toute arete de F qui accede V , une EVI
127// EVI = new TopOpeBRepDS_EdgeVertexInterference(Transition ?? <-> TFF,
128// TopOpeBRepDS_EDGE,E de F,
129// TopOpeBRepDS_VERTEX,Vindex,
130// param de V sur E de F);
131// StoreInterference(EVI,EIL1,BDS);
132
133 // sur EE
134 EPI = new TopOpeBRepDS_CurvePointInterference(TEE,
135 TopOpeBRepDS_FACE,FFindex,
136 TopOpeBRepDS_VERTEX,Vindex,
137 parE);
138 StoreInterference(EPI,EIL2,BDS);
139 }
140
141 else if ( isvertexE ) {
142 Standard_Integer Vindex = BDS.AddShape(V2,2);
143
144 // sur FF
145 // NYI : FaceVertexInterference : on ajoute un vertex INTERNAL a F
146// FVI = new TopOpeBRepDS_FaceVertexInterference(TopAbs_INTERNAL,
147// TopOpeBRepDS_FACE,FFindex,
148// TopOpeBRepDS_VERTEX,Vindex,
149// pUV);
150// StoreInterference(FPI,EIL1,BDS);
151
152 // sur EE
153 EPI = new TopOpeBRepDS_CurvePointInterference(TEE,
154 TopOpeBRepDS_FACE,FFindex,
155 TopOpeBRepDS_VERTEX,Vindex,
156 parE);
157 StoreInterference(EPI,EIL2,BDS);
158 }
159 }
160}
161
162
163
164// ===============
165// private methods
166// ===============
167
168//-----------------------------------------------------------------------
169// Search, among a list of interferences accessed by the iterator <IT>,
170// a geometry whose 3D point is identical yo the 3D point of a DS point <DSP>.
171// TheDSPointGeomTool is a tool able to access the 3D point of the DS point
172// DSP,and to test identity (according to tolerance connected to DSP) of the
173// DS points.
174// return True if such an interference has been found, False else.
175// if True, iterator <IT> points (by the Value() method) on the first
176// interference accessing an identical 3D point.
177//-----------------------------------------------------------------------
178//=======================================================================
179//function : ScanInterfList
180//purpose : private
181//=======================================================================
182
183Standard_Boolean TopOpeBRep_FaceEdgeFiller::ScanInterfList
184 (TopOpeBRepDS_ListIteratorOfListOfInterference& IT,
185 const TopOpeBRepDS_Point& DSP,
186 const TopOpeBRepDS_DataStructure& BDS) const
187{
188 for ( ; IT.More(); IT.Next() ) {
189 Standard_Integer DSPG = IT.Value()->Geometry();
190 const TopOpeBRepDS_Point& otherDSP = BDS.Point(DSPG);
191 if (TopOpeBRep_PointGeomTool::IsEqual(DSP,otherDSP)) return Standard_True;
192 }
193 return Standard_False;
194}
195
196
197//=======================================================================
198//function : GetGeometry
199//purpose : private
200//=======================================================================
201
202Standard_Boolean TopOpeBRep_FaceEdgeFiller::GetGeometry
203 (TopOpeBRepDS_ListIteratorOfListOfInterference& IT,
204 const TopOpeBRep_FaceEdgeIntersector& FEINT,
205 Standard_Integer& G,
206 const TopOpeBRepDS_DataStructure& BDS) const
207{
208 TopOpeBRepDS_Point DSP = TopOpeBRep_PointGeomTool::MakePoint(FEINT);
209 Standard_Boolean found = ScanInterfList(IT,DSP,BDS);
210 if (found) G = IT.Value()->Geometry();
211 return found;
212}
213
214
215//=======================================================================
216//function : GetGeometry
217//purpose : private
218//=======================================================================
219
220Standard_Boolean TopOpeBRep_FaceEdgeFiller::GetGeometry
221 (const TopOpeBRepDS_ListOfInterference& L,
222 const TopOpeBRepDS_Point& DSP,
223 Standard_Integer& G,
224 TopOpeBRepDS_DataStructure& BDS) const
225{
226 TopOpeBRepDS_ListIteratorOfListOfInterference itI(L);
227 Standard_Boolean Ifound = ScanInterfList(itI,DSP,BDS);
228 if (Ifound) G = itI.Value()->Geometry();
229 else G = BDS.AddPoint(DSP);
230 return Ifound; // interference found or not
231}
232
233
234//-----------------------------------------------------------------------
235// StoreInterference : Append an interference I to a list of interference LI
236// : Append I to the interf. list connected to I Geometry()
237//-----------------------------------------------------------------------
238//=======================================================================
239//function : StoreInterference
240//purpose : private
241//=======================================================================
242
243void TopOpeBRep_FaceEdgeFiller::StoreInterference
244(const Handle(TopOpeBRepDS_Interference)& I,
245 TopOpeBRepDS_ListOfInterference& LI,
246 TopOpeBRepDS_DataStructure& BDS) const
247{
248 // append I to list LI
249 LI.Append(I);
250
251 Standard_Boolean appendtoG = Standard_False;
252 Standard_Integer G = I->Geometry();
253
254 // append I to list of interference connected to G = I->Geometry()
255 switch (I->GeometryType()) {
256
257 case TopOpeBRepDS_SOLID : case TopOpeBRepDS_FACE :
258 case TopOpeBRepDS_EDGE : case TopOpeBRepDS_VERTEX :
259// appendtoG = Standard_True;
260// BDS.ChangeShapeInterferences(G).Append(I);
261 break;
262
263 case TopOpeBRepDS_SURFACE :
264 appendtoG = Standard_True;
265 BDS.ChangeSurfaceInterferences(G).Append(I);
266 break;
267
268 case TopOpeBRepDS_CURVE :
269 appendtoG = Standard_True;
270 BDS.ChangeCurveInterferences(G).Append(I);
271 break;
272
273 case TopOpeBRepDS_POINT :
274// appendtoG = Standard_True;
275// BDS.ChangePointInterferences(G).Append(I);
276 break;
277#ifndef DEB
278 default:
279 break;
280#endif
281
282 }
283
284#ifdef DEB
285 if (TopOpeBRepDS_GettraceDSF()) {
286 cout<<"append "; I->Dump(cout);
287 if (appendtoG) cout<<" and to G"<<G<<" list";
288 cout<<endl;
289 }
290#endif
291}
292
293//=======================================================================
294//function : MakeGeometry
295//purpose :
296//=======================================================================
297
298Standard_Integer TopOpeBRep_FaceEdgeFiller::MakeGeometry
299 (TopOpeBRep_FaceEdgeIntersector& FEINT,
300 TopOpeBRepDS_DataStructure& BDS) const
301{
302#ifdef DEB
303 Standard_Integer G;
304#else
305 Standard_Integer G=0;
306#endif
307
308 TopoDS_Vertex V1;
309 Standard_Boolean isvertexF = FEINT.IsVertex(1,V1);
310 TopoDS_Vertex V2;
311 Standard_Boolean isvertexE = FEINT.IsVertex(2,V2);
312 Standard_Boolean isvertex = isvertexF || isvertexE;
313
314 if ( isvertex ) {
315 if ( isvertexF ) G = BDS.AddShape(V1,1);
316 else if ( isvertexE ) G = BDS.AddShape(V2,2);
317 }
318 else
319 G = BDS.AddPoint(TopOpeBRep_PointGeomTool::MakePoint(FEINT));
320 return G;
321}