~ubuntu-branches/ubuntu/precise/insighttoolkit/precise

« back to all changes in this revision

Viewing changes to Testing/Code/Review/itkQuadEdgeMeshCleanFilterTest.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-12-19 20:16:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081219201649-drt97guwl2ryt0cn

* New upstream version.
  - patches/nifti-versioning.patch: Remove.  Applied upstream.
  - control:
  - rules: Update version numbers, package names.

* control: Build-depend on uuid-dev (gdcm uses it).

* copyright: Update download URL.

* rules: Adhere to parallel=N in DEB_BUILD_OPTIONS by setting MAKEFLAGS.

* compat: Set to 7.
* control: Update build-dep on debhelper to version >= 7.

* CMakeCache.txt.debian: Set CMAKE_BUILD_TYPE to "RELEASE" so that we
  build with -O3 (not -O2), necessary to optimize the templated code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   Insight Segmentation & Registration Toolkit
 
4
  Module:    $RCSfile: itkQuadEdgeMeshCleanFilterTest.cxx,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2008-10-04 14:27:51 $
 
7
  Version:   $Revision: 1.3 $
 
8
 
 
9
  Copyright (c) Insight Software Consortium. All rights reserved.
 
10
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
 
11
 
 
12
     This software is distributed WITHOUT ANY WARRANTY; without even
 
13
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 
14
     PURPOSE.  See the above copyright notices for more information.
 
15
 
 
16
=========================================================================*/
 
17
 
 
18
#include "itkQuadEdgeMesh.h"
 
19
#include "itkVTKPolyDataReader.h"
 
20
#include "itkVTKPolyDataWriter.h"
 
21
 
 
22
#include <sstream>
 
23
 
 
24
#include "itkQuadEdgeMeshCleanFilter.h"
 
25
 
 
26
int itkQuadEdgeMeshCleanFilterTest( int argc, char* argv[] )
 
27
{
 
28
  // ** ERROR MESSAGE AND HELP ** //
 
29
  if( argc < 3 )
 
30
    {
 
31
    std::cout <<"Requires 3 argument: " <<std::endl;
 
32
    std::cout <<"1-Input file name " <<std::endl;
 
33
    std::cout <<"2-Relative Tolerance " <<std::endl;
 
34
    std::cout <<"3-Output file name " <<std::endl;
 
35
    return EXIT_FAILURE;
 
36
    }
 
37
 
 
38
  // ** TYPEDEF **
 
39
  typedef double        Coord;
 
40
  const unsigned int    Dimension = 3;
 
41
 
 
42
  typedef itk::QuadEdgeMesh< Coord, Dimension >  MeshType;
 
43
  typedef itk::VTKPolyDataReader< MeshType >     ReaderType;
 
44
  typedef itk::VTKPolyDataWriter< MeshType >     WriterType;
 
45
 
 
46
  // ** READ THE FILE IN **
 
47
  ReaderType::Pointer reader = ReaderType::New( );
 
48
  reader->SetFileName( argv[1] );
 
49
 
 
50
  try
 
51
    {
 
52
    reader->Update( );
 
53
    }
 
54
  catch( itk::ExceptionObject & exp )
 
55
    {
 
56
    std::cerr << "Exception thrown while reading the input file " << std::endl;
 
57
    std::cerr << exp << std::endl;
 
58
    return EXIT_FAILURE;
 
59
    }
 
60
 
 
61
  MeshType::Pointer mesh = reader->GetOutput( );
 
62
 
 
63
  Coord tol;
 
64
  std::stringstream ssout( argv[2] );
 
65
  ssout >>tol;
 
66
 
 
67
  typedef itk::QuadEdgeMeshCleanFilter< MeshType, MeshType > CleanFilterType;
 
68
  CleanFilterType::Pointer filter = CleanFilterType::New();
 
69
  filter->SetInput( mesh );
 
70
  filter->SetRelativeTolerance( tol );
 
71
  filter->Update();
 
72
 
 
73
  // ** WRITE OUTPUT **
 
74
  WriterType::Pointer writer = WriterType::New( );
 
75
  writer->SetInput( filter->GetOutput( ) );
 
76
  writer->SetFileName( argv[3] );
 
77
  writer->Update( );
 
78
 
 
79
  return EXIT_SUCCESS;
 
80
 
 
81
}