[Insight-users] ERROR: VTKPolyDataWriter

Noé Jimenez Costa noein69 at hotmail.com
Tue Jun 23 14:58:30 EDT 2009



Hi guys,
I need your help. I want convert my itkmesh to vtkPolydata and after I want to write it in "ojo.vtk". But, when I try it the mistake appears. Can you help me??


int main(int argc, char * argv[] ) 
{

  if( argc < 3 )
    {
    std::cerr << "Usage: IsoSurfaceExtraction  inputImageFile   objectValue" << std::endl;
    return EXIT_FAILURE;
    }

  const unsigned int Dimension = 3;
  typedef signed short PixelType;

  typedef itk::Image< PixelType, Dimension >   ImageType;

  typedef itk::ImageFileReader< ImageType >    ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( argv[1] );

  try
    {
    reader->Update();
    }
  catch( itk::ExceptionObject & exp )
    {
    std::cerr << "Exception thrown while reading the input file " << std::endl;
    std::cerr << exp << std::endl;
    return EXIT_FAILURE;
    }
  
  typedef itk::DefaultDynamicMeshTraits<double, 3, 3,double,double> TriangleMeshTraits; ///////////////
  typedef itk::Mesh<double,3, TriangleMeshTraits> MeshType;
  typedef itk::BinaryMask3DMeshSource< ImageType, MeshType > MeshSourceType;

  MeshSourceType::Pointer meshSource = MeshSourceType::New();
  
  const PixelType objectValue = static_cast<PixelType>( atof( argv[2] ) );
  meshSource->SetObjectValue( objectValue );
  meshSource->SetInput( reader->GetOutput() );

  try
    {
    meshSource->Update();
    }
  catch( itk::ExceptionObject & exp )
    {
    std::cerr << "Exception thrown during Update() " << std::endl;
    std::cerr << exp << std::endl;
    return EXIT_FAILURE;
    }

  std::cout << "Nodes = " << meshSource->GetNumberOfNodes() << std::endl;
  std::cout << "Cells = " << meshSource->GetNumberOfCells() << std::endl;

vtkPolyData *vtkPolyDataOut = NULL;
itkMeshTovtkPolyData * itkMesh2PolyData = new itkMeshTovtkPolyData();
itkMesh2PolyData->SetInput (meshSource->GetOutput());
vtkPolyDataOut = itkMesh2PolyData->GetOutput();

typedef itk::VTKPolyDataWriter<MeshType>WriterType; 
WriterType::Pointer writer1 = WriterType::New();

write1->SetInput(vtkPolyDataOut);  ///////////////////////////////////  ERROR
writer1->SetFileName( "ojo.vtk" );

  try
    {
    writer1->Update();
    }
  catch( itk::ExceptionObject & exp )
    {
    std::cerr << "Exception thrown during Update() " << std::endl;
    std::cerr << exp << std::endl;
    return EXIT_FAILURE;
    }

writer1->Delete();
return 0;

  return EXIT_SUCCESS;
}


thanks for your help.

_________________________________________________________________
Descubre todas las formas en que puedes estar en contacto con amigos y familiares.
http://www.microsoft.com/windows/windowslive/default.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090623/51171eaa/attachment-0001.htm>


More information about the Insight-users mailing list