]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtk3DSurfaceSTLWidget.h
1b5eb98f07f491d1e08ce3bef507915c2b30652b
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtk3DSurfaceSTLWidget.h
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: vtk3DSurfaceSTLWidget.h,v $
5   Language:  C++
6   Date:      $Date: 2008/10/31 16:32:41 $
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 __VTK3DSURFACESTLWIDGET__
18 #define __VTK3DSURFACESTLWIDGET__
19
20 #include "wxVTKRenderWindowInteractorEditContour.h"
21
22 #include "vtkImagePolyDataSeedConnectivity.h"
23 #include "vtkInteractorStyleCutter.h"
24 #include "kernel/marInterface.h"
25
26 #include <vtkImageData.h>
27 #include <vtkProperty2D.h>
28 #include <vtkPolyData.h>
29 #include <vtkActor.h>
30 #include <vtkMarchingCubes.h>
31 #include <vtkPolyDataMapper.h>
32 #include <vtkRenderer.h>
33 #include <vtkRenderWindow.h>
34 #include <vtkSphereSource.h>
35 #include <vtkOutlineFilter.h>
36 #include <vtkProperty.h>
37
38 /**
39  * \brief Class that brigde to VTK, override double click...
40  */
41 class vtk3DSurfaceSTLWidget : public wxVTKRenderWindowInteractor
42 {
43 public:
44
45     vtk3DSurfaceSTLWidget(
46         wxWindow* parent,
47         wxWindowID id,
48         const wxPoint& pos = wxDefaultPosition,
49         const wxSize& size = wxDefaultSize,
50         long style = 0,
51         const wxString& name = wxPanelNameStr
52         );
53     ~vtk3DSurfaceSTLWidget();
54
55 //EED Borrame
56 //    void OnLeftDClick( wxMouseEvent& event );
57
58     void ConfigureVTK( );
59
60     bool IntersectPlaneWithLine( double* p, double* x1, double* x2, double* x3, double* x4, double* x5 );
61     bool FindCubePointsFromPoints( double* pO, double* pF, double* pickPoint, double* cameraPos );
62     bool GetPointAndNormalIntersection( double* p, double* n, double* pO, double* pF );
63     
64     void ShowMARACASData( marInterface* mar );
65         void ShowMARACASDataAndAxe( marInterface* mar );
66     void SetSurfaceColor(float red, float green, float blue );
67     void SetSurfaceVisibility( bool visible );
68     void SetSTLSurfaceVisibility( bool intvisible , bool extvisible);
69     void SetSurfaceIsoValue( int isoval );
70     void SetSurfaceOpacity( int opaval );
71
72     void GetSphereCenter( double center[3] );
73     void SetAxis( vtkPolyData *axis );
74     void RemoveAxis( );
75
76     void ConstructVessel();
77     void SetCuttingMode( bool mode );
78     void ExportSurfaceAsSTL( const char* fileprefix );
79
80     ///\todo remove
81     vtkImageData        *_marImageData;
82     vtkPolyData         *_marPolyData;
83
84     void SetSTLThresholdRatio(double ratio);
85     float GetSTLThreshold();
86     vtkGetMacro(InitialSphere, int);
87     
88 protected:
89
90     void SetInitialPoint( double* pickPoint, double* cameraPos );
91     void SetInitialPoint( double* point );
92     vtkPolyData* ConvertMarAxisToPolyData();
93     
94     vtkImagePolyDataSeedConnectivity *_psc;
95
96     marInterface                *_mar;
97     vtkRenderer                 *_pRenderer;
98     vtkRenderWindow             *_pRenderWindow;
99     vtkOutlineFilter    *_outLine;
100     vtkPolyDataMapper   *_outMapper;
101     vtkActor                    *_outActor;
102     vtkMarchingCubes    *_mCubes;
103     vtkPolyDataMapper   *_surfMapper;
104     vtkActor                    *_surfActor;
105
106     vtkPolyData                 *_centralLine;
107     vtkPolyDataMapper   *_centralLineMapper;
108     vtkActor                    *_centralLineActor;
109
110     vtkSphereSource             *_spheres[ 4 ];
111     vtkPolyDataMapper   *_spheresMapper[ 4 ];
112     vtkActor                    *_spheresActor[ 4 ];
113
114     vtkPolyDataMapper   *_axesMapper;
115     vtkActor                    *_axesActor;
116
117     vtkActor                    *_actorVessel;
118     vtkActor                    *_actorExternalVessel;
119     //We should keep internal and external as different mesh to be able
120     //to save them in difference files at the end of process:
121     vtkPolyData                 *_stlInternalVessel;
122     vtkPolyData                 *_stlExternalVessel;
123     vtkInteractorStyleCutter *_iasc;
124
125 private:
126
127     int _width;
128     int _height;
129     int _depth;
130     int InitialSphere;
131
132     DECLARE_EVENT_TABLE( );
133
134 };
135
136 #endif //__VTK3DSURFACESTLWIDGET__