1 // SMESH OBJECT : interactive object for SMESH visualization
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_Object.h
25 // Author : Nicolas REJNERI
29 #ifndef SMESH_OBJECT_H
30 #define SMESH_OBJECT_H
33 #include "SALOMEconfig.h"
34 #include CORBA_SERVER_HEADER(SMESH_Mesh)
35 #include CORBA_SERVER_HEADER(SMESH_Group)
39 #include <boost/shared_ptr.hpp>
40 #include <vtkSystemIncludes.h>
42 #include "SMESH_Controls.hxx"
44 class vtkUnstructuredGrid;
46 class SALOME_ExtractUnstructuredGrid;
51 class SMDS_MeshElement;
53 class SMESH_VisualObj;
54 typedef boost::shared_ptr<SMESH_VisualObj> TVisualObjPtr;
58 Class : SMESH_VisualObj
59 Description : Base class for all mesh objects to be visuilised
65 typedef std::list<const SMDS_MeshElement*> TEntityList;
66 typedef std::map<vtkIdType,vtkIdType> TMapOfIds;
70 virtual ~SMESH_VisualObj();
72 virtual void Update( int theIsClear = true ) = 0;
73 virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
74 virtual int GetElemDimension( const int theObjId ) = 0;
76 virtual int GetNbEntities( const SMESH::ElementType) const = 0;
77 virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const = 0;
78 virtual bool IsNodePrs() const = 0;
79 virtual SMDS_Mesh* GetMesh() const = 0;
81 bool GetEdgeNodes( const int theElemId,
84 int& theNodeId2 ) const;
86 vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
88 vtkIdType GetNodeObjId( int theVTKID );
89 vtkIdType GetNodeVTKId( int theObjID );
90 vtkIdType GetElemObjId( int theVTKID );
91 vtkIdType GetElemVTKId( int theObjID );
95 void createPoints( vtkPoints* );
102 TMapOfIds mySMDS2VTKNodes;
103 TMapOfIds myVTK2SMDSNodes;
104 TMapOfIds mySMDS2VTKElems;
105 TMapOfIds myVTK2SMDSElems;
107 vtkUnstructuredGrid* myGrid;
112 Class : SMESH_MeshObj
113 Description : Class for visualisation of mesh
116 class SMESH_MeshObj: public SMESH_VisualObj
120 SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
121 virtual ~SMESH_MeshObj();
123 virtual void Update( int theIsClear = true );
125 virtual int GetNbEntities( const SMESH::ElementType) const;
126 virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
127 virtual bool IsNodePrs() const;
129 virtual int GetElemDimension( const int theObjId );
131 virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
133 SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); }
134 SMDS_Mesh* GetMesh() const { return myMesh; }
138 SMESH::SMESH_Mesh_var myMeshServer;
144 Class : SMESH_SubMeshObj
145 Description : Base class for visualisation of submeshes and groups
148 class SMESH_SubMeshObj: public SMESH_VisualObj
152 SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
153 virtual ~SMESH_SubMeshObj();
155 virtual void Update( int theIsClear = true );
157 virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
158 virtual int GetElemDimension( const int theObjId );
159 virtual SMDS_Mesh* GetMesh() const { return myMeshObj->GetMesh(); }
163 SMESH_MeshObj* myMeshObj;
168 Class : SMESH_GroupObj
169 Description : Class for visualisation of groups
172 class SMESH_GroupObj: public SMESH_SubMeshObj
175 SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
176 virtual ~SMESH_GroupObj();
178 virtual int GetNbEntities( const SMESH::ElementType) const;
179 virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
180 virtual bool IsNodePrs() const;
184 SMESH::SMESH_GroupBase_var myGroupServer;
189 Class : SMESH_subMeshObj
190 Description : Class for visualisation of submeshes
193 class SMESH_subMeshObj : public SMESH_SubMeshObj
197 SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr,
199 virtual ~SMESH_subMeshObj();
201 virtual int GetNbEntities( const SMESH::ElementType) const;
202 virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
203 virtual bool IsNodePrs() const;
207 SMESH::SMESH_subMesh_var mySubMeshServer;
211 extern void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName);