Anonymous - 2013-02-04

Hello,

I dont know why, but I am having problem trying to add a vtkAxesActor in a vtkOrientationMarkerWidget.. I get some segmentation fault. I think it is a vtkOrientationMarkerWidget.  In order to check my code, I tried to use a  vtkAnnotatedCubeActor instead of the vtkAxesActor, and it works until the window is resized. Then the vtkOrientationMarkerWidget freezes and it doesntr refres anymore.

Could anyone help me? I dont know what i ma doing wrong.

Thanks in advance
JuanMa

SAMPLE CODE

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Kitware.VTK;
using System.Runtime.InteropServices;
namespace test4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void renderWindowControl1_Load(object sender, EventArgs e)
        {
            myScene();
            
            //ParametricObjectsDemo();
        }
        private void myScene()
        {
            // source object
            vtkSphereSource SphereSource = vtkSphereSource.New();
            SphereSource.SetRadius(0.5);
            
            // mapper
            vtkPolyDataMapper SphereMapper = vtkPolyDataMapper.New();
            SphereMapper.SetInputConnection(SphereSource.GetOutputPort());
            
            // actor
            vtkActor SphereActor = vtkActor.New();
            SphereActor.SetMapper(SphereMapper);
            // get a reference to the renderwindow of our renderWindowControl1
            vtkRenderWindow RenderWindow = renderWindowControl.RenderWindow;
            // get a reference to the renderer
            vtkRenderer Renderer = RenderWindow.GetRenderers().GetFirstRenderer();
            // set background color
            Renderer.GradientBackgroundOn();
            Renderer.SetBackground2(0.2, 0.3, 0.4);
            Renderer.SetBackground(1.0, 1.0, 1.0);
         
            // add actor to the renderer
            Renderer.AddActor(SphereActor);

            // Add the actors to the scene
            vtkAxesActor axes = vtkAxesActor.New();
            
            // Sets the x axis label to red
            axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor(1, 0, 0);
            axes.GetYAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0, 1, 0);
            axes.GetZAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0, 0, 1);
            // Create the Widget to draw the Axes        
            vtkOrientationMarkerWidget widget = new vtkOrientationMarkerWidget();
            widget.SetOutlineColor( 0.9300, 0.5700, 0.1300 );
            widget.SetOrientationMarker( axes );
            widget.SetInteractor(RenderWindow.GetInteractor());
            widget.SetViewport( 0.1, 0.1, 0.5, 0.5 );
            widget.SetEnabled( 1 );
            widget.InteractiveOn();
            // ensure all actors are visible (in this example not necessarely needed,
            // but in case more than one actor needs to be shown it might be a good idea)
            Renderer.ResetCamera();
            // we need to call Render() for the whole renderWindow, 
            // because vtkAxesActor uses an overlayed renderer for the axes label
            // in total we have now two renderer            
            RenderWindow.Render();
            
        }
    }
}