Salome HOME
a488a210c105ab42137511dce461db07634aeec5
[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 "MED_SharedPtr.hxx"
36 #include "VTKViewer.h"
37
38 #include <string>
39
40 class vtkUnstructuredGrid;
41 class vtkCell;
42
43 namespace VISU
44 {
45   using MED::SharedPtr;
46
47   //---------------------------------------------------------------
48   //! Defines a basic class for intemediate data structures
49   struct TBaseStructure
50   {
51     //! Just to provide possibility of dynamic navigation through the class hierarchy
52     virtual ~TBaseStructure()
53     {}
54
55     std::string myEntry; //!< To simplify publication of the object tree
56   };
57   typedef SharedPtr<TBaseStructure> PBaseStructure;
58
59   //---------------------------------------------------------------
60   typedef vtkUnstructuredGrid TVTKOutput;
61
62   //! Defines a basic abstract interface for VTK to object ID's and backward mapping
63   /*!
64     Where object ID means ID which attached to corresponding MED entity.
65     For example, each MED node can have its own ID as well as any other mesh cell
66   */
67   struct TIDMapper: virtual TBaseStructure
68   {
69     //! Get node object ID for corresponding VTK ID
70     virtual 
71     vtkIdType 
72     GetNodeObjID(vtkIdType theID) const;
73
74     //! Get node VTK ID for corresponding object ID
75     virtual 
76     vtkIdType 
77     GetNodeVTKID(vtkIdType theID) const;
78
79     //! Get coordinates of node for corresponding object ID
80     virtual
81     vtkFloatingPointType* 
82     GetNodeCoord(vtkIdType theObjID);
83
84     //! Get cell object ID for corresponding VTK ID
85     virtual 
86     vtkIdType 
87     GetElemObjID(vtkIdType theID) const;
88
89     //! Get cell VTK ID for corresponding object ID
90     virtual 
91     vtkIdType 
92     GetElemVTKID(vtkIdType theID) const;
93
94     //! Get VTK representation of mesh cell for corresponding object ID
95     virtual
96     vtkCell* 
97     GetElemCell(vtkIdType theObjID);
98
99     //! Get VTK representation of mesh for corresponding MED entity
100     virtual
101     TVTKOutput*
102     GetVTKOutput() = 0;
103   };
104   typedef SharedPtr<TIDMapper> PIDMapper;
105   
106
107   //---------------------------------------------------------------
108   //! Defines an abstract interface for VTK to object ID's and backward mapping
109   /*!
110     This class defines some additional methods that allow get names for corresponding mesh elements
111   */
112   struct TNamedIDMapper: virtual TIDMapper
113   {
114     //! Get name of mesh node for corresponding object ID
115     virtual
116     std::string 
117     GetNodeName(vtkIdType theObjID) const = 0;
118
119     //! Get name of mesh cell for corresponding object ID
120     virtual
121     std::string 
122     GetElemName(vtkIdType theObjID) const = 0;
123   };
124   typedef SharedPtr<TNamedIDMapper> PNamedIDMapper;
125   
126
127   //---------------------------------------------------------------
128   typedef vtkIdType TCellID; 
129   typedef vtkIdType TLocalPntID;
130   //! Defines a type that represent complex ID for defined Gauss Point
131   typedef std::pair<TCellID,TLocalPntID> TGaussPointID;
132
133   struct TGaussPtsIDMapper: virtual TIDMapper
134   {
135     //! Gets complex Gauss Point ID by its VTK ID
136     virtual 
137     TGaussPointID 
138     GetObjID(vtkIdType theID) const = 0;
139
140     //! Gets parent TNamedIDMapper, which contains reference mesh cells
141     virtual 
142     TNamedIDMapper*
143     GetParent() = 0;
144   };
145   typedef SharedPtr<TGaussPtsIDMapper> PGaussPtsIDMapper;
146
147   //---------------------------------------------------------------
148 }
149
150 #endif