[vtkusers] get the center of the vtkboxwidget

Ali Habib ali.mahmoud.habib at gmail.com
Tue Aug 24 17:26:00 EDT 2010


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> 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
>>>
>>> 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
>>
>> 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
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100825/4bf6300b/attachment.htm>


More information about the vtkusers mailing list