ITK  5.3.0
Insight Toolkit
itkTestDriverInclude.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 extern int
58 RegressionTestImage(const char * testImageFilename,
59  const char * baselineImageFilename,
60  int reportErrors,
61  double intensityTolerance,
63  unsigned int radiusTolerance = 0,
64  bool verifyInputInformation = true,
65  double coordinateTolerance = 1.0e-6,
66  double directionTolerance = 1.0e-6);
67 
68 extern int
69 HashTestImage(const char * testImageFilename, const std::string md5hash);
70 
71 
72 extern std::map<std::string, int>
74 
75 using ComparePairType = std::pair<char *, char *>;
76 
77 // A structure to hold regression test parameters
78 using RegressionTestParameters = struct _RegressionTestParameters
79 {
80  std::vector<ComparePairType> compareList;
83  unsigned int radiusTolerance;
87 };
88 
91 
92 
93 using HashPairType = std::pair<const char *, std::vector<std::string>>;
94 
95 extern std::vector<HashPairType> &
97 
98 using ArgumentStringType = char **;
99 
100 
101 // Types to hold parameters that should be processed later
102 using ArgumentsList = std::vector<char *>;
103 
105 {
107 
112 };
113 
114 // A structure to hold redirect output parameters
115 using RedirectOutputParameters = struct _RedirectOutputParameters
116 {
117  bool redirect;
118  std::string fileName;
119 };
120 
123 
124 extern void
125 usage();
126 
127 extern int
128 ProcessArguments(int * ac, ArgumentStringType * av, ProcessedOutputType * processedOutput = nullptr);
129 
130 
132 extern void
133 GetImageType(const char * fileName, itk::IOPixelEnum & pixelType, itk::IOComponentEnum & componentType);
134 
135 extern int
136 RegressionTestImage(const char * testImageFilename,
137  const char * baselineImageFilename,
138  int reportErrors,
139  double intensityTolerance,
141  unsigned int radiusTolerance,
143  double coordinateTolerance,
144  double directionTolerance);
145 
146 
147 extern int
148 HashTestImage(const char * testImageFilename, const std::vector<std::string> & baselineMD5Vector);
149 
150 //
151 // Generate all of the possible baselines
152 // The possible baselines are generated fromn the baselineFilename using the
153 // following algorithm:
154 // 1) strip the suffix
155 // 2) append a digit .x
156 // 3) append the original suffix.
157 // It the file exists, increment x and continue
158 //
159 extern std::map<std::string, int>
160 RegressionTestBaselines(char * baselineFilename);
161 
162 // Needed for explicit instantiate
163 //#include "itkTestingComparisonImageFilter.hxx"
164 
165 #endif
GetRegressionTestParameters
RegressionTestParameters & GetRegressionTestParameters()
ComparePairType
std::pair< char *, char * > ComparePairType
Definition: itkTestDriverInclude.h:75
ProcessArguments
int ProcessArguments(int *ac, ArgumentStringType *av, ProcessedOutputType *processedOutput=nullptr)
intensityTolerance
double intensityTolerance
Definition: itkTestDriverInclude.h:81
itkFloatingPointExceptions.h
usage
void usage()
numberOfPixelsTolerance
unsigned int numberOfPixelsTolerance
Definition: itkTestDriverInclude.h:82
coordinateTolerance
double coordinateTolerance
Definition: itkTestDriverInclude.h:85
ProcessedOutputType::externalProcessMustBeCalled
bool externalProcessMustBeCalled
Definition: itkTestDriverInclude.h:106
RedirectOutputParameters
struct _RedirectOutputParameters { bool redirect RedirectOutputParameters
Definition: itkTestDriverInclude.h:117
itk::CommonEnums::IOComponent
IOComponent
Definition: itkCommonEnums.h:76
ArgumentStringType
char ** ArgumentStringType
Definition: itkTestDriverInclude.h:98
itk::CommonEnums::IOPixel
IOPixel
Definition: itkCommonEnums.h:49
ProcessedOutputType::args
ArgumentsList args
Definition: itkTestDriverInclude.h:108
verifyInputInformation
bool verifyInputInformation
Definition: itkTestDriverInclude.h:84
GetHashTestList
std::vector< HashPairType > & GetHashTestList()
HashTestImage
int HashTestImage(const char *testImageFilename, const std::string md5hash)
directionTolerance
double directionTolerance
Definition: itkTestDriverInclude.h:86
RegressionTestBaselines
std::map< std::string, int > RegressionTestBaselines(char *)
ProcessedOutputType
Definition: itkTestDriverInclude.h:104
itkWin32Header.h
itkImageIOBase.h
itkIntTypes.h
ProcessedOutputType::add_before_env_with_sep
ArgumentsList add_before_env_with_sep
Definition: itkTestDriverInclude.h:111
ProcessedOutputType::add_before_env
ArgumentsList add_before_env
Definition: itkTestDriverInclude.h:110
ProcessedOutputType::add_before_libpath
ArgumentsList add_before_libpath
Definition: itkTestDriverInclude.h:109
radiusTolerance
unsigned int radiusTolerance
Definition: itkTestDriverInclude.h:83
GetRedirectOutputParameters
RedirectOutputParameters & GetRedirectOutputParameters()
HashPairType
std::pair< const char *, std::vector< std::string > > HashPairType
Definition: itkTestDriverInclude.h:93
itk::Math::e
static constexpr double e
Definition: itkMath.h:54
RegressionTestParameters
struct _RegressionTestParameters { std::vector< ComparePairType > compareList RegressionTestParameters
Definition: itkTestDriverInclude.h:80
ArgumentsList
std::vector< char * > ArgumentsList
Definition: itkTestDriverInclude.h:102
RegressionTestImage
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)
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
fileName
std::string fileName
Definition: itkTestDriverInclude.h:118
GetImageType
void GetImageType(const char *fileName, itk::IOPixelEnum &pixelType, itk::IOComponentEnum &componentType)
Get the PixelType and ComponentType from fileName.