]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/OrthoNormalBase.cxx
...
[cpPlugins.git] / lib / cpPlugins / OrthoNormalBase.cxx
1 #include <cpPlugins/OrthoNormalBase.h>
2
3 #include <vtkMatrix4x4.h>
4
5 // -------------------------------------------------------------------------
6 void cpPlugins::OrthoNormalBase::
7 SetITK( itk::LightObject* o )
8 {
9   // Do nothing since itk::Matrix does not belong to LightObject hierarchy.
10 }
11
12 // -------------------------------------------------------------------------
13 void cpPlugins::OrthoNormalBase::
14 SetVTK( vtkObjectBase* o )
15 {
16   auto matrix = dynamic_cast< vtkMatrix4x4* >( o );
17   if( matrix !=  NULL )
18     this->Superclass::SetVTK( matrix );
19 }
20
21 // -------------------------------------------------------------------------
22 cpPlugins::OrthoNormalBase::
23 OrthoNormalBase( )
24   : Superclass( )
25 {
26 }
27
28 // -------------------------------------------------------------------------
29 cpPlugins::OrthoNormalBase::
30 ~OrthoNormalBase( )
31 {
32 }
33
34 // -------------------------------------------------------------------------
35 void cpPlugins::OrthoNormalBase::
36 _CreateVTKActor( ) const
37 {
38   auto matrix =
39     const_cast< vtkMatrix4x4* >( this->GetVTK< vtkMatrix4x4 >( ) );
40   if( matrix != NULL )
41   {
42     this->m_BaseActor.SetBase( matrix );
43     this->m_Actor = this->m_BaseActor.Actor.GetPointer( );
44     /* TODO
45        double o[ 3 ], x[ 3 ], y[ 3 ], z[ 3 ];
46
47        o[ 0 ] = matrix->GetElement( 0, 3 );
48        o[ 1 ] = matrix->GetElement( 1, 3 );
49        o[ 2 ] = matrix->GetElement( 2, 3 );
50
51        x[ 0 ] = matrix->GetElement( 0, 0 ) + o[ 0 ];
52        x[ 1 ] = matrix->GetElement( 1, 0 ) + o[ 1 ];
53        x[ 2 ] = matrix->GetElement( 2, 0 ) + o[ 2 ];
54
55        y[ 0 ] = matrix->GetElement( 0, 1 ) + o[ 0 ];
56        y[ 1 ] = matrix->GetElement( 1, 1 ) + o[ 1 ];
57        y[ 2 ] = matrix->GetElement( 2, 1 ) + o[ 2 ];
58
59        z[ 0 ] = matrix->GetElement( 0, 2 ) + o[ 0 ];
60        z[ 1 ] = matrix->GetElement( 1, 2 ) + o[ 1 ];
61        z[ 2 ] = matrix->GetElement( 2, 2 ) + o[ 2 ];
62
63        static vtkPoints* points = vtkPoints::New( );
64        points->InsertNextPoint( o );
65        points->InsertNextPoint( x );
66        points->InsertNextPoint( y );
67        points->InsertNextPoint( z );
68
69        static vtkCellArray* lines = vtkCellArray::New( );
70        lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 1 );
71        lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 2 );
72        lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 3 );
73
74        static vtkPolyData* base = vtkPolyData::New( );
75        base->SetPoints( points );
76        base->SetLines( lines );
77
78        static vtkPolyDataMapper* mapper = vtkPolyDataMapper::New( );
79        mapper->SetInputData( base );
80
81        static vtkActor* actor = vtkActor::New( );
82        actor->SetMapper( mapper );
83        this->m_Actor = actor;
84     */
85     /*
86       this->m_AxesActor = vtkSmartPointer< vtkAxesActor >::New( );
87       this->m_AxesActor->SetUserMatrix( matrix );
88       this->m_Actor = this->m_AxesActor.GetPointer( );
89     */
90
91   } // fi
92 }
93
94 // eof - $RCSfile$