[vtkusers] get the center of the vtkboxwidget

Ali Habib ali.mahmoud.habib at gmail.com
Tue Aug 24 02:44:39 EDT 2010


Hi All,

I want to get the center fo the vtkbox widget at the beginning of moving it
and at the end of moving it

I tried adding two observers one at interaction event and the second at the
Endinteraction event , but unfortunatly the center result from both of
thoses are the same

any suggestion to solve that

 public static void InteractionEvent(vtk.vtkObject obj, uint eventId, Object
data, IntPtr clientdata)
        {
            vtkBoxWidget widget = vtkBoxWidget.SafeDownCast(obj);
            widget.GetPlanes(planes);
            selectActor.VisibilityOn();


            vtkPolyData before = new vtkPolyData();
            widget.GetPolyData(before);
            center_Before = GetBoundsCenter(before.GetBounds());

            //maceActor.VisibilityOff();
            ///////////// Test writting
/////////////////////////////////////////////
            //Write the file

            /*vtkXMLPolyDataWriter writer = new vtkXMLPolyDataWriter ();
            writer.SetInputConnection(clipper.GetOutputPort());
           writer.SetFileName("disk.vtp");
           writer.Write();*/


        }
        public static void EndInteractionEvent(vtk.vtkObject obj, uint
eventId, Object data, IntPtr clientdata)
        {
            vtkBoxWidget widget = vtkBoxWidget.SafeDownCast(obj);
             vtkPolyData after = new vtkPolyData();
             widget.GetPolyData(after);
             center_After = GetBoundsCenter(after.GetBounds());

             ModifyData();


        }

        private static double[] GetBoundsCenter(double[] bounds)
        {
            double[] center = new double[3];

            center[0] = (bounds[0] + bounds[1]) / 2.0;
            center[1] = (bounds[2] + bounds[3]) / 2.0;
            center[2] = (bounds[4] + bounds[5]) / 2.0;

            return center;
        }

Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100824/1246e5ea/attachment.htm>


More information about the vtkusers mailing list