[vtk-developers] potential speedup for the vtkpolydatatoimagestencil

Mark Roden mmroden at gmail.com
Tue Feb 28 15:08:44 EST 2012


This crashes.

    vtkExtractEdges* theEdger = vtkExtractEdges::New();
    theEdger->SetInput(data);
    theEdger->Update();

    vtkStripper* theStripper = vtkStripper::New();
    theStripper->SetInputConnection(theEdger->GetOutputPort());
    theStripper->Update();

    vtkPolyDataToImageStencil* pol2Stenc = vtkPolyDataToImageStencil::New();
    pol2Stenc->SetTolerance(0);
    pol2Stenc->SetInputConnection(theStripper->GetOutputPort());
//    pol2Stenc->SetInputConnection(extruder->GetOutputPort());
    pol2Stenc->SetInformationInput(flippedImage);
    pol2Stenc->Update();

    vtkImageStencil* stencil = vtkImageStencil::New();
    stencil->SetInput(flippedImage);
    stencil->ReverseStencilOn();
    stencil->SetStencil(pol2Stenc->GetOutput());
    stencil->Update();

If I remove the stripper, then there's no crash, but the result is a
blank image.

On Tue, Feb 28, 2012 at 11:46 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> The vtkExtractEdges filter should do what you need, and you can
> follow it with vtkStripper to ensure that the resulting polylines are
> continuous.
>
>  - David
>
>
> On Tue, Feb 28, 2012 at 12:40 PM, Mark Roden <mmroden at gmail.com> wrote:
>> OK, I think I see the problem here-- the gdcm loader is explicitly
>> loading the data as a polygon rather than as a polyline.
>>
>> Is there a cheap way to convert between the two?  A simple function
>> call, or a way to iterate through the data to convert it to a line so
>> as to use the cheaper code path in the stenciling step?
>>
>> Thanks,
>> Mark
>>
>> On Mon, Feb 27, 2012 at 1:13 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>> There is a dashboard test that uses the direct path (see the section
>>> after "#test again with a contour").  It only uses a single contour,
>>> but I've used vtkPolyDataToImageStencil extensively with a series
>>> of contours.  The example passes the contours through vtkStripper
>>> to make each contour into an ordered, contiguous polyline but I don't
>>> think that step is necessary.
>>>
>>> http://vtk.org/gitweb?p=VTK.git;a=blob;f=Hybrid/Testing/Tcl/TestImageStencilWithPolydata.tcl;#l35
>>>
>>>  - David
>>>
>>> On Mon, Feb 27, 2012 at 2:07 PM, Mark Roden <mmroden at gmail.com> wrote:
>>>> Hi David,
>>>>
>>>> I know where the split in the code is.  My point is that the direct
>>>> path doesn't work with rtstructs, ie, the result of reading rtstructs
>>>> via the vtkGDCMPolyDataReader.  It only works if I run the extrusion
>>>> first.  In addition, I can't find other code that uses the direct
>>>> path, so I can't see how to fix the polydata (if it's, in fact,
>>>> broken) to use the direct path.
>>>>
>>>> So how can I get the direct path to be chosen?  The output from the
>>>> reader is a set of lines, and only adds polys once we do the
>>>> extrusion.  Given that it still takes 10 seconds, _something_ is being
>>>> done there...
>>>>
>>>> Thanks,
>>>> Mark
>>>>
>>>> On Mon, Feb 27, 2012 at 12:58 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>> On Mon, Feb 27, 2012 at 1:24 PM, Mark Roden <mmroden at gmail.com> wrote:
>>>>>
>>>>>> David, if you could please shed some light on how to use the faster code path-- right now, it produces blank binary images.
>>>>>
>>>>> See line 320 in the source code.  That's the "if" statement that
>>>>> chooses the cutter-path (if the input is polys) or the direct path (if
>>>>> the input is polyline contours that are aligned with the slices).
>>>>>
>>>>> http://vtk.org/gitweb?p=VTK.git;a=blob;f=Hybrid/vtkPolyDataToImageStencil.cxx;#l320
>>>>>
>>>>> If you want to be sure about what path your data is taking, you can
>>>>> add print statements to the code, or run your program in a debugger.
>>>>>
>>>>>  - David



More information about the vtk-developers mailing list