/////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Initializes a new instance of the <see cref="TextDocumentItemViewModel"/> class.
        /// </summary>
        public VTKDocumentItemViewModel(VTKDataModel dataModel)
        {
            this.Title = string.Format("VTK Doc {0}", counter++);
            this.Text = string.Format("Dynamically created at {0}", DateTime.Now);
            this.Description = "VTK document";
            this.vtkData = dataModel;

            this.CellAttributeArrayNames = new ObservableCollection<string>();
            this.CellAttributeArrayNames.Add(this.vtkData.CellIdsArrayName);
            this.CellAttributeArrayNames.Add(this.vtkData.CellTypeArrayName);
            this.cellColorArrayName = this.CellAttributeArrayNames[0];
            this.cellColorMapSpaceModel = ColorSpaceModel.HSV;

            // create a VTK output control and make the forms host point to it
            rwc = new RenderWindowControl();
            wfh = new WindowsFormsHost();
            wfh.Child = rwc;
            rwc.CreateGraphics();
            rwc.RenderWindow.SetCurrentCursor(9);

            vtkInteractorStyleSwitch istyle = vtkInteractorStyleSwitch.New();
            rwc.RenderWindow.GetInteractor().SetInteractorStyle(istyle);
            rwc.RenderWindow.GetInteractor().SetPicker(vtkCellPicker.New());
            (istyle).SetCurrentStyleToTrackballCamera();

            rwc.RenderWindow.GetInteractor().LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(leftMouseDown);

            // set up basic viewing
            ren = rwc.RenderWindow.GetRenderers().GetFirstRenderer();
            vtkCamera camera = ren.GetActiveCamera();

            // background color
            ren.SetBackground(0.1, 0.1, 0.1);

            vtkSphereSource sph = vtkSphereSource.New();
            sph.SetThetaResolution(16);
            sph.SetPhiResolution(16);
            sph.SetRadius(0.02);

            vtkGlyph3D glyp = vtkGlyph3D.New();
            glyp.SetSourceConnection(sph.GetOutputPort(0));
            glyp.SetInputConnection(this.vtkData.OutputPort);
            glyp.ScalingOff();
            glyp.OrientOff();

            ctf = vtkColorTransferFunction.New();
            ctf_min_color = System.Windows.Media.Color.FromRgb(0, 128, 255);
            ctf_max_color = System.Windows.Media.Color.FromRgb(64, 255, 64);
            this.BuildCTF();

            //lut.SetValueRange(0.5, 1.0);
            //lut.SetSaturationRange(0.1, 1.0);
            //lut.SetHueRange(0.4, 0.6);
            //lut.SetAlphaRange(0.2, 1.0);
            //lut.SetRampToLinear();
            //lut.Build();

            mapper = vtkPolyDataMapper.New();
            mapper.SetInputConnection(glyp.GetOutputPort());
            mapper.SetLookupTable(ctf);
            mapper.ScalarVisibilityOn();
            mapper.SetScalarModeToUsePointFieldData();
            mapper.SelectColorArray(this.cellColorArrayName);
            // scalar range doens't affect anything when using a ctf (instead of a lut)
            // mapper.SetScalarRange(0, this.vtkData.NumPoints - 1);

            vtkActor actor = vtkActor.New();
            actor.SetMapper(mapper);
            //actor.GetProperty().SetRepresentationToWireframe();
            actor.GetProperty().SetRepresentationToSurface();
            rwc.RenderWindow.GetRenderers().GetFirstRenderer().AddViewProp(actor);
            ren.ResetCamera();
        }
        private void SetUpRenderWindow()
        {
            // create a VTK output control and make the forms host point to it
            rwc = new RenderWindowControl();
            rwc.CreateGraphics();
            windowsFormsHost.Child = rwc;

            // set up basic viewing
            vtkRenderer ren = rwc.RenderWindow.GetRenderers().GetFirstRenderer();

            // background color
            ren.SetBackground(0.0, 0.0, 0.0);

            // interactor style
            vtkInteractorStyleSwitch istyle = vtkInteractorStyleSwitch.New();
            rwc.RenderWindow.GetInteractor().SetInteractorStyle(istyle);
            rwc.RenderWindow.GetInteractor().SetPicker(vtkCellPicker.New());
            (istyle).SetCurrentStyleToTrackballCamera();

            // Demonstrate how to use the vtkBoxWidget 3D widget,
            vtkSphereSource sphere = vtkSphereSource.New();
            sphere.SetRadius(0.25);

            vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New();
            sphereMapper.SetInputConnection(sphere.GetOutputPort());

            vtkActor sphereActor;
            vtkTransform widgetTransform = vtkTransform.New();
            List<Region> region_list = configurator.SimConfig.scenario.regions.ToList();
            for (int ii = 0; ii < region_list.Count; ++ii)
            {
                this.TransferMatrixToVTKTransform(region_list[ii].region_box_spec.transform_matrix, widgetTransform);
                sphereActor = vtkActor.New();
                sphereActor.SetMapper(sphereMapper);
                sphereActor.SetUserTransform(widgetTransform);
                sphereActor.GetProperty().SetOpacity(0.5);
                sphereActor.SetVisibility(region_list[ii].region_visibility ? 1 : 0);
                sphereActorList.Add(sphereActor);
                ren.AddActor(sphereActorList[ii]);
            }

            vtkCubeSource cube = vtkCubeSource.New();
            cube.SetXLength(5.0);
            cube.SetYLength(5.0);
            cube.SetZLength(5.0);

            vtkOutlineSource outline = vtkOutlineSource.New();
            outline.SetBounds(-2, 2, -2, 2, -2, 2);

            vtkPolyDataMapper cubeMapper = vtkPolyDataMapper.New();
            cubeMapper.SetInputConnection(outline.GetOutputPort());

            vtkLODActor cubeActor = vtkLODActor.New();
            cubeActor.SetMapper(cubeMapper);
            cubeActor.VisibilityOn();

            ren.AddActor(cubeActor);

            boxRep = vtkBoxRepresentation.New();
            boxRep.SetTransform(widgetTransform);

            boxWidget = vtkBoxWidget2.New();
            boxWidget.SetInteractor( rwc.RenderWindow.GetInteractor() );
            boxWidget.SetRepresentation( boxRep );
            boxWidget.SetPriority(1);
            boxWidget.InteractionEvt += this.boxInteractionCallback;

            ren.ResetCamera();
        }