<br><font size=2 face="Courier New">I'm trying to use vtkImageViewer2 to
generate texture maps of a rectilinear grid with contour lines (to project
onto terrain grids). Below you'll see that vtkCoordinate conversion
is used to 'extract' the rendered image from the vtkRenderWindow. This
has two problems for your application: 1) the image extents
change, and 2) there will be 'pixel drift'. Can anybody
suggest a way to control the rendered image size? </font>
<br>
<br><font size=2 face="Courier New">I will try to correct for the 'pixel
drift' by using vtkCoordinate.GetComputedDoubleDisplayValue and correcting
with the sub-pixel corrections when calling the final vtkImage.SetOutputOrigin
and vtkImage.SetOutputSpacing.</font>
<br>
<br><font size=2 face="Courier New"> </font><font size=2 color=#008000 face="Courier New">'Use
vtkImageViewer2 to render images of rectilinear grid and contour lines
to use as texture maps</font>
<br><font size=2 face="Courier New"> </font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
m_vtkContourMapRenderer </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">New</font><font size=2 face="Courier New">
vtk.vtkImageViewer2</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.SetInput(vtkBackImage)
</font><font size=2 color=red face="Courier New"><--- Created
a 10x10 vtkImageData with appropriate Origing and Spacing</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.SetSliceOrientationToXY()</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.GetRenderer.AddActor(vtkActor1)</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.GetRenderer.AddActor(vtkActor2)</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.GetRenderWindow.PointSmoothingOn()</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.OffScreenRenderingOn()</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.SetSize(1000,
1000)</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.GetRenderer.GetActiveCamera.ParallelProjectionOn()</font>
<br><font size=2 face="Courier New"> m_vtkContourMapRenderer.GetRenderer.ResetCamera()</font>
<br><font size=2 face="Courier New"> \</font>
<br><font size=2 face="Courier New"> \</font>
<br><font size=2 face="Courier New">
\</font>
<br><font size=2 face="Courier New">
\</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">'Grid data
range</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
dblRngX() </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Double</font><font size=2 face="Courier New">
= m_vtkGrid2D.GetXCoordinates.GetRange(1)</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
dblRngY() </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Double</font><font size=2 face="Courier New">
= m_vtkGrid2D.GetYCoordinates.GetRange(1)</font>
<br>
<br><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">'Render contour
map image</font>
<br><font size=2 face="Courier New">
m_vtkContourMapRenderer.Render()</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
vtkRenderedImage </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">New</font><font size=2 face="Courier New">
vtk.vtkWindowToImageFilter</font>
<br><font size=2 face="Courier New">
vtkRenderedImage.SetInput(m_vtkContourMapRenderer.GetRenderWindow)</font>
<br><font size=2 face="Courier New">
vtkRenderedImage.Update()</font>
<br>
<br><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">'Extract rendered
image</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
vtkCrnPt </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">New</font><font size=2 face="Courier New">
vtk.vtkCoordinate</font>
<br><font size=2 face="Courier New">
vtkCrnPt.SetCoordinateSystemToWorld()</font>
<br><font size=2 face="Courier New">
vtkCrnPt.SetValue(dblRngX(0), dblRngY(0), 0.0)</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
intLLPix() </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Integer</font><font size=2 face="Courier New">
= vtkCrnPt.GetComputedDisplayValue(m_vtkContourMapRenderer.GetRenderer)</font>
<br><font size=2 face="Courier New">
vtkCrnPt.SetValue(dblRngX(1), dblRngY(1), 0.0)</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
intURPix() </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Integer</font><font size=2 face="Courier New">
= vtkCrnPt.GetComputedDisplayValue(m_vtkContourMapRenderer.GetRenderer)</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
vtkExtract </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">New</font><font size=2 face="Courier New">
vtk.vtkImageClip</font>
<br><font size=2 face="Courier New">
vtkExtract.SetInputConnection(vtkRenderedImage.GetOutputPort)</font>
<br><font size=2 face="Courier New">
vtkExtract.ClipDataOn()</font>
<br><font size=2 face="Courier New">
vtkExtract.SetOutputWholeExtent(intLLPix(0), intURPix(0), intLLPix(1),
intURPix(1), 0, 0)</font>
<br><font size=2 face="Courier New">
vtkExtract.Update()</font>
<br>
<br><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">'Set the image
properties</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
intExt() </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Integer</font><font size=2 face="Courier New">
= vtkExtract.GetOutput.GetExtent</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">Dim</font><font size=2 face="Courier New">
vtkImage </font><font size=2 color=blue face="Courier New">As</font><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">New</font><font size=2 face="Courier New">
vtk.vtkImageChangeInformation</font>
<br><font size=2 face="Courier New">
vtkImage.SetInputConnection(vtkExtract.GetOutputPort)</font>
<br><font size=2 face="Courier New">
vtkImage.SetOutputOrigin(dblRngX(0), dblRngY(0), 0.0)</font>
<br><font size=2 face="Courier New">
vtkImage.SetOutputSpacing((dblRngX(1) - dblRngX(0)) / (intExt(1)
- intExt(0)), (dblRngY(1) - dblRngY(0)) / (intExt(3) - intExt(2)), 1.0)</font>
<br><font size=2 face="Courier New">
vtkImage.SetOutputExtentStart(0, 0, 0)</font>
<br><font size=2 face="Courier New">
vtkImage.Update()</font>
<br><font size=2 face="sans-serif"><br>
Steve Koch<br>
<br>
</font>
<br>
<br><font size=3>> Hello,<br>
><br>
> I'm using vtkImageViewer2 to view my datasets and sometimes I need
to view them in true size, so one pixel on the display corresponds always
to one pixel on the image. How can I achieve this with the class vtkImageViewer2?
I > know that if I use vtkImageViewer I'll get this, but I built a more
complex 2D Viewing class with vtkImageViewer2 so I want to find a solution
if possible with vtkImageViewer2. <br>
><br>
> Any suggestions?<br>
><br>
> Thanks in advance!</font><font size=2><tt><br>
</tt></font>
<pre>_________________________________________________________________________
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you
Received this in error, please contact the sender and delete the material
from any computer.
_________________________________________________________________________