Salome HOME
Fix for problem: SIGSEGV appears if to select group after opening "Edit Group" dialog...
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.cxx
index 337aba6483d5bceb36398e573d1c371553a48bbc..3548aaefe33244b272a83704f958bab77908bf22 100644 (file)
 #include "SMESH_ControlsDef.hxx"
 #include "SMESH_ActorUtils.h"
 
-#include "SALOME_Transform.h"
-#include "SALOME_TransformFilter.h"
-#include "SALOME_PassThroughFilter.h"
-#include "SALOME_ExtractUnstructuredGrid.h"
+#include <VTKViewer_Transform.h>
+#include <VTKViewer_TransformFilter.h>
+#include <VTKViewer_PassThroughFilter.h>
+#include <VTKViewer_ExtractUnstructuredGrid.h>
 
 // VTK Includes
 #include <vtkObjectFactory.h>
@@ -75,7 +75,10 @@ using namespace std;
 vtkStandardNewMacro(SMESH_DeviceActor);
 
 
-SMESH_DeviceActor::SMESH_DeviceActor(){
+SMESH_DeviceActor::SMESH_DeviceActor()
+{
+  if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);
+
   myIsShrunk = false;
   myIsShrinkable = false;
   myRepresentation = eSurface;
@@ -91,64 +94,74 @@ SMESH_DeviceActor::SMESH_DeviceActor(){
 
   myShrinkFilter = vtkShrinkFilter::New();
 
+  myStoreClippingMapping = false;
+
   myExtractGeometry = SMESH_ExtractGeometry::New();
   myExtractGeometry->SetReleaseDataFlag(true);
-  myExtractGeometry->SetStoreMapping(true);
   myIsImplicitFunctionUsed = false;
 
-  myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New();
-  myExtractUnstructuredGrid->SetStoreMapping(true);
-
+  myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New();
+    
   myMergeFilter = vtkMergeFilter::New();
 
-  myStoreMapping = false;
-  myGeomFilter = SALOME_GeometryFilter::New();
+  myGeomFilter = VTKViewer_GeometryFilter::New();
 
-  myTransformFilter = SALOME_TransformFilter::New();
+  myTransformFilter = VTKViewer_TransformFilter::New();
 
   for(int i = 0; i < 6; i++)
-    myPassFilter.push_back(SALOME_PassThroughFilter::New());
+    myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
 }
 
 
 SMESH_DeviceActor::~SMESH_DeviceActor(){
-  if(MYDEBUG) MESSAGE("~SMESH_DeviceActor");
+  if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
+
   myProperty->Delete();
 
-  myMapper->RemoveAllInputs();
   myMapper->Delete();
 
-  myShrinkFilter->UnRegisterAllOutputs();
   myShrinkFilter->Delete();
 
-  myExtractUnstructuredGrid->UnRegisterAllOutputs();
   myExtractUnstructuredGrid->Delete();
 
-  myMergeFilter->UnRegisterAllOutputs();
   myMergeFilter->Delete();
 
-  myGeomFilter->UnRegisterAllOutputs();
   myGeomFilter->Delete();
 
-  myExtractGeometry->UnRegisterAllOutputs();
   myExtractGeometry->Delete();
 
-  myTransformFilter->UnRegisterAllOutputs();
   myTransformFilter->Delete();
 
   for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
-    myPassFilter[i]->UnRegisterAllOutputs(); 
     myPassFilter[i]->Delete();
   }
 }
 
 
-void SMESH_DeviceActor::SetStoreMapping(int theStoreMapping){
-  if (myStoreMapping == theStoreMapping)
-    return;
-  myStoreMapping = theStoreMapping;
-  myGeomFilter->SetStoreMapping( myStoreMapping );
-  Modified();
+void
+SMESH_DeviceActor::
+SetStoreGemetryMapping(bool theStoreMapping)
+{
+  myGeomFilter->SetStoreMapping(theStoreMapping);
+  SetStoreClippingMapping(theStoreMapping);
+}
+
+
+void
+SMESH_DeviceActor::
+SetStoreClippingMapping(bool theStoreMapping)
+{
+  myStoreClippingMapping = theStoreMapping;
+  myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
+  SetStoreIDMapping(theStoreMapping);
+}
+
+
+void
+SMESH_DeviceActor::
+SetStoreIDMapping(bool theStoreMapping)
+{
+  myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
 }
 
 
@@ -165,9 +178,6 @@ void
 SMESH_DeviceActor::
 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
 {
-  if(myIsImplicitFunctionUsed == theIsImplicitFunctionUsed)
-    return;
-
   int anId = 0;
   if(theIsImplicitFunctionUsed)
     myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
@@ -175,6 +185,7 @@ SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
     myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
     
   myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
+  SetStoreClippingMapping(myStoreClippingMapping);
 }
 
 
@@ -190,11 +201,10 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
     myExtractGeometry->SetInput(myMergeFilter->GetOutput());
 
     int anId = 0;
-    myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
+    SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
     myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
     
     anId++; // 1
-    myGeomFilter->SetStoreMapping( myStoreMapping );
     myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
 
     anId++; // 2
@@ -221,7 +231,7 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
 }
 
 
-SALOME_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){
+VTKViewer_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){
   return myExtractUnstructuredGrid;
 }
 
@@ -239,7 +249,11 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
   bool anIsInitialized = theFunctor;
   if(anIsInitialized){
     vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+
+    SetStoreIDMapping(true);
+    myExtractUnstructuredGrid->Update();
     vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
+
     aDataSet->ShallowCopy(aGrid);
     
     vtkDoubleArray *aScalars = vtkDoubleArray::New();
@@ -280,14 +294,13 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
 }
 
 void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
-                                         SMESH_DeviceActor* theDeviceActor,
                                          vtkScalarBarActor* theScalarBarActor,
                                          vtkLookupTable* theLookupTable)
 {
   bool anIsInitialized = theFunctor;
   myExtractUnstructuredGrid->ClearRegisteredCells();
   myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
-  myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll);
+  myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
   myVisualObj->UpdateFunctor(theFunctor);
 
   using namespace SMESH::Controls;
@@ -419,17 +432,16 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
   theScalarBarActor->SetVisibility(anIsInitialized);
 }
 
-void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
-                                         SMESH_DeviceActor* theDeviceActor)
+void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
 {
   myExtractUnstructuredGrid->ClearRegisteredCells();
   myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
-  myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll);
+  myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
   myVisualObj->UpdateFunctor(theFunctor);
 
   using namespace SMESH::Controls;
   if(FreeBorders* aFreeBorders = dynamic_cast<FreeBorders*>(theFunctor.get())){
-    myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
+    myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
     vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
     vtkIdType aNbCells = aGrid->GetNumberOfCells();
     for( vtkIdType i = 0; i < aNbCells; i++ ){
@@ -504,7 +516,7 @@ unsigned long int SMESH_DeviceActor::GetMTime(){
 }
 
 
-void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){
+void SMESH_DeviceActor::SetTransform(VTKViewer_Transform* theTransform){
   myTransformFilter->SetTransform(theTransform);
 }
 
@@ -553,7 +565,9 @@ void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){
 
 
 void SMESH_DeviceActor::SetVisibility(int theMode){
-  if(!myExtractUnstructuredGrid->GetInput() || GetUnstructuredGrid()->GetNumberOfCells()){
+  if(!myExtractUnstructuredGrid->GetInput() || 
+     GetUnstructuredGrid()->GetNumberOfCells())
+  {
     vtkLODActor::SetVisibility(theMode);
   }else{
     vtkLODActor::SetVisibility(false);
@@ -576,7 +590,7 @@ int SMESH_DeviceActor::GetNodeObjId(int theVtkID){
     anID = myExtractGeometry->GetNodeObjId(theVtkID);
 
   vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
-  if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; aRetID = "<<aRetID);
+  if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
   return aRetID;
 }