<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><div><br></div><div>Hello. I'm trying to roughly simulate resolution effects that might be seen when CT scanning an object. My thought was to do the following:</div><div><br></div><div>1. import an STL model of the object</div><div>2. create an empty vtkImageDate object (with extents chosen based on bounds of stl)</div><div>3. use vtkPolyDataToImageStencil and vtkImageStencil mask the STL onto the empty image data</div><div>4. then use vtkImageReslice to transform, change resolution, etc</div><div>5. use vtkContourFilter to make a new polydata model with "chunkiness" like from CT slice thickness, etc</div><div><br></div><div>I'm working in Tcl/Tk. A while back I wrote a similar little program to mask out a CT data with an imported STL. In that case I was reading in Dicom data. Now I seem
 to be having problems properly creating an empty/blank vtkImageData into which to stencil the STL.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>       vtkSTLReader targetSTL                             </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>targetSTL SetFileName $filenameTARGET</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>puts [[targetSTL GetOutput] GetBounds</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>#????? what is the correct way to get the model x,y,z bounds? Just getting 1 -1 1 -1 1 -1 here</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>       vtkImageData<span class="Apple-tab-span" style="white-space:pre">        </span>modelAsImage</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>modelAsImage SetDimensions 256 256 256</div><div><span class="Apple-tab-span"
 style="white-space:pre">                        </span>modelAsImage SetOrigin     0..0 0.0 0.0</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>modelAsImage SetSpacing    1.0 1.0 1.0</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>modelAsImage SetExtent <span class="Apple-tab-span" style="white-space:pre">        </span>   0 255 0 255 0 255</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>modelAsImage SetScalarTypeToUnsignedShort</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>modelAsImage AllocateScalars</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>set numBlanks [modelAsImage GetNumberOfPoints]</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>for {set i 0} {$i&lt;$numBlanks} {incr i} {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span><span class="Apple-tab-span"
 style="white-space:pre">        </span>[[modelAsImage GetPointData] GetScalars] SetTuple1 $i 0.0</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">                </span>vtkPolyDataToImageStencil stlToStencil</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>stlToStencil SetInput [targetSTL GetOutput]</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>vtkImageStencil stencil</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>stencil SetInput [modelAsImage GetOutput]     # ??????? This line gives an error - modelAsImage not established properly?</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>stencil SetStencil [stlToStencil GetOutput]</div><div><span class="Apple-tab-span" style="white-space:pre">                
        </span>stencil ReverseStencilOn</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>stencil SetBackgroundValue 1000.0</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>vtkImageReslice reslice1</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>reslice1 SetInput [stencil GetOutput]</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>reslice1 SetResliceTransform initPoseTransf </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>reslice1 SetInterpolationModeToCubic</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>reslice1 SetInformationInput [modelAsImage GetOutput] # ??????? This line gives an error - modelAsImage not established properly?</div><div><br></div><div>I'm having two problems.. First, how can I get the bounds of the imported STL and set the
 extent of the vtkImageData to these values? When I try to use the GetBounds method -1 1 -1 1 -1 1 is returned - not correct for the imported model.</div><div><br></div><div>Second, I keep getting an error at the lines where I call [modelAsImage GetOutput] saying that the GetOutput method doesn't exist or is called with incorrect options. I've been thinking that I must not have created the empty vtkImageData properly. To test this I imported a set of Dicom data instead of trying to create an empty ImageData and it seemed to work (at least ran without errors). </div><div><br></div><div>I would very much appreciate any suggestions. Thank you in advance.</div><div>Marty</div></div><div style="position:fixed"></div></div><br>

      </body></html>