~ubuntu-branches/debian/sid/simpleitk/sid

« back to all changes in this revision

Viewing changes to Testing/Unit/sitkShowTest.cxx

  • Committer: Package Import Robot
  • Author(s): Ghislain Antony Vaillant
  • Date: 2017-11-02 08:49:18 UTC
  • Revision ID: package-import@ubuntu.com-20171102084918-7hs09ih668xq87ej
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
*
 
3
*  Copyright Insight Software Consortium
 
4
*
 
5
*  Licensed under the Apache License, Version 2.0 (the "License");
 
6
*  you may not use this file except in compliance with the License.
 
7
*  You may obtain a copy of the License at
 
8
*
 
9
*         http://www.apache.org/licenses/LICENSE-2.0.txt
 
10
*
 
11
*  Unless required by applicable law or agreed to in writing, software
 
12
*  distributed under the License is distributed on an "AS IS" BASIS,
 
13
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
*  See the License for the specific language governing permissions and
 
15
*  limitations under the License.
 
16
*
 
17
*=========================================================================*/
 
18
 
 
19
#include <cstdlib>
 
20
#include <SimpleITKTestHarness.h>
 
21
#include <SimpleITK.h>
 
22
 
 
23
 
 
24
namespace sitk = itk::simple;
 
25
 
 
26
DataFinder dataFinder;
 
27
 
 
28
int main (int argc, char *argv[])
 
29
{
 
30
 
 
31
  sitk::Image img;
 
32
 
 
33
  std::cout << "Starting sitkShowTest\n";
 
34
 
 
35
  if (argc > 1)
 
36
    {
 
37
    for (int i=1; i<argc; i++)
 
38
      {
 
39
      try
 
40
        {
 
41
        std::cout << "Reading " << argv[i] << std::endl;
 
42
        img = sitk::ReadImage( argv[i] );
 
43
        std::cout << "Showing " << argv[i] << std::endl;
 
44
        sitk::Show(img);
 
45
        }
 
46
      catch (std::exception &e)
 
47
        {
 
48
        std::cout << "Exception: " << e.what() << std::endl;
 
49
        return EXIT_FAILURE;
 
50
        }
 
51
      catch (...)
 
52
        {
 
53
        std::cout << "Default exception\n";
 
54
        return EXIT_FAILURE;
 
55
        }
 
56
      }
 
57
    }
 
58
 
 
59
  else
 
60
    {
 
61
    try
 
62
      {
 
63
      std::cout << "Read 1\n";
 
64
      img = sitk::ReadImage( dataFinder.GetFile ( "Input/RA-Float.nrrd" ) );
 
65
      std::cout << "Show 1\n";
 
66
      sitk::Show(img);
 
67
      }
 
68
    catch (std::exception &e)
 
69
      {
 
70
      std::cout << "Exception: " << e.what() << std::endl;
 
71
      return EXIT_FAILURE;
 
72
      }
 
73
    catch (...)
 
74
      {
 
75
      std::cout << "Default exception\n";
 
76
      return EXIT_FAILURE;
 
77
      }
 
78
 
 
79
 
 
80
    try
 
81
      {
 
82
      std::cout << "Read 2\n";
 
83
      img = sitk::ReadImage( dataFinder.GetFile ( "Input/VM1111Shrink-RGB.png" ) );
 
84
      std::cout << "Show 2\n";
 
85
      sitk::Show(img);
 
86
      }
 
87
    catch (std::exception &e)
 
88
      {
 
89
      std::cout << "Exception: " << e.what() << std::endl;
 
90
      return EXIT_FAILURE;
 
91
      }
 
92
    catch (...)
 
93
      {
 
94
      std::cout << "Default exception\n";
 
95
      return EXIT_FAILURE;
 
96
      }
 
97
 
 
98
    try
 
99
      {
 
100
      std::cout << "Read 3\n";
 
101
      img = sitk::ReadImage( dataFinder.GetFile ( "Input/cthead1-Float.mha" ) );
 
102
      std::cout << "Show 3\n";
 
103
      sitk::Show(img, "Dave was here", true);
 
104
      }
 
105
    catch (std::exception &e)
 
106
      {
 
107
      std::cout << "Exception: " << e.what() << std::endl;
 
108
      return EXIT_FAILURE;
 
109
      }
 
110
    catch (...)
 
111
      {
 
112
      std::cout << "Default exception\n";
 
113
      return EXIT_FAILURE;
 
114
      }
 
115
    }
 
116
 
 
117
  return EXIT_SUCCESS;
 
118
}