[vtkusers] 回复: How to change the points in a polydata

舞法舞天 278124177 at qq.com
Sun Jul 15 04:07:27 EDT 2018


This works well thanks




------------------ 原始邮件 ------------------
发件人: "kenichiro yoshimi"<rccm.kyoshimi at gmail.com>; 
发送时间: 2018年7月14日(星期六) 晚上7:19
收件人: "舞法舞天"<278124177 at qq.com>; 
抄送: "vtkusers"<vtkusers at vtk.org>; 
主题: Re: [vtkusers] How to change the points in a polydata



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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180715/4bdc0cf7/attachment.html>


More information about the vtkusers mailing list