[vtkusers] bug in vtkProp3D::GetOrientation

Patric Weis Patric.Weis at mycrona.de
Wed Nov 20 09:57:51 EST 2002


Dear vtkusers,

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

The same has to be done with

void vtkProp3D::GetOrientation (float o[3])
{
  ...
}


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
MYCRONA







More information about the vtkusers mailing list