[vtkusers] Reading DICOM using vtkImageActor
Matias Montroull
matimontg at gmail.com
Mon Mar 31 20:50:30 EDT 2014
I ran into the same issue with 3D view and had to use this:
ren.ResetCameraClippingRange();
For some reason your view is outside the bounds then when you touch the
actor it then re renders the image and you can see it.
(It is in C# thought) not sure how would be in C++ but you can search
around for that method.
On Mon, Mar 31, 2014 at 1:18 PM, Sam Raby <rabysam28 at gmail.com> wrote:
> Here is the code without text formatting:
>
> vtkSmartPointer<vtkDICOMImageReader> reader = vtkSmartPointer<
> vtkDICOMImageReader>::New();
> reader->SetDirectoryName("/home/DICOM_Dir");
> reader->Update();
> vtkSmartPointer<vtkImageActor> imageActor =
> vtkSmartPointer<vtkImageActor>::New();
> imageActor->SetInputData(reader->GetOutput());
>
> imageMapper = vtkImageSliceMapper::SafeDownCast(
> imageActor->GetMapper() );
> imageMapper->SetSliceNumber(10);
> vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
> ren->AddActor(imageActor);
> ren->ResetCamera();
>
> vtkSmartPointer<vtkRenderWindow> renWin =
> vtkSmartPointer<vtkRenderWindow>::New();
> renWin->AddRenderer(ren);
>
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
> vtkSmartPointer<vtkInteractorStyleTrackballCamera>
> interactorImageStyle =
> vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
>
> renderWindowInteractor->SetInteractorStyle(interactorImageStyle);
> renWin->SetInteractor(renderWindowInteractor);
> renderWindowInteractor->SetRenderWindow(renWin);
> renderWindowInteractor->Initialize();
> renderWindowInteractor->Start();
>
>
> On Mon, Mar 31, 2014 at 11:11 AM, Sam Raby <rabysam28 at gmail.com> wrote:
>
>> Hi,
>>
>> As mentioned, I am reading DICOM using vtkImageActor instead of
>> vtkImageReviewer2. I have a simple code below. The problem is that when I
>> run the code, the slice does not show up, unless I slightly manipulate the
>> window by mouse. Once I touch the window and move the mouse, the slice
>> shows up immediately. Would you let me know why this happens?
>>
>> vtkSmartPointer<vtkDICOMImageReader> reader = vtkSmartPointer<
>> vtkDICOMImageReader>::New();
>> reader->SetDirectoryName("/home/DICOM_Dir");
>> reader->Update();
>> vtkSmartPointer<vtkImageActor> imageActor = vtkSmartPointer<vtkImageActor>::New();
>> imageActor->SetInputData(reader->GetOutput());
>>
>> imageMapper = vtkImageSliceMapper::SafeDownCast( imageActor->GetMapper() );
>> imageMapper->SetSliceNumber(10);
>> vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
>> ren->AddActor(imageActor);
>> ren->ResetCamera();
>>
>> vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
>> renWin->AddRenderer(ren);
>>
>> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
>> vtkSmartPointer<vtkInteractorStyleTrackballCamera> interactorImageStyle = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
>>
>> renderWindowInteractor->SetInteractorStyle(interactorImageStyle);
>> renWin->SetInteractor(renderWindowInteractor);
>> renderWindowInteractor->SetRenderWindow(renWin);
>> renderWindowInteractor->Initialize();
>> renderWindowInteractor->Start();
>>
>>
>> Thanks.
>>
>> -S
>>
>>
>>
>> On Fri, Mar 21, 2014 at 12:57 AM, Sam Raby <rabysam28 at gmail.com> wrote:
>>
>>> Thanks David. Adding SafeDownCast rectified the error, and I can now
>>> change the slice number using vtkImageSliceMapper object.
>>>
>>> I initially was going to change the slice number through vtkImageActor,
>>> but the method that is in charge (i.e. SetZSlice) appeared to be not
>>> working, as reported in the past on the link, and hence I thought to
>>> change the slice number via its mapper. Thanks for the help!
>>>
>>> http://www.paraview.org/Bug/bug_relationship_graph.php?
>>> bug_id=3661&graph=dependency
>>>
>>>
>>> -S
>>>
>>>
>>> On Wed, Mar 19, 2014 at 2:28 PM, David Gobbi <david.gobbi at gmail.com>wrote:
>>>
>>>> On Wed, Mar 19, 2014 at 12:59 PM, Sam Raby <rabysam28 at gmail.com> wrote:
>>>> > thanks for the feedback. I am following your solution as below:
>>>> >
>>>> > vtkImageSliceMapper* myMapper = myActor->GetMapper();
>>>> > myMapper->SetSliceNumber(sliceNum);
>>>> >
>>>> > However I am getting the following error:
>>>> >
>>>> > error: invalid conversion from 'vtkImageMapper3D*' to
>>>> 'vtkImageSliceMapper*'
>>>> > [-fpermissive]
>>>> >
>>>> > I was not sure how to address this. Am I missing something here?
>>>>
>>>> Oops, I guess it needs a cast.
>>>>
>>>> vtkImageSliceMapper* myMapper =
>>>> vtkImageSliceMapper::SafeDownCast(myActor->GetMapper());
>>>>
>>>> Perhaps vtkImageActor should have a SetSliceNumber() and
>>>> SetOrientation() method itself, instead of these methods being just in
>>>> the mapper.
>>>>
>>>> David
>>>>
>>>
>>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140331/ef7ff57b/attachment.html>
More information about the vtkusers
mailing list