From: ana Date: Thu, 15 Dec 2011 13:32:32 +0000 (+0000) Subject: Fix for the bug IPAL22828 TC6.4.0: Displayed entities are wrong X-Git-Tag: V6_5_0a1~240 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6665afd414e242331517f0e0c80b0896371facfb;p=modules%2Fsmesh.git Fix for the bug IPAL22828 TC6.4.0: Displayed entities are wrong --- diff --git a/src/OBJECT/SMESH_ActorUtils.cxx b/src/OBJECT/SMESH_ActorUtils.cxx index ee0a31efd..3e2225b07 100644 --- a/src/OBJECT/SMESH_ActorUtils.cxx +++ b/src/OBJECT/SMESH_ActorUtils.cxx @@ -41,8 +41,10 @@ #include "utilities.h" #include +#include #include #include +#include //#ifdef _DEBUG_ //static int MYDEBUG = 1; @@ -155,6 +157,20 @@ namespace SMESH } } + std::map GetEntitiesFromObject(SMESH_VisualObj *theObject) { + std::map entities; + entities.insert(std::pair(SMDSAbs_0DElement, + theObject ? theObject->GetNbEntities(SMDSAbs_0DElement) : 0)); + entities.insert(std::pair(SMDSAbs_Edge, + theObject ? theObject->GetNbEntities(SMDSAbs_Edge) : 0)); + entities.insert(std::pair(SMDSAbs_Face, + theObject ? theObject->GetNbEntities(SMDSAbs_Face) : 0)); + entities.insert(std::pair(SMDSAbs_Volume, + theObject ? theObject->GetNbEntities(SMDSAbs_Volume) : 0)); + return entities; + } + + #ifndef DISABLE_PLOT2DVIEWER //======================================================================= diff --git a/src/OBJECT/SMESH_ActorUtils.h b/src/OBJECT/SMESH_ActorUtils.h index e98d0f5de..5d02aaa88 100644 --- a/src/OBJECT/SMESH_ActorUtils.h +++ b/src/OBJECT/SMESH_ActorUtils.h @@ -24,6 +24,7 @@ #define SMESH_ACTORUTILS_H #include "SMESH_Object.h" +#include #include @@ -75,6 +76,10 @@ SMESHOBJECT_EXPORT int& delta, QString def); + SMESHOBJECT_EXPORT + std::map + GetEntitiesFromObject(SMESH_VisualObj *theObject); + SMESHOBJECT_EXPORT void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index cfaa700cb..c12d63bfa 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -136,6 +136,8 @@ SMESH_VisualObjDef::SMESH_VisualObjDef() MESSAGE("---------------------------------------------SMESH_VisualObjDef::SMESH_VisualObjDef"); myGrid = vtkUnstructuredGrid::New(); myLocalGrid = false; + ClearEntitiesFlags(); + SMESH::GetEntitiesFromObject(NULL); } SMESH_VisualObjDef::~SMESH_VisualObjDef() { @@ -275,6 +277,7 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid) GetMesh()->compactMesh(); } vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); + updateEntitiesFlags(); myGrid->ShallowCopy(theGrid); //MESSAGE(myGrid->GetReferenceCount()); //MESSAGE( "Update - myGrid->GetNumberOfCells() = "<GetNumberOfCells() ); @@ -598,6 +601,7 @@ vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid() if ( !myLocalGrid && !GetMesh()->isCompacted() ) { GetMesh()->compactMesh(); + updateEntitiesFlags(); vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); myGrid->ShallowCopy(theGrid); } @@ -619,6 +623,62 @@ bool SMESH_VisualObjDef::IsValid() const GetNbEntities(SMDSAbs_Volume) > 0 ; } +//================================================================================= +// function : updateEntitiesFlags +// purpose : Update entities flags +//================================================================================= +void SMESH_VisualObjDef::updateEntitiesFlags() { + + unsigned int tmp = myEntitiesState; + ClearEntitiesFlags(); + + map 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 diff --git a/src/OBJECT/SMESH_Object.h b/src/OBJECT/SMESH_Object.h index b96a26cdc..415b250cd 100644 --- a/src/OBJECT/SMESH_Object.h +++ b/src/OBJECT/SMESH_Object.h @@ -75,6 +75,9 @@ public: virtual vtkIdType GetNodeVTKId( int theObjID ) = 0; virtual vtkIdType GetElemObjId( int theVTKID ) = 0; virtual vtkIdType GetElemVTKId( int theObjID ) = 0; + virtual void ClearEntitiesFlags() = 0; + virtual bool GetEntitiesFlag() = 0; + virtual unsigned int GetEntitiesState() = 0; }; typedef boost::shared_ptr TVisualObjPtr; diff --git a/src/OBJECT/SMESH_ObjectDef.h b/src/OBJECT/SMESH_ObjectDef.h index 5bcbb3aed..edb905d54 100644 --- a/src/OBJECT/SMESH_ObjectDef.h +++ b/src/OBJECT/SMESH_ObjectDef.h @@ -32,6 +32,7 @@ #include "SMESH_Controls.hxx" #include "SMESH_Object.h" #include "SMESH_Client.hxx" +#include "SMESH_Actor.h" // IDL Headers #include @@ -44,7 +45,6 @@ class vtkPoints; class SALOME_ExtractUnstructuredGrid; -class SMESH_Actor; class SMDS_MeshNode; class SMDS_MeshElement; @@ -85,13 +85,17 @@ public: 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; @@ -100,7 +104,11 @@ protected: TMapOfIds myVTK2SMDSElems; bool myLocalGrid; + bool myEntitiesFlag; + unsigned int myEntitiesState; + vtkUnstructuredGrid* myGrid; + std::map myEntitiesCache; };