<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: Tahoma, Verdana, Arial, sans-serif; "><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); ">Christian,</pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); ">Thanks for your response. I did some more extensive testing with gdb. This is what I've found.&nbsp;The function I use is pasted below.&nbsp;</pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); "><meta http-equiv="content-type" content="text/html; charset=utf-8">sampleGrid is the structure storing label ids. For the case where sampleGrid was a 125x125x150 volume, everything works correctly. For a larger volume of 313x313x300 grid, the function crashes in vtkDiscreteMarchingCubes.cxx on line 136:</pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); ">&nbsp;&nbsp; &nbsp;s[0] = scalars[idx]</pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); ">This occurs at the very first iteration of the loop. I discovered that the local variable scalars (which points to the same address as sampleGrid) is no longer accessible within the function. Did VTK delete this&nbsp;structure somewhere between the time the classes were created and the time it was invoked?&nbsp;</pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); ">Any help would be appreciated!</pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); ">Thommen</pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); "><br></pre><pre style="line-height: 17px; white-space: normal; "><meta name="qrichtext" content="1"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "></p>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><font class="Apple-style-span" color="#808000">void</font><span style="color: rgb(192, 192, 192); "> </span><font class="Apple-style-span" color="#2A2A2A">addMultiColorRois</font><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(192, 192, 192); "> </span><span style="color: rgb(128, 128, 0); ">short</span><span style="color: rgb(0, 0, 0); ">*</span><span style="color: rgb(192, 192, 192); "> </span><font class="Apple-style-span" color="#2A2A2A">sampleGrid</font><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(192, 192, 192); "> </span><span style="color: rgb(128, 128, 0); ">int</span><span style="color: rgb(192, 192, 192); "> </span><font class="Apple-style-span" color="#2A2A2A">numContours</font><span style="color: rgb(0, 0, 0); ">,</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">                              </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>dimX<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>dimY<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>dimZ<span style=" color:#000000;">,</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">                              </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span>voxX<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span>voxY<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span>voxZ<span style=" color:#000000;">,</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">                              </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>minX<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>minY<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>minZ<span class="Apple-style-span" style="color: rgb(0, 0, 0); ">)</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#000000;">{</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Use</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">existing</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">array</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">of</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">samples,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">such</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">that</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">vtk</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">does</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">not</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">free</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">memory.</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>vtkShortArray<span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>sampleData<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>vtkShortArray<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>numSamples<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>dimX<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>dimY<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>dimZ<span style=" color:#000000;">;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampleData<span style=" color:#000000;">-&gt;</span>SetArray<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span>sampleGrid<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span>numSamples<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampleData<span style=" color:#000000;">-&gt;</span>SetNumberOfComponents<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampleData<span style=" color:#000000;">-&gt;</span>SetNumberOfTuples<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span>numSamples<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampleData<span style=" color:#000000;">-&gt;</span>SetName<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"values"</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre><pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#000000;"><br></span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Set</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">up</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">sampled</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">data</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">space</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>vtkImageData<span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>sampledSpace<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>vtkImageData<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampledSpace<span style=" color:#000000;">-&gt;</span>SetDimensions<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span>dimX<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span>dimY<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span>dimZ<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampledSpace<span style=" color:#000000;">-&gt;</span>SetScalarTypeToShort<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampledSpace<span style=" color:#000000;">-&gt;</span>GetPointData<span style=" color:#000000;">()-&gt;</span>SetScalars<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span>sampleData<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampledSpace<span style=" color:#000000;">-&gt;</span>SetSpacing<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span>voxX<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span>voxY<span style=" color:#000000;">,</span><span style=" color:#c0c0c0;"> </span>voxZ<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span><span style=" color:#c0c0c0;">  </span><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">set</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">dimensions</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">of</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">a</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">voxel</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampledSpace<span style=" color:#000000;">-&gt;</span>SetOrigin<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span><span style=" color:#808000;">double</span><span style=" color:#000000;">)</span>minX<span style=" color:#000000;">,</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">                           </span><span style=" color:#000000;">(</span><span style=" color:#808000;">double</span><span style=" color:#000000;">)</span>minY<span style=" color:#000000;">,</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">                           </span><span style=" color:#000000;">(</span><span style=" color:#808000;">double</span><span style=" color:#000000;">)</span>minZ<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span><span style=" color:#c0c0c0;">       </span><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">set</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">lower</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">left</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">corner</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">location</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Create</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">isosurface</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>vtkDiscreteMarchingCubes<span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>dmc<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>vtkDiscreteMarchingCubes<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>dmc<span style=" color:#000000;">-&gt;</span>SetInput<span style=" color:#000000;">(</span>sampledSpace<span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>dmc<span style=" color:#000000;">-&gt;</span>GenerateValues<span style=" color:#000000;">(</span>numContours<span style=" color:#000000;">,</span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span>numContours<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; text-indent: 0px; color: rgb(42, 42, 42); "></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;"><br></span></pre><pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>vtkLookupTable<span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>lut<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>vtkLookupTable<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>lut<span style=" color:#000000;">-&gt;</span>SetNumberOfColors<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span>numContours<span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#008000;">//lut-&gt;SetTableRange(0,numContours-1);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>lut<span style=" color:#000000;">-&gt;</span>SetHueRange<span style=" color:#000000;">(</span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span><span style=" color:#000080;">0.667</span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>lut<span style=" color:#000000;">-&gt;</span>Build<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#808000;">for</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>c<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span><span style=" color:#000000;">;</span><span style=" color:#c0c0c0;"> </span>c<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">&lt;</span><span style=" color:#c0c0c0;"> </span>numContours<span style=" color:#000000;">-</span><span style=" color:#000080;">1</span><span style=" color:#000000;">;</span><span style=" color:#c0c0c0;"> </span>c<span style=" color:#000000;">++)</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#000000;">{</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">      </span><span style=" color:#808000;">float</span><span style=" color:#c0c0c0;"> </span>red<span style=" color:#000000;">,</span>green<span style=" color:#000000;">,</span>blue<span style=" color:#000000;">;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">      </span>red<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span>rand<span style=" color:#000000;">()</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">%</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">256</span><span style=" color:#000000;">)/</span><span style=" color:#000080;">255.0</span><span style=" color:#000000;">;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">      </span>green<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span>rand<span style=" color:#000000;">()</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">%</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">256</span><span style=" color:#000000;">)/</span><span style=" color:#000080;">255.0</span><span style=" color:#000000;">;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">      </span>blue<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span>rand<span style=" color:#000000;">()</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">%</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">256</span><span style=" color:#000000;">)/</span><span style=" color:#000080;">255.0</span><span style=" color:#000000;">;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">      </span>lut<span style=" color:#000000;">-&gt;</span>SetTableValue<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span>c<span style=" color:#000000;">,</span>red<span style=" color:#000000;">,</span>green<span style=" color:#000000;">,</span>blue<span style=" color:#000000;">,</span><span style=" color:#000080;">1.0</span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#000000;">}</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;"><br></span></pre><pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Create</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">mapper</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">and</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">actor,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">and</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">add</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">to</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">renderer</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>vtkPolyDataMapper<span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>contourMapper<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>vtkPolyDataMapper<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>contourMapper<span style=" color:#000000;">-&gt;</span>SetInput<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span>dmc<span style=" color:#000000;">-&gt;</span>GetOutput<span style=" color:#000000;">()</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>contourMapper<span style=" color:#000000;">-&gt;</span>SetLookupTable<span style=" color:#000000;">(</span>lut<span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>contourMapper<span style=" color:#000000;">-&gt;</span>SetScalarRange<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">(</span><span style=" color:#000080;">0</span><span style=" color:#000000;">,</span>numContours<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; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>contourMapper<span style=" color:#000000;">-&gt;</span>SetScalarModeToUseCellData<span style=" color:#000000;">();</span></pre><pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#000000;"><br></span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>vtkActor<span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>impGeoActor<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>vtkActor<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>impGeoActor<span style=" color:#000000;">-&gt;</span>SetMapper<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span>contourMapper<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;"><br></span></pre><pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>pos<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>addActor<span style=" color:#000000;">(</span><span style=" color:#c0c0c0;"> </span>impGeoActor<span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">);</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>contourMapper<span style=" color:#000000;">-&gt;</span>Delete<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>dmc<span style=" color:#000000;">-&gt;</span>Delete<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampledSpace<span style=" color:#000000;">-&gt;</span>Delete<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>sampleData<span style=" color:#000000;">-&gt;</span>Delete<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span>lut<span style=" color:#000000;">-&gt;</span>Delete<span style=" color:#000000;">();</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#c0c0c0;">  </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span>pos<span style=" color:#000000;">;</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><span style=" color:#000000;">}</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; color: rgb(42, 42, 42); "><!--EndFragment--></pre></pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); "><br></pre><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); "><meta http-equiv="content-type" content="text/html; charset=utf-8">------------------------------</pre><div style="color: rgb(42, 42, 42); "><br></div><pre style="line-height: 17px; white-space: normal; color: rgb(42, 42, 42); ">Message: 12<br style="line-height: 17px; ">Date: Tue, 1 Mar 2011 10:26:45 +0100<br style="line-height: 17px; ">From: Christian Lackas &lt;lackas@invicro.com&gt;<br style="line-height: 17px; ">Subject: Re: [vtkusers] Visualizing multiple isosurfaces        using<br style="line-height: 17px; ">vtkContourFilter<br style="line-height: 17px; ">To: vtkusers@vtk.org<br style="line-height: 17px; ">Message-ID: &lt;20110301092645.GB24647@invicro.com&gt;<br style="line-height: 17px; ">Content-Type: text/plain; charset=us-ascii<br style="line-height: 17px; "><br style="line-height: 17px; ">* Thommen Korah &lt;thkorah@hotmail.com&gt; [110301 01:25]:<br style="line-height: 17px; "><br style="line-height: 17px; ">Hi Thommen,<br style="line-height: 17px; "><br style="line-height: 17px; ">&gt; I noticed your thread where you were trying to do the same. Similar to<br style="line-height: 17px; ">&gt; your example, I ended up calling generateValues to create N contours<br style="line-height: 17px; ">&gt; and mapped it to colors in a lookup table. Thanks for your example.<br style="line-height: 17px; "><br style="line-height: 17px; ">glad to hear it helped somebody else, also.<br style="line-height: 17px; "><br style="line-height: 17px; ">&gt; While this method works correctly for a 125x125x50 volume, a larger<br style="line-height: 17px; ">&gt; 312x312x300 volume of short int causes a segmentation fault in<br style="line-height: 17px; ">&gt; vtkDiscreteMarchingCubesComputeGradient().<br style="line-height: 17px; "><br style="line-height: 17px; ">The volumes I have worked with can easily be larger than your example,<br style="line-height: 17px; ">however, I typically only have 5-10 ROIs.<br style="line-height: 17px; ">Did you look at the segfault in a debugger already (e.g. is this a<br style="line-height: 17px; ">memory issue or a floating point exception, etc...)? Have you tried<br style="line-height: 17px; ">turning off computation of gradients?<br style="line-height: 17px; "><br style="line-height: 17px; ">It could also help if you can show your code preferably with an example<br style="line-height: 17px; ">dataset.<br style="line-height: 17px; "><br style="line-height: 17px; ">Christian<br style="line-height: 17px; "><br style="line-height: 17px; ">--&nbsp;<br style="line-height: 17px; "><a href="http://www.invicro.com/" target="_blank" style="line-height: 17px; font-weight: inherit; text-decoration: underline; color: rgb(0, 104, 207); cursor: default; ">http://www.invicro.com/</a><br style="line-height: 17px; "><br style="line-height: 17px; "><br style="line-height: 17px; ">------------------------------</pre></span><br><hr id="stopSpelling">From: thkorah@hotmail.com<br>To: karthik.krishnan@kitware.com; vtkusers@vtk.org; lackas@invicro.com; bill.lorensen@gmail.com<br>Subject: RE: [vtkusers] Visualizing multiple isosurfaces using vtkContourFilter<br>Date: Mon, 28 Feb 2011 19:24:50 -0500<br><br>

<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML">
<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}

</style>


Hi Christian,<div><br></div><div>I noticed your thread where you were trying to do the same. Similar to your example, I ended up calling generateValues to create N contours and mapped it to colors in a lookup table. Thanks for your example.</div><div><br></div><div>While this method works correctly for a 125x125x50 volume, a larger 312x312x300 volume of short int causes a segmentation fault in vtkDiscreteMarchingCubesComputeGradient(). The volume has approximately 250 disconnected ROIs labeled from 0-N. Is there a limit on how large the volume can be? Or will the labels cause this error since the class expects the scalars to adhere to a specific layout?&nbsp;</div><div><br></div><div>Thanks,</div><div>Thommen<br><br><hr id="ecxstopSpelling">Date: Thu, 24 Feb 2011 14:15:35 +0530<br>Subject: Re: [vtkusers] Visualizing multiple isosurfaces using vtkContourFilter<br>From: karthik.krishnan@kitware.com<br>To: thkorah@hotmail.com<br>CC: vtkusers@vtk.org<br><br><div>&nbsp;Since this is a labelled image with several label (ids), you&nbsp;could use vtkDiscreteMarchingCubes once on each label of interest instead of vtkContourFilter. This will extract just the interface between the cells containing the label of interest and its neighbors, whatever id they may have.</div>

<div>&nbsp;</div>
<div>--</div>
<div>karthik<br><br></div>
<div class="ecxgmail_quote">On Thu, Feb 24, 2011 at 4:39 AM, Thommen Korah <span dir="ltr">&lt;<a href="mailto:thkorah@hotmail.com">thkorah@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="ecxgmail_quote" style="padding-left:1ex;border-left:#ccc 1px solid">
<div>Thanks for your help. I decided to use the first method with separate filters. I have multiple segmented regions, and each voxel stores the id that it belongs to. So all cells belonging to object 3 will store the number 3. 
<div><br></div>
<div>But when I create cf3 filter and call cf3-&gt;setValue(0,3), it creates the isosurface using all cells. My intent is to create the surface only using cells storing 3. Any idea why this might be?</div>
<div><br></div>
<div>Thanks.</div>
<div><br>&gt; Date: Wed, 23 Feb 2011 08:23:29 -0500<br>&gt; Subject: Re: [vtkusers] Visualizing multiple isosurfaces using vtkContourFilter<br>&gt; From: <a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a><br>
&gt; To: <a href="mailto:thkorah@hotmail.com">thkorah@hotmail.com</a><br>&gt; CC: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a> 
<div>
<div></div>
<div class="h5"><br>&gt; <br>&gt; There are two ways to do this:<br>&gt; <br>&gt; 1) Create two ContourFilters. Use cf1-&gt;SetValue(0,val1) and<br>&gt; cf2-&gt;SetValue(0,val2).<br>&gt; You will need 2 mappers and actors.<br>
&gt; 2) Create one ContourFilter. Use cf-&gt;SetValue(0,val1) and cf-&gt;SetValue(1,val2).<br>&gt; You will need 1 mapper and actor.<br>&gt; <br>&gt; Both use share the same memory.<br>&gt; <br>&gt; Coloring is easier in case 1).<br>
&gt; mapper1-&gt;SetInput(cf1-&gt;GetOutput());<br>&gt; mapper1-&gt;ScalarVisibilityOff();<br>&gt; actor1-&gt;SetMapper(mapper1);<br>&gt; actor1-&gt;GetProperty()-&gt;SetDiffuseColor(r,g,b);<br>&gt; mapper2-&gt;SetInput(cf2-&gt;GetOutput());<br>
&gt; mapper2-&gt;ScalarVisibilityOff();<br>&gt; actor2-&gt;SetMapper(mapper2);<br>&gt; actor2-&gt;GetProperty()-&gt;SetDiffuseColor(r,g,b);<br>&gt; <br>&gt; Case 2 is trickier and involves mucking with lookup tables.<br>&gt; <br>
&gt; <br>&gt; <br>&gt; On Wed, Feb 23, 2011 at 1:16 AM, Thommen Korah &lt;<a href="mailto:thkorah@hotmail.com">thkorah@hotmail.com</a>&gt; wrote:<br>&gt; &gt; Hi,<br>&gt; &gt; I have a pointcloud on which I perform segmentation to extract different<br>
&gt; &gt; structures projecting out of a flat surface (a table for example). The<br>&gt; &gt; pointcloud is stored in a voxel data structure. I would now like to<br>&gt; &gt; visualize these segmented regions by creating &nbsp;isosurfaces using<br>
&gt; &gt; vtkContourFilter for each object. How can I generate multiple surfaces (eg.<br>&gt; &gt; book and a cup lying on the table) using the same shared data in memory? I<br>&gt; &gt; would also like to visualize each segmented region in a different color.<br>
&gt; &gt; Thanks.<br>&gt; &gt; _______________________________________________<br>&gt; &gt; Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>&gt; &gt;<br>&gt; &gt; Visit other Kitware open-source projects at<br>
&gt; &gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt; &gt;<br>&gt; &gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt; &gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt; &gt;<br>&gt; &gt; Follow this link to subscribe/unsubscribe:<br>&gt; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt; &gt;<br>&gt; &gt;<br></div></div></div></div><br>_______________________________________________<br>Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>                                               </body>
</html>