]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/marAxis.h
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / include / marAxis.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 /*=========================================================================
27
28   Program:   wxMaracas
29   Module:    $RCSfile: marAxis.h,v $
30   Language:  C++
31   Date:      $Date: 2012/11/15 14:15:31 $
32   Version:   $Revision: 1.4 $
33
34   Copyright: (c) 2002, 2003
35   License:
36   
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.
40
41 =========================================================================*/
42
43 #ifndef __MAR__KERNEL__AXIS__HXX__
44 #define __MAR__KERNEL__AXIS__HXX__
45
46 #include <vtkPolyData.h>
47 #include <vtkProbeFilter.h>
48 #include <vector>
49
50 //In an ideal future we should get rid of gslobj to get rid of gsl...
51 // PS -> //#include "gslobj.hxx" //PS
52
53 #include "curve.hxx"
54 #include "volume.hxx"
55 #include "marContour.h"
56 #include "marObject.h"
57 #include "ExtractionAxe.h"
58 #include <marAxisContours.h>
59 #include <marIsocontour.h>
60
61 class vtkPoints;
62 class vtkCellArray;
63
64 /**
65  * \brief class describing an axe in Maracas
66  * \todo marAxis ...miss some stuff...
67  */
68 class MAR_KERNEL_EXPORT marAxis : public marObject, public kCurve
69 {
70 public:
71
72 /** An enum.
73 *
74 * More detailed enum description.
75 */
76   
77   enum AxisStateVectorIndexes
78 {
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. */  
101     };
102
103 public:
104
105 /**
106 * Cstor
107 */
108   marAxis( marParameters* p = NULL );
109
110 /**
111 * Destructor
112 */
113   ~marAxis( ) { reset( ); };
114
115 /**
116 * Return description as a std::string
117 */
118   std::string& getDescription( ) { return( _description ); };
119
120 /**
121 * Set description as a std::string
122 */
123   void setDescription( std::string& d ) { _description = d; };
124
125 /**
126 * Add a point to the axis
127 * \warning no check is done
128   */
129   void addAxisPoint( double* p );
130   void changeAxisResolution( );
131   void calculateSignal( kVolume* vol );
132     
133
134   int getActualQuant( )                                         { return _actualQuant;                          }
135
136   float getSignal( uint slice )                         { return( _signal[ slice ] );           };
137
138   double* getSplinePoint( uint i )                      { return ( _points[ i ] );                      };
139
140   int getHealthySlice( )                                        { return( _healthySlice );                      };
141   int getHealthySliceStart( )                           { return( _healthySliceStart );         };
142   int getHealthySliceEnd( )                                     { return( _healthySliceEnd );           };
143
144   void setActualQuant(int act)                          { _actualQuant=act;                                     };
145
146   void setHealthySlice( int hsS, int hs, int hsE );
147
148   void setStartQuant( int sq );
149   void setFinishQuant( int fq );
150
151
152   int   getStartQuant( )                                        { return _startQuant;                           };
153   int   getFinishQuant( )                                       { return _finishQuant;                          };
154
155
156   void start( );
157   void next( )                                                          { _actualQuant++; };
158   void stop( )                                                          { _actualQuant = _finishQuant + 1; };
159   bool isFinished( ) { return( _actualQuant >= _startQuant && _actualQuant <= _finishQuant ); }
160
161   void doSpline ( );
162
163   void cut( int slice, bool up );
164
165 // EED Ojo eduardo esto toca borrarlo
166   void sliceVolumeAxis( kVolume* vol, bool forceCnt = true );
167
168   double* getNormal( unsigned int slice );
169
170   int getNumberOfContours( );
171   int getNumberOfSplinePoints( );
172
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 );
175
176 // EED borrame
177 /*
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 ]);  };
182 */
183
184   bool              if3DcontourExist(int i);
185   void                          Save3Dcontour(FILE *ff,int i);
186   void                          SaveExisting3DContours(FILE *ff);
187         
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
196
197   void                          replaceContour2D(int i,int size,double *vx,double *vy);
198   void                          EraseContour(int i);
199
200   void                          createEmptyVectors();
201   void                          clearAllVectors(); 
202   void                          eraseContourVectorsContent();
203   
204
205   void                          set_points_disc   ( PPPOINTAXE p ) { _points_disc = p; };
206
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);
212
213 /**
214 *  General methods
215 */
216   void                          reset( );
217   void                          copyFrom( const marObject& from );
218
219 /**
220 * Persistence methods
221 */
222   bool                          save( std::ofstream& os );
223   bool                          load( std::ifstream& is );
224
225   vtkPolyData           *Draw( );
226   vtkPolyData           *GetAxisData();
227   void                          Delete( );
228   double*                       getPoints(int i) { return _points[i]; };        
229
230         void AddPointToList(double x, double y, double z, int signal);
231
232
233
234 private:
235
236   double _totalAxisLenght;
237   double _subAxisLenght;
238   double _referenceArea;
239   double _referenceAverDiam;
240
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;
255   int _startQuant;
256   int _finishQuant;
257   int _actualQuant;
258   PPPOINTAXE _points_disc;
259     
260   vtkPolyData* _allData;
261
262   // Properties from marObject
263   //marParameters* _parameters;
264
265   // Properties from kCurve
266   // std::vector< double* > _controlPoints; //  Axis calculated points
267
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);
281   
282
283 protected:
284
285   std::vector <marAxisContours* > quantContours;
286   std::vector <marPoint *> vesselPoints;
287   std::vector <marIsocontour *> lumenContour;
288   bool calibration;
289   
290
291 //  std::vector <marIsocontour* > pointContours;
292   
293
294 };
295
296 #endif // __MAR__KERNEL__AXIS__HXX__