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 # ------------------------------------------------------------------------ */
26 /*=========================================================================
29 Module: $RCSfile: marAxis.h,v $
31 Date: $Date: 2012/11/15 14:15:31 $
32 Version: $Revision: 1.4 $
34 Copyright: (c) 2002, 2003
37 This software is distributed WITHOUT ANY WARRANTY; without even
38 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39 PURPOSE. See the above copyright notice for more information.
41 =========================================================================*/
43 #ifndef __MAR__KERNEL__AXIS__HXX__
44 #define __MAR__KERNEL__AXIS__HXX__
46 #include <vtkPolyData.h>
47 #include <vtkProbeFilter.h>
50 //In an ideal future we should get rid of gslobj to get rid of gsl...
51 // PS -> //#include "gslobj.hxx" //PS
55 #include "marContour.h"
56 #include "marObject.h"
57 #include "ExtractionAxe.h"
58 #include <marAxisContours.h>
59 #include <marIsocontour.h>
65 * \brief class describing an axe in Maracas
66 * \todo marAxis ...miss some stuff...
68 class MAR_KERNEL_EXPORT marAxis : public marObject, public kCurve
74 * More detailed enum description.
77 enum AxisStateVectorIndexes
79 INDX_X = 0, /*!< X coordinate of an axis point. */
80 INDX_Y, /*!< Y coordinate of an axis point. */
81 INDX_Z, /*!< Z coordinate of an axis point. */
82 INDX_V1X, /*!< X coordinate of the first eigen vector. */
83 INDX_V1Y, /*!< Y coordinate of the first eigen vector. */
84 INDX_V1Z, /*!< Z coordinate of the first eigen vector. */
85 INDX_V2X, /*!< X coordinate of the second eigen vector. */
86 INDX_V2Y, /*!< Y coordinate of the second eigen vector. */
87 INDX_V2Z, /*!< Z coordinate of the second eigen vector. */
88 INDX_V3X, /*!< X coordinate of the third eigen vector. */
89 INDX_V3Y, /*!< Y coordinate of the third eigen vector. */
90 INDX_V3Z, /*!< Z coordinate of the third eigen vector. */
91 INDX_LAMBDA1, /*!< Value of the first eigen value. */
92 INDX_LAMBDA2, /*!< Value of the second eigen value. */
93 INDX_LAMBDA3, /*!< Value of the third eigen value. */
94 INDX_MASSE, /*!< Weight of the optimal sphere. */
95 INDX_RAYON, /*!< Radius of the optimal sphere. */
96 INDX_INERTIE, /*!< Inertia of the optimal sphere. */
97 INDX_PTAGEMASSE, /*!< X coordinate of an axis point. */
98 INDX_PTAGERAYON, /*!< X coordinate of an axis point. */
99 INDX_SIGNALVALUE, /*!< X coordinate of an axis point. */
100 INDX_count /*!< Allow counting of this enum. */
108 marAxis( marParameters* p = NULL );
113 ~marAxis( ) { reset( ); };
116 * Return description as a std::string
118 std::string& getDescription( ) { return( _description ); };
121 * Set description as a std::string
123 void setDescription( std::string& d ) { _description = d; };
126 * Add a point to the axis
127 * \warning no check is done
129 void addAxisPoint( double* p );
130 void changeAxisResolution( );
131 void calculateSignal( kVolume* vol );
134 int getActualQuant( ) { return _actualQuant; }
136 float getSignal( uint slice ) { return( _signal[ slice ] ); };
138 double* getSplinePoint( uint i ) { return ( _points[ i ] ); };
140 int getHealthySlice( ) { return( _healthySlice ); };
141 int getHealthySliceStart( ) { return( _healthySliceStart ); };
142 int getHealthySliceEnd( ) { return( _healthySliceEnd ); };
144 void setActualQuant(int act) { _actualQuant=act; };
146 void setHealthySlice( int hsS, int hs, int hsE );
148 void setStartQuant( int sq );
149 void setFinishQuant( int fq );
152 int getStartQuant( ) { return _startQuant; };
153 int getFinishQuant( ) { return _finishQuant; };
157 void next( ) { _actualQuant++; };
158 void stop( ) { _actualQuant = _finishQuant + 1; };
159 bool isFinished( ) { return( _actualQuant >= _startQuant && _actualQuant <= _finishQuant ); }
163 void cut( int slice, bool up );
165 // EED Ojo eduardo esto toca borrarlo
166 void sliceVolumeAxis( kVolume* vol, bool forceCnt = true );
168 double* getNormal( unsigned int slice );
170 int getNumberOfContours( );
171 int getNumberOfSplinePoints( );
173 // EED Ojo Eduardo esto toca redefinirlo o partilo en dos o algo..
174 // vtkPolyData* setContour( int i, int x = -1, int y = -1, std::vector< double* >* points = NULL, marContour* c = NULL );
178 marContour* getContour( int i ) { return( _contours[ i ] ); };
179 kVolume* getSlice( int i ) { return( _slices[ i ] ); };
180 vtkProbeFilter* get3DSlice( int i ) { return( _3Dslices[ i ] ); };
181 vtkImageData* getSliceImage( int i ) { return(_quantificationImages[ i ]); };
184 bool if3DcontourExist(int i);
185 void Save3Dcontour(FILE *ff,int i);
186 void SaveExisting3DContours(FILE *ff);
188 marContour* getContour( int i , kVolume* vol ); // DATA-MODEL-2D
189 kVolume* getSlice( int i , kVolume* vol ); // DATA-MODEL-Voxel XxYx1
190 vtkProbeFilter* get3DSlice( int i , kVolume* vol ); // VISUALISATION-VTK 3D
191 vtkPoints* get3Dcontour( int i , kVolume* vol ); // VISUALISATION-VTK 3D
192 vtkImageData* getSliceImage( int i , kVolume* vol ); // VISUALISATION-VTK 2D
193 vtkPolyData* get2Dcontour( int i , kVolume* vol ); // VISUALISATION-VTK 2D
194 vtkPoints* get2DDiameterMin( int i , kVolume* vol ); // VISUALISATION-VTK 3D
195 vtkPoints* get2DDiameterMax( int i , kVolume* vol ); // VISUALISATION-VTK 3D
197 void replaceContour2D(int i,int size,double *vx,double *vy);
198 void EraseContour(int i);
200 void createEmptyVectors();
201 void clearAllVectors();
202 void eraseContourVectorsContent();
205 void set_points_disc ( PPPOINTAXE p ) { _points_disc = p; };
207 double getTotalLength();
208 double getSubAxisLength();
209 double getReferenceArea(kVolume* vol);
210 double getReferenceAverDiam(kVolume* vol);
211 double getAverageArea(int pIni, int pEnd, kVolume* vol);
217 void copyFrom( const marObject& from );
220 * Persistence methods
222 bool save( std::ofstream& os );
223 bool load( std::ifstream& is );
225 vtkPolyData *Draw( );
226 vtkPolyData *GetAxisData();
228 double* getPoints(int i) { return _points[i]; };
230 void AddPointToList(double x, double y, double z, int signal);
236 double _totalAxisLenght;
237 double _subAxisLenght;
238 double _referenceArea;
239 double _referenceAverDiam;
241 std::string _description; // Axis description
242 std::vector< double* > _points; // Axis spline points
243 std::vector< marContour* > _contours; // DATA-MODEL-2D Axis Contours
244 std::vector< kVolume* > _slices; // DATA-MODEL-Voxel XxYx1 Axis perpendicular Slice
245 std::vector< vtkProbeFilter* > _3Dslices; // VISUALISATION_VTK 3D Axis perpendicular Slice
246 std::vector< vtkPoints* > _3Dcontour; // VISUALISATION_VTK 3D Axis perpendicular Contour
247 std::vector< vtkImageData* > _quantificationImages; // VISUALISATION_VTK 2D Axis perpendicular Coup
248 std::vector< vtkPolyData* > _2Dcontours; // VISUALISATION_VTK 2D Axis perpendicular Contour
249 std::vector< vtkPoints* > _2DDiameterMin; // VISUALISATION_VTK 2D Line diameter Minimum
250 std::vector< vtkPoints* > _2DDiameterMax; // VISUALISATION_VTK 2D Line diameter Maximum
251 std::vector< int > _signal; // Axis intensity signal
252 int _healthySlice; // Healthy slice, if -1 then is unselected
253 int _healthySliceStart;
254 int _healthySliceEnd;
258 PPPOINTAXE _points_disc;
260 vtkPolyData* _allData;
262 // Properties from marObject
263 //marParameters* _parameters;
265 // Properties from kCurve
266 // std::vector< double* > _controlPoints; // Axis calculated points
268 void calculateTotalAxisLenght();
269 void calculateSubAxisLength();
270 void calculateReferenceArea(kVolume* vol );
271 void calculateReferenceAverDiam(kVolume* vol );
272 void createContour( int i , kVolume* vol );
273 void createSlice( int i , kVolume* vol );
274 void create3DSlice( int i , kVolume* vol );
275 void create3Dcontour( int i , kVolume* vol );
276 void createSliceImage( int i , kVolume* vol );
277 void create2Dcontour( int i , kVolume* vol );
278 void create2DDiameterMin(int i , kVolume* vol );
279 void create2DDiameterMax(int i , kVolume* vol );
280 double getAxisLenght( int pIni, int pEnd);
285 std::vector <marAxisContours* > quantContours;
286 std::vector <marPoint *> vesselPoints;
287 std::vector <marIsocontour *> lumenContour;
291 // std::vector <marIsocontour* > pointContours;
296 #endif // __MAR__KERNEL__AXIS__HXX__