]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/marAxis.h
db7c7861431fc84f073a63d568b93a3844c110fb
[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: 2010/04/29 16:05:38 $
7   Version:   $Revision: 1.3 $
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   bool              if3DcontourExist(int i);
160   void                          Save3Dcontour(FILE *ff,int i);
161   void                          SaveExisting3DContours(FILE *ff);
162         
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
171
172   void                          replaceContour2D(int i,int size,double *vx,double *vy);
173   void                          EraseContour(int i);
174
175   void                          createEmptyVectors();
176   void                          clearAllVectors(); 
177   void                          eraseContourVectorsContent();
178   
179
180   void                          set_points_disc   ( PPPOINTAXE p ) { _points_disc = p; };
181
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);
187
188 /**
189 *  General methods
190 */
191   void                          reset( );
192   void                          copyFrom( const marObject& from );
193
194 /**
195 * Persistence methods
196 */
197   bool                          save( std::ofstream& os );
198   bool                          load( std::ifstream& is );
199
200   vtkPolyData           *Draw( );
201   vtkPolyData           *GetAxisData();
202   void                          Delete( );
203   double*                       getPoints(int i) { return _points[i]; };        
204
205         void AddPointToList(double x, double y, double z, int signal);
206
207
208
209 private:
210
211   double _totalAxisLenght;
212   double _subAxisLenght;
213   double _referenceArea;
214   double _referenceAverDiam;
215
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;
230   int _startQuant;
231   int _finishQuant;
232   int _actualQuant;
233   PPPOINTAXE _points_disc;
234     
235   vtkPolyData* _allData;
236
237   // Properties from marObject
238   //marParameters* _parameters;
239
240   // Properties from kCurve
241   // std::vector< double* > _controlPoints; //  Axis calculated points
242
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);
256   
257
258 protected:
259
260   std::vector <marAxisContours* > quantContours;
261   std::vector <marPoint *> vesselPoints;
262   std::vector <marIsocontour *> lumenContour;
263   bool calibration;
264   
265
266 //  std::vector <marIsocontour* > pointContours;
267   
268
269 };
270
271 #endif // __MAR__KERNEL__AXIS__HXX__