0024856: CLang warnings -Wunused-private-field
[occt.git] / src / MeshVS / MeshVS_DeformedDataSource.cxx
CommitLineData
b311480e 1// Created on: 2003-12-11
2// Created by: Alexander SOLOVYOV
973c2be1 3// Copyright (c) 2003-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#include <MeshVS_DeformedDataSource.ixx>
17#include <MeshVS_Buffer.hxx>
18
19//================================================================
20// Function : Constructor MeshVS_DeformedDataSource
21// Purpose :
22//================================================================
23MeshVS_DeformedDataSource::MeshVS_DeformedDataSource( const Handle(MeshVS_DataSource)& theNonDeformDS,
24 const Standard_Real theMagnify )
25{
26 myNonDeformedDataSource = theNonDeformDS;
27 SetMagnify ( theMagnify );
28}
29
30//================================================================
31// Function : shiftCoord
32// Purpose : auxiliary: shift coordinate of the node on a given vector
33//================================================================
34
35static inline void shiftCoord (TColStd_Array1OfReal& Coords, Standard_Integer i, const gp_Vec &aVec)
36{
37 Coords(3*i-2) = Coords(3*i-2) + aVec.X();
38 Coords(3*i-1) = Coords(3*i-1) + aVec.Y();
39 Coords(3*i) = Coords(3*i) + aVec.Z();
40}
41
42//================================================================
43// Function : GetGeom
44// Purpose :
45//================================================================
46Standard_Boolean MeshVS_DeformedDataSource::GetGeom( const Standard_Integer ID,
47 const Standard_Boolean IsElement,
48 TColStd_Array1OfReal& Coords,
49 Standard_Integer& NbNodes,
50 MeshVS_EntityType& Type) const
51{
52 if ( myNonDeformedDataSource.IsNull() ||
53 ! myNonDeformedDataSource->GetGeom ( ID, IsElement, Coords, NbNodes, Type ) )
54 return Standard_False;
55
56 if ( Type==MeshVS_ET_Node )
57 {
58 gp_Vec Vect;
59 if ( ! GetVector( ID, Vect ) )
60 return Standard_False;
61 shiftCoord ( Coords, 1, myMagnify * Vect );
62 }
63 else
64 {
65 MeshVS_Buffer aNodesBuf (NbNodes * sizeof(Standard_Integer));
66 TColStd_Array1OfInteger aNodes (aNodesBuf, 1, NbNodes);
67 if ( !myNonDeformedDataSource->GetNodesByElement ( ID, aNodes, NbNodes ) )
68 return Standard_False;
69 for ( int i=1; i <= NbNodes; i++ )
70 {
71 gp_Vec Vect;
72 if ( ! GetVector( aNodes(i), Vect ) )
73 return Standard_False;
74 shiftCoord ( Coords, i, myMagnify * Vect );
75 }
76 }
77 return Standard_True;
78}
79
80//================================================================
81// Function : GetGeomType
82// Purpose :
83//================================================================
84Standard_Boolean MeshVS_DeformedDataSource::GetGeomType( const Standard_Integer ID,
85 const Standard_Boolean IsElement,
86 MeshVS_EntityType& Type) const
87{
88 if ( myNonDeformedDataSource.IsNull() )
89 return Standard_False;
90 else
91 return myNonDeformedDataSource->GetGeomType( ID, IsElement, Type );
92}
93
94//================================================================
95// Function : Get3DGeom
96// Purpose :
97//================================================================
98Standard_Boolean MeshVS_DeformedDataSource::Get3DGeom( const Standard_Integer ID,
99 Standard_Integer& NbNodes,
100 Handle( MeshVS_HArray1OfSequenceOfInteger )& Data ) const
101{
102 if( myNonDeformedDataSource.IsNull() )
103 return Standard_False;
104 else
105 return myNonDeformedDataSource->Get3DGeom( ID, NbNodes, Data );
106}
107
108//================================================================
109// Function : GetAddr
110// Purpose :
111//================================================================
112Standard_Address MeshVS_DeformedDataSource::GetAddr( const Standard_Integer ID,
113 const Standard_Boolean IsElement ) const
114{
115 if ( myNonDeformedDataSource.IsNull() )
116 return 0;
117 else
118 return myNonDeformedDataSource->GetAddr( ID, IsElement );
119}
120
121//================================================================
122// Function : GetNodesByElement
123// Purpose :
124//================================================================
125Standard_Boolean MeshVS_DeformedDataSource::GetNodesByElement
126 (const Standard_Integer ID,
127 TColStd_Array1OfInteger& NodeIDs,
128 Standard_Integer& NbNodes) const
129{
130 if ( myNonDeformedDataSource.IsNull() )
131 return Standard_False;
132 else
133 return myNonDeformedDataSource->GetNodesByElement( ID, NodeIDs, NbNodes );
134}
135
136//================================================================
137// Function : GetAllNodes
138// Purpose :
139//================================================================
140const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllNodes() const
141{
142 if ( myNonDeformedDataSource.IsNull() )
143 return myEmptyMap;
144 else
145 return myNonDeformedDataSource->GetAllNodes();
146}
147
148//================================================================
149// Function : GetAllElements
150// Purpose :
151//================================================================
152const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllElements() const
153{
154 if ( myNonDeformedDataSource.IsNull() )
155 return myEmptyMap;
156 else
157 return myNonDeformedDataSource->GetAllElements();
158}
159
160//================================================================
161// Function : GetVectors
162// Purpose :
163//================================================================
164const MeshVS_DataMapOfIntegerVector& MeshVS_DeformedDataSource::GetVectors() const
165{
166 return myVectors;
167}
168
169//================================================================
170// Function : SetVectors
171// Purpose :
172//================================================================
173void MeshVS_DeformedDataSource::SetVectors( const MeshVS_DataMapOfIntegerVector& Map )
174{
175 myVectors = Map;
176}
177
178//================================================================
179// Function : GetVector
180// Purpose :
181//================================================================
182Standard_Boolean MeshVS_DeformedDataSource::GetVector( const Standard_Integer ID,
183 gp_Vec& Vect ) const
184{
185 Standard_Boolean aRes = myVectors.IsBound ( ID );
186 if ( aRes )
187 Vect = myVectors.Find ( ID );
188 return aRes;
189}
190
191//================================================================
192// Function : SetVector
193// Purpose :
194//================================================================
195void MeshVS_DeformedDataSource::SetVector( const Standard_Integer ID,
196 const gp_Vec& Vect )
197{
198 Standard_Boolean aRes = myVectors.IsBound ( ID );
199 if ( aRes )
200 myVectors.ChangeFind ( ID ) = Vect;
201 else
202 myVectors.Bind( ID, Vect );
203}
204
205//================================================================
206// Function : SetNonDeformedDataSource
207// Purpose :
208//================================================================
209void MeshVS_DeformedDataSource::SetNonDeformedDataSource( const Handle(MeshVS_DataSource)& theDS )
210{
211 myNonDeformedDataSource = theDS;
212}
213
214//================================================================
215// Function : GetNonDeformedDataSource
216// Purpose :
217//================================================================
218Handle_MeshVS_DataSource MeshVS_DeformedDataSource::GetNonDeformedDataSource() const
219{
220 return myNonDeformedDataSource;
221}
222
223//================================================================
224// Function : SetMagnify
225// Purpose :
226//================================================================
227void MeshVS_DeformedDataSource::SetMagnify( const Standard_Real theMagnify )
228{
229 if ( theMagnify<=0 )
230 myMagnify = 1.0;
231 else
232 myMagnify = theMagnify;
233}
234
235//================================================================
236// Function : GetMagnify
237// Purpose :
238//================================================================
239Standard_Real MeshVS_DeformedDataSource::GetMagnify() const
240{
241 return myMagnify;
242}