1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
28 #include <vtkPlanes.h>
29 #include <vtkProperty.h>
30 #include <vtkPolyData.h>
31 #include <vtkDataSet.h>
32 #include <vtkCellArray.h>
33 #include <vtkTransform.h>
34 #include <vtkTransformFilter.h>
35 #include <vtkDataSetReader.h>
37 #include "wxMPRBaseData.h"
38 #include "pPlotter/HistogramDialog.h"
44 //-------------------------------------------------------------------
45 //-------------------------------------------------------------------
46 //-------------------------------------------------------------------
49 //-------------------------------------------------------------------
50 //-------------------------------------------------------------------
51 //-------------------------------------------------------------------
52 vtkMPRBaseData::vtkMPRBaseData()
63 _transformOrientation = NULL;
67 //-------------------------------------------------------------------
68 vtkMPRBaseData::~vtkMPRBaseData()
70 if (_marImageData) delete _marImageData;
71 if (_transformOrientation) _transformOrientation ->Delete();
74 //-------------------------------------------------------------------
75 void vtkMPRBaseData::Configure()
78 vtkBaseData::Configure();
80 vtkImageData* img = _marImageData->GetImageData();
83 img->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2);
84 //std::cout<<"vtkMPRBaseData::Configure() _x1= "<<_x1<<" _x2= "<<_x2<<" _y1= "<<_y1<<" _y2= "<<_y2<<" _z1= "<<_z1<<" _z2= "<<_z2<<std::endl;
87 if(_transformOrientation==NULL)
89 _transformOrientation=vtkTransform::New();
92 _transformOrientation->Identity();
95 //-------------------------------------------------------------------
96 void vtkMPRBaseData::GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2)
107 //------------------------------------------------------------------------
108 int vtkMPRBaseData::GetMaxPositionX( )
112 //------------------------------------------------------------------------
113 int vtkMPRBaseData::GetMaxPositionY( )
117 //------------------------------------------------------------------------
118 int vtkMPRBaseData::GetMaxPositionZ( )
122 //-------------------------------------------------------------------
123 double vtkMPRBaseData::GetX()
128 //-------------------------------------------------------------------
129 double vtkMPRBaseData::GetY()
133 //-------------------------------------------------------------------
135 ** Calculates the value of the slider and the layer in the image that is spouse to show
137 void vtkMPRBaseData::SetX(double x)
142 vtkImageData* img = _marImageData->GetImageData();
144 /*img->GetDimensions(dim);
155 origin = img->GetOrigin();
158 x=ext[0] + origin[0];
162 x=ext[1] + origin[0];
168 //-------------------------------------------------------------------
170 ** Calculates the value of the slider and the layer in the image that is spouse to show
172 void vtkMPRBaseData::SetY(double y)
177 vtkImageData* img = _marImageData->GetImageData();
179 /*img->GetDimensions(dim);
190 origin = img->GetOrigin();
193 y=ext[2] + origin[1];
197 y=ext[3] + origin[1];
202 //-------------------------------------------------------------------
203 vtkTransform *vtkMPRBaseData::GetTransformOrientation()
205 return _transformOrientation;
207 //-------------------------------------------------------------------
208 void vtkMPRBaseData::SetNormal(double nx, double ny, double nz)
210 double alfa = atan2(ny,nx) * 180.0 / 3.1416;
211 double beta = atan2( nz, sqrt( nx*nx + ny*ny ) ) * 180.0 / 3.1416;
212 _transformOrientation->Identity();
213 _transformOrientation->RotateWXYZ(alfa,0,0,1);
214 _transformOrientation->RotateWXYZ(-beta,0,1,0);
216 //-------------------------------------------------------------------
217 void vtkMPRBaseData::InitTransformOrientation(vtkTransform *trans)
219 _transformOrientation->SetMatrix( trans->GetMatrix() );
224 //-------------------------------------------------------------------
225 //-------------------------------------------------------------------
226 //-------------------------------------------------------------------