[vtkusers] How to really delete cells?

Dominik Szczerba dominik at itis.ethz.ch
Wed Jul 29 08:47:58 EDT 2009


Corinne Tith wrote:
> Dominik,
> 
> I know cells are not removed because i tried something like:
> /my_polyData->GetNumberOfCells(//); // returns 100 cells
> for(int i = 1; i < 10; i++)
>     my_polyData->GetPointData()->//GetArray(0)->SetTuple1(i,10);  //  
> part of my volume color changes
> for(int i = 1; i < 50; i++)
>     my_polyData->DeleteCell(i);
> my_polyData->//RemovedDeletedCells();
> my_polyData>GetNumberOfCells()//; // returns 50 cells/
> 
> It seems ok, but on surface/wireframe mode, my volume is the same 
> (except for the color).

sounds like the actor/mapper is not up to date... you need to call 
Update() or Modify() somewhere (on the dataset and/or the )... Also make 
sure that the input is actually valid, if you re-created the object its 
address changes and you have to make sure the actor/mapper gets the 
right input. One way is to use SetInputConnection style, another way is 
to re-set the input via SetInput().

> 
> Moreover, I coded a method that color my surface by following connected 
> points. Some cells are not connected, even if I use ConnectivityFilter.
> 
> Stephane,
> I tried your suggestion of ShallowCopy and I get a black screen. I think 
> I understand what you mean.
> 
> Maybe I should implement my own filter.
> Thanks a lot for your help
> Corinne

If you are after removing the disconnected regions and keeping only the 
largest one the connectivity filter has been serving me very well for 
years now.

-- Dominik

> 
> 
> 
> 
> 2009/7/28 Dominik Szczerba <dominik at itis.ethz.ch 
> <mailto:dominik at itis.ethz.ch>>
> 
>     Well ConnectivityFilter should do this job for you - no need for
>     extra cell removal by foot.
> 
>     -- Dominik
> 
>     Stephane PLOIX wrote:
> 
> 
>         my_polyData is at the end of a pipeline. Each time you Update it
>         (which is done at each frame if you render it), it is reset to
>         the output of the previous filter.
>         If you want to break the dependency chain, you have to insert a
>         ShallowCopy :
>         output = my_vtkPolyDataConnectivityFilter->GetOutput();
>         my_polyData = vtkPolyData::New();
>         my_polyData ->ShallowCopy(output);
>         ...
>         and remeber to call my_polyData ->Delete() later.
> 
>         But the best way would be to implement a filter that does the
>         job to remove some cells, so that your pipeline is still connected.
> 
>         Stephane
> 
> 
> 
> 
>         *cocoricore at gmail.com <mailto:cocoricore at gmail.com>*
>         Envoyé par : vtkusers-bounces at vtk.org
>         <mailto:vtkusers-bounces at vtk.org>
> 
>         28/07/2009 15:47
> 
>                
>         A
>                dominik at itis.ethz.ch <mailto:dominik at itis.ethz.ch>
>         cc
>                vtkusers at vtk.org <mailto:vtkusers at vtk.org>
>         Objet
>                Re: [vtkusers] How to really delete cells?
> 
> 
>                
> 
> 
> 
> 
> 
>         No change.
> 
>         2009/7/28 Dominik Szczerba < dominik at itis.ethz.ch
>         <mailto:dominik at itis.ethz.ch> <mailto:dominik at itis.ethz.ch
>         <mailto:dominik at itis.ethz.ch>> >
>         And what does calling ->Update() ?
> 
>         Corinne Tith wrote:
>         Thanks for your help. I tried to put your code after
>         my_polyData->RemoveDeletedCells();
>         Unfortunately It doesn't work.
>         I tried to delete lot of cells, they are never really removed.
> 
>         My VTK version is 5.2, does it matter?
> 
> 
>         2009/7/28 Dominik Szczerba < dominik at itis.ethz.ch
>         <mailto:dominik at itis.ethz.ch> <mailto:dominik at itis.ethz.ch
>         <mailto:dominik at itis.ethz.ch>> <mailto: dominik at itis.ethz.ch
>         <mailto:dominik at itis.ethz.ch> <mailto:dominik at itis.ethz.ch
>         <mailto:dominik at itis.ethz.ch>> >>
> 
> 
> 
>           my_polyData->Modified()
> 
>           Corinne Tith wrote:
> 
>               Hi all,
> 
>               I get a polydata volume with a vtkContourFilter and a
>               vtkWindowSincPolyDataFilter.
>               Some cells are not connected to the largest volume. They
>         seem to
>               be 'on' the mesh but have no vertice in common.
> 
>               I tried the filters vtkCleanPolyData and
>               vtkPolyDataConnectivityFilter, but most of my unconnected
>         cells
>               are not removed.
>               Finally, I tried to delete them 'manually', but nothing
>         happens.
> 
>               How can I really remove my unconnected cells?
> 
>               Any help is appreciated, thanks!
> 
> 
>               // generate my volume
>            
>           my_vtkWindowSincPolyDataFilter->SetInputConnection(my_vtkContourFilter->GetOutputPort());
> 
>               // no effect on my cells
>            
>           my_vtkCleanPolyData->SetInputConnection(my_vtkWindowSincPolyDataFilter->GetOutputPort());
> 
>               my_vtkCleanPolyData->PointMergingOn();
>            
>           my_vtkPolyDataConnectivityFilter->SetInputConnection(my_vtkContourFilter->GetOutputPort());
>              
>         my_vtkPolyDataConnectivityFilter->SetExtractionModeToLargestRegion();
>               // manual remove
>               my_vtkPolyDataConnectivityFilter->Update();
>               my_polyData = my_vtkPolyDataConnectivityFilter->GetOutput();
>               for(int i = 0; i < n; i++){
>                     my_polyData->DeleteCell(cellsToRemove[i]);
>               }
>               my_polyData->RemoveDeletedCells();
> 
> 
>            
>           ------------------------------------------------------------------------
> 
>               _______________________________________________
>               Powered by www.kitware.com <http://www.kitware.com>
>         <http://www.kitware.com/> < http://www.kitware.com
>         <http://www.kitware.com/> >
> 
> 
> 
>               Visit other Kitware open-source projects at
>                http://www.kitware.com/opensource/opensource.html
>         <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
>         <http://www.vtk.org/Wiki/VTK_FAQ>
> 
> 
>               Follow this link to subscribe/unsubscribe:
>                http://www.vtk.org/mailman/listinfo/vtkusers
>         <http://www.vtk.org/mailman/listinfo/vtkusers>
> 
> 
> 
> 
> 
>         _______________________________________________
>         Powered by www.kitware.com <http://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
> 
> 
>         ------------------------------------------------------------------------
> 
> 
>         _______________________________________________
>         Powered by www.kitware.com <http://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
> 
> 
> 


-- 
d o m i n i k   s z c z e r b a ,   p h d . . . . . . . . . . .
c o m p u t a t i o n a l   l i f e   s c i e n c e   g r o u p
. . . . . . . i t ' i s   r e s e a r c h   f o u n d a t i o n
. . . . . . . . . . . . . . . . . . . . http://www.itis.ethz.ch




More information about the vtkusers mailing list