[vtkusers] vtkPolyDataConnectivityFilter Help
Mike Jackson
maillist at bluequartz.net
Wed Nov 30 19:34:07 EST 2005
Turns out while this works for smaller data sets ( < 50,000 points)
in our larger data sets (500,000 points) this chaining of clip
filters together does not work well. By work well, I mean it takes
the code 7 minutes to run. This is just with 179 distinct regions in
the model and about 250,000 points.
All that time is taken up looping for each particle and doing a
pair of clip filters for each particle.
Some of the ideas I had were to generate the clipped output for one
of the filters and use that as the input on the next iteration in the
loop. That should let the loops speed up as more iterations go by
because there is less to filter.
I thought about subclassing the clipfilter and trying to over ride
how the cells get clipped. This led to the discovery that the actual
clipping occurs in the vtkCell class. I got lost in the code trying
to figure that out.
I Looked at vtkExtractPolyDataGeometry which again look promising but
I need to provide a vtkImplicitFunction to get that to work. And it
only works on actual xyz point coordinates, which isn't how I want to
"Extract" the regions.
I then saw the *MultiGroup* classes, but those did not seem
promising either.
So then I went down the road of working from the
vtkPolyDataConnectivityFilter source and trying to make up a new
class based on that. There is a tantalizing section of code in that
class where a new vtkPolyData object will be created for a given
Region Id(s). This is pretty close to what I need but not quite. I
worked most of the day on the code and the closest I can come is to
produce the correct number of vtkPolyData Objects (179 in my current
Model), but all the points are copied into each PolyData object
(235,000). If I post some code can some one have a look and tell me
what I might be doing wrong?
Also, on a side note, besides the regular VTK books, are there any
other resources that explain the layout of the vtk Data structures?
Like what is a vtkCell in relation to vtkPolyData? Is that the actual
triangle, or is it a Hexahedral that encompasses a triangle? Stuff
like that?
Thanks for all the help
Respectfully
Mike Jackson
On Nov 26, 2005, at 12:01 AM, Sylvain Jaume wrote:
> Hi Mike,
>
> Please replace:
> clipInsideOut->SetInput(connections->GetOutput() );
> with:
> clipInsideOut->SetInput(clip->GetOutput() );
>
> Let me know if it works for you.
> Cheers,
> Sylvain
>
> Sylvain Jaume wrote:
>
>> Hi Mike,
>>
>> I think this code will solve your problem:
>>
>> unsigned int numRegions = connections->GetNumberOfExtractedRegions
>> ();
>>
>> vtkClipPolyData *clip = vtkClipPolyData::New();
>> clip->SetInput(connections->GetOutput() );
>>
>> vtkClipPolyData *clipInsideOut = vtkClipPolyData::New();
>> clipInsideOut->SetInput(connections->GetOutput() );
>> clipInsideOut->InsideOutOn();
>>
>> for (unsigned int i = 0; i < numRegions; ++i)
>> {
>> std::cout << "----------- Region Number " << i << "
>> ----------" << std::endl;
>>
>> clip->SetValue( (float) i - 0.5 );
>> clipInsideOut->SetValue( (float) i + 0.5 );
>> clipInsideOut->Update();
>>
>> clipInsideOut->GetOutput()->PrintSelf(std::cout, 1);
>> }
>>
>> Cheers,
>> Sylvain
>>
>> Mike Jackson wrote:
>>
>>>
>>> On Nov 23, 2005, at 6:51 PM, Sylvain Jaume wrote:
>>>
>>>> Hi Mike,
>>>>
>>>> You may want to do:
>>>>
>>>> vtkPolyDataConnectivityFilter *connections =
>>>> vtkPolyDataConnectivityFilter::New();
>>>> connections->SetInput(data);
>>>> connections->SetExtractionModeToAllRegions();
>>>> connections->ColorRegionsOn();
>>>> connections->Update();
>>>>
>>>> unsigned int numRegions = connections-
>>>> >GetNumberOfExtractedRegions();
>>>> vtkClipPolyData *clip = vtkClipPolyData::New();
>>>> clip->SetInput(connections->GetOutput() );
>>>>
>>>> for (unsigned int i = 0; i < numRegions; ++i)
>>>> {
>>>> std::cout << "----------- Region Number " << i << "
>>>> ----------" << std::endl;
>>>> clip->SetValue( (float) i );
>>>> clip->Update();
>>>> clip->GetOutput()->PrintSelf(std::cout, 1);
>>>> }
>>>>
>>>> You don't need clip->GenerateClipScalarsOff();
>>>>
>>>> Cheers,
>>>> Sylvain
>>>>
>>>> Mike Jackson wrote:
>>>>
>>>>>
>>>>> On Nov 23, 2005, at 5:18 PM, Sylvain Jaume wrote:
>>>>>
>>>>>>
>>>>>> You could set ColorRegionsOn in vtkPolyDataConnectivityFilter.
>>>>>> Then use vtkClipPolyData with SetValue set to the region id
>>>>>> (i in your code).
>>>>>>
>>>>>> Cheers,
>>>>>> Sylvain
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> I gave that a try, looking extensively at the docs and this is
>>>>> what I have.
>>>>> //Assume data is of type vtkPolyData which has been through a
>>>>> smoothing
>>>>> // and a Decimation, just prior to this.
>>>>> vtkPolyDataConnectivityFilter *connections =
>>>>> vtkPolyDataConnectivityFilter::New();
>>>>> connections->SetInput(data);
>>>>> connections->SetExtractionModeToAllRegions();
>>>>> connections->Update();
>>>>>
>>>>> /// Loop on each Region
>>>>> unsigned int numRegions = connections-
>>>>> >GetNumberOfExtractedRegions();
>>>>> vtkClipPolyData *clip = vtkClipPolyData::New();
>>>>> vtkImplicitBoolean *func = vtkImplicitBoolean::New();
>>>>> clip->SetInput(connections->GetOutput() );
>>>>> clip->SetClipFunction(func);
>>>>> clip->GenerateClipScalarsOff();
>>>>>
>>>>> for (unsigned int i = 0; i < numRegions; ++i)
>>>>> {
>>>>> std::cout << "----------- Region Number " << i << "
>>>>> ----------" << std::endl;
>>>>> clip->SetValue( (float) i );
>>>>> clip->Update();
>>>>> clip->GetOutput()->PrintSelf(std::cout, 1);
>>>>> }
>>>>>
>>>>> When the prints go by the number of polys, vertices, cells...
>>>>> are all Zero. Any idea what I am doing wrong?
>>>>>
>>>>> I think I am getting confused about the implicit function and
>>>>> whether or not to have GenerateClipScalarsOff or
>>>>> GenerateClipScalarsOn.
>>>>> ---
>>>>> Mike Jackson
>>>>> mike _at_ bluequartz dot net
>>>>>
>>>>>
>>>
>>> I have been working on this problem some more today but am still
>>> coming up short.
>>>
>>> This is the code that I have now:
>>>
>>> unsigned int numRegions = connections-
>>> >GetNumberOfExtractedRegions();
>>> vtkClipPolyData *clip = vtkClipPolyData::New();
>>> clip->SetInput(connections->GetOutput() );
>>> clip->InsideOutOn();
>>> for (unsigned int i = 0; i < 5; ++i)
>>> {
>>> std::cout << "----------- Region Number " << i << "
>>> ----------" << std::endl;
>>> clip->SetValue( (float) i );
>>> clip->Update();
>>>
>>> clip->GetOutput()->PrintSelf(std::cout, 1);
>>> }
>>>
>>> But what happens is the number of polygons just keeps growing
>>> with each iteration, eventually on the last iteration, the
>>> number of polygons in the clip are the same as the number of
>>> original polygons. So I think I am just missing something, could
>>> someone please fill me in?
>>>
>>>
>>
>
---
Mike Jackson
mike _at_ bluequartz dot net
More information about the vtkusers
mailing list