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 #ifndef itkPointSetFunction_h 19 #define itkPointSetFunction_h 20 21 #include "itkFunctionBase.h" 22 #include "itkPoint.h" 23 24 namespace itk 25 { 26 27 28 /** \class PointSetFunction 29 * \brief Evaluates a function of an image at specified position. 30 * 31 * FIXME: Documentation was copy-pasted from ImageFunction. 32 * 33 * PointSetFunction is a baseclass for all objects that evaluates 34 * a function of an image at index, continuous index or point. 35 * This class is templated over the input image type, the type 36 * of the function output and the coordinate representation type 37 * (e.g. float or double). 38 * 39 * The input image is set via method SetInputPointSet(). 40 * Methods Evaluate, EvaluateAtIndex and EvaluateAtContinuousIndex 41 * respectively evaluates the function at an geometric point, 42 * image index and continuous image index. 43 * 44 * \warning Image BufferedRegion information is cached during 45 * in SetInputPointSet( image ). If the image BufferedRegion has changed 46 * one must call SetInputPointSet( image ) again to update the cache 47 * to the current values. 48 * 49 * \sa Point 50 * \sa Index 51 * \sa ContinuousIndex 52 * 53 * \ingroup ITKMetricsv4 54 */ 55 template < 56 typename TInputPointSet, 57 typename TOutput, 58 typename TCoordRep = float 59 > 60 class ITK_TEMPLATE_EXPORT PointSetFunction : 61 public FunctionBase<typename TInputPointSet::PointType, TOutput> 62 { 63 public: 64 ITK_DISALLOW_COPY_AND_ASSIGN(PointSetFunction); 65 66 /** Dimension underlying input point set. */ 67 static constexpr unsigned int Dimension = TInputPointSet::PointDimension; 68 69 /** Standard class type aliases. */ 70 using Self = PointSetFunction; 71 using Superclass = FunctionBase 72 <typename TInputPointSet::PointType, TOutput>; 73 using Pointer = SmartPointer<Self>; 74 using ConstPointer = SmartPointer<const Self>; 75 76 /** Run-time type information (and related methods). */ 77 itkTypeMacro( PointSetFunction, FunctionBase ); 78 79 /** InputPointSetType type alias support */ 80 using InputPointSetType = TInputPointSet; 81 82 /** InputPixel type alias support */ 83 using InputPointType = typename InputPointSetType::PointType; 84 using InputPixelType = typename InputPointSetType::PixelType; 85 86 /** InputPointSetPointer type alias support */ 87 using InputPointSetConstPointer = typename InputPointSetType::ConstPointer; 88 89 /** OutputType type alias support */ 90 using OutputType = TOutput; 91 92 /** CoordRepType type alias support */ 93 using CoordRepType = TCoordRep; 94 95 /** Set the input point set. 96 * \warning this method caches BufferedRegion information. 97 * If the BufferedRegion has changed, user must call 98 * SetInputPointSet again to update cached values. */ 99 virtual void SetInputPointSet( const InputPointSetType * ptr ); 100 101 /** Get the input image. */ GetInputPointSet()102 const InputPointSetType * GetInputPointSet() const 103 { return m_PointSet.GetPointer(); } 104 105 /** Evaluate the function at specified Point position. 106 * Subclasses must provide this method. */ 107 TOutput Evaluate( const InputPointType& point ) const override = 0; 108 109 protected: 110 PointSetFunction(); 111 ~PointSetFunction() override = default; 112 void PrintSelf(std::ostream& os, Indent indent) const override; 113 114 /** Const pointer to the input image. */ 115 InputPointSetConstPointer m_PointSet; 116 }; 117 118 } // end namespace itk 119 120 // Define instantiation macro for this template. 121 #define ITK_TEMPLATE_PointSetFunction(_, EXPORT, x, y) namespace itk { \ 122 _(3(class EXPORT PointSetFunction< ITK_TEMPLATE_3 x >)) \ 123 namespace Templates { using PointSetFunction##y = PointSetFunction< ITK_TEMPLATE_3 x >; } \ 124 } 125 126 127 #ifndef ITK_MANUAL_INSTANTIATION 128 # include "itkPointSetFunction.hxx" 129 #endif 130 131 132 #endif 133