Salome HOME
Porting to VTK 6.
[modules/visu.git] / src / PIPELINE / VISU_PipeLine.cxx
index 21137aabe7d7e572ea18b781081473f598bb20ea..f840bbe4145ea692f8e48409cca0e7f6fa871006 100644 (file)
@@ -1,49 +1,42 @@
-//  VISU OBJECT : interactive object for VISU entities implementation
-//
-//  Copyright (C) 2003  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.
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  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.
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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
+// 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.
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
+//  VISU OBJECT : interactive object for VISU entities implementation
 // File:    VISU_PipeLine.cxx
 // Author:  Alexey PETROV
 // Module : VISU
-
-
+//
 #include "VISU_PipeLine.hxx"
-#include "VISU_PipeLineUtils.hxx"
-
-#include "SALOME_ExtractGeometry.h"
+#include "VISU_MapperHolder.hxx"
 
-#include <float.h>
+#include "VISU_PipeLineUtils.hxx"
 
 #include <vtkObjectFactory.h>
-#include <vtkDataSetMapper.h>
-#include <vtkUnstructuredGrid.h>
-
 #include <vtkPlane.h>
-#include <vtkExtractGeometry.h>
-#include <vtkImplicitBoolean.h>
-#include <vtkImplicitFunctionCollection.h>
-#include <vtkMath.h>
 
-static int MYVTKDEBUG = 0;
+#include <float.h>
+#include <algorithm>
+#include <climits>
+#include <limits>
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
@@ -51,256 +44,462 @@ static int MYDEBUG = 0;
 static int MYDEBUG = 0;
 #endif
 
-VISU_PipeLine::VISU_PipeLine()
+
+//----------------------------------------------------------------------------
+VISU_PipeLine
+::VISU_PipeLine():
+  myIsShrinkable(true),
+  myIsFeatureEdgesAllowed(true)
 {
-  if(MYDEBUG) MESSAGE("VISU_PipeLine - "<<this);
-  // Clipping planes
-  myExtractGeometry = SALOME_ExtractGeometry::New();
-  //myExtractGeometry->SetReleaseDataFlag(true);
-  myExtractGeometry->Delete();
-  //myExtractGeometry->DebugOn();
+  if(MYDEBUG) MESSAGE("VISU_PipeLine::VISU_PipeLine - "<<this);
+  
+  vtkMath::UninitializeBounds(myVisibleBounds);
+}
 
-  vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
-  myExtractGeometry->SetImplicitBoolean(anImplicitBoolean);
-  anImplicitBoolean->SetOperationTypeToIntersection();
-  anImplicitBoolean->Delete();
 
-  // Mapper
-  myMapper = TMapper::New();
-  myInput = NULL;
+//----------------------------------------------------------------------------
+VISU_PipeLine
+::~VISU_PipeLine()
+{
+  if(MYDEBUG) MESSAGE("VISU_PipeLine::~VISU_PipeLine - "<<this);
+}
 
-  myIsShrinkable = false;
 
-  SetDebug(MYVTKDEBUG);
+//----------------------------------------------------------------------------
+unsigned long int 
+VISU_PipeLine
+::GetMTime()
+{
+  unsigned long int aTime = Superclass::GetMTime();
+
+  if(myMapperHolder.GetPointer())
+    aTime = std::max(aTime, myMapperHolder->GetMTime());
+
+  return aTime;
 }
 
-VISU_PipeLine::~VISU_PipeLine()
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_PipeLine
+::GetMemorySize()
 {
-  if(MYDEBUG) MESSAGE("~VISU_PipeLine - "<<this);
-  myMapper->Delete();
+  unsigned long int aSize = 0;
+
+  if(myMapperHolder.GetPointer())
+    aSize += myMapperHolder->GetMemorySize();
+  
+  return aSize;
 }
 
-void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){
-  SetInput(thePipeLine->GetInput());
-  myMapper->ShallowCopy(thePipeLine->GetMapper());
-  myExtractGeometry->SetImplicitBoolean(thePipeLine->myExtractGeometry->GetImplicitBoolean());
-  Build();
+
+//----------------------------------------------------------------------------
+void 
+VISU_PipeLine
+::ShallowCopy(VISU_PipeLine *thePipeLine,
+              bool theIsCopyInput)
+{
+  SetImplicitFunction(thePipeLine->GetImplicitFunction());
+  DoShallowCopy(thePipeLine, theIsCopyInput);
+  Update();
 }
 
-void VISU_PipeLine::SameAs(VISU_PipeLine *thePipeLine){
-  ShallowCopy(thePipeLine);
-  myExtractGeometry->SetImplicitBoolean(vtkImplicitBoolean::New());
-  myExtractGeometry->GetImplicitBoolean()->Delete();
+
+//----------------------------------------------------------------------------
+void 
+VISU_PipeLine
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+                bool theIsCopyInput)
+{
+  GetMapperHolder()->ShallowCopy(thePipeLine->GetMapperHolder(),
+                                 theIsCopyInput);
+  for( int i =0 ; i < 6 ; i++)
+    myVisibleBounds[i] = thePipeLine->myVisibleBounds[i];
+  
+  myVisibleComputeTime = thePipeLine->myVisibleComputeTime;
 }
 
-TInput* VISU_PipeLine::GetInput() const
+
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::SameAs(VISU_PipeLine *thePipeLine)
 {
-  return myInput;
+  DoShallowCopy(thePipeLine, false);
+  Update();
 }
 
-TInput* VISU_PipeLine::GetInput2() const
+
+//----------------------------------------------------------------------------
+VISU_MapperHolder* 
+VISU_PipeLine
+::GetMapperHolder()
 {
-  vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput();
-  aDataSet->Update();
-  return aDataSet;
+  if(!myMapperHolder.GetPointer())
+    OnCreateMapperHolder();
+
+  return myMapperHolder.GetPointer();
 }
 
-void VISU_PipeLine::SetInput(TInput* theInput)
+
+//----------------------------------------------------------------------------
+const VISU::PIDMapper&  
+VISU_PipeLine
+::GetIDMapper()
 {
-  myExtractGeometry->SetInput(theInput);
-  if((myInput = theInput))
-    myInput->Update();
+  return GetMapperHolder()->GetIDMapper();
+}
 
-  Modified();
+
+//----------------------------------------------------------------------------
+vtkDataSet* 
+VISU_PipeLine
+::GetInput()
+{
+  return GetMapperHolder()->GetInput();
 }
 
-VISU_PipeLine::TMapper* VISU_PipeLine::GetMapper()
+
+//----------------------------------------------------------------------------
+vtkMapper* 
+VISU_PipeLine
+::GetMapper()
 {
-  if(GetInput()){
-    if(!myMapper->GetInput()){
-      GetInput2()->Update();
-      Build();
-    }
-    myMapper->Update();
-  }
-  return myMapper;
+  return GetMapperHolder()->GetMapper();
 }
 
-void VISU_PipeLine::Update()
+
+//----------------------------------------------------------------------------
+vtkDataSet* 
+VISU_PipeLine
+::GetOutput()
 {
-  myMapper->Update();
+  return GetMapperHolder()->GetOutput();
 }
 
-int VISU_PipeLine::CheckAvailableMemory(const float& theSize)
+
+//----------------------------------------------------------------------------
+bool
+VISU_PipeLine
+::IsPlanarInput()
 {
-  try{
-    if(theSize > ULONG_MAX) return 0;
-    size_t aSize = size_t(theSize);
-    char *aCheck = new char[aSize];
-    if(aCheck) delete [] aCheck;
-    if(MYDEBUG && aCheck == NULL)
-      MESSAGE("CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!");
-    return aCheck != NULL;
-    //return theSize < 1000*1024*1024;
-  }catch(std::bad_alloc& exc){
-    if(MYDEBUG)
-      MESSAGE("CheckAvailableMemory("<<theSize<<") " << exc.what());
-  } catch(...) {
-    if(MYDEBUG)
-      MESSAGE("CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!");
-  }
-  return 0;
+  double aBounds[6];
+  GetInput()->GetBounds( aBounds ); // xmin,xmax, ymin,ymax, zmin,zmax
+  if (fabs( aBounds[0] - aBounds[1] ) <= FLT_MIN ||
+      fabs( aBounds[2] - aBounds[3] ) <= FLT_MIN ||
+      fabs( aBounds[4] - aBounds[5] ) <= FLT_MIN )
+    return true;
+
+  return false;
 }
 
-float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize)
+
+//----------------------------------------------------------------------------
+void 
+VISU_PipeLine
+::SetMapperHolder(VISU_MapperHolder* theHolder)
 {
-  while(!CheckAvailableMemory(theSize))
-    if(theSize > theMinSize)
-      theSize /= 2;
-    else
-      return 0;
-  return theSize;
+  myMapperHolder = theHolder;
+  theHolder->SetPipeLine(this);
 }
 
-//------------------------ Clipping planes -----------------------------------
 
-void VISU_PipeLine::AddClippingPlane(vtkPlane* thePlane)
+//----------------------------------------------------------------------------
+void 
+VISU_PipeLine
+::Init()
+{}
+
+
+//----------------------------------------------------------------------------
+void 
+VISU_PipeLine
+::Update()
 {
-  if(thePlane){
-    if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
-      vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
-      aFunction->AddItem(thePlane);
-    }
-  }
+  GetMapperHolder()->Update();
 }
 
-vtkPlane* VISU_PipeLine::GetClippingPlane(vtkIdType theID) const
+
+//----------------------------------------------------------------------------
+vtkIdType 
+VISU_PipeLine
+::GetNodeObjID(vtkIdType theID)
 {
-  vtkPlane* aPlane = NULL;
-  if(theID >= 0 && theID < GetNumberOfClippingPlanes()){
-    if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
-      vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
-      vtkImplicitFunction* aFun = NULL;
-      aFunction->InitTraversal();
-      for(vtkIdType anID = 0; anID <= theID; anID++)
-       aFun = aFunction->GetNextItem();
-      aPlane = dynamic_cast<vtkPlane*>(aFun);
-    }
-  }
-  return aPlane;
+  return GetMapperHolder()->GetNodeObjID(theID);
 }
 
-void VISU_PipeLine::RemoveAllClippingPlanes()
+//----------------------------------------------------------------------------
+vtkIdType 
+VISU_PipeLine
+::GetNodeVTKID(vtkIdType theID)
 {
-  if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
-    vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
-    aFunction->RemoveAllItems();
-    aBoolean->Modified(); // VTK bug
-  }
+  return GetMapperHolder()->GetNodeVTKID(theID);
 }
 
-vtkIdType VISU_PipeLine::GetNumberOfClippingPlanes() const
+//----------------------------------------------------------------------------
+double* 
+VISU_PipeLine
+::GetNodeCoord(vtkIdType theObjID)
 {
-  if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
-    vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
-    return aFunction->GetNumberOfItems();
-  }
-  return 0;
+  return GetMapperHolder()->GetNodeCoord(theObjID);
 }
 
-static void ComputeBoundsParam (vtkDataSet* theDataSet,
-                                float theDirection[3], float theMinPnt[3],
-                                float& theMaxBoundPrj, float& theMinBoundPrj)
+
+//----------------------------------------------------------------------------
+vtkIdType 
+VISU_PipeLine
+::GetElemObjID(vtkIdType theID)
 {
-  float aBounds[6];
-  theDataSet->GetBounds(aBounds);
+  return GetMapperHolder()->GetElemObjID(theID);
+}
 
-  //Enlarge bounds in order to avoid conflicts of precision
-  for(int i = 0; i < 6; i += 2){
-    static double EPS = 1.0E-3;
-    float aDelta = (aBounds[i+1] - aBounds[i])*EPS;
-    aBounds[i] -= aDelta;
-    aBounds[i+1] += aDelta;
-  }
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PipeLine
+::GetElemVTKID(vtkIdType theID)
+{
+  return GetMapperHolder()->GetElemVTKID(theID);
+}
 
-  float aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
-                              {aBounds[1],aBounds[2],aBounds[4]},
-                              {aBounds[0],aBounds[3],aBounds[4]},
-                              {aBounds[1],aBounds[3],aBounds[4]},
-                              {aBounds[0],aBounds[2],aBounds[5]},
-                              {aBounds[1],aBounds[2],aBounds[5]},
-                              {aBounds[0],aBounds[3],aBounds[5]},
-                              {aBounds[1],aBounds[3],aBounds[5]}};
-
-  int aMaxId = 0, aMinId = aMaxId;
-  theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
-  theMinBoundPrj = theMaxBoundPrj;
-  for(int i = 1; i < 8; i++){
-    float aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
-    if(theMaxBoundPrj < aTmp){
-      theMaxBoundPrj = aTmp;
-      aMaxId = i;
-    }
-    if(theMinBoundPrj > aTmp){
-      theMinBoundPrj = aTmp;
-      aMinId = i;
-    }
-  }
-  float *aMinPnt = aBoundPoints[aMaxId];
-  theMinPnt[0] = aMinPnt[0];
-  theMinPnt[1] = aMinPnt[1];
-  theMinPnt[2] = aMinPnt[2];
+//----------------------------------------------------------------------------
+vtkCell* 
+VISU_PipeLine
+::GetElemCell(vtkIdType  theObjID)
+{
+  return GetMapperHolder()->GetElemCell(theObjID);
 }
 
-static void DistanceToPosition (vtkDataSet* theDataSet,
-                                float theDirection[3], float theDist, float thePos[3])
+
+//----------------------------------------------------------------------------
+bool 
+VISU_PipeLine
+::IsShrinkable()
 {
-  float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
-  ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
-  float aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
-  thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
-  thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
-  thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
+  return myIsShrinkable;
 }
 
-static void PositionToDistance (vtkDataSet* theDataSet,
-                                float theDirection[3], float thePos[3], float& theDist)
+void 
+VISU_PipeLine
+::SetIsShrinkable(bool theIsShrinkable)
 {
-  float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
-  ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
-  float aPrj = vtkMath::Dot(theDirection,thePos);
-  theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
+  if(myIsShrinkable == theIsShrinkable)
+    return;
+
+  myIsShrinkable = theIsShrinkable;
+  Modified();
 }
 
-void VISU_PipeLine::SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane)
+
+//----------------------------------------------------------------------------
+bool 
+VISU_PipeLine
+::IsFeatureEdgesAllowed()
+{
+  return myIsFeatureEdgesAllowed;
+}
+
+void 
+VISU_PipeLine
+::SetIsFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed)
+{
+  if(myIsFeatureEdgesAllowed == theIsFeatureEdgesAllowed)
+    return;
+
+  myIsFeatureEdgesAllowed = theIsFeatureEdgesAllowed;
+  Modified();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
+{
+  GetMapperHolder()->SetImplicitFunction(theFunction);
+} 
+
+//----------------------------------------------------------------------------
+vtkImplicitFunction * 
+VISU_PipeLine
+::GetImplicitFunction()
+{
+  return GetMapperHolder()->GetImplicitFunction();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::SetExtractInside(bool theMode)
+{
+  GetMapperHolder()->SetExtractInside(theMode);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::SetExtractBoundaryCells(bool theMode)
+{
+  GetMapperHolder()->SetExtractBoundaryCells(theMode);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::RemoveAllClippingPlanes()
+{
+  GetMapperHolder()->RemoveAllClippingPlanes();
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PipeLine
+::GetNumberOfClippingPlanes()
+{
+  return GetMapperHolder()->GetNumberOfClippingPlanes();
+}
+
+//----------------------------------------------------------------------------
+bool 
+VISU_PipeLine
+::AddClippingPlane(vtkPlane* thePlane)
+{
+  return GetMapperHolder()->AddClippingPlane(thePlane);
+}
+
+//----------------------------------------------------------------------------
+vtkPlane* 
+VISU_PipeLine
+::GetClippingPlane(vtkIdType theID)
+{
+  return GetMapperHolder()->GetClippingPlane(theID);
+}
+
+//----------------------------------------------------------------------------
+void VISU_PipeLine::RemoveClippingPlane(vtkIdType theID)
+{
+  return GetMapperHolder()->RemoveClippingPlane(theID);
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet* 
+VISU_PipeLine
+::GetClippedInput()
+{
+  return GetMapperHolder()->GetClippedInput();
+}
+
+//----------------------------------------------------------------------------
+vtkAlgorithmOutput* 
+VISU_PipeLine
+::GetClippedInputPort()
+{
+  return GetMapperHolder()->GetClippedInputPort();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::SetPlaneParam(double theDir[3], 
+                double theDist, 
+                vtkPlane* thePlane)
 {
   thePlane->SetNormal(theDir);
-  float anOrigin[3];
-  ::DistanceToPosition(GetInput(),theDir,theDist,anOrigin);
+
+  double anOrigin[3];
+
+  //Make sure that bounds are calculated
+  ComputeVisibleBounds();
+  VISU::DistanceToPosition(myVisibleBounds,
+                           theDir,
+                           theDist,
+                           anOrigin);
+
   thePlane->SetOrigin(anOrigin);
 }
 
-void VISU_PipeLine::GetPlaneParam (float theDir[3], float& theDist, vtkPlane* thePlane)
+
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::GetPlaneParam(double theDir[3], 
+                double& theDist, 
+                vtkPlane* thePlane)
 {
   thePlane->GetNormal(theDir);
-
-  float anOrigin[3];
+  
+  double anOrigin[3];
   thePlane->GetOrigin(anOrigin);
-  ::PositionToDistance(GetInput(),theDir,anOrigin,theDist);
+  
+  //Make sure that bounds are calculated
+  ComputeVisibleBounds();
+  VISU::PositionToDistance(myVisibleBounds,
+                          theDir,
+                          anOrigin,
+                          theDist);
 }
 
-//=======================================================================
-//function : IsPlanarInput
-//purpose  :
-//=======================================================================
-bool VISU_PipeLine::IsPlanarInput() const
+
+//----------------------------------------------------------------------------
+size_t
+VISU_PipeLine
+::CheckAvailableMemory(double theSize)
 {
-  float aBounds[6];
-  GetInput()->GetBounds( aBounds ); // xmin,xmax, ymin,ymax, zmin,zmax
-  if (fabs( aBounds[0] - aBounds[1] ) <= FLT_MIN ||
-      fabs( aBounds[2] - aBounds[3] ) <= FLT_MIN ||
-      fabs( aBounds[4] - aBounds[5] ) <= FLT_MIN )
-    return true;
+  if(theSize < ULONG_MAX){
+    try{
+      size_t aSize = size_t(theSize);
+      if(char *aCheck = new char[aSize]){
+        delete [] aCheck;
+        return aSize;
+      }
+    }catch(std::bad_alloc& exc){
+    }catch(...){
+    }
+  }
+  return 0;
+}
 
-  return false;
+
+//----------------------------------------------------------------------------
+size_t
+VISU_PipeLine
+::GetAvailableMemory(double theSize, 
+                     double theMinSize)
+{
+  // Finds acceptable memory size by half-deflection methods
+  static double EPSILON = 2 * 1024;
+  double aMax = std::max(theSize, theMinSize);
+  double aMin = std::min(theSize, theMinSize);
+  //cout<<"GetAvailableMemory - "<<aMax<<"; "<<aMin;
+  while(!CheckAvailableMemory(aMax) && CheckAvailableMemory(aMin) && (aMax - aMin) > EPSILON){
+    double aRoot = (aMax + aMin) / 2.;
+    if(CheckAvailableMemory(aRoot))
+      aMin = aRoot;
+    else
+      aMax = aRoot;
+  }
+  //cout<<"; "<<aMax<<endl;
+  return (size_t)aMax;
+}
+
+
+//----------------------------------------------------------------------------
+// Re-compute visible bounds if need
+void VISU_PipeLine::ComputeVisibleBounds() {
+  if(GetMTime() > myVisibleComputeTime) {
+    VISU::ComputeVisibleBounds(GetMapperHolder()->GetOutput(), myVisibleBounds);
+    myVisibleComputeTime.Modified();
+  }
 }
+
+//----------------------------------------------------------------------------
+void VISU_PipeLine::GetVisibleBounds(double theBounds[6]) {
+  // Compute or get cached bounds
+  ComputeVisibleBounds(); 
+  for (int i=0; i<6; i++) {
+    theBounds[i] = myVisibleBounds[i];
+  }
+}
+
+//----------------------------------------------------------------------------