[vtkusers] vtkTransform problem

Michele Conconi michele.conconi at unibo.it
Sat Feb 6 11:36:00 EST 2010


Hi everybody.
I'm using vtkTransform and its method Inverse() very extensivly in my 
program. After a big number of calls of this method anyway I cannot 
control anymore nor the matrix of vtkTransform neither the position of 
the associated polydata.
The following code gives an example of my problem.

I read a simple .stl file, bring the associated polydata into a control 
configuration by means of my vtkTransform and here I look at the 
transformation and at the center of the box containing the polydata.
Then I move the polydata into a different configuration, I invert the 
transformation 10 000 000 times and bring the polydata back into the 
control configuration. After 214 cicle of this loop, the center of my 
polydata is no longer equal to that of the control configuration, and 
neither it is the transformation.

Any clue? I'm getting mad about it!
Thanks in advance

Michele


#include "vtkTransformPolyDataFilter.h"
#include "vtkSTLReader.h"
#include "vtkTransform.h"
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    double center[]={0,0,0};
    double c[]={0,0,0};
   
    vtkSTLReader *volumeReader = vtkSTLReader::New();
    vtkTransformPolyDataFilter *TF = vtkTransformPolyDataFilter::New();
    vtkTransform *ActualPosition = vtkTransform::New();
    vtkPolyData *poly = vtkPolyData::New();

    volumeReader->SetFileName("cube.stl");
    TF->SetInput(volumeReader->GetOutput());
    volumeReader->Delete();

    TF->SetTransform(ActualPosition);
    poly=TF->GetOutput();

    ActualPosition->Identity();
    ActualPosition->PostMultiply();
    ActualPosition->RotateX(-45);
    ActualPosition->Translate(10,-20,30);
    poly->Update();

    poly->GetCenter(center);
    cout<<center[0]<<" "<<center[1]<<" "<<center[2]<<endl;//the center 
of the cube containing the polydata in the control configuration  
configuration
    ActualPosition->Print(cout);
   
    int i=0;
    while(i<200000)
    {
        //modify the vtkTransform
        ActualPosition->Identity();
        ActualPosition->PostMultiply();
        ActualPosition->RotateX(0);
        ActualPosition->Translate(0,0,0);
        poly->Update();

        for (int j=0; j<1e7; j++)
        {
            ActualPosition->Inverse();
            //my operations...
            ActualPosition->Inverse();
        }

        if(i%10000==0)
            cout<<i<<endl;

        //bring it back to the control configuration
        ActualPosition->Identity();
        ActualPosition->PostMultiply();
        ActualPosition->RotateX(-45);
        ActualPosition->Translate(10,-20,30);
        poly->Update();

        poly->GetCenter(c);
        //check if the center of the cube containing the polydata is 
still in the right position
        if(c[0]==center[0] && c[1]==center[1] && c[2]==center[2])
            i++;
        else
        {
            cout<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl;
            cout<<i<<endl;
            ActualPosition->Print(cout);
            i=2000000;
        }
    }

    ActualPosition->Delete();
    TF->Delete();
}
-- 
* Eng. Michele Conconi*
Ph.D. student
DIEM - Dept. of Mechanical Engineering
Alma Mater Studiorum - University of Bologna
Viale Risorgimento 2, 40136, Bologna, Italy
Email: michele.conconi at unibo.it
Website: http://www.diem.ing.unibo.it/grab
Office: (+39) 051 20 93451
Mobile: (+39) 329 0287996



* INFORMAZIONE RISERVATA E CONFIDENZIALE *
Questo messaggio contiene informazioni riservate e confidenziali.
Se il lettore non fosse il destinatario del messaggio, inoltrato e 
ricevuto per errore,
il testo dovrà essere immediatamente cancellato dal computer del ricevente.
E' assolutamente proibita qualunque circolazione, disseminazione o
copia del messaggio spedito e/o ricevuto per errore.

* CONFIDENTIALITY and WARNING NOTICE *
This message may contain legally privileged or confidential information.
If the reader is not the intended recipient, you received this message 
in error
and it should therefore be deleted from your computer at once.
Any dissemination, distribution and copying of a message
mistakenly sent or received is strictly forbidden.



More information about the vtkusers mailing list