Salome HOME
Fix regressions 0021322, 0021323
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
index 3e4c1ad8a7fe3d224f8672e91e34dda3d1e6a31b..a998576e9db9f2790eea10f4aeb0956e6349f7c1 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  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 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.
+// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  SMESH OBJECT : interactive object for SMESH visualization
@@ -33,6 +33,7 @@
 #include "SMDS_UnstructuredGrid.hxx"
 #include "SMESH_ScalarBarActor.h"
 #include "VTKViewer_CellCenters.h"
+#include "VTKViewer_DataSetMapper.h"
 #include "VTKViewer_ExtractUnstructuredGrid.h"
 #include "VTKViewer_FramedTextActor.h"
 #include "SALOME_InteractiveObject.hxx"
@@ -103,13 +104,16 @@ SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
                               const char* theName,
                               int theIsClear)
 {
-  SMESH_ActorDef* anActor = SMESH_ActorDef::New();
-  if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
-    anActor->Delete();
-    anActor = NULL;
+  SMESH_ActorDef* anActor = NULL;
+  if(theVisualObj->IsValid() ) {
+    anActor = SMESH_ActorDef::New();
+    if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
+      anActor->Delete();
+      anActor = NULL;
+    }
+    if( anActor )
+      anActor->UpdateScalarBar();
   }
-  if( anActor )
-    anActor->UpdateScalarBar();
   return anActor;
 }
 
@@ -226,6 +230,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
   aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
   aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
+  aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
 
   //Definition 1D device of the actor
   //---------------------------------
@@ -361,6 +366,11 @@ SMESH_ActorDef::SMESH_ActorDef()
 
   myPickableActor = myBaseActor;
 
+  // VSR 13/07/2011: Revert back previous fix for issue 0020749 since it causes regressions, see issues 0021322, 0021323
+  // To be removed later or fix to be improved
+  //myMapper = VTKViewer_DataSetMapper::New();
+  //myMapper->SetInput( myPickableActor->GetUnstructuredGrid() );
+
   myHighlightProp = vtkProperty::New();
   myHighlightProp->SetAmbient(1.0);
   myHighlightProp->SetDiffuse(0.0);
@@ -623,6 +633,10 @@ SMESH_ActorDef::~SMESH_ActorDef()
 
   myImplicitBoolean->Delete();
 
+  // VSR 13/07/2011: Revert back previous fix for issue 0020749 since it causes regressions, see issues 0021322, 0021323
+  // To be removed later or fix to be improved
+  //myMapper->Delete();
+
   myTimeStamp->Delete();
 }
 
@@ -1161,6 +1175,9 @@ void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
 
 
 vtkMapper* SMESH_ActorDef::GetMapper(){
+  // VSR 13/07/2011: Revert back previous fix for issue 0020749 since it causes regressions, see issues 0021322, 0021323
+  // To be removed later or fix to be improved
+  //return myMapper;
   return myPickableActor->GetMapper();
 }