1 // Copyright (C) 2007-2008 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
23 // File : VISU_Convertor.hxx
24 // Author : Alexey PETROV
27 #ifndef VISU_MeshValue_HeaderFile
28 #define VISU_MeshValue_HeaderFile
31 \file VISU_MeshValue.hxx
32 \brief The file contains declarations for basic interfaces that defines mesh value of mesh elements
35 #include "VISU_Convertor.hxx"
36 #include "VISU_ConvertorDef_impl.hxx"
38 #include "MED_SliceArray.hxx"
39 #include "MED_Vector.hxx"
43 //---------------------------------------------------------------
44 //! Define a base class for the container to get access to data assigned to mesh
45 class VISU_CONVERTOR_EXPORT TMeshValueBase
48 //! To intitilize the data strucutre
50 Init(vtkIdType theNbElem,
54 //! Gets memory size used by the instance (bytes).
57 GetMemorySize() const = 0;
59 //! Gets number of mesh elements where the data assigned to.
63 //! Gets number of components of corresponding MED FIELD.
67 //! Gets number of Gauss Points.
75 vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
76 vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
77 vtkIdType myNbGauss; //!< Defines number of Gauss Points
78 vtkIdType myStep; //!< Internal variable
80 typedef MED::SharedPtr<TMeshValueBase> PMeshValue;
83 //---------------------------------------------------------------
84 //! Define a container to get access to data assigned to mesh
85 template<class TValueType>
86 class VISU_CONVERTOR_EXPORT TTMeshValue: public virtual TMeshValueBase
89 typedef MED::TSlice<TValueType> TValueSlice;
90 typedef MED::TCSlice<TValueType> TCValueSlice;
92 typedef TVector<TCValueSlice> TCValueSliceArr;
93 typedef TVector<TValueSlice> TValueSliceArr;
97 GetPointer() const = 0;
103 //! To get assigned values first by Gauss Points and then by components (constant version)
105 GetGaussValueSliceArr(vtkIdType theElemId) const
107 TCValueSliceArr aValueSliceArr(this->myNbGauss);
108 vtkIdType anId = theElemId * this->myStep;
109 for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
110 aValueSliceArr[aGaussId] =
111 TCValueSlice(this->GetPointer(),
113 std::slice(anId, this->myNbComp, 1));
114 anId += this->myNbComp;
116 return aValueSliceArr;
119 //! To get assigned values first by Gauss Points and then by components
121 GetGaussValueSliceArr(vtkIdType theElemId)
123 TValueSliceArr aValueSliceArr(this->myNbGauss);
124 vtkIdType anId = theElemId * this->myStep;
125 for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
126 aValueSliceArr[aGaussId] =
127 TValueSlice(this->GetPointer(),
129 std::slice(anId, this->myNbComp, 1));
130 anId += this->myNbComp;
132 return aValueSliceArr;
135 //! To get assigned values first by components and then by Gauss Points (constant version)
137 GetCompValueSliceArr(vtkIdType theElemId) const
139 TCValueSliceArr aValueSliceArr(this->myNbComp);
140 vtkIdType anId = theElemId * this->myStep;
141 for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
142 aValueSliceArr[aCompId] =
143 TCValueSlice(this->GetPointer(),
145 std::slice(anId, this->myNbGauss, this->myNbComp));
148 return aValueSliceArr;
151 //! To get assigned values first by components and then by Gauss Points
153 GetCompValueSliceArr(vtkIdType theElemId)
155 TValueSliceArr aValueSliceArr(this->myNbComp);
156 vtkIdType anId = theElemId * this->myStep;
157 for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
158 aValueSliceArr[aCompId] =
159 TValueSlice(this->GetPointer(),
161 std::slice(anId, this->myNbGauss, this->myNbComp));
164 return aValueSliceArr;
167 //! Gets memory size used by the instance (bytes).
170 GetMemorySize() const
172 return this->size() * sizeof(TValueType);
177 //---------------------------------------------------------------
178 //! Define a container to get access to data assigned to mesh
179 template<class TValueType, class TContainerType>
180 class TTMeshValueHolder: public virtual TTMeshValue<TValueType>
183 //! To initilize the class instance
185 Init(vtkIdType theNbElem,
186 vtkIdType theNbGauss,
188 const TContainerType& theContainer)
190 TMeshValueBase::Init(theNbElem, theNbGauss, theNbComp);
191 myContainer = theContainer;
195 mutable TContainerType myContainer; //!< Keeps the mesh values container itself
199 //---------------------------------------------------------------
200 // Initilize corresponding vtkDataSetAttributes for TValForTime
202 GetTimeStampOnProfile(const PUnstructuredGrid& theSource,
203 const PFieldImpl& theField,
204 const PValForTimeImpl& theValForTime,
205 const VISU::TEntity& theEntity);
208 //---------------------------------------------------------------
209 // Initilize corresponding vtkDataSetAttributes for TValForTime
211 GetTimeStampOnGaussMesh(const PPolyData& theSource,
212 const PFieldImpl& theField,
213 const PValForTimeImpl& theValForTime);
216 InitMed2VisuArray(std::vector<int>& anArray, EGeometry aEGeom);
219 //---------------------------------------------------------------