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