[vtkusers] "trade" vtkPoints between actors

Jeff Lee jlee1549 at gmail.com
Tue Aug 6 16:52:46 EDT 2013


i don't see that you added cells to the polydata, just points.  you need a
cell array of type vtk_vertex.


On Tue, Aug 6, 2013 at 4:44 PM, Renil <renilac at gmail.com> wrote:

> Hi Jeff Lee,
>
> I tried following your suggestion, and used the example from the
> wiki/examples, /deleteCells/.
> I used a polydata to hold the points and changed the lines to spheres and
> tried to remove the cells associated to one of the points.
> It doesn't seem to be doing anything.
>
> I'm probably not delete any cells, right?
>
> *Code* below:
>
> int main(int, char *[])
> {
>         vtkSmartPointer<vtkPoints> points =
> vtkSmartPointer<vtkPoints>::New();
>         points->InsertNextPoint(0,0,0);
>         points->InsertNextPoint(1,0,0);
>         points->InsertNextPoint(1,1,0);
>         points->InsertNextPoint(0,1,0);
>
>         // vtkSmartPointer<vtkCellArray> lines =
> vtkSmartPointer<vtkCellArray>::New();
>         // lines->InsertNextCell(points->GetNumberOfPoints());
>
>         vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
>         polydata->SetPoints(points);
>
>         vtkSmartPointer<vtkSphereSource> sphereSource =
> vtkSmartPointer<vtkSphereSource>::New();
>         sphereSource->SetThetaResolution(20);
>         sphereSource->SetPhiResolution(20);
>         sphereSource->SetRadius(0.5);
>
>         vtkSmartPointer<vtkGlyph3D> atomGlyphs =
> vtkSmartPointer<vtkGlyph3D>::New();
>         atomGlyphs ->SetInput(polydata);
>         atomGlyphs ->SetSource(sphereSource->GetOutput());
>
>         // Create the mapper & actor for the atoms
>         vtkSmartPointer<vtkPolyDataMapper> atomMapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
>         atomMapper->SetInput(atomGlyphs->GetOutput());
>
>         vtkSmartPointer<vtkActor> sphereActor =
> vtkSmartPointer<vtkActor>::New();
>         sphereActor->SetMapper(atomMapper);
>         sphereActor->GetProperty()->SetColor(0.7, 0.7, 0.7);
>
>         // Tell the polydata to build 'upward' links from points to cells.
>         polydata->BuildLinks();
>         vtkSmartPointer<vtkIdList> cellIds =
> vtkSmartPointer<vtkIdList>::New();
>         polydata->GetPointCells(1, cellIds);
>
>         // Mark a cell as deleted.
>         for (int i = 0; cellIds->GetNumberOfIds();i++){
>                 polydata->DeleteCell(i);
>         }
>
>         // Remove the marked cell.
>         polydata->RemoveDeletedCells();
>
>         vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
>         renderer->AddActor(sphereActor);
>         vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
>         renderWindow->AddRenderer(renderer);
>         vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
>         renderWindowInteractor->SetRenderWindow(renderWindow);
>         renderWindow->Render();
>         renderWindowInteractor->Start();
>
>         return EXIT_SUCCESS;
> }
>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/trade-vtkPoints-between-actors-tp5722498p5722526.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/20130806/3a014d39/attachment.htm>


More information about the vtkusers mailing list