]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/OrthoNormalBase.h
...
[cpPlugins.git] / lib / cpPlugins / OrthoNormalBase.h
1 #ifndef __CPPLUGINS__ORTHONORMALBASE__H__
2 #define __CPPLUGINS__ORTHONORMALBASE__H__
3
4 #include <cpPlugins/DataObject.h>
5 #include <vtkActor.h>
6 #include <vtkAxes.h>
7 #include <vtkPolyDataMapper.h>
8 #include <vtkActor.h>
9 #include <vtkCellArray.h>
10 #include <vtkPoints.h>
11 #include <vtkPolyData.h>
12 #include <vtkPolyDataMapper.h>
13
14 #include <vtkSmartPointer.h>
15
16 namespace cpPlugins
17 {
18   /**
19    */
20   class cpPlugins_EXPORT OrthoNormalBase
21     : public DataObject
22   {
23   public:
24     typedef OrthoNormalBase                 Self;
25     typedef DataObject                      Superclass;
26     typedef itk::SmartPointer< Self >       Pointer;
27     typedef itk::SmartPointer< const Self > ConstPointer;
28
29     struct BaseActor
30     {
31       vtkSmartPointer< vtkPolyData >       Axes;
32       vtkSmartPointer< vtkPolyDataMapper > Mapper;
33       vtkSmartPointer< vtkActor >          Actor;
34
35       void SetBase( vtkMatrix4x4* matrix )
36         {
37           this->Axes = vtkSmartPointer< vtkPolyData >::New( );
38           this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
39           this->Actor = vtkSmartPointer< vtkActor >::New( );
40
41           vtkSmartPointer< vtkPoints > points = vtkSmartPointer< vtkPoints >::New( );
42           points->InsertNextPoint( 0, 0, 0 );
43           points->InsertNextPoint( 1, 0, 0 );
44           points->InsertNextPoint( 0, 1, 0 );
45           points->InsertNextPoint( 0, 0, 1 );
46           vtkSmartPointer< vtkCellArray > lines = vtkSmartPointer< vtkCellArray >::New( );
47           lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 1 );
48           lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 2 );
49           lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 3 );
50           this->Axes->SetPoints( points );
51           this->Axes->SetLines( lines );
52
53           this->Mapper->SetInputData( this->Axes );
54           this->Actor->SetMapper( this->Mapper );
55         }
56     };
57
58   public:
59     itkNewMacro( Self );
60     itkTypeMacro( OrthoNormalBase, DataObject );
61     cpPlugins_Id_Macro( OrthoNormalBase, Object );
62
63   public:
64     virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE;
65     virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE;
66
67     template< class _TMatrix >
68       inline void SetITK( const _TMatrix& m );
69
70     template< class _TMatrix, class _TVector >
71       inline void SetITK( const _TMatrix& m, const _TVector& v );
72
73   protected:
74     OrthoNormalBase( );
75     virtual ~OrthoNormalBase( );
76
77     virtual void _CreateVTKActor( ) const ITK_OVERRIDE;
78
79   private:
80     // Purposely not implemented
81     OrthoNormalBase( const Self& );
82     Self& operator=( const Self& );
83
84   protected:
85     mutable BaseActor m_BaseActor;
86   };
87
88 } // ecapseman
89
90 #include <cpPlugins/OrthoNormalBase.hxx>
91
92 #endif // __CPPLUGINS__ORTHONORMALBASE__H__
93
94 // eof - $RCSfile$