1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : VISU_Convertor.hxx
25 // Author : Alexey PETROV
28 #ifndef VISU_MeshValue_HeaderFile
29 #define VISU_MeshValue_HeaderFile
32 \file VISU_MeshValue.hxx
33 \brief The file contains declarations for basic interfaces that defines mesh value of mesh elements
36 #include "VISU_Convertor.hxx"
37 #include "VISU_ConvertorDef_impl.hxx"
39 #include "MED_SliceArray.hxx"
40 #include "MED_Vector.hxx"
44 //---------------------------------------------------------------
45 //! Define a base class for the container to get access to data assigned to mesh
46 class VISU_CONVERTOR_EXPORT TMeshValueBase
49 //! To intitilize the data strucutre
51 Init(vtkIdType theNbElem,
55 //! Gets memory size used by the instance (bytes).
58 GetMemorySize() const = 0;
60 //! Gets number of mesh elements where the data assigned to.
64 //! Gets number of components of corresponding MED FIELD.
68 //! Gets number of Gauss Points.
76 vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
77 vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
78 vtkIdType myNbGauss; //!< Defines number of Gauss Points
79 vtkIdType myStep; //!< Internal variable
81 typedef MED::SharedPtr<TMeshValueBase> PMeshValue;
84 //---------------------------------------------------------------
85 //! Define a container to get access to data assigned to mesh
86 template<class TValueType>
87 class VISU_CONVERTOR_EXPORT TTMeshValue: public virtual TMeshValueBase
90 typedef MED::TSlice<TValueType> TValueSlice;
91 typedef MED::TCSlice<TValueType> TCValueSlice;
93 typedef TVector<TCValueSlice> TCValueSliceArr;
94 typedef TVector<TValueSlice> TValueSliceArr;
98 GetPointer() const = 0;
104 //! To get assigned values first by Gauss Points and then by components (constant version)
106 GetGaussValueSliceArr(vtkIdType theElemId) const
108 TCValueSliceArr aValueSliceArr(this->myNbGauss);
109 vtkIdType anId = theElemId * this->myStep;
110 for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
111 aValueSliceArr[aGaussId] =
112 TCValueSlice(this->GetPointer(),
114 std::slice(anId, this->myNbComp, 1));
115 anId += this->myNbComp;
117 return aValueSliceArr;
120 //! To get assigned values first by Gauss Points and then by components
122 GetGaussValueSliceArr(vtkIdType theElemId)
124 TValueSliceArr aValueSliceArr(this->myNbGauss);
125 vtkIdType anId = theElemId * this->myStep;
126 for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
127 aValueSliceArr[aGaussId] =
128 TValueSlice(this->GetPointer(),
130 std::slice(anId, this->myNbComp, 1));
131 anId += this->myNbComp;
133 return aValueSliceArr;
136 //! To get assigned values first by components and then by Gauss Points (constant version)
138 GetCompValueSliceArr(vtkIdType theElemId) const
140 TCValueSliceArr aValueSliceArr(this->myNbComp);
141 vtkIdType anId = theElemId * this->myStep;
142 for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
143 aValueSliceArr[aCompId] =
144 TCValueSlice(this->GetPointer(),
146 std::slice(anId, this->myNbGauss, this->myNbComp));
149 return aValueSliceArr;
152 //! To get assigned values first by components and then by Gauss Points
154 GetCompValueSliceArr(vtkIdType theElemId)
156 TValueSliceArr aValueSliceArr(this->myNbComp);
157 vtkIdType anId = theElemId * this->myStep;
158 for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
159 aValueSliceArr[aCompId] =
160 TValueSlice(this->GetPointer(),
162 std::slice(anId, this->myNbGauss, this->myNbComp));
165 return aValueSliceArr;
168 //! Gets memory size used by the instance (bytes).
171 GetMemorySize() const
173 return this->size() * sizeof(TValueType);
178 //---------------------------------------------------------------
179 //! Define a container to get access to data assigned to mesh
180 template<class TValueType, class TContainerType>
181 class TTMeshValueHolder: public virtual TTMeshValue<TValueType>
184 //! To initilize the class instance
186 Init(vtkIdType theNbElem,
187 vtkIdType theNbGauss,
189 const TContainerType& theContainer)
191 TMeshValueBase::Init(theNbElem, theNbGauss, theNbComp);
192 myContainer = theContainer;
196 mutable TContainerType myContainer; //!< Keeps the mesh values container itself
200 //---------------------------------------------------------------
201 // Initilize corresponding vtkDataSetAttributes for TValForTime
203 GetTimeStampOnProfile(const PUnstructuredGrid& theSource,
204 const PFieldImpl& theField,
205 const PValForTimeImpl& theValForTime,
206 const VISU::TEntity& theEntity);
209 //---------------------------------------------------------------
210 // Initilize corresponding vtkDataSetAttributes for TValForTime
212 GetTimeStampOnGaussMesh(const PPolyData& theSource,
213 const PFieldImpl& theField,
214 const PValForTimeImpl& theValForTime);
217 InitMed2VisuArray(std::vector<int>& anArray, EGeometry aEGeom);
220 //---------------------------------------------------------------