To separate interface and implementation of the SMESH_Object class

This commit is contained in:
apo 2004-12-27 10:02:12 +00:00
parent bfe435ad43
commit d43a813fc0
16 changed files with 341 additions and 237 deletions

View File

@ -31,7 +31,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
@COMMENCE@ @COMMENCE@
EXPORT_HEADERS = SMESH_Actor.h SMESH_ActorDef.h SMESH_Object.h SMESH_ActorUtils.h EXPORT_HEADERS = SMESH_Actor.h SMESH_Object.h SMESH_ObjectDef.h SMESH_ActorUtils.h
# Libraries targets # Libraries targets

View File

@ -792,9 +792,9 @@ void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
const char* theEntry, const char* theEntry,
const char* theName, const char* theName,
int theIsClear) int theIsClear)
{ {
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName); Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
setIO(anIO); setIO(anIO);
@ -1047,13 +1047,13 @@ namespace{
} }
void SMESH_ActorDef::SetEntityMode(unsigned int theMode){ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
if(!myVisualObj->GetNbEntities(SMESH::EDGE)) if(!myVisualObj->GetNbEntities(SMDSAbs_Edge))
theMode &= ~eEdges; theMode &= ~eEdges;
if(!myVisualObj->GetNbEntities(SMESH::FACE)) if(!myVisualObj->GetNbEntities(SMDSAbs_Face))
theMode &= ~eFaces; theMode &= ~eFaces;
if(!myVisualObj->GetNbEntities(SMESH::VOLUME)) if(!myVisualObj->GetNbEntities(SMDSAbs_Volume))
theMode &= ~eVolumes; theMode &= ~eVolumes;
if(!theMode) if(!theMode)
@ -1080,9 +1080,9 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
} }
void SMESH_ActorDef::SetRepresentation(int theMode){ void SMESH_ActorDef::SetRepresentation(int theMode){
int aNbEdges = myVisualObj->GetNbEntities(SMESH::EDGE); int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
int aNbFaces = myVisualObj->GetNbEntities(SMESH::FACE); int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
int aNbVolumes = myVisualObj->GetNbEntities(SMESH::VOLUME); int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
if(theMode < 0){ if(theMode < 0){
myRepresentation = eSurface; myRepresentation = eSurface;
if(!aNbFaces && !aNbVolumes && aNbEdges){ if(!aNbFaces && !aNbVolumes && aNbEdges){

View File

@ -25,7 +25,8 @@
// Author : Nicolas REJNERI // Author : Nicolas REJNERI
// Module : SMESH // Module : SMESH
#include "SMESH_Object.h" #include "SMESH_ObjectDef.h"
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
@ -260,7 +261,7 @@ namespace{
} }
/* /*
Class : SMESH_VisualObj Class : SMESH_VisualObjDef
Description : Base class for all mesh objects to be visuilised Description : Base class for all mesh objects to be visuilised
*/ */
@ -268,36 +269,39 @@ namespace{
// function : getCellType // function : getCellType
// purpose : Get type of VTK cell // purpose : Get type of VTK cell
//================================================================================= //=================================================================================
static inline vtkIdType getCellType( const SMESH::ElementType theType, static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
const int theNbNodes ) const int theNbNodes )
{ {
switch( theType ) switch( theType )
{ {
case SMESH::EDGE: return theNbNodes == 2 ? VTK_LINE : VTK_EMPTY_CELL; case SMDSAbs_Edge:
return theNbNodes == 2 ? VTK_LINE : VTK_EMPTY_CELL;
case SMESH::FACE : if ( theNbNodes == 3 ) return VTK_TRIANGLE; case SMDSAbs_Face :
else if ( theNbNodes == 4 ) return VTK_QUAD; if ( theNbNodes == 3 ) return VTK_TRIANGLE;
else return VTK_EMPTY_CELL; else if ( theNbNodes == 4 ) return VTK_QUAD;
else return VTK_EMPTY_CELL;
case SMESH::VOLUME: if ( theNbNodes == 4 ) return VTK_TETRA;
else if ( theNbNodes == 5 ) return VTK_PYRAMID; case SMDSAbs_Volume:
else if ( theNbNodes == 6 ) return VTK_WEDGE; if ( theNbNodes == 4 ) return VTK_TETRA;
else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON; else if ( theNbNodes == 5 ) return VTK_PYRAMID;
else return VTK_EMPTY_CELL; else if ( theNbNodes == 6 ) return VTK_WEDGE;
else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
else return VTK_EMPTY_CELL;
default: return VTK_EMPTY_CELL; default: return VTK_EMPTY_CELL;
} }
} }
//================================================================================= //=================================================================================
// functions : SMESH_VisualObj // functions : SMESH_VisualObjDef
// purpose : Constructor // purpose : Constructor
//================================================================================= //=================================================================================
SMESH_VisualObj::SMESH_VisualObj() SMESH_VisualObjDef::SMESH_VisualObjDef()
{ {
myGrid = vtkUnstructuredGrid::New(); myGrid = vtkUnstructuredGrid::New();
} }
SMESH_VisualObj::~SMESH_VisualObj() SMESH_VisualObjDef::~SMESH_VisualObjDef()
{ {
if ( MYDEBUG ) if ( MYDEBUG )
MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() ); MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() );
@ -308,37 +312,37 @@ SMESH_VisualObj::~SMESH_VisualObj()
// functions : GetNodeObjId, GetNodeVTKId, GetElemObjId, GetElemVTKId // functions : GetNodeObjId, GetNodeVTKId, GetElemObjId, GetElemVTKId
// purpose : Methods for retrieving VTK IDs by SMDS IDs and vice versa // purpose : Methods for retrieving VTK IDs by SMDS IDs and vice versa
//================================================================================= //=================================================================================
vtkIdType SMESH_VisualObj::GetNodeObjId( int theVTKID ) vtkIdType SMESH_VisualObjDef::GetNodeObjId( int theVTKID )
{ {
return myVTK2SMDSNodes.find(theVTKID) == myVTK2SMDSNodes.end() ? -1 : myVTK2SMDSNodes[theVTKID]; return myVTK2SMDSNodes.find(theVTKID) == myVTK2SMDSNodes.end() ? -1 : myVTK2SMDSNodes[theVTKID];
} }
vtkIdType SMESH_VisualObj::GetNodeVTKId( int theObjID ) vtkIdType SMESH_VisualObjDef::GetNodeVTKId( int theObjID )
{ {
return mySMDS2VTKNodes.find(theObjID) == mySMDS2VTKNodes.end() ? -1 : mySMDS2VTKNodes[theObjID]; return mySMDS2VTKNodes.find(theObjID) == mySMDS2VTKNodes.end() ? -1 : mySMDS2VTKNodes[theObjID];
} }
vtkIdType SMESH_VisualObj::GetElemObjId( int theVTKID ) vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID )
{ {
return myVTK2SMDSElems.find(theVTKID) == myVTK2SMDSElems.end() ? -1 : myVTK2SMDSElems[theVTKID]; return myVTK2SMDSElems.find(theVTKID) == myVTK2SMDSElems.end() ? -1 : myVTK2SMDSElems[theVTKID];
} }
vtkIdType SMESH_VisualObj::GetElemVTKId( int theObjID ) vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID )
{ {
return mySMDS2VTKElems.find(theObjID) == mySMDS2VTKElems.end() ? -1 : mySMDS2VTKElems[theObjID]; return mySMDS2VTKElems.find(theObjID) == mySMDS2VTKElems.end() ? -1 : mySMDS2VTKElems[theObjID];
} }
//================================================================================= //=================================================================================
// function : SMESH_VisualObj::createPoints // function : SMESH_VisualObjDef::createPoints
// purpose : Create points from nodes // purpose : Create points from nodes
//================================================================================= //=================================================================================
void SMESH_VisualObj::createPoints( vtkPoints* thePoints ) void SMESH_VisualObjDef::createPoints( vtkPoints* thePoints )
{ {
if ( thePoints == 0 ) if ( thePoints == 0 )
return; return;
TEntityList aNodes; TEntityList aNodes;
vtkIdType nbNodes = GetEntities( SMESH::NODE, aNodes ); vtkIdType nbNodes = GetEntities( SMDSAbs_Node, aNodes );
thePoints->SetNumberOfPoints( nbNodes ); thePoints->SetNumberOfPoints( nbNodes );
int nbPoints = 0; int nbPoints = 0;
@ -365,7 +369,7 @@ void SMESH_VisualObj::createPoints( vtkPoints* thePoints )
// function : buildPrs // function : buildPrs
// purpose : create VTK cells( fill unstructured grid ) // purpose : create VTK cells( fill unstructured grid )
//================================================================================= //=================================================================================
void SMESH_VisualObj::buildPrs() void SMESH_VisualObjDef::buildPrs()
{ {
try try
{ {
@ -396,7 +400,7 @@ void SMESH_VisualObj::buildPrs()
// function : buildNodePrs // function : buildNodePrs
// purpose : create VTK cells for nodes // purpose : create VTK cells for nodes
//================================================================================= //=================================================================================
void SMESH_VisualObj::buildNodePrs() void SMESH_VisualObjDef::buildNodePrs()
{ {
vtkPoints* aPoints = vtkPoints::New(); vtkPoints* aPoints = vtkPoints::New();
createPoints( aPoints ); createPoints( aPoints );
@ -446,7 +450,7 @@ void SMESH_VisualObj::buildNodePrs()
// function : buildElemPrs // function : buildElemPrs
// purpose : Create VTK cells for elements // purpose : Create VTK cells for elements
//================================================================================= //=================================================================================
void SMESH_VisualObj::buildElemPrs() void SMESH_VisualObjDef::buildElemPrs()
{ {
// Create points // Create points
@ -460,7 +464,7 @@ void SMESH_VisualObj::buildElemPrs()
// Calculate cells size // Calculate cells size
static SMESH::ElementType aTypes[ 3 ] = { SMESH::EDGE, SMESH::FACE, SMESH::VOLUME }; static SMDSAbs_ElementType aTypes[ 3 ] = { SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Volume };
// get entity data // get entity data
map< int, int > nbEnts; map< int, int > nbEnts;
@ -469,7 +473,7 @@ void SMESH_VisualObj::buildElemPrs()
for ( int i = 0; i <= 2; i++ ) for ( int i = 0; i <= 2; i++ )
nbEnts[ aTypes[ i ] ] = GetEntities( aTypes[ i ], anEnts[ aTypes[ i ] ] ); nbEnts[ aTypes[ i ] ] = GetEntities( aTypes[ i ], anEnts[ aTypes[ i ] ] );
vtkIdType aCellsSize = 3 * nbEnts[ SMESH::EDGE ]; vtkIdType aCellsSize = 3 * nbEnts[ SMDSAbs_Edge ];
for ( int i = 1; i <= 2; i++ ) // iterate through faces and volumes for ( int i = 1; i <= 2; i++ ) // iterate through faces and volumes
{ {
@ -482,7 +486,7 @@ void SMESH_VisualObj::buildElemPrs()
} }
} }
vtkIdType aNbCells = nbEnts[ SMESH::EDGE ] + nbEnts[ SMESH::FACE ] + nbEnts[ SMESH::VOLUME ]; vtkIdType aNbCells = nbEnts[ SMDSAbs_Edge ] + nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
if ( MYDEBUG ) if ( MYDEBUG )
MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize ); MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize );
@ -554,10 +558,10 @@ void SMESH_VisualObj::buildElemPrs()
// function : GetEdgeNodes // function : GetEdgeNodes
// purpose : Retrieve ids of nodes from edge of elements ( edge is numbered from 1 ) // purpose : Retrieve ids of nodes from edge of elements ( edge is numbered from 1 )
//================================================================================= //=================================================================================
bool SMESH_VisualObj::GetEdgeNodes( const int theElemId, bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
const int theEdgeNum, const int theEdgeNum,
int& theNodeId1, int& theNodeId1,
int& theNodeId2 ) const int& theNodeId2 ) const
{ {
const SMDS_Mesh* aMesh = GetMesh(); const SMDS_Mesh* aMesh = GetMesh();
if ( aMesh == 0 ) if ( aMesh == 0 )
@ -753,26 +757,26 @@ int SMESH_MeshObj::GetElemDimension( const int theObjId )
// function : GetEntities // function : GetEntities
// purpose : Get entities of specified type. Return number of entities // purpose : Get entities of specified type. Return number of entities
//================================================================================= //=================================================================================
int SMESH_MeshObj::GetNbEntities( const SMESH::ElementType theType) const int SMESH_MeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{ {
switch ( theType ) switch ( theType )
{ {
case SMESH::NODE: case SMDSAbs_Node:
{ {
return myMesh->NbNodes(); return myMesh->NbNodes();
} }
break; break;
case SMESH::EDGE: case SMDSAbs_Edge:
{ {
return myMesh->NbEdges(); return myMesh->NbEdges();
} }
break; break;
case SMESH::FACE: case SMDSAbs_Face:
{ {
return myMesh->NbFaces(); return myMesh->NbFaces();
} }
break; break;
case SMESH::VOLUME: case SMDSAbs_Volume:
{ {
return myMesh->NbVolumes(); return myMesh->NbVolumes();
} }
@ -783,31 +787,31 @@ int SMESH_MeshObj::GetNbEntities( const SMESH::ElementType theType) const
} }
} }
int SMESH_MeshObj::GetEntities( const SMESH::ElementType theType, TEntityList& theObjs ) const int SMESH_MeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList& theObjs ) const
{ {
theObjs.clear(); theObjs.clear();
switch ( theType ) switch ( theType )
{ {
case SMESH::NODE: case SMDSAbs_Node:
{ {
SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator(); SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMESH::EDGE: case SMDSAbs_Edge:
{ {
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMESH::FACE: case SMDSAbs_Face:
{ {
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMESH::VOLUME: case SMDSAbs_Volume:
{ {
SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator(); SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
@ -957,14 +961,14 @@ static int getNodesFromElems( SMESH::long_array_var& theElemIds,
// function : getPointers // function : getPointers
// purpose : Get std::list<const SMDS_MeshElement*> from list of IDs // purpose : Get std::list<const SMDS_MeshElement*> from list of IDs
//================================================================================= //=================================================================================
static int getPointers( const SMESH::ElementType theRequestType, static int getPointers( const SMDSAbs_ElementType theRequestType,
SMESH::long_array_var& theElemIds, SMESH::long_array_var& theElemIds,
const SMDS_Mesh* theMesh, const SMDS_Mesh* theMesh,
std::list<const SMDS_MeshElement*>& theResList ) std::list<const SMDS_MeshElement*>& theResList )
{ {
for ( CORBA::Long i = 0, n = theElemIds->length(); i < n; i++ ) for ( CORBA::Long i = 0, n = theElemIds->length(); i < n; i++ )
{ {
const SMDS_MeshElement* anElem = theRequestType == SMESH::NODE const SMDS_MeshElement* anElem = theRequestType == SMDSAbs_Node
? theMesh->FindNode( theElemIds[ i ] ) : theMesh->FindElement( theElemIds[ i ] ); ? theMesh->FindNode( theElemIds[ i ] ) : theMesh->FindElement( theElemIds[ i ] );
if ( anElem != 0 ) if ( anElem != 0 )
@ -979,15 +983,15 @@ static int getPointers( const SMESH::ElementType theRequestType,
// function : GetEntities // function : GetEntities
// purpose : Get entities of specified type. Return number of entities // purpose : Get entities of specified type. Return number of entities
//================================================================================= //=================================================================================
int SMESH_GroupObj::GetNbEntities( const SMESH::ElementType theType) const int SMESH_GroupObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{ {
if(myGroupServer->GetType() == theType){ if(SMDSAbs_ElementType(myGroupServer->GetType()) == theType){
return myGroupServer->Size(); return myGroupServer->Size();
} }
return 0; return 0;
} }
int SMESH_GroupObj::GetEntities( const SMESH::ElementType theType, TEntityList& theResList ) const int SMESH_GroupObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList& theResList ) const
{ {
theResList.clear(); theResList.clear();
SMDS_Mesh* aMesh = myMeshObj->GetMesh(); SMDS_Mesh* aMesh = myMeshObj->GetMesh();
@ -995,12 +999,12 @@ int SMESH_GroupObj::GetEntities( const SMESH::ElementType theType, TEntityList&
if ( myGroupServer->Size() == 0 || aMesh == 0 ) if ( myGroupServer->Size() == 0 || aMesh == 0 )
return 0; return 0;
SMESH::ElementType aGrpType = myGroupServer->GetType(); SMDSAbs_ElementType aGrpType = SMDSAbs_ElementType(myGroupServer->GetType());
SMESH::long_array_var anIds = myGroupServer->GetListOfID(); SMESH::long_array_var anIds = myGroupServer->GetListOfID();
if ( aGrpType == theType ) if ( aGrpType == theType )
return getPointers( theType, anIds, aMesh, theResList ); return getPointers( theType, anIds, aMesh, theResList );
else if ( theType == SMESH::NODE ) else if ( theType == SMDSAbs_Node )
return getNodesFromElems( anIds, aMesh, theResList ); return getNodesFromElems( anIds, aMesh, theResList );
else else
return 0; return 0;
@ -1037,20 +1041,21 @@ SMESH_subMeshObj::~SMESH_subMeshObj()
// function : GetEntities // function : GetEntities
// purpose : Get entities of specified type. Return number of entities // purpose : Get entities of specified type. Return number of entities
//================================================================================= //=================================================================================
int SMESH_subMeshObj::GetNbEntities( const SMESH::ElementType theType) const int SMESH_subMeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{ {
switch ( theType ) switch ( theType )
{ {
case SMESH::NODE: case SMDSAbs_Node:
{ {
return mySubMeshServer->GetNumberOfNodes( false ); return mySubMeshServer->GetNumberOfNodes( false );
} }
break; break;
case SMESH::EDGE: case SMDSAbs_Edge:
case SMESH::FACE: case SMDSAbs_Face:
case SMESH::VOLUME: case SMDSAbs_Volume:
{ {
SMESH::long_array_var anIds = mySubMeshServer->GetElementsByType( theType ); SMESH::long_array_var anIds =
mySubMeshServer->GetElementsByType( SMESH::ElementType(theType) );
return anIds->length(); return anIds->length();
} }
default: default:
@ -1059,7 +1064,7 @@ int SMESH_subMeshObj::GetNbEntities( const SMESH::ElementType theType) const
} }
} }
int SMESH_subMeshObj::GetEntities( const SMESH::ElementType theType, TEntityList& theResList ) const int SMESH_subMeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList& theResList ) const
{ {
theResList.clear(); theResList.clear();
@ -1071,22 +1076,23 @@ int SMESH_subMeshObj::GetEntities( const SMESH::ElementType theType, TEntityList
if ( isNodal ) if ( isNodal )
{ {
if ( theType == SMESH::NODE ) if ( theType == SMDSAbs_Node )
{ {
SMESH::long_array_var anIds = mySubMeshServer->GetNodesId(); SMESH::long_array_var anIds = mySubMeshServer->GetNodesId();
return getPointers( SMESH::NODE, anIds, aMesh, theResList ); return getPointers( SMDSAbs_Node, anIds, aMesh, theResList );
} }
} }
else else
{ {
if ( theType == SMESH::NODE ) if ( theType == SMDSAbs_Node )
{ {
SMESH::long_array_var anIds = mySubMeshServer->GetElementsId(); SMESH::long_array_var anIds = mySubMeshServer->GetElementsId();
return getNodesFromElems( anIds, aMesh, theResList ); return getNodesFromElems( anIds, aMesh, theResList );
} }
else else
{ {
SMESH::long_array_var anIds = mySubMeshServer->GetElementsByType( theType ); SMESH::long_array_var anIds =
mySubMeshServer->GetElementsByType( SMESH::ElementType(theType) );
return getPointers( theType, anIds, aMesh, theResList ); return getPointers( theType, anIds, aMesh, theResList );
} }
} }

View File

@ -29,30 +29,14 @@
#ifndef SMESH_OBJECT_H #ifndef SMESH_OBJECT_H
#define SMESH_OBJECT_H #define SMESH_OBJECT_H
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Group)
#include <map>
#include <list>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <vtkSystemIncludes.h> #include <vtkSystemIncludes.h>
#include "SMESH_Controls.hxx" #include "SMESH_Controls.hxx"
#include "SMDSAbs_ElementType.hxx"
class vtkUnstructuredGrid;
class vtkPoints;
class SALOME_ExtractUnstructuredGrid;
class SMESH_Actor;
class SMDS_Mesh; class SMDS_Mesh;
class SMDS_MeshNode; class vtkUnstructuredGrid;
class SMDS_MeshElement;
class SMESH_VisualObj;
typedef boost::shared_ptr<SMESH_VisualObj> TVisualObjPtr;
/* /*
Class : SMESH_VisualObj Class : SMESH_VisualObj
@ -60,155 +44,27 @@ typedef boost::shared_ptr<SMESH_VisualObj> TVisualObjPtr;
*/ */
class SMESH_VisualObj class SMESH_VisualObj
{ {
protected:
typedef std::list<const SMDS_MeshElement*> TEntityList;
typedef std::map<vtkIdType,vtkIdType> TMapOfIds;
public: public:
SMESH_VisualObj(); virtual void Update( int theIsClear = true ) = 0;
virtual ~SMESH_VisualObj(); virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0;
virtual int GetNbEntities( const SMDSAbs_ElementType theType) const = 0;
virtual SMDS_Mesh* GetMesh() const = 0;
virtual bool GetEdgeNodes( const int theElemId,
const int theEdgeNum,
int& theNodeId1,
int& theNodeId2 ) const = 0;
virtual void Update( int theIsClear = true ) = 0; virtual vtkUnstructuredGrid* GetUnstructuredGrid() = 0;
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0;
virtual int GetNbEntities( const SMESH::ElementType) const = 0;
virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const = 0;
virtual bool IsNodePrs() const = 0;
virtual SMDS_Mesh* GetMesh() const = 0;
bool GetEdgeNodes( const int theElemId,
const int theEdgeNum,
int& theNodeId1,
int& theNodeId2 ) const;
vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
vtkIdType GetNodeObjId( int theVTKID ); virtual vtkIdType GetNodeObjId( int theVTKID ) = 0;
vtkIdType GetNodeVTKId( int theObjID ); virtual vtkIdType GetNodeVTKId( int theObjID ) = 0;
vtkIdType GetElemObjId( int theVTKID ); virtual vtkIdType GetElemObjId( int theVTKID ) = 0;
vtkIdType GetElemVTKId( int theObjID ); virtual vtkIdType GetElemVTKId( int theObjID ) = 0;
protected:
void createPoints( vtkPoints* );
void buildPrs();
void buildNodePrs();
void buildElemPrs();
private:
TMapOfIds mySMDS2VTKNodes;
TMapOfIds myVTK2SMDSNodes;
TMapOfIds mySMDS2VTKElems;
TMapOfIds myVTK2SMDSElems;
vtkUnstructuredGrid* myGrid;
}; };
typedef boost::shared_ptr<SMESH_VisualObj> TVisualObjPtr;
/*
Class : SMESH_MeshObj
Description : Class for visualisation of mesh
*/
class SMESH_MeshObj: public SMESH_VisualObj
{
public:
SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
virtual ~SMESH_MeshObj();
virtual void Update( int theIsClear = true );
virtual int GetNbEntities( const SMESH::ElementType) const;
virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
virtual int GetElemDimension( const int theObjId );
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); }
SMDS_Mesh* GetMesh() const { return myMesh; }
protected:
SMESH::SMESH_Mesh_var myMeshServer;
SMDS_Mesh* myMesh;
};
/*
Class : SMESH_SubMeshObj
Description : Base class for visualisation of submeshes and groups
*/
class SMESH_SubMeshObj: public SMESH_VisualObj
{
public:
SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
virtual ~SMESH_SubMeshObj();
virtual void Update( int theIsClear = true );
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
virtual int GetElemDimension( const int theObjId );
virtual SMDS_Mesh* GetMesh() const { return myMeshObj->GetMesh(); }
protected:
SMESH_MeshObj* myMeshObj;
};
/*
Class : SMESH_GroupObj
Description : Class for visualisation of groups
*/
class SMESH_GroupObj: public SMESH_SubMeshObj
{
public:
SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
virtual ~SMESH_GroupObj();
virtual int GetNbEntities( const SMESH::ElementType) const;
virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
private:
SMESH::SMESH_GroupBase_var myGroupServer;
};
/*
Class : SMESH_subMeshObj
Description : Class for visualisation of submeshes
*/
class SMESH_subMeshObj : public SMESH_SubMeshObj
{
public:
SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr,
SMESH_MeshObj* );
virtual ~SMESH_subMeshObj();
virtual int GetNbEntities( const SMESH::ElementType) const;
virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
protected:
SMESH::SMESH_subMesh_var mySubMeshServer;
};
extern void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName);
#endif #endif

View File

@ -0,0 +1,207 @@
// SMESH OBJECT : interactive object for SMESH visualization
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Object.h
// Author : Nicolas REJNERI
// Module : SMESH
// $Header$
#ifndef SMESH_OBJECTDEF_H
#define SMESH_OBJECTDEF_H
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Group)
#include <map>
#include <list>
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
class vtkPoints;
class SALOME_ExtractUnstructuredGrid;
class SMESH_Actor;
class SMDS_MeshNode;
class SMDS_MeshElement;
/*
Class : SMESH_VisualObj
Description : Base class for all mesh objects to be visuilised
*/
class SMESH_VisualObjDef: public SMESH_VisualObj
{
protected:
typedef std::list<const SMDS_MeshElement*> TEntityList;
typedef std::map<vtkIdType,vtkIdType> TMapOfIds;
public:
SMESH_VisualObjDef();
virtual ~SMESH_VisualObjDef();
virtual void Update( int theIsClear = true ) = 0;
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0;
virtual int GetNbEntities( const SMDSAbs_ElementType theType) const = 0;
virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const = 0;
virtual bool IsNodePrs() const = 0;
virtual SMDS_Mesh* GetMesh() const = 0;
virtual bool GetEdgeNodes( const int theElemId,
const int theEdgeNum,
int& theNodeId1,
int& theNodeId2 ) const;
virtual vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
virtual vtkIdType GetNodeObjId( int theVTKID );
virtual vtkIdType GetNodeVTKId( int theObjID );
virtual vtkIdType GetElemObjId( int theVTKID );
virtual vtkIdType GetElemVTKId( int theObjID );
protected:
void createPoints( vtkPoints* );
void buildPrs();
void buildNodePrs();
void buildElemPrs();
private:
TMapOfIds mySMDS2VTKNodes;
TMapOfIds myVTK2SMDSNodes;
TMapOfIds mySMDS2VTKElems;
TMapOfIds myVTK2SMDSElems;
vtkUnstructuredGrid* myGrid;
};
/*
Class : SMESH_MeshObj
Description : Class for visualisation of mesh
*/
class SMESH_MeshObj: public SMESH_VisualObjDef
{
public:
SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
virtual ~SMESH_MeshObj();
virtual void Update( int theIsClear = true );
virtual int GetNbEntities( const SMDSAbs_ElementType) const;
virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
virtual int GetElemDimension( const int theObjId );
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); }
SMDS_Mesh* GetMesh() const { return myMesh; }
protected:
SMESH::SMESH_Mesh_var myMeshServer;
SMDS_Mesh* myMesh;
};
/*
Class : SMESH_SubMeshObj
Description : Base class for visualisation of submeshes and groups
*/
class SMESH_SubMeshObj: public SMESH_VisualObjDef
{
public:
SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
virtual ~SMESH_SubMeshObj();
virtual void Update( int theIsClear = true );
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
virtual int GetElemDimension( const int theObjId );
virtual SMDS_Mesh* GetMesh() const { return myMeshObj->GetMesh(); }
protected:
SMESH_MeshObj* myMeshObj;
};
/*
Class : SMESH_GroupObj
Description : Class for visualisation of groups
*/
class SMESH_GroupObj: public SMESH_SubMeshObj
{
public:
SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
virtual ~SMESH_GroupObj();
virtual int GetNbEntities( const SMDSAbs_ElementType) const;
virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
private:
SMESH::SMESH_GroupBase_var myGroupServer;
};
/*
Class : SMESH_subMeshObj
Description : Class for visualisation of submeshes
*/
class SMESH_subMeshObj : public SMESH_SubMeshObj
{
public:
SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr,
SMESH_MeshObj* );
virtual ~SMESH_subMeshObj();
virtual int GetNbEntities( const SMDSAbs_ElementType) const;
virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const;
protected:
SMESH::SMESH_subMesh_var mySubMeshServer;
};
extern void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName);
#endif

View File

@ -2381,9 +2381,9 @@ bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString
popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes # popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements # popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
TVisualObjPtr aVisualObj = anActor->GetObject(); TVisualObjPtr aVisualObj = anActor->GetObject();
int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE); int aNbEdges = aVisualObj->GetNbEntities(SMDSAbs_Edge);
int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE); int aNbFaces = aVisualObj->GetNbEntities(SMDSAbs_Face);
int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME); int aNbVolumes = aVisualObj->GetNbEntities(SMDSAbs_Volume);
QMenuItem* mi = popup->findItem( 1131 ); QMenuItem* mi = popup->findItem( 1131 );
if ( mi && mi->popup() ) { if ( mi && mi->popup() ) {

View File

@ -56,6 +56,10 @@
#include <qvalidator.h> #include <qvalidator.h>
#include <qpixmap.h> #include <qpixmap.h>
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Group)
using namespace std; using namespace std;
//================================================================================= //=================================================================================

View File

@ -81,6 +81,10 @@
#include <qobjectlist.h> #include <qobjectlist.h>
#include <qvalidator.h> #include <qvalidator.h>
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Group)
#define SPACING 5 #define SPACING 5
#define MARGIN 10 #define MARGIN 10

View File

@ -70,6 +70,10 @@
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qapplication.h> #include <qapplication.h>
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Group)
#define SPACING 5 #define SPACING 5
#define MARGIN 10 #define MARGIN 10

View File

@ -46,6 +46,8 @@
#include "QAD_MessageBox.h" #include "QAD_MessageBox.h"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_ObjectDef.h"
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"

View File

@ -56,6 +56,10 @@
#include <qvalidator.h> #include <qvalidator.h>
#include <qpixmap.h> #include <qpixmap.h>
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Group)
using namespace std; using namespace std;
//================================================================================= //=================================================================================

View File

@ -55,6 +55,10 @@
#include <qlayout.h> #include <qlayout.h>
#include <qpixmap.h> #include <qpixmap.h>
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Group)
using namespace std; using namespace std;
//================================================================================= //=================================================================================

View File

@ -58,6 +58,10 @@
#include <qvalidator.h> #include <qvalidator.h>
#include <qpixmap.h> #include <qpixmap.h>
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Group)
using namespace std; using namespace std;
//================================================================================= //=================================================================================

View File

@ -55,6 +55,10 @@
#include <qlayout.h> #include <qlayout.h>
#include <qpixmap.h> #include <qpixmap.h>
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Group)
using namespace std; using namespace std;
//================================================================================= //=================================================================================

View File

@ -56,6 +56,10 @@
#include <qspinbox.h> #include <qspinbox.h>
#include <qpixmap.h> #include <qpixmap.h>
// IDL Headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Group)
using namespace std; using namespace std;
//================================================================================= //=================================================================================

View File

@ -50,6 +50,7 @@
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_ObjectDef.h"
using namespace std; using namespace std;