Back to index

salome-smesh  6.5.0
SMESH_ObjectDef.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH OBJECT : interactive object for SMESH visualization
00024 //  File   : SMESH_Object.h
00025 //  Author : Nicolas REJNERI
00026 //  Module : SMESH
00027 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/OBJECT/SMESH_ObjectDef.h,v 1.7.2.2.6.4.2.1 2012-04-13 09:31:05 vsr Exp $
00028 //
00029 #ifndef SMESH_OBJECTDEF_H
00030 #define SMESH_OBJECTDEF_H
00031 
00032 #include "SMESH_Controls.hxx"
00033 #include "SMESH_Object.h"
00034 #include "SMESH_Client.hxx"
00035 #include "SMESH_Actor.h"
00036 
00037 // IDL Headers
00038 #include <SALOMEconfig.h>
00039 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00040 #include CORBA_SERVER_HEADER(SMESH_Group)
00041 
00042 #include <map>
00043 #include <list>
00044 
00045 class vtkPoints;
00046 class SALOME_ExtractUnstructuredGrid;
00047 
00048 class SMDS_MeshNode;
00049 class SMDS_MeshElement;
00050 
00051 /*
00052   Class       : SMESH_VisualObj
00053   Description : Base class for all mesh objects to be visuilised
00054 */
00055 class SMESHOBJECT_EXPORT SMESH_VisualObjDef: public SMESH_VisualObj
00056 {
00057 public:
00058   typedef std::list<const SMDS_MeshElement*>   TEntityList;
00059   typedef std::map<vtkIdType,vtkIdType>  TMapOfIds;
00060   
00061                             SMESH_VisualObjDef();
00062   virtual                   ~SMESH_VisualObjDef();
00063   
00064   virtual bool              Update( int theIsClear = true ) = 0;
00065   virtual bool              NulData() {return 0; };
00066   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
00067   virtual int               GetElemDimension( const int theObjId ) = 0;
00068 
00069   virtual int               GetNbEntities( const SMDSAbs_ElementType theType) const = 0;
00070   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const = 0;
00071   virtual bool              IsNodePrs() const = 0;
00072   virtual SMDS_Mesh*        GetMesh() const = 0;
00073 
00074   virtual bool              IsValid() const;
00075 
00076   virtual bool              GetEdgeNodes( const int theElemId,
00077                                           const int theEdgeNum,
00078                                           int&      theNodeId1,
00079                                           int&      theNodeId2 ) const;
00080 
00081   virtual vtkUnstructuredGrid* GetUnstructuredGrid();
00082   
00083   virtual vtkIdType         GetNodeObjId( int theVTKID );
00084   virtual vtkIdType         GetNodeVTKId( int theObjID );
00085   virtual vtkIdType         GetElemObjId( int theVTKID );
00086   virtual vtkIdType         GetElemVTKId( int theObjID );
00087   
00088   virtual void              ClearEntitiesFlags();
00089   virtual bool              GetEntitiesFlag();
00090   virtual unsigned int      GetEntitiesState();
00091   
00092 protected:
00093 
00094   void                      createPoints( vtkPoints* );
00095   void                      buildPrs(bool buildGrid = false);
00096   void                      buildNodePrs();
00097   void                      buildElemPrs();
00098   void                      updateEntitiesFlags();
00099 //private:
00100 
00101   TMapOfIds                 mySMDS2VTKNodes;
00102   TMapOfIds                 myVTK2SMDSNodes;
00103   TMapOfIds                 mySMDS2VTKElems;
00104   TMapOfIds                 myVTK2SMDSElems;
00105   bool                      myLocalGrid;
00106 
00107   bool                      myEntitiesFlag;
00108   unsigned int              myEntitiesState;
00109 
00110   vtkUnstructuredGrid*      myGrid;
00111   std::map<SMDSAbs_ElementType,int> myEntitiesCache;
00112 };
00113 
00114 
00115 /*
00116   Class       : SMESH_MeshObj
00117   Description : Class for visualisation of mesh
00118 */
00119 
00120 class SMESHOBJECT_EXPORT SMESH_MeshObj: public SMESH_VisualObjDef
00121 {
00122 public:
00123 
00124                             SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
00125   virtual                   ~SMESH_MeshObj();
00126   
00127   virtual bool              Update( int theIsClear = true );
00128   virtual bool              NulData();
00129   
00130   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
00131   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
00132   virtual bool              IsNodePrs() const;
00133 
00134   virtual int               GetElemDimension( const int theObjId );
00135 
00136   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
00137   
00138   SMESH::SMESH_Mesh_ptr     GetMeshServer() { return myClient.GetMeshServer(); }
00139   SMDS_Mesh*                GetMesh() const { return myClient.GetMesh(); }
00140 
00141 protected:
00142   SMESH_Client              myClient;
00143   vtkUnstructuredGrid*      myEmptyGrid;
00144 };
00145 
00146 
00147 /*
00148   Class       : SMESH_SubMeshObj
00149   Description : Base class for visualisation of submeshes and groups
00150 */
00151 
00152 class SMESHOBJECT_EXPORT SMESH_SubMeshObj: public SMESH_VisualObjDef
00153 {
00154 public:
00155 
00156                             SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
00157   virtual                   ~SMESH_SubMeshObj();
00158 
00159   virtual bool              Update( int theIsClear = true );
00160   
00161   virtual void              UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
00162   virtual int               GetElemDimension( const int theObjId );
00163   virtual SMDS_Mesh*        GetMesh() const { return myMeshObj->GetMesh(); }
00164   
00165 protected:
00166 
00167   SMESH_MeshObj*            myMeshObj;
00168 };
00169 
00170 
00171 /*
00172   Class       : SMESH_GroupObj
00173   Description : Class for visualisation of groups
00174 */
00175 
00176 class SMESHOBJECT_EXPORT SMESH_GroupObj: public SMESH_SubMeshObj
00177 {
00178 public:
00179                             SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
00180   virtual                   ~SMESH_GroupObj();
00181 
00182   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
00183   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
00184   virtual bool              IsNodePrs() const;
00185 
00186   virtual SMDSAbs_ElementType GetElementType() const;
00187 
00188 private:
00189 
00190   SMESH::SMESH_GroupBase_var    myGroupServer;
00191 };
00192 
00193 
00194 /*
00195   Class       : SMESH_subMeshObj
00196   Description : Class for visualisation of submeshes
00197 */
00198 
00199 class SMESHOBJECT_EXPORT SMESH_subMeshObj : public SMESH_SubMeshObj
00200 {
00201 public:
00202 
00203                             SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr, 
00204                                               SMESH_MeshObj* );
00205   virtual                   ~SMESH_subMeshObj();
00206 
00207   virtual int               GetNbEntities( const SMDSAbs_ElementType) const;
00208   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
00209   virtual bool              IsNodePrs() const;    
00210   
00211 protected:
00212 
00213   SMESH::SMESH_subMesh_var  mySubMeshServer;
00214 };
00215 
00216 
00217 #endif