ITK  6.0.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 * https://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
57extern int
58RegressionTestImage(const char * testImageFilename,
59 const char * baselineImageFilename,
60 int reportErrors,
61 double intensityTolerance,
62 itk::SizeValueType numberOfPixelsTolerance = 0,
63 unsigned int radiusTolerance = 0,
64 bool verifyInputInformation = true,
65 double coordinateTolerance = 1.0e-6,
66 double directionTolerance = 1.0e-6);
67
68extern int
69HashTestImage(const char * testImageFilename, const std::string md5hash);
70
71
72extern std::map<std::string, int>
74
75using ComparePairType = std::pair<char *, char *>;
76
77// A structure to hold regression test parameters
79{
80 std::vector<ComparePairType> compareList;
83 unsigned int radiusTolerance;
87};
88
91
92
93using HashPairType = std::pair<const char *, std::vector<std::string>>;
94
95extern std::vector<HashPairType> &
97
98using ArgumentStringType = char **;
99
100
101// Types to hold parameters that should be processed later
102using ArgumentsList = std::vector<char *>;
103
105{
107
112};
113
114// A structure to hold redirect output parameters
116{
118 std::string fileName;
119};
120
123
124extern void
126
127extern int
128ProcessArguments(int * ac, ArgumentStringType * av, ProcessedOutputType * processedOutput = nullptr);
129
130
132extern void
133GetImageType(const char * fileName, itk::IOPixelEnum & pixelType, itk::IOComponentEnum & componentType);
134
135extern int
136RegressionTestImage(const char * testImageFilename,
137 const char * baselineImageFilename,
138 int reportErrors,
139 double intensityTolerance,
140 itk::SizeValueType numberOfPixelsTolerance,
141 unsigned int radiusTolerance,
142 bool verifyInputInformation,
143 double coordinateTolerance,
144 double directionTolerance);
145
146
147extern int
148HashTestImage(const char * testImageFilename, const std::vector<std::string> & baselineMD5Vector);
149
150//
151// Generate all of the possible baselines
152// The possible baselines are generated from 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//
159extern std::map<std::string, int>
160RegressionTestBaselines(char * baselineFilename);
161
162// Needed for explicit instantiate
163//#include "itkTestingComparisonImageFilter.hxx"
164
165#endif
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)
void usage()
int ProcessArguments(int *ac, ArgumentStringType *av, ProcessedOutputType *processedOutput=nullptr)
RegressionTestParameters & GetRegressionTestParameters()
void GetImageType(const char *fileName, itk::IOPixelEnum &pixelType, itk::IOComponentEnum &componentType)
Get the PixelType and ComponentType from fileName.
std::map< std::string, int > RegressionTestBaselines(char *)
std::vector< HashPairType > & GetHashTestList()
std::vector< char * > ArgumentsList
int HashTestImage(const char *testImageFilename, const std::string md5hash)
RedirectOutputParameters & GetRedirectOutputParameters()
std::pair< char *, char * > ComparePairType
char ** ArgumentStringType
std::pair< const char *, std::vector< std::string > > HashPairType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
ArgumentsList add_before_env_with_sep
ArgumentsList add_before_libpath
std::vector< ComparePairType > compareList