1 // Copyright (C) 2007-2012 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_PointCoords_HeaderFile
29 #define VISU_PointCoords_HeaderFile
32 \file VISU_PointCoords.hxx
33 \brief The file contains declarations for basic interfaces that defines point coords of mesh elements
36 #include "VISUConvertor.hxx"
37 #include "VISU_Convertor.hxx"
38 #include "VISU_ConvertorDef_impl.hxx"
40 #include "MED_SliceArray.hxx"
41 #include "MED_Structures.hxx"
43 #include <vtkSmartPointer.h>
49 //---------------------------------------------------------------
50 typedef vtkSmartPointer<vtkPointSet> PPointSet;
52 typedef MED::TFloat TCoord;
53 using MED::TCoordSlice;
54 using MED::TCCoordSlice;
56 //---------------------------------------------------------------
57 //! This class is responsible for keeping the mesh node coordinates
58 class VISU_CONVERTOR_EXPORT TCoordHolderBase: public virtual TBaseStructure
61 //! To initilize the instance
63 Init(vtkIdType theNbPoints,
75 //! Gets memory size used by the instance (bytes).
80 //! Get slice of coordinates for defined node (const version)
83 GetCoordSlice(vtkIdType theNodeId) const = 0;
85 //! Get slice of coordinates for defined node
88 GetCoordSlice(vtkIdType theNodeId) = 0;
95 vtkIdType myDim; //!< Dimension of the nodal coordinates
96 vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh
98 typedef MED::SharedPtr<TCoordHolderBase> PCoordHolder;
101 //---------------------------------------------------------------
102 template<class TContainerType>
103 class TCoordHolder: public virtual TCoordHolderBase
106 //! To initilize the class instance
108 Init(vtkIdType theNbPoints,
110 const TContainerType& theCoord)
112 TCoordHolderBase::Init(theNbPoints, theDim);
116 //! Gets pointer to the first element in the node coordinates array
121 //! Gets pointer to the first element in the node coordinates array (const version)
124 GetPointer() const = 0;
126 //! Get slice of coordinates for defined node (const version)
129 GetCoordSlice(vtkIdType theNodeId) const
131 return TCCoordSlice(this->GetPointer(),
133 std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
136 //! Get slice of coordinates for defined node
139 GetCoordSlice(vtkIdType theNodeId)
141 return TCoordSlice(this->GetPointer(),
143 std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
150 return (unsigned char*)this->GetPointer();
154 mutable TContainerType myCoord; //!< Keeps the node coordinates container itself
158 //---------------------------------------------------------------
159 //! This class is responsible for representation of mesh nodes
160 class VISU_CONVERTOR_EXPORT TPointCoords: public virtual TIsVTKDone
165 //! To initilize the class
167 Init(const PCoordHolder& theCoord);
177 GetPointSet() const; //!< Gets corresponding VTK structure
179 //! Gets memory size used by the instance (bytes).
184 //! Get slice of coordinates for defined node (const version)
186 GetCoordSlice(vtkIdType theNodeId) const;
188 //! Get slice of coordinates for defined node
190 GetCoordSlice(vtkIdType theNodeId);
192 //! Get object number for node by its VTK one
195 GetObjID(vtkIdType theID) const;
197 //! Get VTK number for node by its object one
200 GetVTKID(vtkIdType theID) const;
203 //! An container for coordinates of the nodes
205 Usage of slices allow to minimize amount of memory to store the nodal coordinates and
206 provide unifirm way of conversation with this coordinates (independant from mesh dimension)
208 PCoordHolder myCoord; //!< A pointer to the coordinates container holder
209 PPointSet myPointSet; //!< VTK representation for the mesh nodes
212 SetVoidArray() const; //!< Passes the MED node coordinates data directly to VTK
216 //---------------------------------------------------------------
217 //! This class is responsible for representation of mesh nodes
219 In additition to its base functionlity it support mapping of VTK to object numeration and
220 keeps names for each of nodes.
222 class VISU_CONVERTOR_EXPORT TNamedPointCoords: public virtual TPointCoords
225 //! To initilize the class (numeration of the nodes can be missed)
227 Init(const PCoordHolder& theCoord);
229 //! Get name for defined dimension
231 GetName(vtkIdType theDim);
233 //! Get name for defined dimension (const version)
235 GetName(vtkIdType theDim) const;
237 //! Get name of node by its object number
240 GetNodeName(vtkIdType theObjID) const;
244 GetPointSet() const; //!< Gets initialized corresponding VTK structure
246 //! Gets memory size used by the instance (bytes).
252 typedef TVector<std::string> TPointsDim;
253 TPointsDim myPointsDim; //!< Keeps name of each dimension
257 //---------------------------------------------------------------