[vtkusers] get the center of the vtkboxwidget

Jim Peterson jimcp at cox.net
Thu Aug 26 15:08:24 EDT 2010


Ali,
I believe one of your problems is the use of both InteractionEvent and 
EndInteractionEvent callbacks. I think the net effect is both fire on 
the same interaction and result in center_Before and center_After being 
set to the same value and the computed displacement therefore resolving 
to zero, resulting in no change to the point data. I would suggest using 
only EndInteractionEvent, and making the algorythm copy center_After to 
center_Before before getting the center of the current boxWidget. Also, 
I have not used box widgets as you do here, so for my own testing I 
added a vtkPointPicker to the Interaction Window and used the 
EndPickEvent observer function against the interaction window to test 
the point delta.

I still have a lot to learn about vtk myself, I hope my efforts have are 
helpful to you.
Jim

Ali Habib wrote:
> Dear Jim Peterson
>
> I use vtk version 4 the .NET wrapper  , 
> and I use getpolydata then getbound ,any suggestion to get the center 
> after and before to use it in detect the displacement calculation
>
> Best regards 
>
> On Tue, Aug 24, 2010 at 9:11 PM, Jim Peterson <jimcp at cox.net 
> <mailto:jimcp at cox.net>> wrote:
>
>     Eric, Ali and all,
>
>     Fwiw, it was my misinterpretation of Ali's original source code
>     that pointed us at Java. I believe Ali is actually using a .net
>     wrapper and therefore a Windows host platform. The Addobserver and
>     callback signatures in his example code do not match the
>     corresponding Java versions, and I do not have a .net environment
>     to test directly in. In order to make a Java version for testing,
>     I had to wrap Ali's original logic in a class, and I had to make
>     the callbacks instance functions instead of class functions
>     (static) as originally coded. I don't believe these changes should
>     have affected my results, but they are all factors for potential
>     differences.
>
>     I am learning VTK as we go as well, but I suspect we will need to
>     make use of the picker callbacks as opposed to the Interaction
>     callbacks to address the selected boxWidget. If my exploration
>     uncovers anything I will post my results.
>
>     Ali, exactly what version of VTK are you using? I have been
>     testing with the 5.6.0 version myself, and my understanding is the
>     Java wrappers where significantly modified. I wonder if there is
>     any corresponding change required for the .NET wrapper (wherever
>     that comes from).
>
>     Hope that helps,
>     Jim
>
>
>     Eric E. Monson wrote:
>
>         Hey Ali,
>
>         That's strange. I don't have a Java wrappers build right now,
>         but I tried modifying the Examples/Tutorial/Step6/.../Cone6
>         example for both Python and Cxx and both of them give me back
>         modified bounds as I move the box widget... They both use
>         InteractionEvent, and if I print the bounds in the callback I
>         see the numbers changing as I move the box...
>
>         I was going to suggest trying to add your GetPolyData and
>         GetBounds calls to the event callback in Step6.java, but I see
>         that doesn't exist!
>
>         So, I don't want to get too off-topic with Ali's problem, but
>         does anyone know why there isn't a Step6.java? I don't use the
>         Java wrappers much -- are there any special issues with the
>         BoxWidget and Java?
>
>         Hopefully someone else can be more help,
>         -Eric
>
>         ------------------------------------------------------
>         Eric E Monson
>         Duke Visualization Technology Group
>
>
>         On Aug 24, 2010, at 2:44 AM, Ali Habib wrote:
>
>          
>
>             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
>             _______________________________________________
>             Powered by www.kitware.com <http://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
>                
>
>
>         _______________________________________________
>         Powered by www.kitware.com <http://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
>
>          
>
>
>




More information about the vtkusers mailing list