I just downloaded the bunny dataset. I modified this wiki example: <a href="http://vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataExtractNormals">http://vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataExtractNormals</a> to use a vtkPLYReader.<br>
<br>The bunny data has no normals defined.<br><br><div class="gmail_quote">On Tue, Oct 18, 2011 at 2:36 PM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">After<div class="im"><br>reader1->SetFileName ( inputFilename.c_str() );<br></div>try<br>
reader1->Update();<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Tue, Oct 18, 2011 at 10:40 AM, andon <span dir="ltr"><<a href="mailto:antoniod987@gmail.com" target="_blank">antoniod987@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Well, the code is quite standard:<br>
<br>
-<br>
-<br>
-<br>
std::string inputFilename = "../data/bunny.ply";<br>
<br>
vtkSmartPointer<vtkPLYReader> reader1 =<br>
vtkSmartPointer<vtkPLYReader>::New();<br>
reader1->SetFileName ( inputFilename.c_str() );<br>
<br>
// Visualize<br>
vtkSmartPointer<vtkPolyDataMapper> mapper1 =<br>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
mapper1->SetInputConnection(reader1->GetOutputPort());<br>
<br>
vtkSmartPointer<vtkPolyData> polydata =<br>
vtkSmartPointer<vtkPolyData>::New();<br>
polydata->DeepCopy(reader1->GetOutput());<br>
<br>
vtkDoubleArray* normalDataDouble =<br>
vtkDoubleArray::SafeDownCast(polydata->GetPointData()->GetArray("Normals"));<br>
<br>
vtkSmartPointer<vtkActor> actor1 =<br>
vtkSmartPointer<vtkActor>::New();<br>
actor1->SetMapper(mapper1);<br>
//bunny2<br>
std::string inputFilename2 = "../data/bunny.ply";<br>
<br>
vtkSmartPointer<vtkPLYReader> reader2 =<br>
vtkSmartPointer<vtkPLYReader>::New();<br>
reader2->SetFileName ( inputFilename2.c_str() );<br>
<br>
// Visualize<br>
vtkSmartPointer<vtkPolyDataMapper> mapper2 =<br>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
mapper2->SetInputConnection(reader2->GetOutputPort());<br>
<br>
vtkSmartPointer<vtkActor> actor2 =<br>
vtkSmartPointer<vtkActor>::New();<br>
actor2->SetMapper(mapper2);<br>
<br>
// A renderer and render window<br>
vtkSmartPointer<vtkRenderer> renderer =<br>
vtkSmartPointer<vtkRenderer>::New();<br>
vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
vtkSmartPointer<vtkRenderWindow>::New();<br>
renderWindow->AddRenderer(renderer);<br>
<br>
<br>
<br>
// An interactor<br>
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>
vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
<br>
renderWindowInteractor->SetRenderWindow(renderWindow);<br>
actor1->SetPosition(1,0,0);<br>
actor2->SetPosition(1.2,0,0);<br>
renderer->AddActor(actor1);<br>
renderer->AddActor(actor2);<br>
renderer->SetBackground(1,1,1);<br>
<br>
vtkSmartPointer<vtkInteractorStyleSwitch> style =<br>
vtkSmartPointer<vtkInteractorStyleSwitch>::New();<br>
renderWindowInteractor->SetInteractorStyle(style);<br>
-<br>
-<br>
-<br>
The rest of the code is not necessary....I'm trying than I'm using some ply<br>
files from here: <a href="http://graphics.im.ntu.edu.tw/%7Erobin/courses/cg03/model/" target="_blank">http://graphics.im.ntu.edu.tw/~robin/courses/cg03/model/</a><br>
<br>
and i need to extract normals from the actor that i create from the ply<br>
file, in particular in relation with some cells (that i will pick from<br>
cellpicker) , because i have to make some consideration about cells<br>
orientation.....can you help me??? i try to use "polydata" for extract<br>
normals but the array normalsDataDouble that i obtain is not<br>
initialized...if i try to use this array i throw in an exception....<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Extract-Normals-tp4905504p4913930.html" target="_blank">http://vtk.1045678.n5.nabble.com/Extract-Normals-tp4905504p4913930.html</a><br>
</font><div>Sent from the VTK - Users mailing list archive at Nabble.com.<br>
</div><div><div></div><div>_______________________________________________<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>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>