]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 20 Feb 2017 20:51:28 +0000 (15:51 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 20 Feb 2017 20:51:28 +0000 (15:51 -0500)
plugins/ITKRasterFilters/RasterImageFilter.cxx

index 233271403dd19954495755431fb1764e35857eb7..097566c9664cfe660ee45eec87b53796599d4a6b 100644 (file)
@@ -2,6 +2,7 @@
 #include <cpInstances/DataObjects/Image.h>
 #include <cpInstances/DataObjects/Mesh.h>
 
+#include <vtkPolyData.h>
 #include <itkTriangleMeshToBinaryImageFilter.h>
 #include <cpExtensions/Algorithms/RasterContourFilter.h>
 
@@ -32,10 +33,19 @@ cpPluginsITKRasterFilters::RasterImageFilter::
 void cpPluginsITKRasterFilters::RasterImageFilter::
 _GenerateData( )
 {
-  auto o = this->GetInputData( "Input" );
-  cpPlugins_Demangle_Mesh_Meshes_1( o, _GD0_2D, 2 )
-    cpPlugins_Demangle_Mesh_Meshes_1( o, _GD0_3D, 3 )
-    this->_Error( "Invalid input image dimension." );
+  auto mesh = this->GetInputData< vtkPolyData >( "Input" );
+  double bounds[ 6 ];
+  mesh->GetBounds( bounds );
+  double zdiff = std::fabs( bounds[ 5 ] - bounds[ 4 ] );
+  if( zdiff > 1e-5 )
+  {
+    cpPlugins_Demangle_Mesh_Meshes_1(
+      this->GetInputData( "Input" ), _GD0_3D, 3
+      )
+      this->_Error( "Invalid input image dimension." );
+  }
+  else
+    this->_GD0_2D( mesh );
 }
 
 // -------------------------------------------------------------------------
@@ -73,7 +83,12 @@ _GD1_2D( _TMesh* mesh )
   filter->SetTemplate( this->GetInputData< _TBaseImage >( "TemplateImage" ) );
   filter->ClearPoints( );
   for( unsigned long i = 0; i < mesh->GetNumberOfPoints( ); ++i )
-    filter->AddPoint( mesh->GetPoint( i ) );
+  {
+    double pnt[ 3 ];
+    mesh->GetPoint( i, pnt );
+    filter->AddPoint( pnt );
+
+  } // rof
 
   // Execute and connect output
   filter->Update( );