1 /*=========================================================================
4 Module: $RCSfile: marAxis.h,v $
6 Date: $Date: 2010/04/29 16:05:38 $
7 Version: $Revision: 1.3 $
9 Copyright: (c) 2002, 2003
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notice for more information.
16 =========================================================================*/
18 #ifndef __MAR__KERNEL__AXIS__HXX__
19 #define __MAR__KERNEL__AXIS__HXX__
21 #include <vtkPolyData.h>
22 #include <vtkProbeFilter.h>
25 //In an ideal future we should get rid of gslobj to get rid of gsl...
26 // PS -> //#include "gslobj.hxx" //PS
30 #include "marContour.h"
31 #include "marObject.h"
32 #include "ExtractionAxe.h"
33 #include <marAxisContours.h>
34 #include <marIsocontour.h>
40 * \brief class describing an axe in Maracas
41 * \todo marAxis ...miss some stuff...
43 class MAR_KERNEL_EXPORT marAxis : public marObject, public kCurve
49 * More detailed enum description.
52 enum AxisStateVectorIndexes
54 INDX_X = 0, /*!< X coordinate of an axis point. */
55 INDX_Y, /*!< Y coordinate of an axis point. */
56 INDX_Z, /*!< Z coordinate of an axis point. */
57 INDX_V1X, /*!< X coordinate of the first eigen vector. */
58 INDX_V1Y, /*!< Y coordinate of the first eigen vector. */
59 INDX_V1Z, /*!< Z coordinate of the first eigen vector. */
60 INDX_V2X, /*!< X coordinate of the second eigen vector. */
61 INDX_V2Y, /*!< Y coordinate of the second eigen vector. */
62 INDX_V2Z, /*!< Z coordinate of the second eigen vector. */
63 INDX_V3X, /*!< X coordinate of the third eigen vector. */
64 INDX_V3Y, /*!< Y coordinate of the third eigen vector. */
65 INDX_V3Z, /*!< Z coordinate of the third eigen vector. */
66 INDX_LAMBDA1, /*!< Value of the first eigen value. */
67 INDX_LAMBDA2, /*!< Value of the second eigen value. */
68 INDX_LAMBDA3, /*!< Value of the third eigen value. */
69 INDX_MASSE, /*!< Weight of the optimal sphere. */
70 INDX_RAYON, /*!< Radius of the optimal sphere. */
71 INDX_INERTIE, /*!< Inertia of the optimal sphere. */
72 INDX_PTAGEMASSE, /*!< X coordinate of an axis point. */
73 INDX_PTAGERAYON, /*!< X coordinate of an axis point. */
74 INDX_SIGNALVALUE, /*!< X coordinate of an axis point. */
75 INDX_count /*!< Allow counting of this enum. */
83 marAxis( marParameters* p = NULL );
88 ~marAxis( ) { reset( ); };
91 * Return description as a std::string
93 std::string& getDescription( ) { return( _description ); };
96 * Set description as a std::string
98 void setDescription( std::string& d ) { _description = d; };
101 * Add a point to the axis
102 * \warning no check is done
104 void addAxisPoint( double* p );
105 void changeAxisResolution( );
106 void calculateSignal( kVolume* vol );
109 int getActualQuant( ) { return _actualQuant; }
111 float getSignal( uint slice ) { return( _signal[ slice ] ); };
113 double* getSplinePoint( uint i ) { return ( _points[ i ] ); };
115 int getHealthySlice( ) { return( _healthySlice ); };
116 int getHealthySliceStart( ) { return( _healthySliceStart ); };
117 int getHealthySliceEnd( ) { return( _healthySliceEnd ); };
119 void setActualQuant(int act) { _actualQuant=act; };
121 void setHealthySlice( int hsS, int hs, int hsE );
123 void setStartQuant( int sq );
124 void setFinishQuant( int fq );
127 int getStartQuant( ) { return _startQuant; };
128 int getFinishQuant( ) { return _finishQuant; };
132 void next( ) { _actualQuant++; };
133 void stop( ) { _actualQuant = _finishQuant + 1; };
134 bool isFinished( ) { return( _actualQuant >= _startQuant && _actualQuant <= _finishQuant ); }
138 void cut( int slice, bool up );
140 // EED Ojo eduardo esto toca borrarlo
141 void sliceVolumeAxis( kVolume* vol, bool forceCnt = true );
143 double* getNormal( unsigned int slice );
145 int getNumberOfContours( );
146 int getNumberOfSplinePoints( );
148 // EED Ojo Eduardo esto toca redefinirlo o partilo en dos o algo..
149 // vtkPolyData* setContour( int i, int x = -1, int y = -1, std::vector< double* >* points = NULL, marContour* c = NULL );
153 marContour* getContour( int i ) { return( _contours[ i ] ); };
154 kVolume* getSlice( int i ) { return( _slices[ i ] ); };
155 vtkProbeFilter* get3DSlice( int i ) { return( _3Dslices[ i ] ); };
156 vtkImageData* getSliceImage( int i ) { return(_quantificationImages[ i ]); };
159 bool if3DcontourExist(int i);
160 void Save3Dcontour(FILE *ff,int i);
161 void SaveExisting3DContours(FILE *ff);
163 marContour* getContour( int i , kVolume* vol ); // DATA-MODEL-2D
164 kVolume* getSlice( int i , kVolume* vol ); // DATA-MODEL-Voxel XxYx1
165 vtkProbeFilter* get3DSlice( int i , kVolume* vol ); // VISUALISATION-VTK 3D
166 vtkPoints* get3Dcontour( int i , kVolume* vol ); // VISUALISATION-VTK 3D
167 vtkImageData* getSliceImage( int i , kVolume* vol ); // VISUALISATION-VTK 2D
168 vtkPolyData* get2Dcontour( int i , kVolume* vol ); // VISUALISATION-VTK 2D
169 vtkPoints* get2DDiameterMin( int i , kVolume* vol ); // VISUALISATION-VTK 3D
170 vtkPoints* get2DDiameterMax( int i , kVolume* vol ); // VISUALISATION-VTK 3D
172 void replaceContour2D(int i,int size,double *vx,double *vy);
173 void EraseContour(int i);
175 void createEmptyVectors();
176 void clearAllVectors();
177 void eraseContourVectorsContent();
180 void set_points_disc ( PPPOINTAXE p ) { _points_disc = p; };
182 double getTotalLength();
183 double getSubAxisLength();
184 double getReferenceArea(kVolume* vol);
185 double getReferenceAverDiam(kVolume* vol);
186 double getAverageArea(int pIni, int pEnd, kVolume* vol);
192 void copyFrom( const marObject& from );
195 * Persistence methods
197 bool save( std::ofstream& os );
198 bool load( std::ifstream& is );
200 vtkPolyData *Draw( );
201 vtkPolyData *GetAxisData();
203 double* getPoints(int i) { return _points[i]; };
205 void AddPointToList(double x, double y, double z, int signal);
211 double _totalAxisLenght;
212 double _subAxisLenght;
213 double _referenceArea;
214 double _referenceAverDiam;
216 std::string _description; // Axis description
217 std::vector< double* > _points; // Axis spline points
218 std::vector< marContour* > _contours; // DATA-MODEL-2D Axis Contours
219 std::vector< kVolume* > _slices; // DATA-MODEL-Voxel XxYx1 Axis perpendicular Slice
220 std::vector< vtkProbeFilter* > _3Dslices; // VISUALISATION_VTK 3D Axis perpendicular Slice
221 std::vector< vtkPoints* > _3Dcontour; // VISUALISATION_VTK 3D Axis perpendicular Contour
222 std::vector< vtkImageData* > _quantificationImages; // VISUALISATION_VTK 2D Axis perpendicular Coup
223 std::vector< vtkPolyData* > _2Dcontours; // VISUALISATION_VTK 2D Axis perpendicular Contour
224 std::vector< vtkPoints* > _2DDiameterMin; // VISUALISATION_VTK 2D Line diameter Minimum
225 std::vector< vtkPoints* > _2DDiameterMax; // VISUALISATION_VTK 2D Line diameter Maximum
226 std::vector< int > _signal; // Axis intensity signal
227 int _healthySlice; // Healthy slice, if -1 then is unselected
228 int _healthySliceStart;
229 int _healthySliceEnd;
233 PPPOINTAXE _points_disc;
235 vtkPolyData* _allData;
237 // Properties from marObject
238 //marParameters* _parameters;
240 // Properties from kCurve
241 // std::vector< double* > _controlPoints; // Axis calculated points
243 void calculateTotalAxisLenght();
244 void calculateSubAxisLength();
245 void calculateReferenceArea(kVolume* vol );
246 void calculateReferenceAverDiam(kVolume* vol );
247 void createContour( int i , kVolume* vol );
248 void createSlice( int i , kVolume* vol );
249 void create3DSlice( int i , kVolume* vol );
250 void create3Dcontour( int i , kVolume* vol );
251 void createSliceImage( int i , kVolume* vol );
252 void create2Dcontour( int i , kVolume* vol );
253 void create2DDiameterMin(int i , kVolume* vol );
254 void create2DDiameterMax(int i , kVolume* vol );
255 double getAxisLenght( int pIni, int pEnd);
260 std::vector <marAxisContours* > quantContours;
261 std::vector <marPoint *> vesselPoints;
262 std::vector <marIsocontour *> lumenContour;
266 // std::vector <marIsocontour* > pointContours;
271 #endif // __MAR__KERNEL__AXIS__HXX__