wxMaracasRenderImageTransformation.cpp
Go to the documentation of this file.00001 #include "wxMaracasRenderImageTransformation.h"
00002 #include "wxMaracasRendererView.h"
00003
00007 wxMaracasRenderImageTransformation::wxMaracasRenderImageTransformation(wxMaracasMultipleVolumeRendererManager* _vol, wxMaracasSurfaceRenderingManager* _surface1,
00008 wxMaracasSurfaceRenderingManager* _surface2, wxMaracasSurfaceRenderingManager* _surface3, int id)
00009 {
00010 vol = _vol;
00011 surface1 = _surface1;
00012 surface2 = _surface2;
00013 surface3 = _surface3;
00014
00015 propID = id;
00016 transformV = vtkTransform::New();
00017 transformS1 = vtkTransform::New();
00018 transformS2 = vtkTransform::New();
00019 transformS3 = vtkTransform::New();
00020 }
00021
00025 wxMaracasRenderImageTransformation::~wxMaracasRenderImageTransformation()
00026 {
00027
00028 }
00029
00033 void wxMaracasRenderImageTransformation::Translate(int tx, int ty, int tz, int rx, int ry, int rz, int sx, int sy, int sz)
00034 {
00035
00036
00037
00038
00039 double volspX;
00040 double volspY;
00041 double volspZ;
00042 vol->getImageData()->GetSpacing(volspX, volspY, volspZ);
00043
00044 double surfspX;
00045 double surfspY;
00046 double surfspZ;
00047 surface1->getImageData()->GetSpacing(surfspX, surfspY, surfspZ);
00048
00049 int ext[6];
00050 vol->getImageData()->GetExtent(ext);
00051
00052 transformV ->Identity();
00053 transformS1 ->Identity();
00054 transformS2 ->Identity();
00055 transformS3 ->Identity();
00056
00057 transformV ->PostMultiply();
00058 transformS1 ->PostMultiply();
00059 transformS2 ->PostMultiply();
00060 transformS3 ->PostMultiply();
00061
00062 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[1]-ext[0])*volspX );
00063 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[3]-ext[2])*surfspY);
00064 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[5]-ext[4])*surfspZ);
00065
00066 transformV ->Translate( -(ext[1]-ext[0])*volspX/2, -(ext[3]-ext[2])*volspY/2, -(ext[5]-ext[4])*volspZ/2 );
00067 transformS1->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
00068 transformS2->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
00069 transformS3->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
00070
00071 transformV ->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
00072 transformS1->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
00073 transformS2->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
00074 transformS3->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
00075
00076 transformV ->RotateX( rx );
00077 transformS1->RotateX( rx );
00078 transformS2->RotateX( rx );
00079 transformS3->RotateX( rx );
00080
00081 transformV ->RotateY( ry );
00082 transformS1->RotateY( ry );
00083 transformS2->RotateY( ry );
00084 transformS3->RotateY( ry );
00085
00086 transformV ->RotateZ( rz );
00087 transformS1->RotateZ( rz );
00088 transformS2->RotateZ( rz );
00089 transformS3->RotateZ( rz );
00090
00091 transformV ->Translate( tx*volspX + (ext[1]-ext[0])*volspX/2, ty*volspY + (ext[3]-ext[2])*volspY/2, tz*volspZ + (ext[5]-ext[4])*volspZ/2 );
00092 transformS1->Translate( tx*surfspX + (ext[1]-ext[0])*volspX/2, ty*surfspY + (ext[3]-ext[2])*volspY/2, tz*surfspZ + (ext[5]-ext[4])*volspZ/2 );
00093 transformS2->Translate( tx*surfspX + (ext[1]-ext[0])*volspX/2, ty*surfspY + (ext[3]-ext[2])*volspY/2, tz*surfspZ + (ext[5]-ext[4])*volspZ/2 );
00094 transformS3->Translate( tx*surfspX + (ext[1]-ext[0])*volspX/2, ty*surfspY + (ext[3]-ext[2])*volspY/2, tz*surfspZ + (ext[5]-ext[4])*volspZ/2 );
00095
00096 Refresh();
00097 }
00098
00102 void wxMaracasRenderImageTransformation::Refresh()throw(char*)
00103 {
00104 transformV->Update();
00105 transformS1->Update();
00106 transformS2->Update();
00107 transformS3->Update();
00108
00109 vol->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
00110
00111
00112 surface1->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
00113
00114
00115 surface2->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
00116
00117
00118 surface3->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
00119
00120 }