[vtkusers] Please help me use vtkLinearExtrusionFilter

Christopher Bruns cmbruns at stanford.edu
Thu Jun 29 15:54:10 EDT 2006


Thank you so much Obada, for your thorough and diligent discovery of the 
underlying cause of the crashes that I experienced.

I applied your patch, and now it works beautifully.

Rebuilding my vtk libraries including your change to vtkRibbonFilter.cxx 
is probably the approach that I will take.  I tried inserting a 
vtkCleanPolyData filter to correct the data corruption, but that filter 
crashed as well.  I wish I could discover a way to work around the 
problem for existing vtk builds, without writing/reading to/from the 
file system.

My own feeble attempts to diagnose the problem included using 
vtkPolyDataWriter to view the object contents.  It's ironic that your 
suggested workaround involved using vtkPolyDataWriter as a filter to 
clean up the data.

May I ask what was your technique for tracking down this problem?

Thanks again for your kind and generous solution.

-Christopher

Obada Mahdi wrote:
> Hi Christopher,
> 
> I have made an attempt to track down the problem and might have found at 
> least the reason.
> 
> Christopher Bruns wrote:
> 
>>  I get a "Access violation reading location 0x00000000" when 
>> attempting to use vtkLinearExtrusionFilter with certain input 
>> pipelines, while I can get it to work with others.
>>
>>  Presumably I am neglecting to populate part of the input data 
>> pipeline correctly.  Can someone please suggest how I might fix my 
>> error here?  Is there some other filter I need to add?
>>
>>  In my debugger the crash appears to occur at line 214 of 
>> vtklinearextrusionfilter.cxx in the method RequestData, which contains 
>> the statement "outputPD->CopyData(pd,ptId,ptId);"  The variable pd 
>> contains input vtkPointData.  Deeper in the stack, 
>> pd->Data[0]->GetVoidPointer(0) returns 0x0000000 instead of returning 
>> a valid pointer, because  pd->Data[0]->Array is zero as well.
> 
> 
> The problem seems to be caused by a small typo in vtkRibbonFilter.cxx 
> that leads to some bogus data array entries in the PointData struct, 
> messing up the extrusion filter later: There is a line
> |  outPD->CopyAllocate(pd,numNewCells);
> which should read
> |  outCD->CopyAllocate(cd,numNewCells);
> (see attached diff).
> 
> I was able to perfectly reproduce all the results (and crashes) you 
> mentioned with a recent CVS version of VTK, and your test program 
> appears to work fine with the above line corrected.
> 
> If rebuilding VTK is not an option for you, and you do not need CellData 
> to be filtered through, there might be other ways to work around that 
> problem and get colored thick ribbons :-)  After all, no point data 
> information is destroyed, and you only need to get rid of any bogus 
> (empty) data field introduced by vtkRibbonFilter.  For example, writing 
> the the output of vtkRibbonFilter to a file (using vtkPolyDataWriter) 
> and feeding that same file to vtkExtrusionFilter using a 
> vtkPolyDataReader did also work for me.
> 
> 
> Good luck :-)
> 
> Obada
> 
> 
> ------------------------------------------------------------------------
> 
> diff -u -r1.80 vtkRibbonFilter.cxx
> --- Graphics/vtkRibbonFilter.cxx	21 Apr 2005 13:42:16 -0000	1.80
> +++ Graphics/vtkRibbonFilter.cxx	24 Jun 2006 04:21:38 -0000
> @@ -176,7 +176,7 @@
>    //
>    numNewCells = inLines->GetNumberOfCells();
>    outCD->CopyNormalsOff();
> -  outPD->CopyAllocate(pd,numNewCells);
> +  outCD->CopyAllocate(cd,numNewCells);
>  
>    //  Create points along each polyline that are connected into NumberOfSides
>    //  triangle strips. Texture coordinates are optionally generated.




More information about the vtkusers mailing list