<div dir="ltr"><div><div>If your data is 512x512x512 then<br>reader->SetDataExtent(0,512,0,512,0,512);<br></div>should be:<br>reader->SetDataExtent(0,511,0,511,0,511);<br><br></div>Also be certain you are setting the correct endianness.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 9, 2013 at 10:25 AM, Massinissa Bandou <span dir="ltr"><<a href="mailto:Massinissa.Bandou@usherbrooke.ca" target="_blank">Massinissa.Bandou@usherbrooke.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everyone,<br>
<br>
I tried to read a (.raw) file with the following code but it displays a RED<br>
CUBE. Here is some information about my file dataInfo.txt<br>
<<a href="http://vtk.1045678.n5.nabble.com/file/n5721842/dataInfo.txt" target="_blank">http://vtk.1045678.n5.nabble.com/file/n5721842/dataInfo.txt</a>> . Is there<br>
something wrong in my code?<br>
<br>
thx for your time and help!<br>
<br>
sorry my file is too large to be send.<br>
<br>
#include <vtkSmartPointer.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkRenderer.h><br>
#include <vtkActor><br>
#include <vtkImageReader><br>
#include <vtkDataSetMapper><br>
<br>
int main(int argc, char *argv[])<br>
{<br>
vtkImageReader *reader = vtkImageReader::New();<br>
reader->SetFileName(file.c_str());<br>
reader->SetFileDimensionality(3);<br>
reader->SetNumberOfScalarComponents(1);<br>
reader->SetDataExtent(0,512,0,512,0,512);<br>
reader->SetDataSpacing(0.145, 0.145, 0.145);<br>
reader->SetDataByteOrderToBigEndian();<br>
reader->SetDataScalarTypeToChar();<br>
reader->Update();<br>
<br>
vtkSmartPointer<vtkDataSetMapper> map =<br>
vtkSmartPointer<vtkDataSetMapper>::New();<br>
map->SetInputConnection(reader->GetOutputPort());<br>
<br>
<br>
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();<br>
actor->SetMapper(map);<br>
<br>
vtkSmartPointer<vtkRenderWindowInteractor> interactor =<br>
vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
<br>
vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
vtkSmartPointer<vtkRenderWindow>::New();<br>
interactor->SetRenderWindow(renderWindow);<br>
vtkSmartPointer<vtkRenderer> renderer =<br>
vtkSmartPointer<vtkRenderer>::New();<br>
renderWindow->AddRenderer(renderer);<br>
renderer->AddActor(actor);<br>
<br>
renderWindow->Render();<br>
interactor->Start();<br>
}<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/RAW-file-tp5721842.html" target="_blank">http://vtk.1045678.n5.nabble.com/RAW-file-tp5721842.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>