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