Bug in vtkCubeAxesActor2D?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug in vtkCubeAxesActor2D?

jotto
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();

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Bug in vtkCubeAxesActor2D?

32sthide
use   axes->SetCornerOffset(0.0);
Reply | Threaded
Open this post in threaded view
|

Re: Bug in vtkCubeAxesActor2D?

32sthide
or in your case         axes.SetCornerOffset(0.0);