example_LoadPlugins
example_ReadWriteImage
example_ReadImageSeriesWriteImage
+ example_ReadQuadEdgeMesh
example_ReadQuadEdgeMeshWithoutPlugins
+ example_RenderQuadEdgeMesh
+ example_RenderQuadEdgeMeshWithoutPlugins
)
FOREACH(prog ${EXAMPLES_PROGRAMS})
--- /dev/null
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+int main( int argc, char* argv[] )
+{
+ if( argc < 5 )
+ {
+ std::cerr
+ << "Usage: " << argv[ 0 ]
+ << " plugins_file"
+ << " input_mesh"
+ << " dimensions pixel_type" << std::endl;
+ return( 1 );
+
+ } // fi
+ std::string plugins_file = argv[ 1 ];
+ std::string input_mesh_file = argv[ 2 ];
+ std::string dimensions = argv[ 3 ];
+ std::string pixel_type = argv[ 4 ];
+
+ // Create interface
+ typedef cpPlugins::Interface::Interface TInterface;
+ typedef TInterface::TClasses TClasses;
+
+ TInterface plugins;
+ plugins.Load( plugins_file );
+
+ // Create objects
+ typedef cpPlugins::Interface::ProcessObject TProcessObject;
+ typedef TProcessObject::TParameters TParameters;
+ cpPlugins::Interface::ProcessObject* reader;
+
+ reader =
+ dynamic_cast< TProcessObject* >(
+ plugins.CreateObject( "cpPlugins::Plugins::MeshReader" )
+ );
+ if( reader == NULL )
+ {
+ std::cerr << "No suitable reader found in plugins." << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Configure reader
+ TParameters reader_params = reader->GetDefaultParameters( );
+ reader_params[ "FileName" ].second = input_mesh_file;
+ reader_params[ "PixelType" ].second = pixel_type;
+ reader_params[ "MeshDimension" ].second = dimensions;
+ reader->SetParameters( reader_params );
+
+ // Execute reader
+ std::string msg = reader->Update( );
+
+ if( msg != "" )
+ std::cerr << "ERROR: " << msg << std::endl;
+
+ // Free memory
+ delete reader;
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Mesh.h>
+
+#include <vtkActor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkProperty.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+int main( int argc, char* argv[] )
+{
+ if( argc < 5 )
+ {
+ std::cerr
+ << "Usage: " << argv[ 0 ]
+ << " plugins_file"
+ << " input_mesh"
+ << " dimensions pixel_type" << std::endl;
+ return( 1 );
+
+ } // fi
+ std::string plugins_file = argv[ 1 ];
+ std::string input_mesh_file = argv[ 2 ];
+ std::string dimensions = argv[ 3 ];
+ std::string pixel_type = argv[ 4 ];
+
+ // Create interface
+ typedef cpPlugins::Interface::Interface TInterface;
+ typedef TInterface::TClasses TClasses;
+
+ TInterface plugins;
+ plugins.Load( plugins_file );
+
+ // Create objects
+ typedef cpPlugins::Interface::ProcessObject TProcessObject;
+ typedef TProcessObject::TParameters TParameters;
+ cpPlugins::Interface::ProcessObject* reader;
+
+ reader =
+ dynamic_cast< TProcessObject* >(
+ plugins.CreateObject( "cpPlugins::Plugins::MeshReader" )
+ );
+ if( reader == NULL )
+ {
+ std::cerr << "No suitable reader found in plugins." << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Configure reader
+ TParameters reader_params = reader->GetDefaultParameters( );
+ reader_params[ "FileName" ].second = input_mesh_file;
+ reader_params[ "PixelType" ].second = pixel_type;
+ reader_params[ "MeshDimension" ].second = dimensions;
+ reader->SetParameters( reader_params );
+
+ // Execute reader
+ std::string msg = reader->Update( );
+
+ if( msg != "" )
+ std::cerr << "ERROR: " << msg << std::endl;
+
+ // Create actor
+ vtkSmartPointer< vtkActor > actor =
+ vtkSmartPointer< vtkActor >::New( );
+ actor->SetMapper(
+ dynamic_cast< cpPlugins::Interface::Mesh* >( reader->GetOutput( 0 ) )->
+ GetVTKMapper( )
+ );
+ actor->GetProperty( )->SetColor( 1, 1, 0 );
+ actor->GetProperty( )->SetOpacity( 0.5 );
+
+ // Configure visualization objects
+ vtkSmartPointer< vtkRenderer > renderer =
+ vtkSmartPointer< vtkRenderer >::New( );
+ renderer->SetBackground( 0.1, 0.3, 0.5 );
+
+ vtkSmartPointer< vtkRenderWindow > window =
+ vtkSmartPointer< vtkRenderWindow >::New( );
+ window->AddRenderer( renderer );
+ window->SetSize( 800, 800 );
+
+ // Set up the interaction
+ vtkSmartPointer< vtkRenderWindowInteractor > interactor =
+ vtkSmartPointer< vtkRenderWindowInteractor >::New( );
+ window->SetInteractor( interactor );
+
+ // Associate actors
+ renderer->AddActor( actor );
+
+ // Begin interaction
+ window->Render( );
+ interactor->Start( );
+
+ // Free memory
+ delete reader;
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <cpPlugins/Extensions/QuadEdgeMesh.h>
+#include <cpPlugins/Extensions/MeshReader.h>
+#include <cpPlugins/Extensions/OpenGLMeshMapper.h>
+
+#include <vtkActor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkProperty.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+// -------------------------------------------------------------------------
+const unsigned int Dimension = 3;
+typedef float TScalar;
+typedef cpPlugins::Extensions::QuadEdgeMesh< TScalar, Dimension > TMesh;
+typedef cpPlugins::Extensions::OpenGLMeshMapper< TMesh > TMeshMapper;
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ if( argc < 2 )
+ {
+ std::cerr
+ << "Usage: " << argv[ 0 ]
+ << " input_mesh"
+ << std::endl;
+ return( 1 );
+
+ } // fi
+
+ typedef cpPlugins::Extensions::MeshReader< TMesh > TReader;
+ TReader::Pointer reader = TReader::New( );
+ reader->SetFileName( argv[ 1 ] );
+ reader->Update( );
+
+ // Map mesh
+ vtkSmartPointer< TMeshMapper > mapper =
+ vtkSmartPointer< TMeshMapper >::New( );
+ mapper->SetInputData( reader->GetOutput( ) );
+
+ // Create actor
+ vtkSmartPointer< vtkActor > actor =
+ vtkSmartPointer< vtkActor >::New( );
+ actor->SetMapper( mapper );
+ actor->GetProperty( )->SetColor( 1, 1, 0 );
+ actor->GetProperty( )->SetOpacity( 0.5 );
+
+ // Configure visualization objects
+ vtkSmartPointer< vtkRenderer > renderer =
+ vtkSmartPointer< vtkRenderer >::New( );
+ renderer->SetBackground( 0.1, 0.3, 0.5 );
+
+ vtkSmartPointer< vtkRenderWindow > window =
+ vtkSmartPointer< vtkRenderWindow >::New( );
+ window->AddRenderer( renderer );
+ window->SetSize( 800, 800 );
+
+ // Set up the interaction
+ vtkSmartPointer< vtkRenderWindowInteractor > interactor =
+ vtkSmartPointer< vtkRenderWindowInteractor >::New( );
+ window->SetInteractor( interactor );
+
+ // Associate actors
+ renderer->AddActor( actor );
+
+ // Begin interaction
+ window->Render( );
+ interactor->Start( );
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
unsigned int indId = 0;
for( cIt = cells->Begin( ); cIt != cells->End( ); cIt++ )
{
- /* TODO
- const typename M::TQuadEdgeCell* cell =
- dynamic_cast< const typename M::TQuadEdgeCell* >( cIt.Value( ) );
- const typename M::TPrimalEdge* edge =
- cell->GetEntryPrimalEdge( );
- typename M::TPrimalEdge::ConstIterator iIt = edge->BeginLnext( );
- for( ; iIt != edge->EndLnext( ); ++iIt )
- this->Indices[ indId++ ] = ( *iIt )->GetOrigin( );
- */
+ const typename M::TQuadEdgeCell* cell =
+ dynamic_cast< const typename M::TQuadEdgeCell* >( cIt.Value( ) );
+ const typename M::TPrimalEdge* edge =
+ cell->GetEntryPrimalEdge( );
+ typename M::TPrimalEdge::ConstIterator iIt = edge->BeginLnext( );
+ for( ; iIt != edge->EndLnext( ); ++iIt )
+ this->Indices[ indId++ ] = ( *iIt )->GetOrigin( );
} // fi
M* mesh = dynamic_cast< M* >( this->Superclass::GetDataObject( ) );
_TMapper* mapper = _TMapper::New( );
mapper->SetInputData( mesh );
- mapper->Update( );
this->m_Mapper = mapper;
}
-// -------------------------------------------------------------------------
-/* TODO
-template< unsigned int D >
-void cpPlugins::Interface::Mesh::
-_ConnectToVTK_0( )
-{
- itk::DataObject* dobj = this->Superclass::GetDataObject( );
-
- cpPlugins_Interface_Mesh_Pixel( char, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( short, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( int, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( long, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( unsigned char, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( unsigned short, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( unsigned int, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( unsigned long, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( float, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_Pixel( double, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( char, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( short, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( int, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( long, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( unsigned char, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( unsigned short, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( unsigned int, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( unsigned long, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( float, D, dobj, _ConnectToVTK_1 );
- else cpPlugins_Interface_Mesh_RGB( double, D, dobj, _ConnectToVTK_1 );
-}
-
-// -------------------------------------------------------------------------
-template< class P, unsigned int D >
-void cpPlugins::Interface::Mesh::
-_ConnectToVTK_1( )
-{
- typedef itk::Mesh< P, D > _TMesh;
- typedef itk::MeshToVTKMeshFilter< _TMesh > _TFilter;
-
- _TMesh* img =
- dynamic_cast< _TMesh* >( this->Superclass::GetDataObject( ) );
- typename _TFilter::Pointer filter = _TFilter::New( );
- filter->SetInput( img );
- filter->Update( );
- this->m_VTKMeshData = filter->GetOutput( );
- this->m_Mesh2VTKMeshData = filter;
-}
-*/
-
// eof - $RCSfile$
#include <cpPlugins/Plugins/ImageSeriesReader.h>
#include <cpPlugins/Plugins/ImageWriter.h>
#include <cpPlugins/Plugins/MarchingCubes.h>
+#include <cpPlugins/Plugins/MeshReader.h>
/// TODO: doc
PLUMA_CONNECTOR
host.add( new cpPlugins::Plugins::ImageSeriesReaderProvider( ) );
host.add( new cpPlugins::Plugins::ImageWriterProvider( ) );
host.add( new cpPlugins::Plugins::MarchingCubesProvider( ) );
+ host.add( new cpPlugins::Plugins::MeshReaderProvider( ) );
return( true );
}
virtual std::string GetClassName( ) const;
protected:
-
virtual std::string _GenerateData( );
template< unsigned int D >
--- /dev/null
+#include <cpPlugins/Plugins/MeshReader.h>
+#include <cpPlugins/Interface/Mesh.h>
+
+#include <cpPlugins/Extensions/QuadEdgeMesh.h>
+#include <cpPlugins/Extensions/MeshReader.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::MeshReader::
+MeshReader( )
+ : Superclass( )
+{
+ this->SetNumberOfOutputs( 1 );
+ this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
+
+ this->m_DefaultParameters[ "FileName" ] =
+ TParameter( "string", "no_file_name" );
+ this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "float" );
+ this->m_DefaultParameters[ "MeshDimension" ] = TParameter( "int", "3" );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::MeshReader::
+~MeshReader( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::MeshReader::
+GetClassName( ) const
+{
+ return( "cpPlugins::Plugins::MeshReader" );
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::MeshReader::
+_GenerateData( )
+{
+ TParameters::const_iterator dIt;
+
+ // Get image dimension
+ dIt = this->m_Parameters.find( "MeshDimension" );
+ if( dIt == this->m_Parameters.end( ) )
+ dIt = this->m_DefaultParameters.find( "MeshDimension" );
+
+ std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh dimension not supported.";
+ if( dIt->second.second == "3" ) r = this->_GD0< 3 >( );
+
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int D >
+std::string cpPlugins::Plugins::MeshReader::
+_GD0( )
+{
+ TParameters::const_iterator tIt, cIt;
+
+ // Get image pixel type
+ tIt = this->m_Parameters.find( "PixelType" );
+ if( tIt == this->m_Parameters.end( ) )
+ tIt = this->m_DefaultParameters.find( "PixelType" );
+
+ std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh pixel type not supported";
+ if( tIt->second.second == "float" )
+ r = this->_GD1< float, D >( );
+ else if( tIt->second.second == "double" )
+ r = this->_GD1< double, D >( );
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class P, unsigned int D >
+std::string cpPlugins::Plugins::MeshReader::
+_GD1( )
+{
+ TParameters::const_iterator fIt;
+
+ // Get filename
+ fIt = this->m_Parameters.find( "FileName" );
+ if( fIt == this->m_Parameters.end( ) )
+ fIt = this->m_DefaultParameters.find( "FileName" );
+
+ typedef cpPlugins::Extensions::QuadEdgeMesh< P, D > _TMesh;
+ typedef cpPlugins::Extensions::MeshReader< _TMesh > _TReader;
+
+ _TReader* reader =
+ dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) );
+ if( reader == NULL )
+ {
+ this->m_Reader = _TReader::New( );
+ reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) );
+
+ } // fi
+ reader->SetFileName( fIt->second.second );
+ try
+ {
+ reader->Update( );
+ }
+ catch( itk::ExceptionObject& err )
+ {
+ return( err.GetDescription( ) );
+
+ } // yrt
+ this->_SetOutput( 0, reader->GetOutput( ) );
+
+ return( "" );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__PLUGINS__MESHREADER__H__
+#define __CPPLUGINS__PLUGINS__MESHREADER__H__
+
+#include <cpPlugins/Plugins/cpPlugins_Export.h>
+#include <cpPlugins/Interface/SourceObject.h>
+#include <itkProcessObject.h>
+
+namespace cpPlugins
+{
+ namespace Plugins
+ {
+ /**
+ */
+ class cpPlugins_EXPORT MeshReader
+ : public cpPlugins::Interface::SourceObject
+ {
+ public:
+ typedef MeshReader Self;
+ typedef cpPlugins::Interface::SourceObject Superclass;
+
+ typedef Superclass::TParameter TParameter;
+ typedef Superclass::TParameters TParameters;
+
+ public:
+ MeshReader( );
+ virtual ~MeshReader( );
+
+ virtual std::string GetClassName( ) const;
+
+ protected:
+ virtual std::string _GenerateData( );
+
+ template< unsigned int D >
+ std::string _GD0( );
+
+ template< class P, unsigned int D >
+ std::string _GD1( );
+
+ protected:
+ itk::ProcessObject::Pointer m_Reader;
+ };
+
+ // ---------------------------------------------------------------------
+ PLUMA_INHERIT_PROVIDER( MeshReader, cpPlugins::Interface::Object );
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__MESHREADER__H__
+
+// eof - $RCSfile$