[vtkusers] problem compiling my application
Sean McInerney
seanm at nmr.mgh.harvard.edu
Tue Aug 17 20:19:19 EDT 2004
Hi Lucas,
You are missing:
#include "vtkStructuredPoints.h"
See <http://www.vtk.org/Wiki/VTK_FAQ#Forward_declaration_in_VTK_4.x>
-Sean
Lucas Lorenzo wrote:
> Hi all,
>
> I'm trying to compile a simple program that reads a volume in the form
> of vtkStructuredPoints and extracts a particular slice (using
> vtkImageReslice) in order to display it:
>
>
> #include "vtkStructuredPointsReader.h"
> #include "vtkLookupTable.h"
> #include "vtkImageReslice.h"
> #include "vtkRenderWindow.h"
> #include "vtkCamera.h"
> #include "vtkActor.h"
> #include "vtkRenderer.h"
> #include "vtkDataSetMapper.h"
> #include "vtkRenderWindowInteractor.h"
>
> int main( int argc, char *argv[] )
> {
>
> vtkStructuredPointsReader *image_reader =
> vtkStructuredPointsReader::New();
> image_reader->SetFileName("myfile.vtk");
>
>
> unsigned short lowval = 0;
> unsigned short highval = 306;
> vtkLookupTable *lut = vtkLookupTable::New();
> lut->SetNumberOfTableValues(1024);
> lut->SetTableRange(lowval,highval);
> lut->SetHueRange(1,1);
> lut->SetSaturationRange(0,0);
> lut->SetValueRange(0,1);
> lut->Build();
>
>
> vtkImageReslice *get_slice = vtkImageReslice::New();
> get_slice->SetInput(image_reader->GetOutput());
> get_slice->SetOutputDimensionality(2);
> get_slice->SetResliceAxesOrigin(0,0,33);
>
>
> vtkDataSetMapper *im_mapper = vtkDataSetMapper::New();
> im_mapper->SetInput(get_slice->GetOutput());
> im_mapper->SetScalarRange(lowval,highval);
> im_mapper->SetColorModeToMapScalars();
> im_mapper->SetLookupTable(lut);
>
>
> vtkActor *imActor = vtkActor::New();
> imActor->SetMapper(im_mapper);
>
>
> // Create the RenderWindow, Renderer and both Actors
> vtkRenderer *ren1 = vtkRenderer::New();
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren1);
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
>
> // Add the actors to the renderer, set the background and size
> ren1->AddActor(imActor);
> renWin->SetSize(640,640);
>
>
> // render the image
> vtkCamera *cam1 = ren1->GetActiveCamera();
> cam1->Zoom(2.5);
> renWin->Render();
>
>
> // deallocate memory:
> image_reader->Delete();
> lut->Delete();
> get_slice->Delete();
> im_mapper->Delete();
> imActor->Delete();
> ren1->Delete();
> renWin->Delete();
> iren->Delete();
>
>
> return 0;
> }
>
> When compiling I have the following error:
>
> Building dependencies. cmake.depends...
> -- Loading VTK CMake commands
> -- Loading VTK CMake commands - done
> Building object file ThresholdVTK.o...
> /private/var/automount/mom/u/lucas/Borrar/ThresholdVTK.cxx: In function
> `int
> main(int, char**)':
> /private/var/automount/mom/u/lucas/Borrar/ThresholdVTK.cxx:30: error: no
> matching function for call to `vtkImageReslice::SetInput(
> vtkStructuredPoints*)'
> /scratch/lucas/bin/VTK-4.4/VTK-binary/include/vtk/
> vtkImageToImageFilter.h:40: error: candidates
> are: virtual void vtkImageToImageFilter::SetInput(vtkImageData*)
> /private/var/automount/mom/u/lucas/Borrar/ThresholdVTK.cxx:36: error: no
> matching function for call to
> `vtkDataSetMapper::SetInput(vtkImageData*)'
> /scratch/lucas/bin/VTK-4.4/VTK-binary/include/vtk/vtkDataSetMapper.h:
> 56: error: candidates
> are: void vtkDataSetMapper::SetInput(vtkDataSet*)
> make[1]: *** [ThresholdVTK.o] Error 1
> make: *** [default_target] Error 2
>
> It is my understanding that vtkStructuredPoints inherits vtkImageData.
> But I must be missing something here.
> If you guys have any clue about this, please let me know.
> Thanks,
>
> Lucas Lorenzo
>
> PS: the CMakeList.txt file is only this:
>
> PROJECT (ThresholdVTK)
>
> INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
> IF (USE_VTK_FILE)
> INCLUDE(${USE_VTK_FILE})
> ENDIF (USE_VTK_FILE)
>
> ADD_EXECUTABLE(ThresholdVTK ThresholdVTK.cxx)
> TARGET_LINK_LIBRARIES(ThresholdVTK vtkRendering vtkImaging vtkIO)
>
> University of Utah
> Nora Eccles Harrison CardioVascular Research and Training Institute
> Fellows Room
> 95 South 2000 East
> Salt Lake City, UT 84112-5000
>
> e-mail: lucas at cvrti.utah.edu
> telephone: 801-587-9536
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list