[vtkusers] codes
Bill Lorensen
bill.lorensen at gmail.com
Wed Jan 16 07:55:29 EST 2013
Please keep discussion on the mailing list...
I assume you are using VTK 5.x
1) After you read the data with the reader, you desttory it with these
statements:
// Specify the size of the image data
imageData->SetDimensions(675,401,450);
#if VTK_MAJOR_VERSION <= 5
imageData->SetNumberOfScalarComponents(GetNumberOfScalars+1);
imageData->SetScalarTypeToInt();
#else
imageData->AllocateScalars(VTK_DOUBLE,1);
#endif
Remove them.
On Wed, Jan 16, 2013 at 1:44 AM, shirani kannangara
<mangalika673 at gmail.com>wrote:
> On Tue, Jan 15, 2013 at 9:54 PM, Bill Lorensen <bill.lorensen at gmail.com>
> wrote:
>
>> imageData = reader->GetOutput
>
> Thank you very much Bill.The program was build with zero errorswith one
> warning as follows.Therefore the image reader did not work properly .Hence
> command window did not show the output.I will send everything for you for
> easy reference.
>
>
> #include <vtkSmartPointer.h>
> #include <vtkImageReader2.h>
> #include <vtkImageData.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkInteractorStyleImage.h>
> #include <vtkRenderer.h>
> #include <vtkImageActor.h>
> #include <vtkVersion.h>
> #include <vtkSmartPointer.h>
> #include <vtkImageData.h>
>
> int main(int argc, char *argv[])
> {
> int GetNumberOfScalars;
> // Verify command line arguments
> /*if(argc < 2)
> {
> std::cout << "Usage: " << argv[0]
> << " InputFilename" << std::endl;
> return EXIT_FAILURE;
> }*/
> // Parse command line arguments
> //std::string inputFilename =("D:\\rgbabdomen\\Debug\\output.vtk");
>
> // Read file
> vtkSmartPointer<vtkImageReader2> reader =
> vtkSmartPointer<vtkImageReader2>::New();
> reader->SetFileName(("D:\\rgbabdomen\\Debug\\output.vtk"));
> reader->SetDataScalarTypeToUnsignedChar();
> reader->Update();
>
> //int main(int, char *[])
>
> // Create an image data
> vtkSmartPointer<vtkImageData> imageData =
> vtkSmartPointer<vtkImageData>::New();
>
> imageData = reader->GetOutput();
>
> // Specify the size of the image data
> imageData->SetDimensions(675,401,450);
> #if VTK_MAJOR_VERSION <= 5
> imageData->SetNumberOfScalarComponents(GetNumberOfScalars+1);
> imageData->SetScalarTypeToInt();
>
>
> #else
> imageData->AllocateScalars(VTK_DOUBLE,1);
> #endif
>
> int* dims = imageData->GetDimensions();
> // int dims[3]; // can't do this
>
> std::cout << "Dims: " << " x: " << dims[0] << " y: " << dims[1] << " z:
> " << dims[2] << std::endl;
>
> std::cout << "Number of points: " << imageData->GetNumberOfPoints() <<
> std::endl;
> std::cout << "Number of cells: " << imageData->GetNumberOfCells() <<
> std::endl;
> std::cout << "Number of scalars''
> <<imageData->GetNumberOfScalars<<std::endl;
>
>
> output
> 1>------ Build started: Project: ImageReader2, Configuration: Debug Win32
> ------
> 1>Compiling...
> 1>imagereader.cxx
> 1>d:\dup2\imagereader.cxx(47) : warning C4700: uninitialized local
> variable 'GetNumberOfScalars' used
> 1>Linking...
> 1>Embedding manifest...
> 1>Build log was saved at
> "file://d:\dup2\ImageReader2.dir\Debug\BuildLog.htm"
> 1>ImageReader2 - 0 error(s), 1 warning(s)
> ========== Build: 1 succeeded, 0 failed, 2 up-to-date, 0 skipped ==========
>
> Debug Error
>
> Run-timeCheck Failure #3-The variable GetNumberOfScalars is being used
> without being initialized.
>
> Can you please show me the correct way of initializing
> "GetNumberOfScalars".
> Hope you will reply to me soon.
>
> regards
>
>
--
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130116/a8d7c5e4/attachment.htm>
More information about the vtkusers
mailing list