From 3ba3d8a91d1747db171e88cc097658e1349b5440 Mon Sep 17 00:00:00 2001 From: dmv Date: Thu, 5 Nov 2009 15:06:10 +0000 Subject: [PATCH] 0020575: EDF 1162 SMESH: Mesh is displayed in "Nodes" mode after compute --- src/OBJECT/SMESH_Object.cxx | 13 +++++++++++++ src/OBJECT/SMESH_Object.h | 1 + src/OBJECT/SMESH_ObjectDef.h | 2 ++ src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 3 ++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index a6908f78e..e7ef139a4 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -520,6 +520,19 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, return true; } +//================================================================================= +// function : IsValid +// purpose : Return true if there are some entities +//================================================================================= +bool SMESH_VisualObjDef::IsValid() const +{ + return GetNbEntities(SMDSAbs_Node) > 0 || + GetNbEntities(SMDSAbs_0DElement) > 0 || + GetNbEntities(SMDSAbs_Edge) > 0 || + GetNbEntities(SMDSAbs_Face) > 0 || + GetNbEntities(SMDSAbs_Volume) > 0 ; +} + /* Class : SMESH_MeshObj Description : Class for visualisation of mesh diff --git a/src/OBJECT/SMESH_Object.h b/src/OBJECT/SMESH_Object.h index 118c13ad8..3bc178eca 100644 --- a/src/OBJECT/SMESH_Object.h +++ b/src/OBJECT/SMESH_Object.h @@ -65,6 +65,7 @@ public: const int theEdgeNum, int& theNodeId1, int& theNodeId2 ) const = 0; + virtual bool IsValid() const = 0; virtual vtkUnstructuredGrid* GetUnstructuredGrid() = 0; diff --git a/src/OBJECT/SMESH_ObjectDef.h b/src/OBJECT/SMESH_ObjectDef.h index 094504f33..82f540913 100644 --- a/src/OBJECT/SMESH_ObjectDef.h +++ b/src/OBJECT/SMESH_ObjectDef.h @@ -69,6 +69,8 @@ public: virtual bool IsNodePrs() const = 0; virtual SMDS_Mesh* GetMesh() const = 0; + virtual bool IsValid() const; + virtual bool GetEdgeNodes( const int theElemId, const int theEdgeNum, int& theNodeId1, diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index 3841a194e..7b5db1430 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -712,7 +712,8 @@ namespace SMESH _PTR(Study) aDocument = aStudy->studyDS(); // Pass non-visual objects (hypotheses, etc.), return true in this case CORBA::Long anId = aDocument->StudyId(); - if (TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)) + TVisualObjPtr aVisualObj; + if ( (aVisualObj = GetVisualObj(anId,theEntry)) && aVisualObj->IsValid()) { if ((anActor = CreateActor(aDocument,theEntry,true))) { bool needFitAll = noSmeshActors(theWnd); // fit for the first object only -- 2.39.2