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