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_PointCoords_HeaderFile
28 #define VISU_PointCoords_HeaderFile
31 \file VISU_PointCoords.hxx
32 \brief The file contains declarations for basic interfaces that defines point coords of mesh elements
35 #include "VISUConvertor.hxx"
36 #include "VISU_Convertor.hxx"
37 #include "VISU_ConvertorDef_impl.hxx"
39 #include "MED_SliceArray.hxx"
40 #include "MED_Structures.hxx"
42 #include <vtkSmartPointer.h>
48 //---------------------------------------------------------------
49 typedef vtkSmartPointer<vtkPointSet> PPointSet;
51 typedef MED::TFloat TCoord;
52 using MED::TCoordSlice;
53 using MED::TCCoordSlice;
55 //---------------------------------------------------------------
56 //! This class is responsible for keeping the mesh node coordinates
57 class VISU_CONVERTOR_EXPORT TCoordHolderBase: public virtual TBaseStructure
60 //! To initilize the instance
62 Init(vtkIdType theNbPoints,
74 //! Gets memory size used by the instance (bytes).
79 //! Get slice of coordinates for defined node (const version)
82 GetCoordSlice(vtkIdType theNodeId) const = 0;
84 //! Get slice of coordinates for defined node
87 GetCoordSlice(vtkIdType theNodeId) = 0;
94 vtkIdType myDim; //!< Dimension of the nodal coordinates
95 vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh
97 typedef MED::SharedPtr<TCoordHolderBase> PCoordHolder;
100 //---------------------------------------------------------------
101 template<class TContainerType>
102 class TCoordHolder: public virtual TCoordHolderBase
105 //! To initilize the class instance
107 Init(vtkIdType theNbPoints,
109 const TContainerType& theCoord)
111 TCoordHolderBase::Init(theNbPoints, theDim);
115 //! Gets pointer to the first element in the node coordinates array
120 //! Gets pointer to the first element in the node coordinates array (const version)
123 GetPointer() const = 0;
125 //! Get slice of coordinates for defined node (const version)
128 GetCoordSlice(vtkIdType theNodeId) const
130 return TCCoordSlice(this->GetPointer(),
132 std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
135 //! Get slice of coordinates for defined node
138 GetCoordSlice(vtkIdType theNodeId)
140 return TCoordSlice(this->GetPointer(),
142 std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
149 return (unsigned char*)this->GetPointer();
153 mutable TContainerType myCoord; //!< Keeps the node coordinates container itself
157 //---------------------------------------------------------------
158 //! This class is responsible for representation of mesh nodes
159 class VISU_CONVERTOR_EXPORT TPointCoords: public virtual TIsVTKDone
164 //! To initilize the class
166 Init(const PCoordHolder& theCoord);
176 GetPointSet() const; //!< Gets corresponding VTK structure
178 //! Gets memory size used by the instance (bytes).
183 //! Get slice of coordinates for defined node (const version)
185 GetCoordSlice(vtkIdType theNodeId) const;
187 //! Get slice of coordinates for defined node
189 GetCoordSlice(vtkIdType theNodeId);
191 //! Get object number for node by its VTK one
194 GetObjID(vtkIdType theID) const;
196 //! Get VTK number for node by its object one
199 GetVTKID(vtkIdType theID) const;
202 //! An container for coordinates of the nodes
204 Usage of slices allow to minimize amount of memory to store the nodal coordinates and
205 provide unifirm way of conversation with this coordinates (independant from mesh dimension)
207 PCoordHolder myCoord; //!< A pointer to the coordinates container holder
208 PPointSet myPointSet; //!< VTK representation for the mesh nodes
211 SetVoidArray() const; //!< Passes the MED node coordinates data directly to VTK
215 //---------------------------------------------------------------
216 //! This class is responsible for representation of mesh nodes
218 In additition to its base functionlity it support mapping of VTK to object numeration and
219 keeps names for each of nodes.
221 class VISU_CONVERTOR_EXPORT TNamedPointCoords: public virtual TPointCoords
224 //! To initilize the class (numeration of the nodes can be missed)
226 Init(const PCoordHolder& theCoord);
228 //! Get name for defined dimension
230 GetName(vtkIdType theDim);
232 //! Get name for defined dimension (const version)
234 GetName(vtkIdType theDim) const;
236 //! Get name of node by its object number
239 GetNodeName(vtkIdType theObjID) const;
243 GetPointSet() const; //!< Gets initialized corresponding VTK structure
245 //! Gets memory size used by the instance (bytes).
251 typedef TVector<std::string> TPointsDim;
252 TPointsDim myPointsDim; //!< Keeps name of each dimension
256 //---------------------------------------------------------------