1 // File: MeshVS_DeformedDataSource.cxx
2 // Created: Thu Dec 11 2003
3 // Author: Alexander SOLOVYOV
4 // Copyright: Open CASCADE 2003
6 #include <MeshVS_DeformedDataSource.ixx>
7 #include <MeshVS_Buffer.hxx>
9 //================================================================
10 // Function : Constructor MeshVS_DeformedDataSource
12 //================================================================
13 MeshVS_DeformedDataSource::MeshVS_DeformedDataSource( const Handle(MeshVS_DataSource)& theNonDeformDS,
14 const Standard_Real theMagnify )
16 myNonDeformedDataSource = theNonDeformDS;
17 SetMagnify ( theMagnify );
20 //================================================================
21 // Function : shiftCoord
22 // Purpose : auxiliary: shift coordinate of the node on a given vector
23 //================================================================
25 static inline void shiftCoord (TColStd_Array1OfReal& Coords, Standard_Integer i, const gp_Vec &aVec)
27 Coords(3*i-2) = Coords(3*i-2) + aVec.X();
28 Coords(3*i-1) = Coords(3*i-1) + aVec.Y();
29 Coords(3*i) = Coords(3*i) + aVec.Z();
32 //================================================================
35 //================================================================
36 Standard_Boolean MeshVS_DeformedDataSource::GetGeom( const Standard_Integer ID,
37 const Standard_Boolean IsElement,
38 TColStd_Array1OfReal& Coords,
39 Standard_Integer& NbNodes,
40 MeshVS_EntityType& Type) const
42 if ( myNonDeformedDataSource.IsNull() ||
43 ! myNonDeformedDataSource->GetGeom ( ID, IsElement, Coords, NbNodes, Type ) )
44 return Standard_False;
46 if ( Type==MeshVS_ET_Node )
49 if ( ! GetVector( ID, Vect ) )
50 return Standard_False;
51 shiftCoord ( Coords, 1, myMagnify * Vect );
55 MeshVS_Buffer aNodesBuf (NbNodes * sizeof(Standard_Integer));
56 TColStd_Array1OfInteger aNodes (aNodesBuf, 1, NbNodes);
57 if ( !myNonDeformedDataSource->GetNodesByElement ( ID, aNodes, NbNodes ) )
58 return Standard_False;
59 for ( int i=1; i <= NbNodes; i++ )
62 if ( ! GetVector( aNodes(i), Vect ) )
63 return Standard_False;
64 shiftCoord ( Coords, i, myMagnify * Vect );
70 //================================================================
71 // Function : GetGeomType
73 //================================================================
74 Standard_Boolean MeshVS_DeformedDataSource::GetGeomType( const Standard_Integer ID,
75 const Standard_Boolean IsElement,
76 MeshVS_EntityType& Type) const
78 if ( myNonDeformedDataSource.IsNull() )
79 return Standard_False;
81 return myNonDeformedDataSource->GetGeomType( ID, IsElement, Type );
84 //================================================================
85 // Function : Get3DGeom
87 //================================================================
88 Standard_Boolean MeshVS_DeformedDataSource::Get3DGeom( const Standard_Integer ID,
89 Standard_Integer& NbNodes,
90 Handle( MeshVS_HArray1OfSequenceOfInteger )& Data ) const
92 if( myNonDeformedDataSource.IsNull() )
93 return Standard_False;
95 return myNonDeformedDataSource->Get3DGeom( ID, NbNodes, Data );
98 //================================================================
101 //================================================================
102 Standard_Address MeshVS_DeformedDataSource::GetAddr( const Standard_Integer ID,
103 const Standard_Boolean IsElement ) const
105 if ( myNonDeformedDataSource.IsNull() )
108 return myNonDeformedDataSource->GetAddr( ID, IsElement );
111 //================================================================
112 // Function : GetNodesByElement
114 //================================================================
115 Standard_Boolean MeshVS_DeformedDataSource::GetNodesByElement
116 (const Standard_Integer ID,
117 TColStd_Array1OfInteger& NodeIDs,
118 Standard_Integer& NbNodes) const
120 if ( myNonDeformedDataSource.IsNull() )
121 return Standard_False;
123 return myNonDeformedDataSource->GetNodesByElement( ID, NodeIDs, NbNodes );
126 //================================================================
127 // Function : GetAllNodes
129 //================================================================
130 const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllNodes() const
132 if ( myNonDeformedDataSource.IsNull() )
135 return myNonDeformedDataSource->GetAllNodes();
138 //================================================================
139 // Function : GetAllElements
141 //================================================================
142 const TColStd_PackedMapOfInteger& MeshVS_DeformedDataSource::GetAllElements() const
144 if ( myNonDeformedDataSource.IsNull() )
147 return myNonDeformedDataSource->GetAllElements();
150 //================================================================
151 // Function : GetVectors
153 //================================================================
154 const MeshVS_DataMapOfIntegerVector& MeshVS_DeformedDataSource::GetVectors() const
159 //================================================================
160 // Function : SetVectors
162 //================================================================
163 void MeshVS_DeformedDataSource::SetVectors( const MeshVS_DataMapOfIntegerVector& Map )
168 //================================================================
169 // Function : GetVector
171 //================================================================
172 Standard_Boolean MeshVS_DeformedDataSource::GetVector( const Standard_Integer ID,
175 Standard_Boolean aRes = myVectors.IsBound ( ID );
177 Vect = myVectors.Find ( ID );
181 //================================================================
182 // Function : SetVector
184 //================================================================
185 void MeshVS_DeformedDataSource::SetVector( const Standard_Integer ID,
188 Standard_Boolean aRes = myVectors.IsBound ( ID );
190 myVectors.ChangeFind ( ID ) = Vect;
192 myVectors.Bind( ID, Vect );
195 //================================================================
196 // Function : SetNonDeformedDataSource
198 //================================================================
199 void MeshVS_DeformedDataSource::SetNonDeformedDataSource( const Handle(MeshVS_DataSource)& theDS )
201 myNonDeformedDataSource = theDS;
204 //================================================================
205 // Function : GetNonDeformedDataSource
207 //================================================================
208 Handle_MeshVS_DataSource MeshVS_DeformedDataSource::GetNonDeformedDataSource() const
210 return myNonDeformedDataSource;
213 //================================================================
214 // Function : SetMagnify
216 //================================================================
217 void MeshVS_DeformedDataSource::SetMagnify( const Standard_Real theMagnify )
222 myMagnify = theMagnify;
225 //================================================================
226 // Function : GetMagnify
228 //================================================================
229 Standard_Real MeshVS_DeformedDataSource::GetMagnify() const