[vtkusers] How do I extract multiple vtkPolyData from a single vtkPolyData read from an XML file.
kent williams
nkwmailinglists at gmail.com
Wed Dec 12 17:49:42 EST 2007
I hope you don't mind me reposting your response to the list; you sent
it to me alone.
I looked at this as a solution and it rather baffled me, so I have a
solution that involves fiddling around with the vtkCells directly. I
know that the vtkPolyData in the disk file will comprise a collection
of lines, so i call vtk::PolyData->GetPoints() to get the point array,
then vtk::PolyData->GetLInes() to get the lines. Then I call
vtkCellArray::GetCell() to pick out the indices for each line's points
in the point array....
Convoluted I know, but I couldn't really see how to use
vtkPolyDataConnectivityFilter could do ti for me, so I went caveman on
the problem.
It would ultimately be more useful to have some simple things
happening, like there being some sort of converse to
vtkAppendPolyData, or some way, given that you know the structure of
the data you're reading in you could just ask the reader for it. But
so long asa I get the job done it doesn't matter so much to me....
On Dec 12, 2007 3:45 PM, Alexandre GOUAILLARD <hanfei at caltech.edu> wrote:
> Hi kent,
>
> You can use vtkPolyDataConnectivityFilter that will help you separate
> contours that are not connected.
>
> Run once with SetExtractionModeToAllRegion() to get the number of contours
> with GetNumberOfExtractedRegions(), then extract them by adding the region
> Id through AddSpecifiedRegion(int id). I don't remember how to get the
> output then, but this should get you started.
>
> For information, you have the equivalent in ITK:
> VtkPolyData => itkMesh / itkQuadEdgeMEsh
> VtkPolyDataConnectivityFilter => itkConnectedRegionMeshFilter /
> itkQuadEdgeMeshExtractCOmponentFilter
>
> Alex.
>
>
>
> On 12/12/07 1:22 PM, "kent williams" <nkwmailinglists at gmail.com> wrote:
>
> > Code example below but here is what I'm trying to do: I load a 3D
> > volume and use vtkContourWidget to trace contours on different slices.
> > Then, I need to write out a file that contains all those contours.
> > To write the file out is easy: my code is below. Basically I use a
> > vtkAppendPolyData object to stick all the contours (which I save as
> > vtkPolyData) into a single vtkPolyData, and then write that out.
> >
> > But there really isn't the opposite of a vtkAppendPolyData. I assume
> > I'll have to do some sort of traversal to pull my contours back out of
> > the reader's output. Does anyone have an example of that?
> >
> > void
> > vtkKWImageViewerWidget::
> > SaveROI(const char *filename)
> > {
> > vtkAppendPolyData *pd = vtkAppendPolyData::New();
> > for(TraceMap::iterator tmIt = this->m_SliceTraces.begin();
> > tmIt != this->m_SliceTraces.end(); ++tmIt)
> > {
> > for(PolyDataList::iterator polyIt = tmIt->second.begin();
> > polyIt != tmIt->second.end(); ++polyIt)
> > {
> > pd->AddInput(*polyIt);
> > }
> > }
> > pd->Update();
> > vtkXMLPolyDataWriter *writer = vtkXMLPolyDataWriter::New();
> > writer->SetInput(pd->GetOutput());
> > writer->SetDataModeToAscii();
> > writer->SetFileName(filename);
> > writer->Write();
> > writer->Delete();
> > pd->Delete();
> > }
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
More information about the vtkusers
mailing list