[vtkusers] Using a boxwidgets transform to rotate a non-vtk 3D model?

Cory Quammen cory.quammen at kitware.com
Thu Aug 6 10:40:16 EDT 2015


TK,

You can get the orientation in angle-axis representation with

double wxyz[4];
t->GetOrientationWXYZ(wxyz);

>From the docs [1]:

The angle (w) is in degrees and the axis (xyz) is a unit vector.

You should be able to apply this rotation to your molecule model's
RotateAboutVector function.

HTH,
Cory

[1]
http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f


On Wed, Aug 5, 2015 at 8:54 PM, Totte Karlsson <totte at dunescientific.com>
wrote:

> Hello,
> I'm using vtk to visualize 3D models of molecules.
> The actual molecular model is decoupled from vtk code, and visualization
> is implemented using a model-view kind of design.
>
> Currently I have the following challenge. If a user wants to manipulate
> the absolute orientation of the molecule, it is done by manipulating the
> underlying model using rotation functions, like RotateX, RotateY,
> RotateAboutVector, and translation functions TranslateX, Y etc.
>
> For now 3D rotations are simply done using two scrollbars, one horizontal
> and one vertical, causing the underlying model being rotated about the vtk
> viewUP vector and the vtk cameraPlane normal respectively.  This works
> fine, but is not so intuitive for the user.
>
> Instead I believe allowing interaction with something like a box widget
> that encapsulates the molecule view, (with disabled handles), would be
> better.
>
> The challenge is how to figure out how to capture the boxwidgets
> orientation in a callback, and using this information in order to
> manipulate the underlying molecular model.
>
> For example, a boxwidget callback (from boxwidget example at
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget):
>
> class vtkMyCallback : public vtkCommand
> {
>     public:
>         static vtkMyCallback *New()       {            return new
> vtkMyCallback;    }
>
>     virtual void Execute(vtkObject *caller, unsigned long, void*)
>     {
>         vtkSmartPointer<vtkTransform> t =
> vtkSmartPointer<vtkTransform>::New();
>         vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
>         widget->GetTransform(t);
>
>         double* angles?? = t->GetOrientation();
>         if(aMoleculeModel)
>         {
>             //Use some secret(!) code to manipulate orientation of a
> molecule to 'rotate' it together with the boxWidget
>             aMoleculeModel->RotateZ(??);
>             aMoleculeModel->RotateY(??);
>             aMoleculeModel->RotateZ(??);
>         }
>     }
>     Molecule* aMoleculeModel;
>
> Anyone seeing how to do this or have some pointers?
>
> Cheers,
> tk
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150806/7bd0cc75/attachment.html>


More information about the vtkusers mailing list