[vtkusers] DelimitedTextReader

Luca Cinquepalmi cinquepalmi at planetek.it
Thu Jan 27 04:55:49 EST 2011


Hi,
I'm trying to execute the example presented at

http://www.vtk.org/Wiki/VTK/Examples/Cxx/InfoVis/DelimitedTextReader

which read a csv file (x y z n) and visualize it. When i visualize my 
file the image is all black, while it should have the color/value 
expressed in "n" value. In my case n is a GrayScale value. How can i 
modify it? I think i should modify the command

actor->GetProperty()->SetColor(1,0,0);

bu I don't know how. Can anybody help me? Thanks a lot.

Luca



The application I created works well, but the image wich appears is all 
black, while i want

Il 27/01/2011 9.25, jimmigoo ha scritto:
> Hi David!
> Thanks for the fast reply!
> I tried to change just these two code lines
>        reslice->SetOutputSpacing(xResolution,yResolution,1);
>        resample->SetAxisOutputSpacing(2, 1);
> but it didn't work again.
> So, I tried to change other two code lines
>        reslice->SetOutputExtent(0,XExtent-1,0,YExtent-1,0,1);
>        resample->SetOutputExtent(0,XExtent-1,0,YExtent-1,0,1);
> but it didn't work again.
>
> Do you know how I have to change the code to make it workable?
> I'm looking for your reply!
> Best regards,
> jimmigoo
>
>
> void ResampleDTM()
> {
>        //------------- open original file ----------------------------------
>        vtkStructuredPointsReader* imageReader =
> vtkStructuredPointsReader::New();
>        imageReader->SetFileName(“SaintHelene.vtk”);
>        imageReader->Update();
>        //------------- reslice original vtkImageData ------------------------
>        vtkImageReslice* reslice = vtkImageReslice::New();
>        reslice->SetInput(imageReader->GetOutput());
>        reslice->SetOutputOrigin(X0,Y0,0);
>        reslice->SetOutputSpacing(xResolution,yResolution,1);
>        int XExtent = (int)((Xmax_new- Xmin_new)/xResolution);
>        int YExtent = (int)((Ymax_new- Ymin_new)/yResolution);
>        reslice->SetOutputExtent(0,XExtent-1,0,YExtent-1,0,1);
>        reslice->Update();
>        //------------- resample original vtkImageData
> ------------------------
>        vtkImageResample * resample = vtkImageResample::New();
>        resample->SetInputConnection(0, reslice->GetOutputPort());
>        resample->SetDimensionality(3);
>        resample->SetAxisMagnificationFactor(0,1.0);
>        resample->SetAxisMagnificationFactor(1,1.0);
>        resample->SetAxisMagnificationFactor(2,1.0);
>
>        XExtent = (int)((Xmax_new- Xmin_new)/xResolution_new);
>        YExtent = (int)((Ymax_new- Ymin_new)/yResolution_new);
>
>        resample->SetOutputOrigin(X0_new,Y0_new,0);
>        resample->SetOutputExtent(0,XExtent-1,0,YExtent-1,0,1);
>        resample->SetAxisOutputSpacing(0, xResolution_new);
>        resample->SetAxisOutputSpacing(1, yResolution_new);
>        resample->SetAxisOutputSpacing(2, 1);
>        resample->Update();
>        vtkImageData* map = resample->GetOutput();
>        map->GetPointData()->GetArray(0)->SetName("cellvar");
>        //------------- write resampled file
> ----------------------------------
>        vtkStructuredPointsWriter* fileWriter =
> vtkStructuredPointsWriter::New();
>        fileWriter->SetFileTypeToBinary();
>        fileWriter->SetInput(resample->GetOutput());
>        fileWriter->SetFileName(“output.vtk”);
>        fileWriter->Write();
>        //----------------- clean up
> ------------------------------------------
>        fileWriter->Delete();
>        resample->Delete();
>        reslice->Delete();
>        imageReader->Delete();
>
> //---------------------------------------------------------------------
> }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110127/088052a3/attachment.htm>


More information about the vtkusers mailing list