[vtkusers] .RAW file
Bill Lorensen
bill.lorensen at gmail.com
Tue Jul 9 11:38:50 EDT 2013
If your data is 512x512x512 then
reader->SetDataExtent(0,512,0,512,0,512);
should be:
reader->SetDataExtent(0,511,0,511,0,511);
Also be certain you are setting the correct endianness.
On Tue, Jul 9, 2013 at 10:25 AM, Massinissa Bandou <
Massinissa.Bandou at usherbrooke.ca> wrote:
> Hello everyone,
>
> I tried to read a (.raw) file with the following code but it displays a RED
> CUBE. Here is some information about my file dataInfo.txt
> <http://vtk.1045678.n5.nabble.com/file/n5721842/dataInfo.txt> . Is there
> something wrong in my code?
>
> thx for your time and help!
>
> sorry my file is too large to be send.
>
> #include <vtkSmartPointer.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkRenderer.h>
> #include <vtkActor>
> #include <vtkImageReader>
> #include <vtkDataSetMapper>
>
> int main(int argc, char *argv[])
> {
> vtkImageReader *reader = vtkImageReader::New();
> reader->SetFileName(file.c_str());
> reader->SetFileDimensionality(3);
> reader->SetNumberOfScalarComponents(1);
> reader->SetDataExtent(0,512,0,512,0,512);
> reader->SetDataSpacing(0.145, 0.145, 0.145);
> reader->SetDataByteOrderToBigEndian();
> reader->SetDataScalarTypeToChar();
> reader->Update();
>
> vtkSmartPointer<vtkDataSetMapper> map =
> vtkSmartPointer<vtkDataSetMapper>::New();
> map->SetInputConnection(reader->GetOutputPort());
>
>
> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
> actor->SetMapper(map);
>
> vtkSmartPointer<vtkRenderWindowInteractor> interactor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
>
> vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
> interactor->SetRenderWindow(renderWindow);
> vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
> renderWindow->AddRenderer(renderer);
> renderer->AddActor(actor);
>
> renderWindow->Render();
> interactor->Start();
> }
>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/RAW-file-tp5721842.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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
>
--
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130709/b188c2b1/attachment.htm>
More information about the vtkusers
mailing list