[vtk-developers] Issue with vtkRenderer::ResetCameraClippingRange() (+bug tracker)
Mathieu Malaterre
mathieu.malaterre at gmail.com
Thu Jul 23 08:25:42 EDT 2009
I have open a bug report for this issue.
http://public.kitware.com/Bug/view.php?id=9306
Thanks for comments.
On Mon, Dec 22, 2008 at 6:37 PM, Mathieu
Malaterre<mathieu.malaterre at gmail.com> wrote:
> Hello there,
>
> I have written up a small example to exhibit an issue I am having
> with VTK 5.2:
>
> https://gdcm.svn.sourceforge.net/svnroot/gdcm/Sandbox/VTK
>
> If you start the small app :
>
> $ ./test /usr/share/VTKData/Data/headsq
>
> The first slice of the headsq is shown (vtkImageViewer2). Now press a
> couple of time 'space' and you'll be iterating over each slice. You'll
> notice quickly that the ending slice are all black. Now restart the
> experience but leave the initial spacing of 1.5 for the Z direction
> and you'll see that all slice will be shown.
>
> Could someone please let me know what I am missing after calling
> vtkRenderer::ResetCameraClippingRange() (AFAIK as I know there should
> not be anything else required).
>
> Thank you, and happy new year.
> --
> Mathieu
>
> #include "vtkImageViewer2.h"
> #include "vtkCommand.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkRenderer.h"
> #include "vtkTestUtilities.h"
> #include "vtkImageReader.h"
>
> class vtkGDCMObserver : public vtkCommand
> {
> public:
> static vtkGDCMObserver *New()
> {
> return new vtkGDCMObserver;
> }
> vtkGDCMObserver()
> {
> ImageViewer = NULL;
> }
> ~vtkGDCMObserver()
> {
> }
> virtual void Execute(vtkObject *caller, unsigned long event, void*
> /*calldata*/)
> {
> if ( this->ImageViewer )
> {
> vtkRenderWindowInteractor * rwi =
> vtkRenderWindowInteractor::SafeDownCast( caller );
> if ( event == vtkCommand::CharEvent )
> {
> char keycode = 0;
> if( rwi ) keycode = rwi->GetKeyCode();
> int max = ImageViewer->GetSliceMax();
> int slice = (ImageViewer->GetSlice() + 1) % ++max;
> ImageViewer->SetSlice( slice );
> ImageViewer->GetRenderer()->ResetCameraClippingRange();
> ImageViewer->Render();
> }
> }
> }
> vtkImageViewer2 *ImageViewer;
> };
>
> int main(int argc, char *argv[])
> {
> char* fname =
> vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/headsq/quarter");
>
> vtkImageReader *reader = vtkImageReader::New();
> reader->SetDataByteOrderToLittleEndian();
> reader->SetDataExtent(0,63,0,63,1,93);
> //reader->SetDataSpacing(3.2, 3.2, 1.5); //ok
> reader->SetDataSpacing(3.2, 3.2, 10.5); // not ok
> reader->SetFilePrefix(fname);
> reader->SetDataMask(0x7fff);
>
> delete [] fname;
>
> vtkImageViewer2 *viewer = vtkImageViewer2::New();
> viewer->SetInput(reader->GetOutput());
>
> //viewer->SetColorLevel (0.5 * (range[1] + range[0]));
> //viewer->SetColorWindow (range[1] - range[0]);
>
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> viewer->SetupInteractor (iren);
> viewer->Render();
>
> vtkGDCMObserver *obs = vtkGDCMObserver::New();
> obs->ImageViewer = viewer;
> iren->AddObserver(vtkCommand::CharEvent,obs);
> obs->Delete();
>
> iren->Initialize();
> iren->Start();
>
> reader->Delete();
> viewer->Delete();
> iren->Delete();
>
> return 0;
> }
>
--
Mathieu
http://mathieumalaterre.com
More information about the vtk-developers
mailing list