ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkTestDriverInclude.h
Go to the documentation of this file.
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  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkTestDriverInclude_h
29 #define itkTestDriverInclude_h
30 //
31 // This file is used by the TestDriver executables generated by CMake's
32 // create_test_sourcelist. It defines a function, ProcessArguments
33 // that processes the command line for the test driver prior to
34 // invoking the test. It also defines the RegressionTestImage function
35 // that is called after a test has been run by the driver.
36 // command line options prior to invoking the test.
37 //
38 
39 #include <algorithm>
40 #include <fstream>
41 #include <iostream>
42 #include <map>
43 #include <string>
44 #include <vector>
45 
46 #include "itksys/Process.h"
47 #include "itksys/SystemTools.hxx"
48 #include "vnl/vnl_sample.h"
49 
51 #include "itkImageIOBase.h"
52 #include "itkIntTypes.h"
53 #include "itkWin32Header.h"
54 
55 #define ITK_TEST_DIMENSION_MAX 6
56 
57 int RegressionTestImage(const char *testImageFilename,
58  const char *baselineImageFilename,
59  int reportErrors,
60  double intensityTolerance,
61  ::itk::SizeValueType numberOfPixelsTolerance = 0,
62  unsigned int radiusTolerance = 0,
63  bool verifyInputInformation = true,
64  double coordinateTolerance = 1.0e-6,
65  double directionTolerance = 1.0e-6);
66 
67 int HashTestImage( const char *testImageFilename,
68  const std::string md5hash );
69 
70 
71 std::map< std::string, int > RegressionTestBaselines(char *);
72 
73 using ComparePairType = std::pair< char *, char * >;
74 
75 // A structure to hold regression test parameters
76 typedef struct
77 {
78  std::vector< ComparePairType > compareList;
81  unsigned int radiusTolerance;
86 
88 
89 
90 using HashPairType = std::pair< const char *, std::vector<std::string> >;
91 
92 std::vector< HashPairType >& GetHashTestList();
93 
94 using ArgumentStringType = char **;
95 
96 
97 // Types to hold parameters that should be processed later
98 using ArgumentsList = std::vector< char * >;
99 
101 {
103 
108 };
109 
110 // A structure to hold redirect output parameters
111 typedef struct
112 {
113  bool redirect;
114  std::string fileName;
116 
118 
119 void usage();
120 
121 
122 int ProcessArguments(int *ac, ArgumentStringType *av, ProcessedOutputType * processedOutput = nullptr );
123 
124 
126 void GetImageType( const char * fileName,
128  itk::ImageIOBase::IOComponentType &componentType );
129 
130 int RegressionTestImage(const char *testImageFilename,
131  const char *baselineImageFilename,
132  int reportErrors,
133  double intensityTolerance,
134  ::itk::SizeValueType numberOfPixelsTolerance,
135  unsigned int radiusTolerance,
136  bool verifyInputInformation,
137  double coordinateTolerance,
138  double directionTolerance);
139 
140 
141 int HashTestImage( const char *testImageFilename,
142  const std::vector<std::string> &baselineMD5Vector );
143 
144 //
145 // Generate all of the possible baselines
146 // The possible baselines are generated fromn the baselineFilename using the
147 // following algorithm:
148 // 1) strip the suffix
149 // 2) append a digit .x
150 // 3) append the original suffix.
151 // It the file exists, increment x and continue
152 //
153 std::map< std::string, int > RegressionTestBaselines(char *baselineFilename);
154 
155 // Needed for explicit instantiate
156 //#include "itkTestingComparisonImageFilter.hxx"
157 
158 #endif
ArgumentsList add_before_libpath
char ** ArgumentStringType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
std::vector< char * > ArgumentsList
void GetImageType(const char *fileName, itk::ImageIOBase::IOPixelType &pixelType, itk::ImageIOBase::IOComponentType &componentType)
Get the PixelType and ComponentType from fileName.
std::pair< char *, char * > ComparePairType
ArgumentsList add_before_env_with_sep
int HashTestImage(const char *testImageFilename, const std::string md5hash)
int RegressionTestImage(const char *testImageFilename, const char *baselineImageFilename, int reportErrors, double intensityTolerance,::itk::SizeValueType numberOfPixelsTolerance=0, unsigned int radiusTolerance=0, bool verifyInputInformation=true, double coordinateTolerance=1.0e-6, double directionTolerance=1.0e-6)
std::map< std::string, int > RegressionTestBaselines(char *)
std::vector< HashPairType > & GetHashTestList()
RedirectOutputParameters & GetRedirectOutputParameters()
RegressionTestParameters & GetRegressionTestParameters()
std::pair< const char *, std::vector< std::string > > HashPairType
static constexpr double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:53
std::vector< ComparePairType > compareList
int ProcessArguments(int *ac, ArgumentStringType *av, ProcessedOutputType *processedOutput=nullptr)
void usage()