[vtkusers] Bug in vtkCubeAxesActor2D?
Jahn Otto Næsgaard Andersen
jotto at jotto.no
Wed Sep 5 11:12:54 EDT 2012
I am trying to show a rectangle with a photo on + axes. The rectangle is
centered at (0,0,0), and the size is (1,1). I'm using vtkCubeAxesActor2D
for the axes.
The axes do not fit the rectangle correctly -- it doesn't go from edge to
edge. The ticks seem to be positioned at -0.45 to 0.45 instead of -0.5 to
0.5
https://dl.dropbox.com/u/8597999/axes.jpg
Is this a VTK bug or something wrong in my code?
Here is my code:
// Read the image which will be the texture
vtkJPEGReader jPEGReader = vtkJPEGReader.New();
jPEGReader.SetFileName("F:\\pixortphotos\\quitesomephotos\\IMG_1735.JPG");
// Create a plane
vtkPlaneSource planeSource = vtkPlaneSource.New();
planeSource.SetCenter(0.0, 0.0, 0.0);
planeSource.SetNormal(0.0, 0.0, 1.0);
// Apply the texture
vtkTexture texture = vtkTexture.New();
texture.SetInputConnection(jPEGReader.GetOutputPort());
vtkTextureMapToPlane texturePlane = vtkTextureMapToPlane.New();
texturePlane.SetInputConnection(planeSource.GetOutputPort());
vtkPolyDataMapper planeMapper = vtkPolyDataMapper.New();
planeMapper.SetInputConnection(texturePlane.GetOutputPort());
vtkActor texturedPlane = vtkActor.New();
texturedPlane.SetMapper(planeMapper);
texturedPlane.SetTexture(texture);
// Create components of the rendering subsystem
//
vtkRenderer renderer =
_renderWindowControl.RenderWindow.GetRenderers().GetFirstRenderer();
renderer.SetBackground(1.0, 1.0, 1.0);
vtkRenderWindow renWin = _renderWindowControl.RenderWindow;
// Axes
// Create a text property for both cube axes
var tprop = vtkTextProperty.New();
tprop.SetColor(0.3, 0.3, 0.3);
tprop.ShadowOn();
var normals = vtkPolyDataNormals.New();
normals.SetInputConnection(planeSource.GetOutputPort());
var axes = vtkCubeAxesActor2D.New();
axes.SetInput(planeSource.GetOutput());
axes.SetCamera(renderer.GetActiveCamera());
axes.SetLabelFormat("%6.4g");
axes.SetFlyModeToOuterEdges();
axes.SetFontFactor(1.0);
axes.SetAxisTitleTextProperty(tprop);
axes.SetAxisLabelTextProperty(tprop);
axes.GetProperty().SetColor(0, 0, 0);
axes.SetYAxisVisibility(0);
renderer.AddViewProp(axes);
// Interactor
vtkRenderWindowInteractor renderWindowInteractor =
vtkRenderWindowInteractor.New();
renderWindowInteractor.SetRenderWindow(renWin);
var interactorStyle = vtkInteractorStyleImage.New();
renderWindowInteractor.SetInteractorStyle(interactorStyle);
vtkCamera camera = renderer.GetActiveCamera();
camera.ParallelProjectionOn();
axes.SetCamera(camera);
// Add the actors to the renderer, set the window size
renderer.AddActor(texturedPlane);
renderer.ResetCamera();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120905/080eb7e8/attachment.htm>
More information about the vtkusers
mailing list