<div dir="ltr">First I read a seriers of contours and create a vtkPolyData with vtkAppendPolyData (e.g.: 100 contours as 1 polydata).<br><br>Then, create a vtkImageData with the same spacing  and origin as the dicom image and set the extent to the extent of polydata.<br>
<br>Now apply vtkLinearExtrusionFilter to the polydata and then apply vtkPolyDataToImageStencil, now finally applying the vtkImageStencil.<br><br>I works satisfactorily for vtkPolyData with bounds[2] in the range 0 to 50 or so. But becomes slow when I need to extrude on all the z slices of the image.<br>
<br>here is the code<br><br><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">*</span>bounds<span style=" color:#000000;">=</span>appendFilter<span style=" color:#000000;">-&gt;</span>GetOutput<span style=" color:#000000;">()-&gt;</span>GetBounds<span style=" color:#000000;">();</span>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>vtkSmartPointer<span style=" color:#000000;">&lt;</span>vtkImageData<span style=" color:#000000;">&gt;</span><span style=" color:#c0c0c0;"> </span>binary_image<span style=" color:#000000;">=</span>vtkSmartPointer<span style=" color:#000000;">&lt;</span>vtkImageData<span style=" color:#000000;">&gt;::</span>New<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>binary_image<span style=" color:#000000;">-&gt;</span>SetScalarTypeToUnsignedChar<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#008000;">///Use</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">the</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">smallest</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">mask</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">which</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">the</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">mesh</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">fits</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Add</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">two</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">voxels</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">on</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">each</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">side</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">to</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">make</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">sure</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">the</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">mesh</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">fits</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>samp_origin<span style=" color:#000000;">=</span>imgData<span style=" color:#000000;">-&gt;</span>GetOrigin<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>spacing<span style=" color:#000000;">=</span>imgData<span style=" color:#000000;">-&gt;</span>GetSpacing<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>binary_image<span style=" color:#000000;">-&gt;</span>SetSpacing<span style=" color:#000000;">(</span>spacing<span style=" color:#000000;">);</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#000080;">///</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">Put</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">the</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">origin</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">on</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">a</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">voxel</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">to</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">avoid</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">small</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">skips</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>binary_image<span style=" color:#000000;">-&gt;</span>SetOrigin<span style=" color:#000000;">(</span>floor<span style=" color:#000000;">((</span>bounds<span style=" color:#000000;">[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">]-</span>samp_origin<span style=" color:#000000;">[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">])/</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">]-</span><span style=" color:#000080;">2</span><span style=" color:#000000;">)*</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">]+</span>samp_origin<span style=" color:#000000;">[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">],</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                                       </span>floor<span style=" color:#000000;">((</span>bounds<span style=" color:#000000;">[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">]-</span>samp_origin<span style=" color:#000000;">[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">])/</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">]-</span><span style=" color:#000080;">2</span><span style=" color:#000000;">)*</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">]+</span>samp_origin<span style=" color:#000000;">[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">],</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                                       </span>floor<span style=" color:#000000;">((</span>bounds<span style=" color:#000000;">[</span><span style=" color:#000080;">4</span><span style=" color:#000000;">]-</span>samp_origin<span style=" color:#000000;">[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">])/</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">]-</span><span style=" color:#000080;">2</span><span style=" color:#000000;">)*</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">]+</span>samp_origin<span style=" color:#000000;">[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">]);</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>origin<span style=" color:#000000;">=</span>binary_image<span style=" color:#000000;">-&gt;</span>GetOrigin<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>binary_image<span style=" color:#000000;">-&gt;</span>SetExtent<span style=" color:#000000;">(</span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span>ceil<span style=" color:#000000;">((</span>bounds<span style=" color:#000000;">[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">]-</span>origin<span style=" color:#000000;">[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">])/</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">]+</span><span style=" color:#000080;">4</span><span style=" color:#000000;">),</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                                       </span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span>ceil<span style=" color:#000000;">((</span>bounds<span style=" color:#000000;">[</span><span style=" color:#000080;">3</span><span style=" color:#000000;">]-</span>origin<span style=" color:#000000;">[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">])/</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">]+</span><span style=" color:#000080;">4</span><span style=" color:#000000;">),</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                                       </span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span>ceil<span style=" color:#000000;">((</span>bounds<span style=" color:#000000;">[</span><span style=" color:#000080;">5</span><span style=" color:#000000;">]-</span>origin<span style=" color:#000000;">[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">])/</span>spacing<span style=" color:#000000;">[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">])+</span><span style=" color:#000080;">4</span><span style=" color:#000000;">);</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>binary_image<span style=" color:#000000;">-&gt;</span>AllocateScalars<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>memset<span style=" color:#000000;">(</span>binary_image<span style=" color:#000000;">-&gt;</span>GetScalarPointer<span style=" color:#000000;">(),</span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span>binary_image<span style=" color:#000000;">-&gt;</span>GetDimensions<span style=" color:#000000;">()[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">]*</span>binary_image<span style=" color:#000000;">-&gt;</span>GetDimensions<span style=" color:#000000;">()[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">]*</span>binary_image<span style=" color:#000000;">-&gt;</span>GetDimensions<span style=" color:#000000;">()[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">]*</span><span style=" color:#808000;">sizeof</span><span style=" color:#000000;">(</span><span style=" color:#808000;">unsigned</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">char</span><span style=" color:#000000;">));</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span>qDebug<span style=" color:#000000;">()&lt;&lt;</span>binary_image<span style=" color:#000000;">-&gt;</span>GetExtent<span style=" color:#000000;">()[</span><span style=" color:#000080;">0</span><span style=" color:#000000;">]&lt;&lt;</span>binary_image<span style=" color:#000000;">-&gt;</span>GetExtent<span style=" color:#000000;">()[</span><span style=" color:#000080;">1</span><span style=" color:#000000;">]&lt;&lt;</span>binary_image<span style=" color:#000000;">-&gt;</span>GetExtent<span style=" color:#000000;">()[</span><span style=" color:#000080;">2</span><span style=" color:#000000;">]&lt;&lt;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                    </span>binary_image<span style=" color:#000000;">-&gt;</span>GetExtent<span style=" color:#000000;">()[</span><span style=" color:#000080;">3</span><span style=" color:#000000;">]&lt;&lt;</span>binary_image<span style=" color:#000000;">-&gt;</span>GetExtent<span style=" color:#000000;">()[</span><span style=" color:#000080;">4</span><span style=" color:#000000;">]&lt;&lt;</span>binary_image<span style=" color:#000000;">-&gt;</span>GetExtent<span style=" color:#000000;">()[</span><span style=" color:#000080;">5</span><span style=" color:#000000;">]&lt;&lt;</span><span style=" color:#008000;">&quot;Binary</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">image</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">extent&quot;</span><span style=" color:#000000;">;</span></pre>



<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>vtkSmartPointer<span style=" color:#000000;">&lt;</span>vtkPolyDataToImageStencil<span style=" color:#000000;">&gt;</span><span style=" color:#c0c0c0;"> </span>sts<span style=" color:#000000;">=</span>vtkSmartPointer<span style=" color:#000000;">&lt;</span>vtkPolyDataToImageStencil<span style=" color:#000000;">&gt;::</span>New<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#008000;">//The</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">following</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">line</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">is</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">extremely</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">important</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#008000;">//<a href="http://www.nabble.com/Bug-in-vtkPolyDataToImageStencil--td23368312.html#a23370933">http://www.nabble.com/Bug-in-vtkPolyDataToImageStencil--td23368312.html#a23370933</a></span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>sts<span style=" color:#000000;">-&gt;</span>SetTolerance<span style=" color:#000000;">(</span><span style=" color:#000080;">0</span><span style=" color:#000000;">);</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>sts<span style=" color:#000000;">-&gt;</span>SetInformationInput<span style=" color:#000000;">(</span>binary_image<span style=" color:#000000;">);</span><span style=" color:#c0c0c0;">                        </span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>vtkSmartPointer<span style=" color:#000000;">&lt;</span>vtkLinearExtrusionFilter<span style=" color:#000000;">&gt;</span><span style=" color:#c0c0c0;"> </span>extrude<span style=" color:#000000;">=</span>vtkSmartPointer<span style=" color:#000000;">&lt;</span>vtkLinearExtrusionFilter<span style=" color:#000000;">&gt;::</span>New<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>extrude<span style=" color:#000000;">-&gt;</span>SetInput<span style=" color:#000000;">(</span>appendFilter<span style=" color:#000000;">-&gt;</span>GetOutput<span style=" color:#000000;">());</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>extrude<span style=" color:#000000;">-&gt;</span>CappingOn<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#008000;">///We</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">extrude</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">the</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">-slice_spacing</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">direction</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">to</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">respect</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">the</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">FOCAL</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">convention</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>extrude<span style=" color:#000000;">-&gt;</span>SetVector<span style=" color:#000000;">(</span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span><span style=" color:#000000;">,-</span>zSpacing<span style=" color:#000000;">);</span><span style=" color:#008000;">//Correct</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Z</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">spacing</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">is</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">important</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span><span style=" color:#008000;">//qDebug()&lt;&lt;-zSpacing&lt;&lt;&quot;-ve</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">zSpacing&quot;;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>sts<span style=" color:#000000;">-&gt;</span>SetInput<span style=" color:#000000;">(</span>extrude<span style=" color:#000000;">-&gt;</span>GetOutput<span style=" color:#000000;">());</span></pre>



<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>qDebug<span style=" color:#000000;">()&lt;&lt;</span>t<span style=" color:#000000;">-&gt;</span>currentTime<span style=" color:#000000;">()&lt;&lt;</span><span style=" color:#008000;">&quot;Stencil</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">start&quot;</span><span style=" color:#000000;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>vtkSmartPointer<span style=" color:#000000;">&lt;</span>vtkImageStencil<span style=" color:#000000;">&gt;</span><span style=" color:#c0c0c0;"> </span>stencil<span style=" color:#000000;">=</span>vtkSmartPointer<span style=" color:#000000;">&lt;</span>vtkImageStencil<span style=" color:#000000;">&gt;::</span>New<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>stencil<span style=" color:#000000;">-&gt;</span>SetStencil<span style=" color:#000000;">(</span>sts<span style=" color:#000000;">-&gt;</span>GetOutput<span style=" color:#000000;">());</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>stencil<span style=" color:#000000;">-&gt;</span>SetInput<span style=" color:#000000;">(</span>binary_image<span style=" color:#000000;">);</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>stencil<span style=" color:#000000;">-&gt;</span>Update<span style=" color:#000000;">();</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">               </span>qDebug<span style=" color:#000000;">()&lt;&lt;</span>t<span style=" color:#000000;">-&gt;</span>currentTime<span style=" color:#000000;">()&lt;&lt;</span><span style=" color:#008000;">&quot;Stencil</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">stop&quot;</span><span style=" color:#000000;">;</span></pre>
<br><br> <br><br>The bslowest execution occus only when I do this for the body contour, which is there on every dicom image slice.<br><br>Can you have a look at the code and suggest ways to improve the speed,please. The idea is from vv open source viewer.<br>
<br>Thanks<br><br>Jothy<br><br><div class="gmail_quote">On Mon, Jul 25, 2011 at 1:18 PM, David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Jothy,<br>
<br>
How are you creating the stencil?  The reason that I ask is that<br>
vtkImageStencil is a fast filter, so I doubt that it is what is causing<br>
the slowdown.  But some of the stencil source filters, especially<br>
vtkImplicitFunctionToImageStencil, can be slow depending on how<br>
they are used.<br>
<font color="#888888"><br>
 - David<br>
</font><div><div></div><div class="h5"><br>
On Mon, Jul 25, 2011 at 3:09 AM, Jothy &lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; I am running in release mode in QtCreator. I even tried running from outside and also copiling with -o2 and -03 optimization flags, but there is no improvement.<br>
&gt;<br>
&gt; Jothy<br>
&gt;<br>
&gt; On Sun, Jul 24, 2011 at 4:18 AM, John Drescher &lt;<a href="mailto:drescherjm@gmail.com">drescherjm@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Sat, Jul 23, 2011 at 3:48 PM, Jothy &lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; Hi all,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; In my program vtkImageStencil take alomost 2-3 mins for vtkImageData with<br>
&gt;&gt; &gt; 160 slices with 0.9x0.9x2.5 spacing. Is there any way to speed up this?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; Are you running release mode? And also not inside the debugger?<br>
&gt;&gt; Running debug mode or inside the Visual Studio can slow down some<br>
&gt;&gt; applications considerably ( I am talking about &gt; 10 times slower).<br>
&gt;&gt;<br>
&gt;&gt; John<br>
</div></div></blockquote></div><br></div>