#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
+// -------------------------------------------------------------------------
+cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle*
+cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle::
+New( )
+{
+ return( new _3DInteractorStyle( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::_3DInteractorStyle::
+OnKeyPress( )
+{
+ vtkRenderWindowInteractor* i = this->Interactor;
+ std::string key = i->GetKeySym( );
+ if( key == "r" || key == "R" )
+ {
+ this->CurrentRenderer->ResetCamera( );
+ i->Render( );
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
cpExtensions::QT::SimpleMPRWidget::
SimpleMPRWidget( QWidget* parent )
this->m_VTK[ 1 ] = this->m_UI->VTK_Y;
this->m_VTK[ 2 ] = this->m_UI->VTK_Z;
this->m_VTK[ 3 ] = this->m_UI->VTK_3D;
-
for( unsigned int i = 0; i < 4; ++i )
{
this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
AddRenderer( this->m_Renderers[ i ] );
} // rof
+ vtkSmartPointer< _3DInteractorStyle > style =
+ vtkSmartPointer< _3DInteractorStyle >::New( );
+ this->m_VTK[ 3 ]->GetRenderWindow( )->
+ GetInteractor( )->SetInteractorStyle( style );
+ style->SetCurrentRenderer( this->m_Renderers[ 3 ] );
// Connect slots
QObject::connect(
{
if( actor != NULL )
{
+ std::cout << name << " " << actor << std::endl;
+
this->m_Renderers[ 3 ]->AddViewProp( actor );
this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
this->m_NamedActors[ name ].insert( actor );
+ std::cout << "Size: " << this->m_NamedActors.size( ) << " " << this->m_NamedActors[ name ].size( ) << std::endl;
+
+
+ double bounds[ 6 ];
+ this->m_Renderers[ 3 ]->ComputeVisiblePropBounds( bounds );
+ std::cout
+ << bounds[ 0 ] << " " << bounds[ 1 ] << " "
+ << bounds[ 2 ] << " " << bounds[ 3 ] << " "
+ << bounds[ 4 ] << " " << bounds[ 5 ] << std::endl;
} // fi
}
auto ia = dynamic_cast< vtkImageActor* >( actor );
if( ia == NULL )
{
- auto ma = dynamic_cast< vtkActor* >( actor );
+ auto ma = dynamic_cast< vtkProp3D* >( actor );
if( ma != NULL )
this->AddMeshActor( ma, name );
}
#include <map>
#include <set>
#include <QWidget>
+#include <vtkInteractorStyleTrackballCamera.h>
+#include <vtkRenderWindowInteractor.h>
#include <vtkProp.h>
#include <vtkSmartPointer.h>
#include <cpExtensions/Visualization/ImageSliceActors.h>
typedef std::map< std::string, TActors > TNamedActors;
typedef cpExtensions::Visualization::ImageSliceActors TSliceActors;
+ protected:
+ /**
+ */
+ class _3DInteractorStyle
+ : public vtkInteractorStyleTrackballCamera
+ {
+ public:
+ vtkTypeMacro(
+ _3DInteractorStyle, vtkInteractorStyleTrackballCamera
+ );
+
+ public:
+ static _3DInteractorStyle* New( );
+
+ virtual void OnChar( ) { }
+ virtual void OnKeyDown( ) { }
+ virtual void OnKeyUp( ) { }
+ virtual void OnKeyRelease( ) { }
+ virtual void OnKeyPress( );
+ };
+
public:
explicit SimpleMPRWidget( QWidget* parent = 0 );
virtual ~SimpleMPRWidget( );
vtkProp* cpPlugins::DataObject::
GetVTKActor( )
{
- if( this->m_Actor == NULL )
+ if( this->m_Actor.GetPointer( ) == NULL )
this->_CreateVTKActor( );
- return( this->m_Actor );
+ return( this->m_Actor.GetPointer( ) );
}
// -------------------------------------------------------------------------
const vtkProp* cpPlugins::DataObject::
GetVTKActor( ) const
{
- if( this->m_Actor == NULL )
+ if( this->m_Actor.GetPointer( ) == NULL )
this->_CreateVTKActor( );
- return( this->m_Actor );
+ return( this->m_Actor.GetPointer( ) );
}
// -------------------------------------------------------------------------
cpPlugins::DataObject::
DataObject( )
: Superclass( ),
- m_Source( NULL ),
- m_Actor( NULL )
+ m_Source( NULL )
+ /* TODO
+ ,
+ m_Actor( NULL )
+ */
{
}
cpPlugins::DataObject::
~DataObject( )
{
- if( this->m_Actor != NULL )
- this->m_Actor->Delete( );
+ /* TODO
+ if( this->m_Actor != NULL )
+ this->m_Actor->Delete( );
+ */
}
// -------------------------------------------------------------------------
#define __CPPLUGINS__DATAOBJECT__H__
#include <cpPlugins/Object.h>
+#include <vtkProp.h>
+#include <vtkSmartPointer.h>
// Some forward declarations
-class vtkProp;
+// TODO: class vtkProp;
namespace cpPlugins
{
protected:
ProcessObject* m_Source;
- mutable vtkProp* m_Actor;
+ // TODO: mutable vtkProp* m_Actor;
+ mutable vtkSmartPointer< vtkProp > m_Actor;
};
} // ecapseman
#include <itkTriangleCell.h>
#include <itkPolygonCell.h>
-#include <vtkActor.h>
-#include <vtkPolyDataNormals.h>
-#include <vtkPolyData.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkQuadricLODActor.h>
-#include <vtkStripper.h>
-
#define cpPlugins_Mesh_MAX_POLYS 65535
+// -------------------------------------------------------------------------
+void cpPlugins::Mesh::MeshActor::
+SetMesh( vtkPolyData* mesh )
+{
+ this->Normals = NULL;
+ this->Stripper = NULL;
+ this->Mapper = NULL;
+ this->LODActor = NULL;
+ this->Actor = NULL;
+ if( mesh != NULL )
+ {
+ unsigned long nPolys = mesh->GetNumberOfPolys( );
+ if( nPolys >= cpPlugins_Mesh_MAX_POLYS )
+ {
+ this->Normals = vtkSmartPointer< vtkPolyDataNormals >::New( );
+ this->Stripper = vtkSmartPointer< vtkStripper >::New( );
+ this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->LODActor = vtkSmartPointer< vtkQuadricLODActor >::New( );
+
+ double r[ 2 ];
+ mesh->GetScalarRange( r );
+
+ this->Normals->SetInputData( mesh );
+ this->Normals->SetFeatureAngle( 60.0 );
+ this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) );
+ this->Mapper->SetInputConnection( this->Stripper->GetOutputPort( ) );
+ this->Mapper->UseLookupTableScalarRangeOff( );
+ this->Mapper->SetScalarRange( r[ 0 ], r[ 1 ] );
+ this->LODActor->SetMapper( this->Mapper );
+ this->LODActor->DeferLODConstructionOff( );
+ }
+ else
+ {
+ this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->Actor = vtkSmartPointer< vtkActor >::New( );
+ this->Mapper->SetInputData( mesh );
+ this->Actor->SetMapper( this->Mapper );
+
+ } // fi
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
void cpPlugins::Mesh::
SetITK( itk::LightObject* o )
void cpPlugins::Mesh::
_CreateVTKActor( ) const
{
+ this->m_MeshActor.SetMesh(
+ const_cast< vtkPolyData* >( this->GetVTK< vtkPolyData >( ) )
+ );
+ if( this->m_MeshActor.LODActor.GetPointer( ) != NULL )
+ this->m_Actor = this->m_MeshActor.LODActor.GetPointer( );
+ else if( this->m_MeshActor.Actor.GetPointer( ) != NULL )
+ this->m_Actor = this->m_MeshActor.Actor.GetPointer( );
+ else
+ this->m_Actor = NULL;
+
+ /* TODO
vtkPolyData* mesh =
const_cast< vtkPolyData* >( this->GetVTK< vtkPolyData >( ) );
if( mesh != NULL )
} // fi
} // fi
+ */
}
// eof - $RCSfile$
#include <cpPlugins/DataObject.h>
-// Some forward declarations
-class vtkObject;
+#include <vtkActor.h>
+#include <vtkPolyDataNormals.h>
+#include <vtkPolyData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkQuadricLODActor.h>
+#include <vtkStripper.h>
+#include <vtkSmartPointer.h>
namespace cpPlugins
{
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
+ struct MeshActor
+ {
+ vtkSmartPointer< vtkPolyDataNormals > Normals;
+ vtkSmartPointer< vtkStripper > Stripper;
+ vtkSmartPointer< vtkPolyDataMapper > Mapper;
+ vtkSmartPointer< vtkQuadricLODActor > LODActor;
+ vtkSmartPointer< vtkActor > Actor;
+
+ void SetMesh( vtkPolyData* mesh );
+ };
+
public:
itkNewMacro( Self );
itkTypeMacro( Mesh, DataObject );
// Purposely not implemented
Mesh( const Self& );
Self& operator=( const Self& );
+
+ protected:
+ mutable MeshActor m_MeshActor;
};
} // ecapseman
#include <cpPlugins/OrthoNormalBase.h>
-#include <vtkAxesActor.h>
#include <vtkMatrix4x4.h>
// -------------------------------------------------------------------------
{
auto matrix =
const_cast< vtkMatrix4x4* >( this->GetVTK< vtkMatrix4x4 >( ) );
- if( matrix != NULL )
+ if( matrix != NULL )
{
- auto actor = vtkAxesActor::New( );
- actor->SetUserMatrix( matrix );
- this->m_Actor = actor;
+ this->m_BaseActor.SetBase( matrix );
+ this->m_Actor = this->m_BaseActor.Actor.GetPointer( );
+ /* TODO
+ double o[ 3 ], x[ 3 ], y[ 3 ], z[ 3 ];
+
+ o[ 0 ] = matrix->GetElement( 0, 3 );
+ o[ 1 ] = matrix->GetElement( 1, 3 );
+ o[ 2 ] = matrix->GetElement( 2, 3 );
+
+ x[ 0 ] = matrix->GetElement( 0, 0 ) + o[ 0 ];
+ x[ 1 ] = matrix->GetElement( 1, 0 ) + o[ 1 ];
+ x[ 2 ] = matrix->GetElement( 2, 0 ) + o[ 2 ];
+
+ y[ 0 ] = matrix->GetElement( 0, 1 ) + o[ 0 ];
+ y[ 1 ] = matrix->GetElement( 1, 1 ) + o[ 1 ];
+ y[ 2 ] = matrix->GetElement( 2, 1 ) + o[ 2 ];
+
+ z[ 0 ] = matrix->GetElement( 0, 2 ) + o[ 0 ];
+ z[ 1 ] = matrix->GetElement( 1, 2 ) + o[ 1 ];
+ z[ 2 ] = matrix->GetElement( 2, 2 ) + o[ 2 ];
+
+ static vtkPoints* points = vtkPoints::New( );
+ points->InsertNextPoint( o );
+ points->InsertNextPoint( x );
+ points->InsertNextPoint( y );
+ points->InsertNextPoint( z );
+
+ static vtkCellArray* lines = vtkCellArray::New( );
+ lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 1 );
+ lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 2 );
+ lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 3 );
+
+ static vtkPolyData* base = vtkPolyData::New( );
+ base->SetPoints( points );
+ base->SetLines( lines );
+
+ static vtkPolyDataMapper* mapper = vtkPolyDataMapper::New( );
+ mapper->SetInputData( base );
+
+ static vtkActor* actor = vtkActor::New( );
+ actor->SetMapper( mapper );
+ this->m_Actor = actor;
+ */
+ /*
+ this->m_AxesActor = vtkSmartPointer< vtkAxesActor >::New( );
+ this->m_AxesActor->SetUserMatrix( matrix );
+ this->m_Actor = this->m_AxesActor.GetPointer( );
+ */
} // fi
}
#define __CPPLUGINS__ORTHONORMALBASE__H__
#include <cpPlugins/DataObject.h>
+#include <vtkActor.h>
+#include <vtkAxes.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkActor.h>
+#include <vtkCellArray.h>
+#include <vtkPoints.h>
+#include <vtkPolyData.h>
+#include <vtkPolyDataMapper.h>
+
+#include <vtkSmartPointer.h>
namespace cpPlugins
{
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
+ struct BaseActor
+ {
+ vtkSmartPointer< vtkPolyData > Axes;
+ vtkSmartPointer< vtkPolyDataMapper > Mapper;
+ vtkSmartPointer< vtkActor > Actor;
+
+ void SetBase( vtkMatrix4x4* matrix )
+ {
+ this->Axes = vtkSmartPointer< vtkPolyData >::New( );
+ this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->Actor = vtkSmartPointer< vtkActor >::New( );
+
+ vtkSmartPointer< vtkPoints > points = vtkSmartPointer< vtkPoints >::New( );
+ points->InsertNextPoint( 0, 0, 0 );
+ points->InsertNextPoint( 1, 0, 0 );
+ points->InsertNextPoint( 0, 1, 0 );
+ points->InsertNextPoint( 0, 0, 1 );
+ vtkSmartPointer< vtkCellArray > lines = vtkSmartPointer< vtkCellArray >::New( );
+ lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 1 );
+ lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 2 );
+ lines->InsertNextCell( 2 ); lines->InsertCellPoint( 0 ); lines->InsertCellPoint( 3 );
+ this->Axes->SetPoints( points );
+ this->Axes->SetLines( lines );
+
+ this->Mapper->SetInputData( this->Axes );
+ this->Actor->SetMapper( this->Mapper );
+ }
+ };
+
public:
itkNewMacro( Self );
itkTypeMacro( OrthoNormalBase, DataObject );
template< class _TMatrix >
inline void SetITK( const _TMatrix& m );
+ template< class _TMatrix, class _TVector >
+ inline void SetITK( const _TMatrix& m, const _TVector& v );
+
protected:
OrthoNormalBase( );
virtual ~OrthoNormalBase( );
// Purposely not implemented
OrthoNormalBase( const Self& );
Self& operator=( const Self& );
+
+ protected:
+ mutable BaseActor m_BaseActor;
};
} // ecapseman
this->m_VTKObject = matrix;
}
+// -------------------------------------------------------------------------
+template< class _TMatrix, class _TVector >
+void cpPlugins::OrthoNormalBase::
+SetITK( const _TMatrix& m, const _TVector& v )
+{
+ vtkMatrix4x4* matrix = vtkMatrix4x4::New( );
+ matrix->Identity( );
+ for( unsigned int i = 0; i < 3; ++i )
+ if( i < _TMatrix::RowDimensions )
+ for( unsigned int j = 0; j < 3; ++j )
+ if( j < _TMatrix::ColumnDimensions )
+ matrix->SetElement( i, j, m[ i ][ j ] );
+ for( unsigned int i = 0; i < 3; ++i )
+ if( i < _TVector::Dimension )
+ matrix->SetElement( i, 3, v[ i ] );
+ this->m_VTKObject = matrix;
+}
+
#endif // __CPPLUGINS__ORTHONORMALBASE__HXX__
// eof - $RCSfile$
return( NULL );
}
-// -------------------------------------------------------------------------
-cpPlugins::
-DataObject* cpPlugins::ProcessObject::
-GetOutput( const std::string& id )
-{
- auto i = this->m_Outputs.find( id );
- if( i != this->m_Outputs.end( ) )
- return( dynamic_cast< DataObject* >( i->second.GetPointer( ) ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::
-DataObject* cpPlugins::ProcessObject::
-GetOutput( const std::string& id ) const
-{
- auto i = this->m_Outputs.find( id );
- if( i != this->m_Outputs.end( ) )
- return( dynamic_cast< const DataObject* >( i->second.GetPointer( ) ) );
- else
- return( NULL );
-}
-
// -------------------------------------------------------------------------
bool cpPlugins::ProcessObject::
SetInputPort( const std::string& id, const OutputPort& port )
DataObject* GetInput( const std::string& id );
const DataObject* GetInput( const std::string& id ) const;
- DataObject* GetOutput( const std::string& id );
- const DataObject* GetOutput( const std::string& id ) const;
+
+ template< class _TType = DataObject >
+ inline _TType* GetOutput( const std::string& id );
+
+ template< class _TType = DataObject >
+ inline const _TType* GetOutput( const std::string& id ) const;
template< class _TType >
- _TType* GetInputData( const std::string& name );
+ inline _TType* GetInputData( const std::string& name );
template< class _TType >
- _TType* GetOutputData( const std::string& name );
+ inline _TType* GetOutputData( const std::string& name );
bool SetInputPort( const std::string& id, const OutputPort& port );
#ifndef __CPPLUGINS__PROCESSOBJECT__HXX__
#define __CPPLUGINS__PROCESSOBJECT__HXX__
+// -------------------------------------------------------------------------
+template< class _TType >
+_TType* cpPlugins::ProcessObject::
+GetOutput( const std::string& id )
+{
+ auto i = this->m_Outputs.find( id );
+ if( i != this->m_Outputs.end( ) )
+ return( dynamic_cast< _TType* >( i->second.GetPointer( ) ) );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+template< class _TType >
+const _TType* cpPlugins::ProcessObject::
+GetOutput( const std::string& id ) const
+{
+ auto i = this->m_Outputs.find( id );
+ if( i != this->m_Outputs.end( ) )
+ return( dynamic_cast< const _TType* >( i->second.GetPointer( ) ) );
+ else
+ return( NULL );
+}
+
// -------------------------------------------------------------------------
template< class _TType >
_TType* cpPlugins::ProcessObject::