Salome HOME
Merge from V6_main 11/02/2013
[modules/smesh.git] / src / OBJECT / SMESH_ObjectDef.h
1 // Copyright (C) 2007-2012  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
23 //  SMESH OBJECT : interactive object for SMESH visualization
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 #include "SMESH_Actor.h"
36
37 // IDL Headers
38 #include <SALOMEconfig.h>
39 #include CORBA_SERVER_HEADER(SMESH_Mesh)
40 #include CORBA_SERVER_HEADER(SMESH_Group)
41
42 #include <map>
43 #include <list>
44
45 class vtkPoints;
46 class SALOME_ExtractUnstructuredGrid;
47
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 bool              NulData() {return 0; };
66   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
67   virtual int               GetElemDimension( const int theObjId ) = 0;
68
69   virtual int               GetNbEntities( const SMDSAbs_ElementType theType) const = 0;
70   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const = 0;
71   virtual bool              IsNodePrs() const = 0;
72   virtual SMDS_Mesh*        GetMesh() const = 0;
73   virtual SMESH::SMESH_Mesh_ptr GetMeshServer() = 0;
74
75   virtual bool              IsValid() const;
76
77   virtual bool              GetEdgeNodes( const int theElemId,
78                                           const int theEdgeNum,
79                                           int&      theNodeId1,
80                                           int&      theNodeId2 ) const;
81
82   virtual vtkUnstructuredGrid* GetUnstructuredGrid();
83   
84   virtual vtkIdType         GetNodeObjId( int theVTKID );
85   virtual vtkIdType         GetNodeVTKId( int theObjID );
86   virtual vtkIdType         GetElemObjId( int theVTKID );
87   virtual vtkIdType         GetElemVTKId( int theObjID );
88   
89   virtual void              ClearEntitiesFlags();
90   virtual bool              GetEntitiesFlag();
91   virtual unsigned int      GetEntitiesState();
92   
93 protected:
94
95   void                      createPoints( vtkPoints* );
96   void                      buildPrs(bool buildGrid = false);
97   void                      buildNodePrs();
98   void                      buildElemPrs();
99   void                      updateEntitiesFlags();
100 //private:
101
102   TMapOfIds                 mySMDS2VTKNodes;
103   TMapOfIds                 myVTK2SMDSNodes;
104   TMapOfIds                 mySMDS2VTKElems;
105   TMapOfIds                 myVTK2SMDSElems;
106   bool                      myLocalGrid;
107
108   bool                      myEntitiesFlag;
109   unsigned int              myEntitiesState;
110
111   vtkUnstructuredGrid*      myGrid;
112   std::map<SMDSAbs_ElementType,int> myEntitiesCache;
113 };
114
115
116 /*
117   Class       : SMESH_MeshObj
118   Description : Class for visualisation of mesh
119 */
120
121 class SMESHOBJECT_EXPORT SMESH_MeshObj: public SMESH_VisualObjDef
122 {
123 public:
124
125                             SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
126   virtual                   ~SMESH_MeshObj();
127   
128   virtual bool              Update( int theIsClear = true );
129   virtual bool              NulData();
130   
131   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
132   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
133   virtual bool              IsNodePrs() const;
134
135   virtual int               GetElemDimension( const int theObjId );
136
137   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
138   
139   virtual SMESH::SMESH_Mesh_ptr GetMeshServer() { return myClient.GetMeshServer(); }
140   virtual SMDS_Mesh*        GetMesh() const { return myClient.GetMesh(); }
141
142 protected:
143
144   SMESH_Client              myClient;
145   vtkUnstructuredGrid*      myEmptyGrid;
146 };
147
148
149 /*
150   Class       : SMESH_SubMeshObj
151   Description : Base class for visualisation of submeshes and groups
152 */
153
154 class SMESHOBJECT_EXPORT SMESH_SubMeshObj: public SMESH_VisualObjDef
155 {
156 public:
157
158                             SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
159   virtual                   ~SMESH_SubMeshObj();
160
161   virtual bool              Update( int theIsClear = true );
162   
163   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
164   virtual int               GetElemDimension( const int theObjId );
165   virtual SMDS_Mesh*        GetMesh() const { return myMeshObj->GetMesh(); }
166   virtual SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshObj->GetMeshServer(); }
167   
168 protected:
169
170   SMESH_MeshObj*            myMeshObj;
171 };
172
173
174 /*
175   Class       : SMESH_GroupObj
176   Description : Class for visualisation of groups
177 */
178
179 class SMESHOBJECT_EXPORT SMESH_GroupObj: public SMESH_SubMeshObj
180 {
181 public:
182                             SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
183   virtual                   ~SMESH_GroupObj();
184
185   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
186   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
187   virtual bool              IsNodePrs() const;
188
189   virtual SMDSAbs_ElementType GetElementType() const;
190
191 private:
192
193   SMESH::SMESH_GroupBase_var    myGroupServer;
194 };
195
196
197 /*
198   Class       : SMESH_subMeshObj
199   Description : Class for visualisation of submeshes
200 */
201
202 class SMESHOBJECT_EXPORT SMESH_subMeshObj : public SMESH_SubMeshObj
203 {
204 public:
205
206                             SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr, 
207                                               SMESH_MeshObj* );
208   virtual                   ~SMESH_subMeshObj();
209
210   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
211   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
212   virtual bool              IsNodePrs() const;    
213   
214 protected:
215
216   SMESH::SMESH_subMesh_var  mySubMeshServer;
217 };
218
219
220 #endif