[vtkusers] bug in vtkProp3D::GetOrientation (2nd trial)

Patric Weis Patric.Weis at Mycrona.de
Wed Jan 29 02:56:52 EST 2003


Sorry for reposting this again, but I have not got any answer.
Until now it is not fixed in the current cvs trunk.

Could someone please check if I am right?
Thanks!

Patric Weis


On 2002-11-20 I wrote:

There seems to be a bug in vtkProp3D::GetOrientation().

1. Problem scenario
===================
1. Create an actor and rotate it via vtkActor::SetUserTransform()
    or vtkActor::SetUserMatrix().
2. Pick the actor.
3. The actor rotates after the picking. :(
This can be repeated. Every pick rotates the actor to another
orientation. :( :(

You can invoke this strange behaviour by the following piece of code:

.....
   // Create a cone:
   vtkConeSource *cone = vtkConeSource::New();
   vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
     coneMapper->SetInput(cone->GetOutput());
   vtkActor *coneActor = vtkActor::New();
     coneActor->SetMapper(coneMapper);

   //Rotate the cone about 45 degrees:
   vtkTransform *transform = vtkTransform::New();
     transform->RotateZ(45.0);
     coneActor->SetUserTransform(transform);

   renderer->AddActor(coneActor);
.....


2. Problem solution
===================
In vtkProp3D.cxx (Revision: 1.28, nightly built 2002/11/19, line 144)
exchange the routine

.....
float *vtkProp3D::GetOrientation ()
{
   float   *orientation;

   // return the orientation of the transformation matrix
   orientation = this->Transform->GetOrientation();
   this->Orientation[0] = orientation[0];
   this->Orientation[1] = orientation[1];
   this->Orientation[2] = orientation[2];

   vtkDebugMacro(<< " Returning Orientation of ( " <<  this->Orientation[0]
   << ", " << this->Orientation[1] << ", " << this->Orientation[2] << ")\n");

   return this->Orientation;
} // vtkProp3D::Getorientation
.....

by

.....
float *vtkProp3D::GetOrientation ()
{
   return this->Transform->GetOrientation();
} // vtkProp3D::Getorientation


3. Reason
=========
this->Transform->GetOrientation() returns the orientation of the
overall(!) transformation, i.e the concatenation of the user matrix and
internal matrix of origin, position, scale and internal(!) orientation.

When writing the overall(!) orientation (contains the orientation of user
matrix) to the internal(!) orientation, you will mix user matrix orientation
and internal orientation. Then the actor's orientation changes each time
the matrix is computed by vtkProp3D::ComputeMatrix(). This happens e.g.
when the actor's GetBounds() is invoked.


Hope I'm right! ;)

Patric Weis





More information about the vtkusers mailing list