[vtkusers] How to change the points in a polydata
kenichiro yoshimi
rccm.kyoshimi at gmail.com
Sat Jul 14 07:19:31 EDT 2018
Hi 舞法舞天,
If written as follows, this will work well.
---
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
points->ShallowCopy(data->GetPoints());
for (int i = 0; i < n; i++)
{
double *p = points->GetPoint(i);
p[2] = 0;
points->SetPoint(i, p);
}
---
Best
2018年7月14日(土) 15:41 舞法舞天 <278124177 at qq.com>:
>
> Hello.
> I read a ply file and want to change its' points' postion, but the code below doesn't work , how can i do?
> vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
> reader->SetFileName("d:\\plane.ply");
> reader->Update();
> vtkPolyData* data = reader->GetOutput();
> int n = data->GetNumberOfPoints();
> vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
> points->DeepCopy(data->GetPoints());
> for (int i = 0; i < n; i++)
> {
> double *p = points->GetPoint(i);
> p[2] = 0;
> }
> vtkSmartPointer<vtkSimplePointsWriter>writer = vtkSmartPointer<vtkSimplePointsWriter>::New();
> writer->SetInputData(data);
> writer->SetFileName("d:\\abc.txt");
> writer->Update();
> vtkSmartPointer<vtkPolyDataMapper> mapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> mapper->SetInputData(data);
> mapper->Update();
> vtkSmartPointer<vtkActor> actor =
> vtkSmartPointer<vtkActor>::New();
> actor->SetMapper(mapper);
> //actor->GetProperty()->SetRepresentationToWireframe();
> vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
> renderer->AddActor(actor);
> vtkSmartPointer<vtkRenderWindow> window =
> vtkSmartPointer<vtkRenderWindow>::New();
> window->AddRenderer(renderer);
> vtkSmartPointer<vtkRenderWindowInteractor> interactor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
> interactor->SetRenderWindow(window);
>
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list