]> SALOME platform Git repositories - modules/visu.git/blob - src/CONVERTOR/VISU_IDMapper.hxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / CONVERTOR / VISU_IDMapper.hxx
1 //  VISU CONVERTOR :
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //  File   : VISU_Convertor.hxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #ifndef VISU_IDMapper_HeaderFile
28 #define VISU_IDMapper_HeaderFile
29
30 /*! 
31   \file VISU_IDMapper.hxx
32   \brief The file contains declarations for basic interfaces that defines mapping of mesh elements
33 */
34
35 #include "VISUConvertor.hxx"
36
37 #include "MED_SharedPtr.hxx"
38 #include "MED_Vector.hxx"
39 #include "VTKViewer.h"
40
41 #include <string>
42 #include <map>
43
44 class vtkUnstructuredGrid;
45 class vtkPolyData;
46 class vtkDataSet;
47 class vtkCell;
48
49 namespace VISU
50 {
51   using MED::SharedPtr;
52   using MED::TVector;
53
54   
55   typedef TVector<vtkIdType> TIdTypeVector;
56   typedef std::map<vtkIdType,TIdTypeVector> TObj2IdTypeVector;
57   
58   struct VISU_CONVERTOR_EXPORT TStructured
59   {
60     TStructured():
61       myIsStructured(false),
62       myType(true)
63     {}
64
65     virtual
66     bool
67     IsStructured() const;
68
69     /*!
70      * Get structure of grille
71      * see also MED::TGrilleInfo::GetGrilleStructure
72      * see also MED::TGrilleInfo::GetNbIndexes
73      */
74     virtual TIdTypeVector
75     GetStructure();
76     
77     /*!
78      * Gets i,j,k by object id
79      * return -1, if not found
80      */
81     virtual TIdTypeVector
82     GetIndexesOfNode(vtkIdType theNodeId);
83
84     /*!
85      * Gets object id by i,j,k
86      * return -1, if not found
87      */
88     virtual vtkIdType
89     GetObjectIDByIndexes(TIdTypeVector theVec);
90
91   public:
92     bool myIsStructured; //!< To define mesh type (structured - true, non structured - false)
93     bool myType; //!< To define structured mesh is polair
94
95     /*!provides grille structure for structured grid.
96      * Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ...
97      */
98     TIdTypeVector myGrilleStructure;
99     
100     TObj2IdTypeVector myObjID2StructureID;//!< map of object id to i,j,k ids of structured grid nodes
101     
102   };
103   
104   //---------------------------------------------------------------
105   //! Defines a basic class for intemediate data structures
106   struct VISU_CONVERTOR_EXPORT TBaseStructure: virtual TStructured
107   {
108     //! Just to provide possibility of dynamic navigation through the class hierarchy
109     virtual ~TBaseStructure()
110     {}
111
112     std::string myEntry; //!< To simplify publication of the object tree
113   };
114   typedef MED::SharedPtr<TBaseStructure> PBaseStructure;
115
116   //---------------------------------------------------------------
117   //! Defines a basic abstract interface for VTK to object ID's and backward mapping
118   /*!
119     Where object ID means ID which attached to corresponding MED entity.
120     For example, each MED node can have its own ID as well as any other mesh cell
121   */
122   struct VISU_CONVERTOR_EXPORT TIDMapper: virtual TBaseStructure
123   {
124     //! Get node object ID for corresponding VTK ID
125     virtual 
126     vtkIdType 
127     GetNodeObjID(vtkIdType theID) const;
128
129     //! Get node VTK ID for corresponding object ID
130     virtual 
131     vtkIdType 
132     GetNodeVTKID(vtkIdType theID) const;
133
134     //! Get coordinates of node for corresponding object ID
135     virtual
136     vtkFloatingPointType* 
137     GetNodeCoord(vtkIdType theObjID);
138
139     //! Get cell object ID for corresponding VTK ID
140     virtual 
141     vtkIdType 
142     GetElemObjID(vtkIdType theID) const;
143
144     //! Get cell VTK ID for corresponding object ID
145     virtual 
146     vtkIdType 
147     GetElemVTKID(vtkIdType theID) const;
148
149     //! Get VTK representation of mesh cell for corresponding object ID
150     virtual
151     vtkCell* 
152     GetElemCell(vtkIdType theObjID);
153
154     //! Get VTK representation of mesh for corresponding MED entity
155     virtual
156     vtkDataSet*
157     GetOutput() = 0;
158
159     //! Gets memory size used by the instance (bytes).
160     virtual
161     unsigned long int
162     GetMemorySize() = 0;
163   };
164   typedef MED::SharedPtr<TIDMapper> PIDMapper;
165   
166
167   //---------------------------------------------------------------
168   struct VISU_CONVERTOR_EXPORT TUnstructuredGridIDMapper: virtual TIDMapper
169   {
170     //! Get VTK representation of mesh for corresponding MED entity
171     virtual
172     vtkUnstructuredGrid*
173     GetUnstructuredGridOutput() = 0;
174
175     //! Reimplement the TIDMapper::GetOutput
176     virtual
177     vtkDataSet*
178     GetOutput();
179   };
180   typedef MED::SharedPtr<TUnstructuredGridIDMapper> PUnstructuredGridIDMapper;
181   
182
183   //---------------------------------------------------------------
184   //! Defines an abstract interface for VTK to object ID's and backward mapping
185   /*!
186     This class defines some additional methods that allow get names for corresponding mesh elements
187   */
188   struct TNamedIDMapper: virtual TUnstructuredGridIDMapper
189   {
190     //! Get name of mesh node for corresponding object ID
191     virtual
192     std::string 
193     GetNodeName(vtkIdType theObjID) const = 0;
194
195     //! Get name of mesh cell for corresponding object ID
196     virtual
197     std::string 
198     GetElemName(vtkIdType theObjID) const = 0;
199   };
200   typedef MED::SharedPtr<TNamedIDMapper> PNamedIDMapper;
201   
202
203   //---------------------------------------------------------------
204   struct TPolyDataIDMapper: virtual TIDMapper
205   {
206     //! Get VTK representation of mesh for corresponding MED entity
207     virtual
208     vtkPolyData*
209     GetPolyDataOutput() = 0;
210
211     //! Reimplement the TIDMapper::GetOutput
212     virtual
213     vtkDataSet*
214     GetOutput();
215   };
216   typedef MED::SharedPtr<TPolyDataIDMapper> PPolyDataIDMapper;
217   
218
219   //---------------------------------------------------------------
220   typedef vtkIdType TCellID; 
221   typedef vtkIdType TLocalPntID;
222   //! Defines a type that represent complex ID for defined Gauss Point
223   typedef std::pair<TCellID,TLocalPntID> TGaussPointID;
224
225   struct TGaussPtsIDMapper: virtual TPolyDataIDMapper
226   {
227     //! Gets complex Gauss Point ID by its VTK ID
228     virtual 
229     TGaussPointID 
230     GetObjID(vtkIdType theID) const = 0;
231
232     //! Gets VTK ID by its complex Gauss Point ID 
233     virtual 
234     vtkIdType 
235     GetVTKID(const TGaussPointID& theID) const = 0;
236
237     //! Gets parent TNamedIDMapper, which contains reference mesh cells
238     virtual 
239     TNamedIDMapper*
240     GetParent() const = 0;
241   };
242   typedef MED::SharedPtr<TGaussPtsIDMapper> PGaussPtsIDMapper;
243
244   //---------------------------------------------------------------
245 }
246
247 #endif