2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 #include "bbvtkTransform.h"
29 #include "bbvtkPackage.h"
32 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,Transform);
33 BBTK_BLACK_BOX_IMPLEMENTATION(Transform,bbtk::AtomicBlackBox);
35 // --------------------------------------------------------------
37 void Transform::bbUserSetDefaultValues()
41 vecScale.push_back(1); // scale x
42 vecScale.push_back(1); // scale y
43 vecScale.push_back(1); // scale z
44 bbSetInputScale(vecScale);
46 vecRotateWXYZ.push_back(0); //angle
47 vecRotateWXYZ.push_back(1); //vx
48 vecRotateWXYZ.push_back(0); //vy
49 vecRotateWXYZ.push_back(0); //vz
50 bbSetInputRotateWXYZ(vecRotateWXYZ);
52 vecTranslate.push_back(0); //tx
53 vecTranslate.push_back(0); //ty
54 vecTranslate.push_back(0); //tz
55 bbSetInputTranslate(vecTranslate);
57 vecSpacing.push_back(1); //spacing x
58 vecSpacing.push_back(1); //spacing y
59 vecSpacing.push_back(1); //spacing z
60 bbSetInputSpacing(vecSpacing);
65 // --------------------------------------------------------------
66 void Transform::bbUserInitializeProcessing()
68 bbUserFinalizeProcessing();
69 result = vtkTransform::New();
73 // --------------------------------------------------------------
74 void Transform::bbUserFinalizeProcessing()
84 // --------------------------------------------------------------
85 void Transform::Process()
87 bbUserInitializeProcessing();
88 if (bbGetInputIn()!=NULL)
90 result->Concatenate( bbGetInputIn()->GetMatrix() );
93 if ((bbGetInputTranslate().size()>=3) && (bbGetInputSpacing().size()>=3))
95 double tx = bbGetInputTranslate()[0] * bbGetInputSpacing()[0];
96 double ty = bbGetInputTranslate()[1] * bbGetInputSpacing()[1];
97 double tz = bbGetInputTranslate()[2] * bbGetInputSpacing()[2];
98 result->Translate(tx,ty,tz);
101 if (bbGetInputScale().size()>=3)
103 result->Scale(bbGetInputScale()[0], bbGetInputScale()[1], bbGetInputScale()[2]);
106 if (bbGetInputRotateWXYZ().size()>=4)
108 result->RotateWXYZ(bbGetInputRotateWXYZ()[0],bbGetInputRotateWXYZ()[1], bbGetInputRotateWXYZ()[2], bbGetInputRotateWXYZ()[3]);
111 bbSetOutputOut(result);
114 // EO namespace bbvtk