]> SALOME platform Git repositories - modules/visu.git/blobdiff - src/PIPELINE/VISU_PipeLine.cxx
Salome HOME
Merge from BR_WIN_INDUS_514 branch 21/03/2011 (Windows industrialization)
[modules/visu.git] / src / PIPELINE / VISU_PipeLine.cxx
index d9809ae56cc51d9d4114c25bd9885ddd1fe11bb1..58820209514a39709f2383f24c1b31ab2285ca65 100644 (file)
@@ -52,6 +52,8 @@ VISU_PipeLine
   myIsFeatureEdgesAllowed(true)
 {
   if(MYDEBUG) MESSAGE("VISU_PipeLine::VISU_PipeLine - "<<this);
+  
+  vtkMath::UninitializeBounds(myVisibleBounds);
 }
 
 
@@ -111,6 +113,10 @@ VISU_PipeLine
 {
   GetMapperHolder()->ShallowCopy(thePipeLine->GetMapperHolder(),
                                  theIsCopyInput);
+  for( int i =0 ; i < 6 ; i++)
+    myVisibleBounds[i] = thePipeLine->myVisibleBounds[i];
+  
+  myVisibleComputeTime = thePipeLine->myVisibleComputeTime;
 }
 
 
@@ -394,7 +400,10 @@ VISU_PipeLine
   thePlane->SetNormal(theDir);
 
   vtkFloatingPointType anOrigin[3];
-  VISU::DistanceToPosition(GetInput(),
+
+  //Make sure that bounds are calculated
+  ComputeVisibleBounds();
+  VISU::DistanceToPosition(myVisibleBounds,
                            theDir,
                            theDist,
                            anOrigin);
@@ -411,14 +420,16 @@ VISU_PipeLine
                 vtkPlane* thePlane)
 {
   thePlane->GetNormal(theDir);
-
+  
   vtkFloatingPointType anOrigin[3];
   thePlane->GetOrigin(anOrigin);
-
-  VISU::PositionToDistance(GetInput(),
-                             theDir,
-                             anOrigin,
-                             theDist);
+  
+  //Make sure that bounds are calculated
+  ComputeVisibleBounds();
+  VISU::PositionToDistance(myVisibleBounds,
+                          theDir,
+                          anOrigin,
+                          theDist);
 }
 
 
@@ -465,4 +476,22 @@ VISU_PipeLine
 }
 
 
+//----------------------------------------------------------------------------
+// Re-compute visible bounds if need
+void VISU_PipeLine::ComputeVisibleBounds() {
+  if(GetMTime() > myVisibleComputeTime) {
+    VISU::ComputeVisibleBounds(GetMapperHolder()->GetOutput(), myVisibleBounds);
+    myVisibleComputeTime.Modified();
+  }
+}
+
+//----------------------------------------------------------------------------
+void VISU_PipeLine::GetVisibleBounds(vtkFloatingPointType theBounds[6]) {
+  // Compute or get cached bounds
+  ComputeVisibleBounds(); 
+  for (int i=0; i<6; i++) {
+    theBounds[i] = myVisibleBounds[i];
+  }
+}
+
 //----------------------------------------------------------------------------