[vtkusers] question about vtkPolyDataConnectivityFilter

Mike Jackson imikejackson at gmail.com
Sat Apr 5 11:44:05 EDT 2008


I am not fully understanding what you are trying to accomplish. If you
could post some more details regarding the code you are trying to
write and what you would like that code to output the vtk list might
be more helpful.

Mike

On Sat, Apr 5, 2008 at 9:19 AM, Anja Ende <anja.ende at googlemail.com> wrote:
> Hi Mike,
>
>  Thanks for your reply! I did as you had suggested but am having
>  problems as follows:
>
>  int npts, *pts;
>  int numCells = polyData->GetLines()->GetNumberOfCells();
>  while (polyData->GetLines()->GetNextCell(npts,pts) )
>  {
>         for (int j = 0; j < npts; ++j)
>         {
>                 vtkCell * cell = ....
>         }
>  }
>
>  How can I now access the current cell. I ran this through the debugger
>  and I can see that the number of points returned by GetNextCell() is
>  2. However, I am not sure how I can now access these coordinates! Any
>  ideas?
>
>  Thanks,
>
>  Anja
>
>
>
>  On 05/04/2008, Mike Jackson <imikejackson at gmail.com> wrote:
>  > You also want to add:
>  >
>  >  polyDataFilter->SetExtractionModeToAllRegions();
>  >
>  >  After you run the filter the first time then you will run it in a loop,
>  > each time through the loop you set:
>  >  for (int i = 0; i < numRegions; ++i)
>  >  {
>  >  polyDataFilter->InitializeSpecifiedRegionList ()
>  >  polyDataFilter->AddSpecifiedRegion (i);
>  >  polyDataFilter->SetInput(contourFilter->GetOutput());
>  >  polyDataFilter->SetScalarRange(255.0, 255.0);
>  >  polyDataFilter->Update();
>  >  vtkPolyData* polyData = polYDataFilter->getOUtput();
>  >  }
>  >
>  >  That is only one way and it has been a while since I have had to do
>  > something like this. There may be newer/faster ways.
>  >
>  >  The way we solved it was to re-write the vtkPolYDataConnectivityFilter to
>  > actually extract all the regions and store them in a vtkPolyDataCollection.
>  > This proved the fastest for us.
>  >
>  >  Our code can be found here:
>  > http://titanium.imts.us/viewvc/Task_4/Mesher/DNAPolyDataConnectivityFilter.cpp?view=log
>  > http://titanium.imts.us/viewvc/Task_4/Mesher/DNAPolyDataConnectivityFilter.h?view=log
>  >
>  >  They may need to be updated for vtk 5.x but you are welcome to use the
>  > code.
>  >
>  >  --
>  >  Mike Jackson   Senior Research Engineer
>  >  Innovative Management & Technology Services
>  >
>  >
>  >
>  >  On Apr 5, 2008, at 7:27 AM, Anja Ende wrote:
>  >
>  > >
>  > > Hi everyone,
>  > >
>  > > I am using vtkPolyDataConnectivityFilter as follows:
>  > >
>  > > vtkContourFilter * contourFilter = vtkContourFilter::New();
>  > > contourFilter->SetInput(vtkDicomReader->GetOutput());
>  > > contourFilter->SetValue(0, 255);
>  > >
>  > > vtkPolyDataConnectivityFilter * polyDataFilter =
>  > > vtkPolyDataConnectivityFilter::New();
>  > > polyDataFilter->SetInput(contourFilter->GetOutput());
>  > > polyDataFilter->SetScalarRange(255.0, 255.0);
>  > > polyDataFilter->Update();
>  > >
>  > > int regions =
>  > polyDataFilter->GetNumberOfExtractedRegions();
>  > >
>  > > Now what I want to do is iterate through all the regions and each of
>  > > the points in the region. However, I cannot figure out how to do this.
>  > > Anyone has any idea on how I can iterate through the regions and the
>  > > points?
>  > >
>  > > Cheers,
>  > >
>  > > Anja
>
>
>  --
>  Cheers,
>
>  Anja
>



More information about the vtkusers mailing list