Salome HOME
Merge from V5_1_main 10/06/2010
[modules/visu.git] / src / PIPELINE / VISU_DataSetMapperHolder.cxx
index 313c6d683595e6f37b4d510adecc54123e2f4434..dc51018231d94200e1ba36c8e2ce89fa93b58295 100644 (file)
@@ -1,6 +1,6 @@
-//  VISU OBJECT : interactive object for VISU entities implementation
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  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
 //  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
 //
+
+//  VISU OBJECT : interactive object for VISU entities implementation
 // File:    VISU_DataSetMapperHolder.cxx
 // Author:  Alexey PETROV
 // Module : VISU
-
-
+//
 #include "VISU_DataSetMapperHolder.hxx"
 #include "SALOME_ExtractGeometry.h"
+#include "VISU_ElnoDisassembleFilter.hxx"
 #include "VISU_LookupTable.hxx"
 
 #include "VISU_PipeLineUtils.hxx"
@@ -41,6 +41,8 @@
 #include <vtkImplicitFunctionCollection.h>
 #include <vtkMath.h>
 
+#include <cmath>
+
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 #else
@@ -55,10 +57,13 @@ vtkStandardNewMacro(VISU_DataSetMapperHolder);
 //----------------------------------------------------------------------------
 VISU_DataSetMapperHolder
 ::VISU_DataSetMapperHolder():
-  myExtractGeometry(SALOME_ExtractGeometry::New())
+  myElnoDisassembleFilter( VISU_ElnoDisassembleFilter::New() ),
+  myExtractGeometry( SALOME_ExtractGeometry::New() )
 {
   if(MYDEBUG) MESSAGE("VISU_DataSetMapperHolder::VISU_DataSetMapperHolder - "<<this);
 
+  myElnoDisassembleFilter->Delete();
+
   // Clipping functionality
   myExtractGeometry->Delete();
   myExtractGeometry->SetStoreMapping(true);
@@ -83,19 +88,33 @@ VISU_DataSetMapperHolder
 void 
 VISU_DataSetMapperHolder
 ::ShallowCopy(VISU_MapperHolder *theMapperHolder,
-             bool theIsCopyInput)
+              bool theIsCopyInput)
 {
   if(VISU_DataSetMapperHolder* aMapperHolder = dynamic_cast<VISU_DataSetMapperHolder*>(theMapperHolder)){
     if(theIsCopyInput)
       SetUnstructuredGridIDMapper(aMapperHolder->GetUnstructuredGridIDMapper());
     
     VISU::CopyDataSetMapper(GetDataSetMapper(), 
-                           aMapperHolder->GetDataSetMapper(), 
-                           theIsCopyInput);
+                            aMapperHolder->GetDataSetMapper(), 
+                            theIsCopyInput);
+    myExtractGeometry->SetImplicitFunction(aMapperHolder->GetImplicitFunction());
   }
 }
 
 
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::SetElnoDisassembleState( bool theIsShrunk )
+{
+  vtkFloatingPointType aShrinkFactor = std::abs( myElnoDisassembleFilter->GetShrinkFactor() );
+  if ( theIsShrunk )
+    myElnoDisassembleFilter->SetShrinkFactor( aShrinkFactor );
+  else
+    myElnoDisassembleFilter->SetShrinkFactor( -aShrinkFactor );
+}
+
+
 //----------------------------------------------------------------------------
 unsigned long int
 VISU_DataSetMapperHolder
@@ -116,9 +135,10 @@ void
 VISU_DataSetMapperHolder
 ::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper)
 {
-  myExtractGeometry->SetInput(theIDMapper->GetUnstructuredGridOutput());
+  myElnoDisassembleFilter->SetInput( theIDMapper->GetUnstructuredGridOutput() );
+  myExtractGeometry->SetInput( myElnoDisassembleFilter->GetOutput() );
   myUnstructuredGridIDMapper = theIDMapper;
-  SetIDMapper(theIDMapper);
+  SetIDMapper( theIDMapper );
 }
 
 
@@ -215,7 +235,7 @@ VISU_DataSetMapperHolder
 //----------------------------------------------------------------------------
 vtkFloatingPointType* 
 VISU_DataSetMapperHolder
-::GetNodeCoord(int theObjID)
+::GetNodeCoord(vtkIdType theObjID)
 {
   return Superclass::GetNodeCoord(theObjID);
 }
@@ -297,6 +317,7 @@ VISU_DataSetMapperHolder
     if (vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()) {
       vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
       aFunction->AddItem(thePlane);
+      aBoolean->Modified();
       // Check, that at least one cell present after clipping.
       // This check was introduced because of bug IPAL8849.
       vtkDataSet* aClippedDataSet = GetClippedInput();
@@ -319,13 +340,26 @@ VISU_DataSetMapperHolder
       vtkImplicitFunction* aFun = NULL;
       aFunction->InitTraversal();
       for(vtkIdType anID = 0; anID <= theID; anID++)
-       aFun = aFunction->GetNextItem();
+        aFun = aFunction->GetNextItem();
       aPlane = dynamic_cast<vtkPlane*>(aFun);
     }
   }
   return aPlane;
 }
 
+//----------------------------------------------------------------------------
+void VISU_DataSetMapperHolder::RemoveClippingPlane(vtkIdType theID)
+{
+  if(theID >= 0 && theID < GetNumberOfClippingPlanes()){
+    if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
+      vtkImplicitFunctionCollection* aFunctions = aBoolean->GetFunction();
+      aFunctions->RemoveItem(theID);
+      aBoolean->Modified();
+    }
+  }
+}
+
+
 //----------------------------------------------------------------------------
 void
 VISU_DataSetMapperHolder