Version: 6.3.1

src/CONVERTOR/VISU_MeshValue.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  VISU CONVERTOR :
00024 //  File   : VISU_Convertor.hxx
00025 //  Author : Alexey PETROV
00026 //  Module : VISU
00027 //
00028 #ifndef VISU_MeshValue_HeaderFile
00029 #define VISU_MeshValue_HeaderFile
00030 
00036 #include "VISU_Convertor.hxx"
00037 #include "VISU_ConvertorDef_impl.hxx"
00038 
00039 #include "MED_SliceArray.hxx"
00040 #include "MED_Vector.hxx"
00041 
00042 namespace VISU
00043 {
00044   //---------------------------------------------------------------
00046   class VISU_CONVERTOR_EXPORT TMeshValueBase
00047   {
00048   public:
00050     void
00051     Init(vtkIdType theNbElem,
00052          vtkIdType theNbGauss,
00053          vtkIdType theNbComp);
00054 
00056     virtual
00057     unsigned long int
00058     GetMemorySize() const = 0;
00059 
00061     vtkIdType
00062     GetNbElem() const;
00063 
00065     vtkIdType
00066     GetNbComp() const;
00067 
00069     vtkIdType
00070     GetNbGauss() const;
00071 
00072     size_t
00073     size() const;
00074 
00075   protected:
00076     vtkIdType myNbElem; 
00077     vtkIdType myNbComp; 
00078     vtkIdType myNbGauss; 
00079     vtkIdType myStep; 
00080   };
00081   typedef MED::SharedPtr<TMeshValueBase> PMeshValue;
00082 
00083 
00084   //---------------------------------------------------------------
00086   template<class TValueType>
00087   class VISU_CONVERTOR_EXPORT TTMeshValue: public virtual TMeshValueBase
00088   {
00089   public:
00090     typedef MED::TSlice<TValueType> TValueSlice;
00091     typedef MED::TCSlice<TValueType> TCValueSlice;
00092     
00093     typedef TVector<TCValueSlice> TCValueSliceArr;
00094     typedef TVector<TValueSlice> TValueSliceArr;
00095 
00096     virtual
00097     const TValueType*
00098     GetPointer() const = 0;
00099 
00100     virtual
00101     TValueType*
00102     GetPointer() = 0;
00103 
00105     TCValueSliceArr
00106     GetGaussValueSliceArr(vtkIdType theElemId) const
00107     {
00108       TCValueSliceArr aValueSliceArr(this->myNbGauss);
00109       vtkIdType anId = theElemId * this->myStep;
00110       for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
00111         aValueSliceArr[aGaussId] =
00112           TCValueSlice(this->GetPointer(), 
00113                        this->size(),
00114                        std::slice(anId, this->myNbComp, 1));
00115         anId += this->myNbComp;
00116       }
00117       return aValueSliceArr;
00118     }
00119 
00121     TValueSliceArr 
00122     GetGaussValueSliceArr(vtkIdType theElemId)
00123     {
00124       TValueSliceArr aValueSliceArr(this->myNbGauss);
00125       vtkIdType anId = theElemId * this->myStep;
00126       for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
00127         aValueSliceArr[aGaussId] =
00128           TValueSlice(this->GetPointer(), 
00129                       this->size(),
00130                       std::slice(anId, this->myNbComp, 1));
00131         anId += this->myNbComp;
00132       }
00133       return aValueSliceArr;
00134     }
00135 
00137     TCValueSliceArr
00138     GetCompValueSliceArr(vtkIdType theElemId) const
00139     {
00140       TCValueSliceArr aValueSliceArr(this->myNbComp);
00141       vtkIdType anId = theElemId * this->myStep;
00142       for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
00143         aValueSliceArr[aCompId] =
00144           TCValueSlice(this->GetPointer(), 
00145                        this->size(),
00146                        std::slice(anId, this->myNbGauss, this->myNbComp));
00147         anId += 1;
00148       }
00149       return aValueSliceArr;
00150     }
00151 
00153     TValueSliceArr 
00154     GetCompValueSliceArr(vtkIdType theElemId)
00155     {
00156       TValueSliceArr aValueSliceArr(this->myNbComp);
00157       vtkIdType anId = theElemId * this->myStep;
00158       for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
00159         aValueSliceArr[aCompId] =
00160           TValueSlice(this->GetPointer(), 
00161                       this->size(),
00162                       std::slice(anId, this->myNbGauss, this->myNbComp));
00163         anId += 1;
00164       }
00165       return aValueSliceArr;
00166     }
00167 
00169     virtual
00170     unsigned long int
00171     GetMemorySize() const
00172     {
00173       return this->size() * sizeof(TValueType);
00174     }
00175   };
00176   
00177 
00178   //---------------------------------------------------------------
00180   template<class TValueType, class TContainerType>
00181   class TTMeshValueHolder: public virtual TTMeshValue<TValueType>
00182   {
00183   public:
00185     void
00186     Init(vtkIdType theNbElem,
00187          vtkIdType theNbGauss,
00188          vtkIdType theNbComp,
00189          const TContainerType& theContainer)
00190     {
00191       TMeshValueBase::Init(theNbElem, theNbGauss, theNbComp);
00192       myContainer = theContainer;
00193     }
00194 
00195   protected:
00196     mutable TContainerType myContainer; 
00197   };
00198 
00199 
00200   //---------------------------------------------------------------
00201   // Initilize corresponding vtkDataSetAttributes for TValForTime
00202   void 
00203   GetTimeStampOnProfile(const PUnstructuredGrid& theSource,
00204                         const PFieldImpl& theField, 
00205                         const PValForTimeImpl& theValForTime,
00206                         const VISU::TEntity& theEntity);
00207 
00208 
00209   //---------------------------------------------------------------
00210   // Initilize corresponding vtkDataSetAttributes for TValForTime
00211   void 
00212   GetTimeStampOnGaussMesh(const PPolyData& theSource,
00213                           const PFieldImpl& theField, 
00214                           const PValForTimeImpl& theValForTime);
00215 
00216   void 
00217   InitMed2VisuArray(std::vector<int>& anArray, EGeometry aEGeom);
00218 
00219 
00220   //---------------------------------------------------------------
00221 }
00222 
00223 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS