Salome HOME
f136c3714289f4a8a02fc5e354a9fb0b401a8fa8
[modules/smesh.git] / src / OBJECT / SMESH_ObjectDef.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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 //  SMESH OBJECT : interactive object for SMESH visualization
23 //  File   : SMESH_Object.h
24 //  Author : Nicolas REJNERI
25 //  Module : SMESH
26 //  $Header$
27 //
28 #ifndef SMESH_OBJECTDEF_H
29 #define SMESH_OBJECTDEF_H
30
31 #include "SMESH_Controls.hxx"
32 #include "SMESH_Object.h"
33 #include "SMESH_Client.hxx"
34
35 // IDL Headers
36 #include <SALOMEconfig.h>
37 #include CORBA_SERVER_HEADER(SMESH_Mesh)
38 #include CORBA_SERVER_HEADER(SMESH_Group)
39
40 #include <map>
41 #include <list>
42
43 class vtkPoints;
44 class SALOME_ExtractUnstructuredGrid;
45
46 class SMESH_Actor;
47 class SMDS_MeshNode;
48 class SMDS_MeshElement;
49
50 /*
51   Class       : SMESH_VisualObj
52   Description : Base class for all mesh objects to be visuilised
53 */
54 class SMESHOBJECT_EXPORT SMESH_VisualObjDef: public SMESH_VisualObj
55 {
56 public:
57   typedef std::list<const SMDS_MeshElement*>   TEntityList;
58   typedef std::map<vtkIdType,vtkIdType>  TMapOfIds;
59   
60                             SMESH_VisualObjDef();
61   virtual                   ~SMESH_VisualObjDef();
62   
63   virtual bool              Update( int theIsClear = true ) = 0;
64   virtual bool              NulData() {return 0; };
65   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
66   virtual int               GetElemDimension( const int theObjId ) = 0;
67
68   virtual int               GetNbEntities( const SMDSAbs_ElementType theType) const = 0;
69   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const = 0;
70   virtual bool              IsNodePrs() const = 0;
71   virtual SMDS_Mesh*        GetMesh() const = 0;
72
73   virtual bool              IsValid() const;
74
75   virtual bool              GetEdgeNodes( const int theElemId,
76                                           const int theEdgeNum,
77                                           int&      theNodeId1,
78                                           int&      theNodeId2 ) const;
79
80   virtual vtkUnstructuredGrid* GetUnstructuredGrid();
81   
82   virtual vtkIdType         GetNodeObjId( int theVTKID );
83   virtual vtkIdType         GetNodeVTKId( int theObjID );
84   virtual vtkIdType         GetElemObjId( int theVTKID );
85   virtual vtkIdType         GetElemVTKId( int theObjID );
86   
87 protected:
88
89   void                      createPoints( vtkPoints* );
90   void                      buildPrs(bool buildGrid = false);
91   void                      buildNodePrs();
92   void                      buildElemPrs();
93   
94 //private:
95
96   TMapOfIds                 mySMDS2VTKNodes;
97   TMapOfIds                 myVTK2SMDSNodes;
98   TMapOfIds                 mySMDS2VTKElems;
99   TMapOfIds                 myVTK2SMDSElems;
100   bool                      myLocalGrid;
101
102   vtkUnstructuredGrid*      myGrid;
103 };
104
105
106 /*
107   Class       : SMESH_MeshObj
108   Description : Class for visualisation of mesh
109 */
110
111 class SMESHOBJECT_EXPORT SMESH_MeshObj: public SMESH_VisualObjDef
112 {
113 public:
114
115                             SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
116   virtual                   ~SMESH_MeshObj();
117   
118   virtual bool              Update( int theIsClear = true );
119   virtual bool              NulData();
120   
121   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
122   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
123   virtual bool              IsNodePrs() const;
124
125   virtual int               GetElemDimension( const int theObjId );
126
127   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
128   
129   SMESH::SMESH_Mesh_ptr     GetMeshServer() { return myClient.GetMeshServer(); }
130   SMDS_Mesh*                GetMesh() const { return myClient.GetMesh(); }
131
132 protected:
133   SMESH_Client              myClient;
134   vtkUnstructuredGrid*      myEmptyGrid;
135 };
136
137
138 /*
139   Class       : SMESH_SubMeshObj
140   Description : Base class for visualisation of submeshes and groups
141 */
142
143 class SMESHOBJECT_EXPORT SMESH_SubMeshObj: public SMESH_VisualObjDef
144 {
145 public:
146
147                             SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
148   virtual                   ~SMESH_SubMeshObj();
149
150   virtual bool              Update( int theIsClear = true );
151   
152   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
153   virtual int               GetElemDimension( const int theObjId );
154   virtual SMDS_Mesh*        GetMesh() const { return myMeshObj->GetMesh(); }
155   
156 protected:
157
158   SMESH_MeshObj*            myMeshObj;
159 };
160
161
162 /*
163   Class       : SMESH_GroupObj
164   Description : Class for visualisation of groups
165 */
166
167 class SMESHOBJECT_EXPORT SMESH_GroupObj: public SMESH_SubMeshObj
168 {
169 public:
170                             SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
171   virtual                   ~SMESH_GroupObj();
172
173   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
174   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
175   virtual bool              IsNodePrs() const;
176
177   virtual SMDSAbs_ElementType GetElementType() const;
178
179 private:
180
181   SMESH::SMESH_GroupBase_var    myGroupServer;
182 };
183
184
185 /*
186   Class       : SMESH_subMeshObj
187   Description : Class for visualisation of submeshes
188 */
189
190 class SMESHOBJECT_EXPORT SMESH_subMeshObj : public SMESH_SubMeshObj
191 {
192 public:
193
194                             SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr, 
195                                               SMESH_MeshObj* );
196   virtual                   ~SMESH_subMeshObj();
197
198   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
199   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
200   virtual bool              IsNodePrs() const;    
201   
202 protected:
203
204   SMESH::SMESH_subMesh_var  mySubMeshServer;
205 };
206
207
208 #endif