1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #include "mirtk/ExtrapolateImageFunction.h"
21 
22 #include "mirtk/ConstExtrapolateImageFunction.h"
23 #include "mirtk/ConstExtrapolateImageFunctionWithPeriodicTime.h"
24 #include "mirtk/NearestNeighborExtrapolateImageFunction.h"
25 #include "mirtk/RepeatExtrapolateImageFunction.h"
26 #include "mirtk/MirrorExtrapolateImageFunction.h"
27 
28 
29 namespace mirtk {
30 
31 
32 // -----------------------------------------------------------------------------
ExtrapolateImageFunction()33 ExtrapolateImageFunction::ExtrapolateImageFunction()
34 {
35 }
36 
37 // -----------------------------------------------------------------------------
~ExtrapolateImageFunction()38 ExtrapolateImageFunction::~ExtrapolateImageFunction()
39 {
40 }
41 
42 // -----------------------------------------------------------------------------
43 ExtrapolateImageFunction *
New(enum ExtrapolationMode mode,const BaseImage * image)44 ExtrapolateImageFunction::New(enum ExtrapolationMode mode, const BaseImage *image)
45 {
46   ExtrapolateImageFunction *p = NULL;
47   switch (mode) {
48     case Extrapolation_None:   { p = NULL;                                          break; }
49     case Extrapolation_Const:  { p = new ConstExtrapolateImageFunction();           break; }
50     case Extrapolation_NN:     { p = new NearestNeighborExtrapolateImageFunction(); break; }
51     case Extrapolation_Repeat: { p = new RepeatExtrapolateImageFunction();          break; }
52     case Extrapolation_Mirror: { p = new MirrorExtrapolateImageFunction();          break; }
53     case Extrapolation_ConstWithPeriodicTime:
54       p = new ConstExtrapolateImageFunctionWithPeriodicTime();
55       break;
56     default:
57    	  cerr << "ExtrapolateImageFunction::New: Unknwon extrapolation mode: " << mode << endl;
58       exit(1);
59   }
60   if (p) p->Input(image);
61   return p;
62 }
63 
64 
65 } // namespace mirtk
66