[vtkusers] Extract Normals
Bill Lorensen
bill.lorensen at gmail.com
Tue Oct 18 14:36:29 EDT 2011
After
reader1->SetFileName ( inputFilename.c_str() );
try
reader1->Update();
On Tue, Oct 18, 2011 at 10:40 AM, andon <antoniod987 at gmail.com> wrote:
> Well, the code is quite standard:
>
> -
> -
> -
> std::string inputFilename = "../data/bunny.ply";
>
> vtkSmartPointer<vtkPLYReader> reader1 =
> vtkSmartPointer<vtkPLYReader>::New();
> reader1->SetFileName ( inputFilename.c_str() );
>
> // Visualize
> vtkSmartPointer<vtkPolyDataMapper> mapper1 =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> mapper1->SetInputConnection(reader1->GetOutputPort());
>
> vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
> polydata->DeepCopy(reader1->GetOutput());
>
> vtkDoubleArray* normalDataDouble =
>
> vtkDoubleArray::SafeDownCast(polydata->GetPointData()->GetArray("Normals"));
>
> vtkSmartPointer<vtkActor> actor1 =
> vtkSmartPointer<vtkActor>::New();
> actor1->SetMapper(mapper1);
> //bunny2
> std::string inputFilename2 = "../data/bunny.ply";
>
> vtkSmartPointer<vtkPLYReader> reader2 =
> vtkSmartPointer<vtkPLYReader>::New();
> reader2->SetFileName ( inputFilename2.c_str() );
>
> // Visualize
> vtkSmartPointer<vtkPolyDataMapper> mapper2 =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> mapper2->SetInputConnection(reader2->GetOutputPort());
>
> vtkSmartPointer<vtkActor> actor2 =
> vtkSmartPointer<vtkActor>::New();
> actor2->SetMapper(mapper2);
>
> // A renderer and render window
> vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
> vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
> renderWindow->AddRenderer(renderer);
>
>
>
> // An interactor
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
>
> renderWindowInteractor->SetRenderWindow(renderWindow);
> actor1->SetPosition(1,0,0);
> actor2->SetPosition(1.2,0,0);
> renderer->AddActor(actor1);
> renderer->AddActor(actor2);
> renderer->SetBackground(1,1,1);
>
> vtkSmartPointer<vtkInteractorStyleSwitch> style =
> vtkSmartPointer<vtkInteractorStyleSwitch>::New();
> renderWindowInteractor->SetInteractorStyle(style);
> -
> -
> -
> The rest of the code is not necessary....I'm trying than I'm using some ply
> files from here: http://graphics.im.ntu.edu.tw/~robin/courses/cg03/model/
>
> and i need to extract normals from the actor that i create from the ply
> file, in particular in relation with some cells (that i will pick from
> cellpicker) , because i have to make some consideration about cells
> orientation.....can you help me??? i try to use "polydata" for extract
> normals but the array normalsDataDouble that i obtain is not
> initialized...if i try to use this array i throw in an exception....
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Extract-Normals-tp4905504p4913930.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111018/6ac5b8e7/attachment.htm>
More information about the vtkusers
mailing list