]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/marAxis.h
76eb8640294c9b1f3dbad2a55e9a1adffe5e563b
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / include / marAxis.h
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: marAxis.h,v $
5   Language:  C++
6   Date:      $Date: 2009/05/14 13:55:07 $
7   Version:   $Revision: 1.1 $
8
9   Copyright: (c) 2002, 2003
10   License:
11   
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.
15
16 =========================================================================*/
17
18 #ifndef __MAR__KERNEL__AXIS__HXX__
19 #define __MAR__KERNEL__AXIS__HXX__
20
21 #include <vtkPolyData.h>
22 #include <vtkProbeFilter.h>
23 #include <vector>
24
25 //In an ideal future we should get rid of gslobj to get rid of gsl...
26 // PS -> //#include "gslobj.hxx" //PS
27
28 #include "curve.hxx"
29 #include "volume.hxx"
30 #include "marContour.h"
31 #include "marObject.h"
32 #include "ExtractionAxe.h"
33 #include <marAxisContours.h>
34 #include <marIsocontour.h>
35
36 class vtkPoints;
37 class vtkCellArray;
38
39 /**
40  * \brief class describing an axe in Maracas
41  * \todo marAxis ...miss some stuff...
42  */
43 class MAR_KERNEL_EXPORT marAxis : public marObject, public kCurve
44 {
45 public:
46
47 /** An enum.
48 *
49 * More detailed enum description.
50 */
51   
52   enum AxisStateVectorIndexes
53 {
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. */  
76     };
77
78 public:
79
80 /**
81 * Cstor
82 */
83   marAxis( marParameters* p = NULL );
84
85 /**
86 * Destructor
87 */
88   ~marAxis( ) { reset( ); };
89
90 /**
91 * Return description as a std::string
92 */
93   std::string& getDescription( ) { return( _description ); };
94
95 /**
96 * Set description as a std::string
97 */
98   void setDescription( std::string& d ) { _description = d; };
99
100 /**
101 * Add a point to the axis
102 * \warning no check is done
103   */
104   void addAxisPoint( double* p );
105   void changeAxisResolution( );
106   void calculateSignal( kVolume* vol );
107     
108
109   int getActualQuant( )                                         { return _actualQuant;                          }
110
111   float getSignal( uint slice )                         { return( _signal[ slice ] );           };
112
113   double* getSplinePoint( uint i )                      { return ( _points[ i ] );                      };
114
115   int getHealthySlice( )                                        { return( _healthySlice );                      };
116   int getHealthySliceStart( )                           { return( _healthySliceStart );         };
117   int getHealthySliceEnd( )                                     { return( _healthySliceEnd );           };
118
119   void setActualQuant(int act)                          { _actualQuant=act;                                     };
120
121   void setHealthySlice( int hsS, int hs, int hsE );
122
123   void setStartQuant( int sq );
124   void setFinishQuant( int fq );
125
126
127   int   getStartQuant( )                                        { return _startQuant;                           };
128   int   getFinishQuant( )                                       { return _finishQuant;                          };
129
130
131   void start( );
132   void next( )                                                          { _actualQuant++; };
133   void stop( )                                                          { _actualQuant = _finishQuant + 1; };
134   bool isFinished( ) { return( _actualQuant >= _startQuant && _actualQuant <= _finishQuant ); }
135
136   void doSpline ( );
137
138   void cut( int slice, bool up );
139
140 // EED Ojo eduardo esto toca borrarlo
141   void sliceVolumeAxis( kVolume* vol, bool forceCnt = true );
142
143   double* getNormal( unsigned int slice );
144
145   int getNumberOfContours( );
146   int getNumberOfSplinePoints( );
147
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 );
150
151 // EED borrame
152 /*
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 ]);  };
157 */
158
159
160   bool              if3DcontourExist(int i); 
161   void                          Save3Dcontour(FILE *ff,int i);
162   void                          SaveExisting3DContours(FILE *ff);
163
164         
165   marContour*           getContour(             int i , kVolume* vol );         // DATA-MODEL-2D  
166   kVolume*                      getSlice(               int i , kVolume* vol );         // DATA-MODEL-Voxel XxYx1
167   vtkProbeFilter*       get3DSlice(             int i , kVolume* vol );         // VISUALISATION-VTK 3D
168   vtkPoints*            get3Dcontour(   int i , kVolume* vol );         // VISUALISATION-VTK 3D
169   vtkImageData*         getSliceImage(  int i , kVolume* vol );         // VISUALISATION-VTK 2D
170   vtkPolyData*          get2Dcontour(   int i , kVolume* vol );         // VISUALISATION-VTK 2D
171   vtkPoints*            get2DDiameterMin(       int i , kVolume* vol );         // VISUALISATION-VTK 3D
172   vtkPoints*            get2DDiameterMax(       int i , kVolume* vol );         // VISUALISATION-VTK 3D
173
174   void                          replaceContour2D(int i,int size,double *vx,double *vy);
175   void                          EraseContour(int i);
176
177   void                          createEmptyVectors();
178   void                          clearAllVectors(); 
179   void                          eraseContourVectorsContent();
180   
181
182   void                          set_points_disc   ( PPPOINTAXE p ) { _points_disc = p; };
183
184   double                        getTotalLength();
185   double                        getSubAxisLength();
186   double                        getReferenceArea(kVolume* vol);
187   double                        getReferenceAverDiam(kVolume* vol);
188   double                        getAverageArea(int pIni, int pEnd, kVolume* vol);
189
190 /**
191 *  General methods
192 */
193   void                          reset( );
194   void                          copyFrom( const marObject& from );
195
196 /**
197 * Persistence methods
198 */
199   bool                          save( std::ofstream& os );
200   bool                          load( std::ifstream& is );
201
202   vtkPolyData           *Draw( );
203   vtkPolyData           *GetAxisData();
204   void                          Delete( );
205   double*                       getPoints(int i) { return _points[i]; };        
206
207         void AddPointToList(double x, double y, double z, int signal);
208
209
210
211 private:
212
213   double _totalAxisLenght;
214   double _subAxisLenght;
215   double _referenceArea;
216   double _referenceAverDiam;
217
218   std::string                                           _description;                           //  Axis description
219   std::vector< double* >                        _points;                                        //  Axis spline points
220   std::vector< marContour* >            _contours;                                      //  DATA-MODEL-2D                       Axis Contours
221   std::vector< kVolume* >                       _slices;                                        //  DATA-MODEL-Voxel XxYx1      Axis perpendicular Slice
222   std::vector< vtkProbeFilter* >        _3Dslices;                                      //  VISUALISATION_VTK 3D        Axis perpendicular Slice
223   std::vector< vtkPoints* >                     _3Dcontour;                                     //  VISUALISATION_VTK 3D        Axis perpendicular Contour
224   std::vector< vtkImageData* >          _quantificationImages;          //  VISUALISATION_VTK 2D    Axis perpendicular Coup
225   std::vector< vtkPolyData* >           _2Dcontours;                            //  VISUALISATION_VTK 2D        Axis perpendicular Contour
226   std::vector< vtkPoints* >                     _2DDiameterMin;                         //  VISUALISATION_VTK 2D        Line diameter Minimum
227   std::vector< vtkPoints* >                     _2DDiameterMax;                         //  VISUALISATION_VTK 2D        Line diameter Maximum
228   std::vector< int >                            _signal;                                        //  Axis intensity signal
229   int _healthySlice;                     //  Healthy slice, if -1 then is unselected
230   int _healthySliceStart;
231   int _healthySliceEnd;
232   int _startQuant;
233   int _finishQuant;
234   int _actualQuant;
235   PPPOINTAXE _points_disc;
236     
237   vtkPolyData* _allData;
238
239   // Properties from marObject
240   //marParameters* _parameters;
241
242   // Properties from kCurve
243   // std::vector< double* > _controlPoints; //  Axis calculated points
244
245   void          calculateTotalAxisLenght();     
246   void          calculateSubAxisLength();
247   void          calculateReferenceArea(kVolume* vol );
248   void          calculateReferenceAverDiam(kVolume* vol );
249   void          createContour(          int i   , kVolume* vol );
250   void          createSlice(            int i   , kVolume* vol );
251   void          create3DSlice(          int i   , kVolume* vol );
252   void          create3Dcontour(        int i   , kVolume* vol );
253   void          createSliceImage(       int i   , kVolume* vol );
254   void          create2Dcontour(        int i   , kVolume* vol );
255   void          create2DDiameterMin(int i       , kVolume* vol );
256   void          create2DDiameterMax(int i       , kVolume* vol );
257   double        getAxisLenght(          int pIni, int pEnd);
258   
259
260 protected:
261
262   std::vector <marAxisContours* > quantContours;
263   std::vector <marPoint *> vesselPoints;
264   std::vector <marIsocontour *> lumenContour;
265   bool calibration;
266   
267
268 //  std::vector <marIsocontour* > pointContours;
269   
270
271 };
272
273 #endif // __MAR__KERNEL__AXIS__HXX__