[vtkusers] How do I extract multiple vtkPolyData from a single vtkPolyData read from an XML file.
luca.antiga at gmail.com
Thu Dec 13 03:07:10 EST 2007
what about setting a cell data scalar value to each appended
component before appending
and thresholding afterwards. A bit of a waste of memory, but at least
you don't have to make the
assumption that your components will be simply connected.
Now that I think about that, this could be a nice simple
enhancement for vtkAppendPolyData:
to set the scalar value internally for later de-assembling.
On Dec 13, 2007, at 12:47 AM, Alexandre GOUAILLARD wrote:
> I thought I cc the list, my bad.
> Send me one of your file with all the contour merged in the same
> and I ll send you back the corresponding code using
> filter tonight.
> On 12/12/07 2:49 PM, "kent williams" <nkwmailinglists at gmail.com>
>> I hope you don't mind me reposting your response to the list; you
>> 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
>> then vtk::PolyData->GetLInes() to get the lines. Then I call
>> vtkCellArray::GetCell() to pick out the indices for each line's
>> 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>
>>> Hi kent,
>>> You can use vtkPolyDataConnectivityFilter that will help you
>>> contours that are not connected.
>>> Run once with SetExtractionModeToAllRegion() to get the number of
>>> 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 /
>>> On 12/12/07 1:22 PM, "kent williams" <nkwmailinglists at gmail.com>
>>>> 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
>>>> 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
>>>> 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?
>>>> 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)
>>>> vtkXMLPolyDataWriter *writer = vtkXMLPolyDataWriter::New();
>>>> This is the private VTK discussion list.
>>>> Please keep messages on-topic. Check the FAQ at:
>>>> Follow this link to subscribe/unsubscribe:
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/
> Follow this link to subscribe/unsubscribe:
More information about the vtkusers