]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Plugins/MarchingCubes.cxx
32040333bd7737760253e0facb5eded80ed9d81e
[cpPlugins.git] / lib / cpPlugins / Plugins / MarchingCubes.cxx
1 #include <cpPlugins/Plugins/MarchingCubes.h>
2 #include <cpPlugins/Interface/Image.h>
3 #include <cpPlugins/Interface/Mesh.h>
4
5 #include <itkImageFileReader.h>
6
7 #define ITK_MANUAL_INSTANTIATION
8 #include <itkImage.h>
9 #include <itkRGBPixel.h>
10
11 // -------------------------------------------------------------------------
12 cpPlugins::Plugins::MarchingCubes::
13 MarchingCubes( )
14   : Superclass( )
15 {
16   this->SetNumberOfInputs( 1 );
17   this->SetNumberOfOutputs( 1 );
18   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
19
20   /* TODO
21      this->m_DefaultParameters[ "FileName" ] =
22      TParameter( "string", "no_file_name" );
23      this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "uchar" );
24      this->m_DefaultParameters[ "ImageDimension" ] = TParameter( "int", "2" );
25      this->m_DefaultParameters[ "IsColorImage" ] = TParameter( "bool", "0" );
26   */
27 }
28
29 // -------------------------------------------------------------------------
30 cpPlugins::Plugins::MarchingCubes::
31 ~MarchingCubes( )
32 {
33 }
34
35 // -------------------------------------------------------------------------
36 std::string cpPlugins::Plugins::MarchingCubes::
37 GetClassName( ) const
38 {
39   return( "cpPlugins::Plugins::MarchingCubes" );
40 }
41
42 // -------------------------------------------------------------------------
43 std::string cpPlugins::Plugins::MarchingCubes::
44 _GenerateData( )
45 {
46   return( "" );
47   /* TODO
48      TParameters::const_iterator dIt;
49
50      // Get image dimension
51   dIt = this->m_Parameters.find( "ImageDimension" );
52   if( dIt == this->m_Parameters.end( ) )
53     dIt = this->m_DefaultParameters.find( "ImageDimension" );
54
55   std::string r = "cpPlugins::Plugins::MarchingCubes: itk::Image dimension not supported.";
56   if     ( dIt->second.second == "1" ) r = this->_GD0< 1 >( );
57   else if( dIt->second.second == "2" ) r = this->_GD0< 2 >( );
58   else if( dIt->second.second == "3" ) r = this->_GD0< 3 >( );
59   else if( dIt->second.second == "4" ) r = this->_GD0< 4 >( );
60
61   return( r );
62   */
63 }
64
65 // -------------------------------------------------------------------------
66 template< unsigned int D >
67 std::string cpPlugins::Plugins::MarchingCubes::
68 _GD0( )
69 {
70   return( "" );
71   /* TODO
72   TParameters::const_iterator tIt, cIt;
73
74   // Get image pixel type
75   tIt = this->m_Parameters.find( "PixelType" );
76   if( tIt == this->m_Parameters.end( ) )
77     tIt = this->m_DefaultParameters.find( "PixelType" );
78   cIt = this->m_Parameters.find( "IsColorImage" );
79   if( cIt == this->m_Parameters.end( ) )
80     cIt = this->m_DefaultParameters.find( "IsColorImage" );
81
82   std::string r = "cpPlugins::Plugins::MarchingCubes: itk::Image pixel type not supported";
83   if( cIt->second.second == "0" )
84   {
85     if( tIt->second.second == "char" )
86       r = this->_GD1< char, D >( );
87     else if( tIt->second.second == "short" )
88       r = this->_GD1< short, D >( );
89     else if( tIt->second.second == "int" )
90       r = this->_GD1< int, D >( );
91     else if( tIt->second.second == "long" )
92       r = this->_GD1< long, D >( );
93     else if( tIt->second.second == "uchar" )
94       r = this->_GD1< unsigned char, D >( );
95     else if( tIt->second.second == "ushort" )
96       r = this->_GD1< unsigned short, D >( );
97     else if( tIt->second.second == "uint" )
98       r = this->_GD1< unsigned int, D >( );
99     else if( tIt->second.second == "ulong" )
100       r = this->_GD1< unsigned long, D >( );
101     else if( tIt->second.second == "float" )
102       r = this->_GD1< float, D >( );
103     else if( tIt->second.second == "double" )
104       r = this->_GD1< double, D >( );
105   }
106   else if( cIt->second.second == "1" )
107   {
108     if( tIt->second.second == "char" )
109       r = this->_GD1< itk::RGBPixel< char >, D >( );
110     else if( tIt->second.second == "short" )
111       r = this->_GD1< itk::RGBPixel< short >, D >( );
112     else if( tIt->second.second == "int" )
113       r = this->_GD1< itk::RGBPixel< int >, D >( );
114     else if( tIt->second.second == "long" )
115       r = this->_GD1< itk::RGBPixel< long >, D >( );
116     else if( tIt->second.second == "uchar" )
117       r = this->_GD1< itk::RGBPixel< unsigned char >, D >( );
118     else if( tIt->second.second == "ushort" )
119       r = this->_GD1< itk::RGBPixel< unsigned short >, D >( );
120     else if( tIt->second.second == "uint" )
121       r = this->_GD1< itk::RGBPixel< unsigned int >, D >( );
122     else if( tIt->second.second == "ulong" )
123       r = this->_GD1< itk::RGBPixel< unsigned long >, D >( );
124     else if( tIt->second.second == "float" )
125       r = this->_GD1< itk::RGBPixel< float >, D >( );
126     else if( tIt->second.second == "double" )
127       r = this->_GD1< itk::RGBPixel< double >, D >( );
128   } // fi
129   return( r );
130 */
131 }
132
133 // -------------------------------------------------------------------------
134 template< class P, unsigned int D >
135 std::string cpPlugins::Plugins::MarchingCubes::
136 _GD1( )
137 {
138   return( "" );
139   /* TODO
140   TParameters::const_iterator fIt;
141
142   // Get filename
143   fIt = this->m_Parameters.find( "FileName" );
144   if( fIt == this->m_Parameters.end( ) )
145     fIt = this->m_DefaultParameters.find( "FileName" );
146
147   typedef itk::Image< P, D > _TImage;
148   typedef itk::ImageFileReader< _TImage > _TReader;
149
150   _TReader* reader =
151     dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) );
152   if( reader == NULL )
153   {
154     this->m_Reader = _TReader::New( );
155     reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) );
156
157   } // fi
158   reader->SetFileName( fIt->second.second );
159   try
160   {
161     reader->Update( );
162   }
163   catch( itk::ExceptionObject& err )
164   {
165     return( err.GetDescription( ) );
166
167   } // yrt
168   this->_SetOutput( 0, reader->GetOutput( ) );
169   return( "" );
170 */
171 }
172
173 // eof - $RCSfile$