#include "utilities.h"
#include <vtkUnstructuredGrid.h>
+#include <vtkCellType.h>
#include <vtkXMLUnstructuredGridWriter.h>
#include <vtkUnstructuredGridWriter.h>
+#include <vtkUnsignedCharArray.h>
//#ifdef _DEBUG_
//static int MYDEBUG = 1;
}
}
+ std::map<SMDSAbs_ElementType,int> GetEntitiesFromObject(SMESH_VisualObj *theObject) {
+ std::map<SMDSAbs_ElementType,int> entities;
+ entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_0DElement,
+ theObject ? theObject->GetNbEntities(SMDSAbs_0DElement) : 0));
+ entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_Edge,
+ theObject ? theObject->GetNbEntities(SMDSAbs_Edge) : 0));
+ entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_Face,
+ theObject ? theObject->GetNbEntities(SMDSAbs_Face) : 0));
+ entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_Volume,
+ theObject ? theObject->GetNbEntities(SMDSAbs_Volume) : 0));
+ return entities;
+ }
+
+
#ifndef DISABLE_PLOT2DVIEWER
//=======================================================================
MESSAGE("---------------------------------------------SMESH_VisualObjDef::SMESH_VisualObjDef");
myGrid = vtkUnstructuredGrid::New();
myLocalGrid = false;
+ ClearEntitiesFlags();
+ SMESH::GetEntitiesFromObject(NULL);
}
SMESH_VisualObjDef::~SMESH_VisualObjDef()
{
GetMesh()->compactMesh();
}
vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
+ updateEntitiesFlags();
myGrid->ShallowCopy(theGrid);
//MESSAGE(myGrid->GetReferenceCount());
//MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
if ( !myLocalGrid && !GetMesh()->isCompacted() )
{
GetMesh()->compactMesh();
+ updateEntitiesFlags();
vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
myGrid->ShallowCopy(theGrid);
}
GetNbEntities(SMDSAbs_Volume) > 0 ;
}
+//=================================================================================
+// function : updateEntitiesFlags
+// purpose : Update entities flags
+//=================================================================================
+void SMESH_VisualObjDef::updateEntitiesFlags() {
+
+ unsigned int tmp = myEntitiesState;
+ ClearEntitiesFlags();
+
+ map<SMDSAbs_ElementType,int> entities = SMESH::GetEntitiesFromObject(this);
+
+
+ if( myEntitiesCache[SMDSAbs_0DElement] != 0 || myEntitiesCache[SMDSAbs_0DElement] >= entities[SMDSAbs_0DElement] )
+ myEntitiesState &= ~SMESH_Actor::e0DElements;
+
+ if( myEntitiesCache[SMDSAbs_Edge] != 0 || myEntitiesCache[SMDSAbs_Edge] >= entities[SMDSAbs_Edge] )
+ myEntitiesState &= ~SMESH_Actor::eEdges;
+
+ if( myEntitiesCache[SMDSAbs_Face] != 0 || myEntitiesCache[SMDSAbs_Face] >= entities[SMDSAbs_Face] )
+ myEntitiesState &= ~SMESH_Actor::eFaces;
+
+ if( myEntitiesCache[SMDSAbs_Volume] != 0 || myEntitiesCache[SMDSAbs_Volume] >= entities[SMDSAbs_Volume] )
+ myEntitiesState &= ~SMESH_Actor::eVolumes;
+
+ if( tmp != myEntitiesState ) {
+ myEntitiesFlag = true;
+ }
+
+ myEntitiesCache = entities;
+}
+
+//=================================================================================
+// function : ClearEntitiesFlags
+// purpose : Clear the entities flags
+//=================================================================================
+void SMESH_VisualObjDef::ClearEntitiesFlags() {
+ myEntitiesState = SMESH_Actor::eAllEntity;
+ myEntitiesFlag = false;
+}
+
+//=================================================================================
+// function : GetEntitiesFlag
+// purpose : Return the entities flag
+//=================================================================================
+bool SMESH_VisualObjDef::GetEntitiesFlag() {
+ return myEntitiesFlag;
+}
+
+//=================================================================================
+// function : GetEntitiesState
+// purpose : Return the entities state
+//=================================================================================
+unsigned int SMESH_VisualObjDef::GetEntitiesState() {
+ return myEntitiesState;
+}
+
/*
Class : SMESH_MeshObj
Description : Class for visualisation of mesh
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
#include "SMESH_Client.hxx"
+#include "SMESH_Actor.h"
// IDL Headers
#include <SALOMEconfig.h>
class vtkPoints;
class SALOME_ExtractUnstructuredGrid;
-class SMESH_Actor;
class SMDS_MeshNode;
class SMDS_MeshElement;
virtual vtkIdType GetElemObjId( int theVTKID );
virtual vtkIdType GetElemVTKId( int theObjID );
+ virtual void ClearEntitiesFlags();
+ virtual bool GetEntitiesFlag();
+ virtual unsigned int GetEntitiesState();
+
protected:
void createPoints( vtkPoints* );
void buildPrs(bool buildGrid = false);
void buildNodePrs();
void buildElemPrs();
-
+ void updateEntitiesFlags();
//private:
TMapOfIds mySMDS2VTKNodes;
TMapOfIds myVTK2SMDSElems;
bool myLocalGrid;
+ bool myEntitiesFlag;
+ unsigned int myEntitiesState;
+
vtkUnstructuredGrid* myGrid;
+ std::map<SMDSAbs_ElementType,int> myEntitiesCache;
};