[vtkusers] passing an vtkCharArray through vtkExtractPolyDataGeometry filter

Karl Merkley karl at elemtech.com
Sat Oct 18 10:50:07 EDT 2008


On Oct 17, 2008, at 4:52 PM, Karl Merkley wrote:

>
> I have polydata that has a vtkCharArray attached as cell data to the  
> polydata.   I pass this polydata through the  
> vtkExtractPolyDataGeometry filter and the cell data is set on all  
> the wrong cells.  This is embedded in a big piece of code so I don't  
> have a small problem that demonstrates this but this is basically  
> what I am doing . . .
>
>
>    // set up a selection loop based on the ordered points in the edges
>    vtkSmartPointer<vtkMyImplicitSelectionOffset> loop =
>       vtkSmartPointer<vtkMyImplicitSelectionOffset>::New();
>    loop->SetLoop(loopPts);
>    loop->SetNormal(0.0, 0.0, 1.0);
>    loop->SetAutomaticNormalGeneration(0);
>    loop->SetOffsetValue(offsetSize);
>
>    // now extract the geometry from each loop
>    vtkSmartPointer<vtkExtractPolyDataGeometry> extract =
>      vtkSmartPointer<vtkExtractPolyDataGeometry>::New();
>    extract->SetImplicitFunction(loop);
>    extract->ExtractInsideOff();
>    extract->SetInput(extractedGeometry);
>    extract->Update();
>
>
> When I write out the data before and after this block of code I find  
> that the vtkCharArray is set correctly before and it is incorrect  
> after this point.   Is this a bug?   Am I misusing the filter?  I  
> _thought_ that filters were supposed to pass the data arrays through  
> without mangling them.
>
> Clarification would be appreciated!
>


Here is the rest of the story.   The above happens in a loop.   The  
pseudo code would be something like:

Given: an initial polydata and a list of holes

for each hole in list

    build an ordered list of points
    create an implicit selection loop
    extract the hole from the initial polydata
    shallow copy the resulting polydata back into the initial polydata

repeat

Now, obviously the data array in the initial polydata is being copied  
because it is still there when I finish the loop (and the extract  
filter does call CopyData like it is supposed to) the data is just on  
the wrong cells!  I thought this might be a ShallowCopy vs. DeepCopy  
problem, but changing the copy type did not affect the results.     
There are no lines in the polydata prior to entering this loop and the  
data is on the correct cells prior to this loop.   I checked that  
because I thought it might be a misalignment between the lines and  
polys in the polydata.  No luck there either.

Now in the end, maybe I need a better algorithm.   Any ideas on how to  
efficiently aggregate all the holes into multiple loops and do the  
extract in one operation?   The holes may overlap so intersections   
would have to be determined and new holes created.   This looks like  
an O(n^2) search to test for intersections and that could be expensive.

Any ideas would be appreciated.

     Karl










More information about the vtkusers mailing list