Salome HOME
[Bug PAL7444] display mesh takes a lot of more memory in 2.1.0 than in 2.0.0.
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
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 // IDL Headers
33 #include "SALOMEconfig.h"
34 #include CORBA_SERVER_HEADER(SMESH_Mesh)
35 #include CORBA_SERVER_HEADER(SMESH_Group)
36
37 #include <map>
38 #include <list>
39
40 #include "SMESH_Controls.hxx"
41 #include "SMESH_Object.h"
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 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 void              Update( int theIsClear = true ) = 0;
64   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
65   virtual int               GetElemDimension( const int theObjId ) = 0;
66
67   virtual int               GetNbEntities( const SMDSAbs_ElementType theType) const = 0;
68   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const = 0;
69   virtual bool              IsNodePrs() const = 0;
70   virtual SMDS_Mesh*        GetMesh() const = 0;
71
72   virtual bool              GetEdgeNodes( const int theElemId,
73                                           const int theEdgeNum,
74                                           int&      theNodeId1,
75                                           int&      theNodeId2 ) const;
76
77   virtual vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
78   
79   virtual vtkIdType         GetNodeObjId( int theVTKID );
80   virtual vtkIdType         GetNodeVTKId( int theObjID );
81   virtual vtkIdType         GetElemObjId( int theVTKID );
82   virtual vtkIdType         GetElemVTKId( int theObjID );
83   
84 protected:
85
86   void                      createPoints( vtkPoints* );
87   void                      buildPrs();
88   void                      buildNodePrs();
89   void                      buildElemPrs();
90   
91 private:                                   
92
93   TMapOfIds                 mySMDS2VTKNodes;
94   TMapOfIds                 myVTK2SMDSNodes;
95   TMapOfIds                 mySMDS2VTKElems;
96   TMapOfIds                 myVTK2SMDSElems;
97
98   vtkUnstructuredGrid*      myGrid;
99 };
100
101
102 /*
103   Class       : SMESH_MeshObj
104   Description : Class for visualisation of mesh
105 */
106
107 class SMESH_MeshObj: public SMESH_VisualObjDef
108 {
109 public:
110
111                             SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
112   virtual                   ~SMESH_MeshObj();
113   
114   virtual void              Update( int theIsClear = true );
115   
116   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
117   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
118   virtual bool              IsNodePrs() const;
119
120   virtual int               GetElemDimension( const int theObjId );
121
122   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
123   
124   SMESH::SMESH_Mesh_ptr     GetMeshServer() { return myMeshServer.in(); }
125   SMDS_Mesh*                GetMesh() const { return myMesh; }
126
127 protected:
128
129   SMESH::SMESH_Mesh_var     myMeshServer;
130   SMDS_Mesh*                myMesh;
131 };
132
133
134 /*
135   Class       : SMESH_SubMeshObj
136   Description : Base class for visualisation of submeshes and groups
137 */
138
139 class SMESH_SubMeshObj: public SMESH_VisualObjDef
140 {
141 public:
142
143                             SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
144   virtual                   ~SMESH_SubMeshObj();
145
146   virtual void              Update( int theIsClear = true );
147   
148   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
149   virtual int               GetElemDimension( const int theObjId );
150   virtual SMDS_Mesh*        GetMesh() const { return myMeshObj->GetMesh(); }
151   
152 protected:
153
154   SMESH_MeshObj*            myMeshObj;
155 };
156
157
158 /*
159   Class       : SMESH_GroupObj
160   Description : Class for visualisation of groups
161 */
162
163 class SMESH_GroupObj: public SMESH_SubMeshObj
164 {
165 public:
166                             SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
167   virtual                   ~SMESH_GroupObj();
168
169   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
170   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
171   virtual bool              IsNodePrs() const;
172
173 private:
174
175   SMESH::SMESH_GroupBase_var    myGroupServer;
176 };
177
178
179 /*
180   Class       : SMESH_subMeshObj
181   Description : Class for visualisation of submeshes
182 */
183
184 class SMESH_subMeshObj : public SMESH_SubMeshObj
185 {
186 public:
187
188                             SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr, 
189                                               SMESH_MeshObj* );
190   virtual                   ~SMESH_subMeshObj();
191
192   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
193   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
194   virtual bool              IsNodePrs() const;    
195   
196 protected:
197
198   SMESH::SMESH_subMesh_var  mySubMeshServer;
199 };
200
201
202 #endif