]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/marContour.h
change in CmakeLists.txt maracasVisuLib
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / marContour.h
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: marContour.h,v $
5   Language:  C++
6   Date:      $Date: 2008/10/31 16:32:54 $
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 #ifndef __MAR__KERNEL__CONTOUR__HXX__
18 #define __MAR__KERNEL__CONTOUR__HXX__
19
20
21 #include "marObject.h"
22
23 //#include <kgfo/volume.hxx>
24 #include "volume.hxx"
25 #include "mathdefs.h"
26
27 #include <vtkUnstructuredGrid.h>
28 #include <vector>
29
30
31
32 /** /def marObject
33  *  \brief Contour object.
34  */
35 class MAR_KERNEL_EXPORT marContour : public marObject
36 {
37     public:
38
39     /** Default constructor.
40      */
41     marContour( double s, marParameters* p = NULL );
42
43     /** Default destructor.
44      */
45     ~marContour( ) { reset( ); };
46
47     double getS( ) { return( _s ); };
48
49     void setS( double s ) { _s = s; };
50
51     /** Adds a contour point.
52      */
53     void addContourPoint( double x, double y );
54
55     /** Resamples current contour, according to actual parameters,
56      *  to have more or less points.
57      */
58     void resample( );
59
60     /** Returns if the contour has any points.
61      */
62     bool isCalculated( );
63
64     /** General analyzers.
65      */
66     int getNumberOfPoints( );
67     void getPoint( double* p, int i );
68
69     /** Quantification analyzers.
70      */
71         void calculateVariables();
72         void do_spline( );
73     double getArea()                                    {       return _area;                                   }
74     double getPerimeter()                               {       return _perimeter;                              }
75     double getDiameterFromArea()                {       return _diameterFromArea;               }
76     double getDiameterFromPerimeter()   {       return _diameterFromPerimeter;  }
77     double getMinimumDiameter()                 {       return _minimumDiameter;                }
78     double getMaximumDiameter()                 {       return _maximumDiameter;                }
79     double getAverageDiameter()                 {       return _averageDiameter;                }
80
81     void getMaximumLine( double* pO, double* pF );
82     void getMinimumLine( double* pO, double* pF );
83
84
85     /** General methods.
86      */
87     void reset( );
88     void copyFrom( const marObject& from );
89     vtkUnstructuredGrid* Draw( );
90     void Delete( );
91
92     /** Persistence methods.
93      */
94     bool save( std::ofstream& os );
95     bool load( std::ifstream& is );
96
97     private:
98
99
100         void calculateArea();
101         void calculatePerimeter();
102         void calculateDiameterFromArea()                { _diameterFromArea                     = sqrt( 4.0 * getArea( ) / GTM_PI ) ;                           }
103         void calculateDiameterFromPerimeter()   { _diameterFromPerimeter        = getPerimeter( )       / GTM_PI ;                                              }       
104         void calculateMinimumMaximumDiameter(); 
105         void calculateAverageDiameter()         { _averageDiameter = ( getMaximumDiameter( ) + getMinimumDiameter( ) ) * 0.5 ;  }
106                 
107         std::vector< double* > _points;
108
109 // EED borrame
110 //    std::vector< temPoint< float,2 >* > _no_spline_points;   //  Points that define contour without spline (persistence)
111     std::vector< double* > _no_spline_points;   //  Points that define contour without spline (persistence)
112
113     double _s; // paramètre curviligne (entre 0 et 1)
114     double _min[ 4 ];
115     double _max[ 4 ];
116     vtkUnstructuredGrid* _allData;
117
118         double _area;
119         double _perimeter;
120         double _diameterFromArea;
121         double _diameterFromPerimeter;
122         double _minimumDiameter;
123         double _maximumDiameter;
124         double _averageDiameter;
125
126
127
128 };
129
130 #endif // __MAR__KERNEL__CONTOUR__HXX__