Version: 6.3.1

src/CONVERTOR/VISU_PointCoords.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_PointCoords_HeaderFile
00029 #define VISU_PointCoords_HeaderFile
00030 
00036 #include "VISUConvertor.hxx"
00037 #include "VISU_Convertor.hxx"
00038 #include "VISU_ConvertorDef_impl.hxx"
00039 
00040 #include "MED_SliceArray.hxx"
00041 #include "MED_Structures.hxx"
00042 
00043 #include <vtkSmartPointer.h>
00044 
00045 class vtkPointSet;
00046 
00047 namespace VISU
00048 {
00049   //---------------------------------------------------------------
00050   typedef vtkSmartPointer<vtkPointSet> PPointSet;
00051 
00052   typedef MED::TFloat TCoord;
00053   using MED::TCoordSlice;
00054   using MED::TCCoordSlice;
00055 
00056   //---------------------------------------------------------------
00058   class VISU_CONVERTOR_EXPORT TCoordHolderBase: public virtual TBaseStructure
00059   {
00060   public:
00062     void
00063     Init(vtkIdType theNbPoints,
00064          vtkIdType theDim);
00065 
00066     vtkIdType
00067     GetNbPoints() const;
00068 
00069     vtkIdType
00070     GetDim() const;
00071 
00072     size_t
00073     size() const;
00074 
00076     virtual
00077     unsigned long int
00078     GetMemorySize();
00079 
00081     virtual
00082     TCCoordSlice
00083     GetCoordSlice(vtkIdType theNodeId) const = 0;
00084 
00086     virtual
00087     TCoordSlice 
00088     GetCoordSlice(vtkIdType theNodeId) = 0;
00089 
00090     virtual
00091     unsigned char*
00092     GetValuePtr() = 0;
00093 
00094   protected:
00095     vtkIdType myDim; 
00096     vtkIdType myNbPoints; 
00097   };
00098   typedef MED::SharedPtr<TCoordHolderBase> PCoordHolder;
00099 
00100 
00101   //---------------------------------------------------------------
00102   template<class TContainerType>
00103   class TCoordHolder: public virtual TCoordHolderBase
00104   {
00105   public:
00107     void
00108     Init(vtkIdType theNbPoints,
00109          vtkIdType theDim,
00110          const TContainerType& theCoord)
00111     {
00112       TCoordHolderBase::Init(theNbPoints, theDim);
00113       myCoord = theCoord;
00114     }
00115 
00117     virtual
00118     TCoord*
00119     GetPointer() = 0;
00120 
00122     virtual
00123     const TCoord*
00124     GetPointer() const = 0;
00125 
00127     virtual
00128     TCCoordSlice
00129     GetCoordSlice(vtkIdType theNodeId) const
00130     {
00131       return TCCoordSlice(this->GetPointer(), 
00132                           this->size(),
00133                           std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
00134     }
00135 
00137     virtual
00138     TCoordSlice 
00139     GetCoordSlice(vtkIdType theNodeId)
00140     {
00141       return TCoordSlice(this->GetPointer(), 
00142                          this->size(),
00143                          std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
00144     }
00145 
00146     virtual
00147     unsigned char*
00148     GetValuePtr()
00149     {
00150       return (unsigned char*)this->GetPointer();
00151     }
00152 
00153   protected:
00154     mutable TContainerType myCoord; 
00155   };
00156 
00157 
00158   //---------------------------------------------------------------
00160   class VISU_CONVERTOR_EXPORT TPointCoords: public virtual TIsVTKDone
00161   {
00162   public:
00163     TPointCoords();
00164 
00166     void
00167     Init(const PCoordHolder& theCoord);
00168 
00169     vtkIdType
00170     GetNbPoints() const;
00171 
00172     vtkIdType
00173     GetDim() const;
00174 
00175     virtual
00176     vtkPointSet*
00177     GetPointSet() const; 
00178 
00180     virtual
00181     unsigned long int
00182     GetMemorySize();
00183 
00185     TCCoordSlice
00186     GetCoordSlice(vtkIdType theNodeId) const;
00187 
00189     TCoordSlice 
00190     GetCoordSlice(vtkIdType theNodeId);
00191 
00193     virtual
00194     vtkIdType
00195     GetObjID(vtkIdType theID) const;
00196 
00198     virtual
00199     vtkIdType
00200     GetVTKID(vtkIdType theID) const;
00201 
00202   protected:
00204 
00208     PCoordHolder myCoord; 
00209     PPointSet myPointSet; 
00210 
00211     void
00212     SetVoidArray() const; 
00213   };
00214 
00215 
00216   //---------------------------------------------------------------
00218 
00222   class VISU_CONVERTOR_EXPORT TNamedPointCoords: public virtual TPointCoords
00223   {
00224   public:
00226     void
00227     Init(const PCoordHolder& theCoord);
00228     
00230     std::string&
00231     GetName(vtkIdType theDim);
00232     
00234     const std::string&
00235     GetName(vtkIdType theDim) const;
00236 
00238     virtual
00239     std::string 
00240     GetNodeName(vtkIdType theObjID) const;
00241 
00242     virtual
00243     vtkPointSet*
00244     GetPointSet() const; 
00245 
00247     virtual
00248     unsigned long int
00249     GetMemorySize();
00250 
00251   protected:
00252     typedef TVector<std::string> TPointsDim;
00253     TPointsDim myPointsDim; 
00254   };
00255 
00256 
00257   //---------------------------------------------------------------
00258 }
00259 
00260 #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