Commit d2b9db59 authored by Aashish Chaudhary's avatar Aashish Chaudhary Committed by Code Review

Merge topic 'volume_update_issue' into master

498c2528 BUG: Representation not updating when volume input changed
parents 13b4440d 498c2528
......@@ -21,6 +21,7 @@ set (GenericVolumeCxxTests
TestGPURayCastMapperBenchmark.cxx
TestGPURayCastNearestDataTypesMIP.cxx
TestGPURayCastPerspectiveParallel.cxx
TestGPURayCastVolumeUpdate.cxx
TestMinIntensityRendering.cxx
TestProjectedTetrahedra.cxx
TestSmartVolumeMapper.cxx
......
This diff is collapsed.
......@@ -58,7 +58,6 @@ vtkGPUVolumeRayCastMapper::vtkGPUVolumeRayCastMapper()
this->MaskType
= vtkGPUVolumeRayCastMapper::LabelMapMaskType;
this->AMRMode=0;
this->ClippedCroppingRegionPlanes[0]=VTK_DOUBLE_MAX;
this->ClippedCroppingRegionPlanes[1]=VTK_DOUBLE_MIN;
......@@ -407,7 +406,6 @@ int vtkGPUVolumeRayCastMapper::ValidateRender(vtkRenderer *ren,
return goodSoFar;
}
// ----------------------------------------------------------------------------
// Description:
// Called by the AMR Volume Mapper.
......@@ -431,7 +429,6 @@ void vtkGPUVolumeRayCastMapper::CreateCanonicalView(
int oldSwap = ren->GetRenderWindow()->GetSwapBuffers();
ren->GetRenderWindow()->SwapBuffersOff();
int dim[3];
image->GetDimensions(dim);
int *size = ren->GetRenderWindow()->GetSize();
......@@ -442,12 +439,10 @@ void vtkGPUVolumeRayCastMapper::CreateCanonicalView(
this->CanonicalViewImageData = bigImage;
double scale[2];
scale[0] = dim[0] / static_cast<double>(size[0]);
scale[1] = dim[1] / static_cast<double>(size[1]);
// Save the visibility flags of the renderers and set all to false except
// for the ren.
vtkRendererCollection *renderers=ren->GetRenderWindow()->GetRenderers();
......@@ -514,11 +509,9 @@ void vtkGPUVolumeRayCastMapper::CreateCanonicalView(
ren->SetActiveCamera(canonicalViewCamera);
ren->GetRenderWindow()->Render();
ren->SetActiveCamera(savedCamera);
canonicalViewCamera->Delete();
// Shrink to image to the desired size
vtkImageResample *resample = vtkImageResample::New();
resample->SetInputData( bigImage );
......
......@@ -117,8 +117,6 @@ public:
this->Extents[5] = VTK_INT_MIN;
this->MaskTextures = new vtkMapMaskTextureId;
this->PrevInput = NULL;
}
// Destructor
......@@ -197,7 +195,6 @@ public:
void ComputeBounds(vtkImageData* input);
// Update transfer color function based on the incoming inputs and number of
// scalar components.
// TODO Deal with numberOfScalarComponents > 1
......@@ -319,7 +316,7 @@ public:
vtkMapMaskTextureId* MaskTextures;
vtkVolumeMask* CurrentMask;
vtkImageData* PrevInput;
vtkTimeStamp InputUpdateTime;
vtkShaderProgram* ShaderProgram;
vtkOpenGLShaderCache* ShaderCache;
......@@ -599,8 +596,6 @@ bool vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::LoadVolume(
this->TextureSize[2], 0,
format, type, dataPtr);
// Set scale and bias to their defaults
glPixelTransferf(GL_RED_SCALE,1.0);
glPixelTransferf(GL_RED_BIAS, 0.0);
......@@ -1202,7 +1197,8 @@ bool vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::IsCameraInside(
void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::UpdateVolumeGeometry(
vtkRenderer* ren, vtkVolume* vol, vtkImageData* input)
{
if (input != this->PrevInput || this->IsCameraInside(ren, vol) ||
if (input->GetMTime() > this->InputUpdateTime.GetMTime() ||
this->IsCameraInside(ren, vol) ||
this->CameraWasInsideInLastUpdate)
{
vtkNew<vtkTessellatedBoxSource> boxSource;
......@@ -1212,7 +1208,8 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::UpdateVolumeGeometry(
vtkNew<vtkDensifyPolyData> densityPolyData;
if (input == this->PrevInput && this->IsCameraInside(ren, vol))
if (input->GetMTime() <= this->InputUpdateTime.GetMTime() &&
this->IsCameraInside(ren, vol))
{
// Normals should be transformed using the transpose of inverse
// InverseVolumeMat
......@@ -1872,7 +1869,6 @@ void vtkOpenGLGPUVolumeRayCastMapper::BuildShader(vtkRenderer* ren,
this->Impl->ShaderBuildTime.Modified();
}
//-----------------------------------------------------------------------------
// Update the reduction factor of the render viewport (this->ReductionFactor)
// according to the time spent in seconds to render the previous frame
......@@ -1922,7 +1918,6 @@ void vtkOpenGLGPUVolumeRayCastMapper::ComputeReductionFactor(
newFactor / oldFactor > 1.3 ||
newFactor / oldFactor < .95 )
{
this->ReductionFactor = (newFactor+oldFactor)/2.0;
this->ReductionFactor = (this->ReductionFactor > 5.0) ? (1.00) :
......@@ -2003,8 +1998,10 @@ void vtkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer* ren,
this->Impl->InverseVolumeMat->Invert();
// Update the volume if needed
if (input != this->Impl->PrevInput)
bool volumeModified = false;
if (input->GetMTime() > this->Impl->InputUpdateTime.GetMTime())
{
volumeModified = true;
input->GetDimensions(this->Impl->Dimensions);
// Update bounds, data, and geometry
......@@ -2359,7 +2356,10 @@ void vtkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer* ren,
this->Impl->BBoxPolyData->GetNumberOfCells() * 3,
GL_UNSIGNED_INT, 0);
this->Impl->PrevInput = input;
if (volumeModified)
{
this->Impl->InputUpdateTime.Modified();
}
glFinish();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment