1 #include <cpPlugins/OrthoNormalBase.h>
3 #include <vtkMatrix4x4.h>
5 // -------------------------------------------------------------------------
6 void cpPlugins::OrthoNormalBase::
7 SetITK( itk::LightObject* o )
9 // Do nothing since itk::Matrix does not belong to LightObject hierarchy.
12 // -------------------------------------------------------------------------
13 void cpPlugins::OrthoNormalBase::
14 SetVTK( vtkObjectBase* o )
16 auto matrix = dynamic_cast< vtkMatrix4x4* >( o );
18 this->Superclass::SetVTK( matrix );
21 // -------------------------------------------------------------------------
22 cpPlugins::OrthoNormalBase::
28 // -------------------------------------------------------------------------
29 cpPlugins::OrthoNormalBase::
34 // -------------------------------------------------------------------------
35 void cpPlugins::OrthoNormalBase::
36 _CreateVTKActor( ) const
39 const_cast< vtkMatrix4x4* >( this->GetVTK< vtkMatrix4x4 >( ) );
42 this->m_BaseActor.SetBase( matrix );
43 this->m_Actor = this->m_BaseActor.Actor.GetPointer( );
45 double o[ 3 ], x[ 3 ], y[ 3 ], z[ 3 ];
47 o[ 0 ] = matrix->GetElement( 0, 3 );
48 o[ 1 ] = matrix->GetElement( 1, 3 );
49 o[ 2 ] = matrix->GetElement( 2, 3 );
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 ];
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 ];
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 ];
63 static vtkPoints* points = vtkPoints::New( );
64 points->InsertNextPoint( o );
65 points->InsertNextPoint( x );
66 points->InsertNextPoint( y );
67 points->InsertNextPoint( z );
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 );
74 static vtkPolyData* base = vtkPolyData::New( );
75 base->SetPoints( points );
76 base->SetLines( lines );
78 static vtkPolyDataMapper* mapper = vtkPolyDataMapper::New( );
79 mapper->SetInputData( base );
81 static vtkActor* actor = vtkActor::New( );
82 actor->SetMapper( mapper );
83 this->m_Actor = actor;
86 this->m_AxesActor = vtkSmartPointer< vtkAxesActor >::New( );
87 this->m_AxesActor->SetUserMatrix( matrix );
88 this->m_Actor = this->m_AxesActor.GetPointer( );