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