1 // Created on: 2003-12-11
2 // Created by: Alexander SOLOVYOV
3 // Copyright (c) 2003-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <MeshVS_DeformedDataSource.ixx>
17 #include <MeshVS_Buffer.hxx>
19 //================================================================
20 // Function : Constructor MeshVS_DeformedDataSource
22 //================================================================
23 MeshVS_DeformedDataSource::MeshVS_DeformedDataSource( const Handle(MeshVS_DataSource)& theNonDeformDS,
24 const Standard_Real theMagnify )
26 myNonDeformedDataSource = theNonDeformDS;
27 SetMagnify ( theMagnify );
30 //================================================================
31 // Function : shiftCoord
32 // Purpose : auxiliary: shift coordinate of the node on a given vector
33 //================================================================
35 static inline void shiftCoord (TColStd_Array1OfReal& Coords, Standard_Integer i, const gp_Vec &aVec)
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();
42 //================================================================
45 //================================================================
46 Standard_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
52 if ( myNonDeformedDataSource.IsNull() ||
53 ! myNonDeformedDataSource->GetGeom ( ID, IsElement, Coords, NbNodes, Type ) )
54 return Standard_False;
56 if ( Type==MeshVS_ET_Node )
59 if ( ! GetVector( ID, Vect ) )
60 return Standard_False;
61 shiftCoord ( Coords, 1, myMagnify * Vect );
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++ )
72 if ( ! GetVector( aNodes(i), Vect ) )
73 return Standard_False;
74 shiftCoord ( Coords, i, myMagnify * Vect );
80 //================================================================
81 // Function : GetGeomType
83 //================================================================
84 Standard_Boolean MeshVS_DeformedDataSource::GetGeomType( const Standard_Integer ID,
85 const Standard_Boolean IsElement,
86 MeshVS_EntityType& Type) const
88 if ( myNonDeformedDataSource.IsNull() )
89 return Standard_False;
91 return myNonDeformedDataSource->GetGeomType( ID, IsElement, Type );
94 //================================================================
95 // Function : Get3DGeom
97 //================================================================
98 Standard_Boolean MeshVS_DeformedDataSource::Get3DGeom( const Standard_Integer ID,
99 Standard_Integer& NbNodes,
100 Handle( MeshVS_HArray1OfSequenceOfInteger )& Data ) const
102 if( myNonDeformedDataSource.IsNull() )
103 return Standard_False;
105 return myNonDeformedDataSource->Get3DGeom( ID, NbNodes, Data );
108 //================================================================
109 // Function : GetAddr
111 //================================================================
112 Standard_Address MeshVS_DeformedDataSource::GetAddr( const Standard_Integer ID,
113 const Standard_Boolean IsElement ) const
115 if ( myNonDeformedDataSource.IsNull() )
118 return myNonDeformedDataSource->GetAddr( ID, IsElement );
121 //================================================================
122 // Function : GetNodesByElement
124 //================================================================
125 Standard_Boolean MeshVS_DeformedDataSource::GetNodesByElement
126 (const Standard_Integer ID,
127 TColStd_Array1OfInteger& NodeIDs,
128 Standard_Integer& NbNodes) const
130 if ( myNonDeformedDataSource.IsNull() )
131 return Standard_False;
133 return myNonDeformedDataSource->GetNodesByElement( ID, NodeIDs, NbNodes );
136 //================================================================
137 // Function : GetAllNodes
139 //================================================================
140 const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllNodes() const
142 if ( myNonDeformedDataSource.IsNull() )
145 return myNonDeformedDataSource->GetAllNodes();
148 //================================================================
149 // Function : GetAllElements
151 //================================================================
152 const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllElements() const
154 if ( myNonDeformedDataSource.IsNull() )
157 return myNonDeformedDataSource->GetAllElements();
160 //================================================================
161 // Function : GetVectors
163 //================================================================
164 const MeshVS_DataMapOfIntegerVector& MeshVS_DeformedDataSource::GetVectors() const
169 //================================================================
170 // Function : SetVectors
172 //================================================================
173 void MeshVS_DeformedDataSource::SetVectors( const MeshVS_DataMapOfIntegerVector& Map )
178 //================================================================
179 // Function : GetVector
181 //================================================================
182 Standard_Boolean MeshVS_DeformedDataSource::GetVector( const Standard_Integer ID,
185 Standard_Boolean aRes = myVectors.IsBound ( ID );
187 Vect = myVectors.Find ( ID );
191 //================================================================
192 // Function : SetVector
194 //================================================================
195 void MeshVS_DeformedDataSource::SetVector( const Standard_Integer ID,
198 Standard_Boolean aRes = myVectors.IsBound ( ID );
200 myVectors.ChangeFind ( ID ) = Vect;
202 myVectors.Bind( ID, Vect );
205 //================================================================
206 // Function : SetNonDeformedDataSource
208 //================================================================
209 void MeshVS_DeformedDataSource::SetNonDeformedDataSource( const Handle(MeshVS_DataSource)& theDS )
211 myNonDeformedDataSource = theDS;
214 //================================================================
215 // Function : GetNonDeformedDataSource
217 //================================================================
218 Handle(MeshVS_DataSource) MeshVS_DeformedDataSource::GetNonDeformedDataSource() const
220 return myNonDeformedDataSource;
223 //================================================================
224 // Function : SetMagnify
226 //================================================================
227 void MeshVS_DeformedDataSource::SetMagnify( const Standard_Real theMagnify )
232 myMagnify = theMagnify;
235 //================================================================
236 // Function : GetMagnify
238 //================================================================
239 Standard_Real MeshVS_DeformedDataSource::GetMagnify() const