0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / HLRTopoBRep / HLRTopoBRep_Data.cxx
CommitLineData
b311480e 1// Created on: 1994-10-24
2// Created by: Christophe MARION
3// Copyright (c) 1994-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
42cf5bc1 17
18#include <HLRTopoBRep_Data.hxx>
7fd59977 19#include <HLRTopoBRep_ListOfVData.hxx>
42cf5bc1 20#include <HLRTopoBRep_VData.hxx>
7fd59977 21#include <TopoDS.hxx>
42cf5bc1 22#include <TopoDS_Edge.hxx>
23#include <TopoDS_Face.hxx>
24#include <TopoDS_Shape.hxx>
25#include <TopoDS_Vertex.hxx>
26#include <TopTools_ListIteratorOfListOfShape.hxx>
7fd59977 27
28//=======================================================================
29//function : HLRTopoBRep_Data
30//purpose :
31//=======================================================================
7fd59977 32HLRTopoBRep_Data::HLRTopoBRep_Data ()
33{
34 Clear();
35}
36
37//=======================================================================
38//function : Clear
39//purpose :
40//=======================================================================
41
42void HLRTopoBRep_Data::Clear ()
43{
44 myOldS.Clear();
45 mySplE.Clear();
46 myData.Clear();
47 myOutV.Clear();
48 myIntV.Clear();
49 myEdgesVertices.Clear();
50}
51
52//=======================================================================
53//function : Clean
54//purpose :
55//=======================================================================
56
57void HLRTopoBRep_Data::Clean ()
58{
59}
60
61//=======================================================================
62//function : EdgeHasSplE
63//purpose :
64//=======================================================================
65
66Standard_Boolean
67HLRTopoBRep_Data::EdgeHasSplE (const TopoDS_Edge& E) const
68{
69 if (!mySplE.IsBound(E)) return Standard_False;
70 return !mySplE(E).IsEmpty();
71}
72
73//=======================================================================
74//function : FaceHasIntL
75//purpose :
76//=======================================================================
77
78Standard_Boolean
79HLRTopoBRep_Data::FaceHasIntL (const TopoDS_Face& F) const
80{
81 if (!myData.IsBound(F)) return Standard_False;
82 return !myData(F).FaceIntL().IsEmpty();
83}
84
85//=======================================================================
86//function : FaceHasOutL
87//purpose :
88//=======================================================================
89
90Standard_Boolean
91HLRTopoBRep_Data::FaceHasOutL (const TopoDS_Face& F) const
92{
93 if (!myData.IsBound(F)) return Standard_False;
94 return !myData(F).FaceOutL().IsEmpty();
95}
96
97//=======================================================================
98//function : FaceHasIsoL
99//purpose :
100//=======================================================================
101
102Standard_Boolean
103HLRTopoBRep_Data::FaceHasIsoL (const TopoDS_Face& F) const
104{
105 if (!myData.IsBound(F)) return Standard_False;
106 return !myData(F).FaceIsoL().IsEmpty();
107}
108
109//=======================================================================
110//function : IsSplEEdgeEdge
111//purpose :
112//=======================================================================
113
114Standard_Boolean
115HLRTopoBRep_Data::IsSplEEdgeEdge (const TopoDS_Edge& E1,
116 const TopoDS_Edge& E2) const
117{
118 Standard_Boolean found = Standard_False;
119 if (EdgeHasSplE(E1)) {
120
121 TopTools_ListIteratorOfListOfShape itS;
122 for (itS.Initialize(EdgeSplE(E1));
123 itS.More() && !found;
124 itS.Next())
125 found= itS.Value().IsSame(E2);
126 }
127 else
128 found = E1.IsSame(E2);
129 return found;
130}
131
132//=======================================================================
133//function : IsIntLFaceEdge
134//purpose :
135//=======================================================================
136
137Standard_Boolean
138HLRTopoBRep_Data::IsIntLFaceEdge (const TopoDS_Face& F,
139 const TopoDS_Edge& E) const
140{
141 Standard_Boolean found = Standard_False;
142 if (FaceHasIntL(F)) {
143
144 TopTools_ListIteratorOfListOfShape itE;
145 for(itE.Initialize(FaceIntL(F));
146 itE.More() && !found;
147 itE.Next()) {
148 found = IsSplEEdgeEdge(TopoDS::Edge(itE.Value()),E);
149 }
150 }
151 return found;
152}
153
154//=======================================================================
155//function : IsOutLFaceEdge
156//purpose :
157//=======================================================================
158
159Standard_Boolean
160HLRTopoBRep_Data::IsOutLFaceEdge (const TopoDS_Face& F,
161 const TopoDS_Edge& E) const
162{
163 Standard_Boolean found = Standard_False;
164 if (FaceHasOutL(F)) {
165
166 TopTools_ListIteratorOfListOfShape itE;
167 for(itE.Initialize(FaceOutL(F));
168 itE.More() && !found;
169 itE.Next()) {
170 found = IsSplEEdgeEdge(TopoDS::Edge(itE.Value()),E);
171 }
172 }
173 return found;
174}
175
176//=======================================================================
177//function : IsIsoLFaceEdge
178//purpose :
179//=======================================================================
180
181Standard_Boolean
182HLRTopoBRep_Data::IsIsoLFaceEdge (const TopoDS_Face& F,
183 const TopoDS_Edge& E) const
184{
185 Standard_Boolean found = Standard_False;
186 if (FaceHasIsoL(F)) {
187
188 TopTools_ListIteratorOfListOfShape itE;
189 for(itE.Initialize(FaceIsoL(F));
190 itE.More() && !found;
191 itE.Next()) {
192 found = IsSplEEdgeEdge(TopoDS::Edge(itE.Value()),E);
193 }
194 }
195 return found;
196}
197
198//=======================================================================
199//function : NewSOldS
200//purpose :
201//=======================================================================
202
203TopoDS_Shape HLRTopoBRep_Data::NewSOldS (const TopoDS_Shape& NewS) const
204{
205 if (myOldS.IsBound(NewS)) return myOldS(NewS);
206 else return NewS;
207}
208
209//=======================================================================
210//function : AddOldS
211//purpose :
212//=======================================================================
213
214void HLRTopoBRep_Data::AddOldS (const TopoDS_Shape& NewS,
215 const TopoDS_Shape& OldS)
216{
217 if (!myOldS.IsBound(NewS))
218 myOldS.Bind(NewS,OldS);
219}
220
221//=======================================================================
222//function : AddSplE
223//purpose :
224//=======================================================================
225
226TopTools_ListOfShape & HLRTopoBRep_Data::AddSplE (const TopoDS_Edge& E)
227{
228 if (!mySplE.IsBound(E)) {
229 TopTools_ListOfShape empty;
230 mySplE.Bind(E,empty);
231 }
232 return mySplE(E);
233}
234
235//=======================================================================
236//function : AddIntL
237//purpose :
238//=======================================================================
239
240TopTools_ListOfShape & HLRTopoBRep_Data::AddIntL (const TopoDS_Face& F)
241{
242 if (!myData.IsBound(F)) {
243 HLRTopoBRep_FaceData theData;
244 myData.Bind(F, theData);
245 }
246 return myData(F).AddIntL();
247}
248
249//=======================================================================
250//function : AddOutL
251//purpose :
252//=======================================================================
253
254TopTools_ListOfShape & HLRTopoBRep_Data::AddOutL (const TopoDS_Face& F)
255{
256 if (!myData.IsBound(F)) {
257 HLRTopoBRep_FaceData theData;
258 myData.Bind(F, theData);
259 }
260 return myData(F).AddOutL();
261}
262
263//=======================================================================
264//function : AddIsoL
265//purpose :
266//=======================================================================
267
268TopTools_ListOfShape & HLRTopoBRep_Data::AddIsoL (const TopoDS_Face& F)
269{
270 if (!myData.IsBound(F)) {
271 HLRTopoBRep_FaceData theData;
272 myData.Bind(F, theData);
273 }
274 return myData(F).AddIsoL();
275}
276
277//=======================================================================
278//function : InitEdge
279//purpose :
280//=======================================================================
281
282void HLRTopoBRep_Data::InitEdge ()
283{
284 myEIterator.Initialize(myEdgesVertices);
285
286 while (myEIterator.More() && myEIterator.Value().IsEmpty())
287 myEIterator.Next();
288}
289
290//=======================================================================
291//function : NextEdge
292//purpose :
293//=======================================================================
294
295void HLRTopoBRep_Data::NextEdge ()
296{
297 myEIterator.Next();
298
299 while (myEIterator.More() && myEIterator.Value().IsEmpty())
300 myEIterator.Next();
301}
302
303//=======================================================================
304//function : InitVertex
305//purpose :
306//=======================================================================
307
308void HLRTopoBRep_Data::InitVertex (const TopoDS_Edge& E)
309{
310 if (!myEdgesVertices.IsBound(E)) {
311 HLRTopoBRep_ListOfVData empty;
312 myEdgesVertices.Bind(E,empty);
313 }
314 HLRTopoBRep_ListOfVData& L = myEdgesVertices(E);
315 myVList = &L;
316 myVIterator.Initialize(L);
317}
318
319//=======================================================================
320//function : Vertex
321//purpose :
322//=======================================================================
323
324const TopoDS_Vertex & HLRTopoBRep_Data::Vertex () const
325{
326 return TopoDS::Vertex(myVIterator.Value().Vertex());
327}
328
329//=======================================================================
330//function : Parameter
331//purpose :
332//=======================================================================
333
334Standard_Real HLRTopoBRep_Data::Parameter() const
335{
336 return myVIterator.Value().Parameter();
337}
338
339//=======================================================================
340//function : InsertBefore
341//purpose :
342//=======================================================================
343
344void HLRTopoBRep_Data::InsertBefore (const TopoDS_Vertex& V,
345 const Standard_Real P)
346{
347 HLRTopoBRep_VData VD(P,V);
681f3919 348 myVList->InsertBefore(VD,myVIterator);
7fd59977 349}
350
351//=======================================================================
352//function : Append
353//purpose :
354//=======================================================================
355
356void HLRTopoBRep_Data::Append (const TopoDS_Vertex& V,
357 const Standard_Real P)
358{
359 HLRTopoBRep_VData VD(P,V);
681f3919 360 myVList->Append(VD);
7fd59977 361}
362