[vtkusers] How to get rid of vtkTransform warning: ...doing hack to support legacy code. This is deprecated in VTK 4.2

David Gobbi david.gobbi at gmail.com
Mon May 6 10:00:06 EDT 2013


Hi Anka,

You're not supposed to Get the transform's matrix and modify it.

In order for VTK to work as it should, the transform's timestamp
has to be updated whenever it's contents are modified.  Any time
you call Rotate(), Inverse(), Translate() etc. on a transform, these
functions update the timestamp.  However, if you Get() the matrix
and modify the matrix directly, then the transform's timestamp is
not updated... so VTK gives a warning that you are doing something
that might result in undefined behavior.

If you want to change the matrix, do something like this instead:

double newmatrix[16] = {
  -0.994485, 0.0114648, 0.10425, -109.91,
   0.10425, -0.994485, -0.0114648, 10.34,
   0.0114648, -0.10425, 0.994485, 0.0,
   0.0, 0.0, 0.0, 1.0 };
transform->SetMatrix(newmatrix);

 - David

On Mon, May 6, 2013 at 7:13 AM, Anka Kochanowska <pluszcz at gmail.com> wrote:
> Hi!
> Sorry for postuing again, Imaybe this time someone could help?
>
> Using vtk5.10 (Ubuntu 12.04), I am always getting messages:
>
> Warning: In
> /export01/anka/ibis2/sb/ibisExternalDependencies/vtk-5.10/src/Common/vtkTransform.cxx,
> line 201
> vtkTransform (0x1b6e680): InternalUpdate: doing hack to support legacy code.
> This is deprecated in VTK 4.2.  May be removed in a future version.
>
>
> What do I have to do to get rid of the warning?
>
>
> Here is a simple example:
> //IncerseTransform
>
> #include "vtkMatrix4x4.h"
>
> #include "vtkTransform.h"
>
> #include "vtkLinearTransform.h"
>
> #include "vtkSmartPointer.h"
>
>
> int main(int arg, char ** argv)
>
>  {
>
> vtkSmartPointer<vtkTransform> transform =
> vtkSmartPointer<vtkTransform>::New();
>
>     transform->Identity();
>
>     vtkMatrix4x4 *mat = transform->GetMatrix();
>
>     mat->SetElement(0,0,-0.994485);
>
>     mat->SetElement(0,1,0.0114648);
>
>     mat->SetElement(0,2,0.10425);
>
>     mat->SetElement(0,3,-109.911);
>
>     mat->SetElement(1,0,0.104868);
>
>     mat->SetElement(1,1,0.123302);
>
>     mat->SetElement(1,2,0.986813);
>
>     mat->SetElement(1,3,36.2377);
>
>     mat->SetElement(2,0,-0.00154065);
>
>     mat->SetElement(2,1,0.992303);
>
>     mat->SetElement(2,2,-0.123824);
>
>     mat->SetElement(2,3,-41.2797);
>
>
>     double det = mat->Determinant(mat);
>
>
>     cout << "Determinant = " << det << endl;
>
>
>     vtkIndent indent;
>
>     mat->PrintSelf(cout, indent);
>
>
>     vtkSmartPointer<vtkMatrix4x4> invMat =
> vtkSmartPointer<vtkMatrix4x4>::New();
>
>     invMat->Identity();
>
>     cout << "GetInverse will produce warning\n";
>
>     transform->GetInverse(invMat);
>
>     cout << "out of GetInverse\n";
>
>     return 0;
>
>   }
>
> CMakeLists.txt
>
>
> cmake_minimum_required(VERSION 2.6)
>
> PROJECT(InverseIransform)
>
> FIND_PACKAGE(VTK REQUIRED)
> INCLUDE(${VTK_USE_FILE})
>
> ADD_EXECUTABLE(InverseIransform inversetransform.cxx)
> TARGET_LINK_LIBRARIES(InverseIransform vtkHybrid)



More information about the vtkusers mailing list