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 itkSymmetricEllipsoidInteriorExteriorSpatialFunction_h 19 #define itkSymmetricEllipsoidInteriorExteriorSpatialFunction_h 20 21 #include "itkInteriorExteriorSpatialFunction.h" 22 23 namespace itk 24 { 25 /** \class SymmetricEllipsoidInteriorExteriorSpatialFunction 26 * \brief Function implementation of an ellipsoid 27 * 28 * Similar to EllipsoidInteriorExteriorSpatialFunction in that it 29 * implements a function that returns 1 for points inside or on the surface 30 * of a ellipsoid and 0 for points outside the ellipsoid. However, this 31 * ellipsoid is defined by a single orientation vector and deals 32 * only with symmetric ellipsoids. An n-dimensional symmetric ellipsoid 33 * is one which has m axes of equal length and (n - m) unique axes lengths. 34 * Specifically, this class deals with the case where (n - m) = 1 and 35 * the ellipsoid's major axis is oriented along a singles orientation vector. 36 * \ingroup ITKCommon 37 */ 38 template< unsigned int VDimension = 3, 39 typename TInput = Point< double, VDimension > > 40 class ITK_TEMPLATE_EXPORT SymmetricEllipsoidInteriorExteriorSpatialFunction: 41 public InteriorExteriorSpatialFunction< VDimension, TInput > 42 { 43 public: 44 /** Standard class type aliases. */ 45 using Self = SymmetricEllipsoidInteriorExteriorSpatialFunction; 46 using Superclass = InteriorExteriorSpatialFunction< VDimension >; 47 using Pointer = SmartPointer< Self >; 48 using ConstPointer = SmartPointer< const Self >; 49 using VectorType = Vector< double, VDimension >; 50 51 /** Method for creation through the object factory. */ 52 itkNewMacro(Self); 53 54 /** Run-time information. */ 55 itkTypeMacro(SymmetricEllipsoidInteriorExteriorSpatialFunction, InteriorExteriorSpatialFunction); 56 57 /** Input type for the function. */ 58 using InputType = typename Superclass::InputType; 59 60 /** Output type for the function. */ 61 using OutputType = typename Superclass::OutputType; 62 63 /** Evaluates the function at a given position. */ 64 OutputType Evaluate(const InputType & position) const override; 65 66 /** Get and set the center of the ellipsoid. */ 67 itkGetConstMacro(Center, InputType); 68 itkSetMacro(Center, InputType); 69 70 /** Set the orientation vector of the ellipsoid's unique axis and axes lengths. 71 * Must be normalized!!!!! */ 72 void SetOrientation(VectorType orientation, double uniqueAxis, double symmetricAxes); 73 74 protected: 75 SymmetricEllipsoidInteriorExteriorSpatialFunction(); 76 ~SymmetricEllipsoidInteriorExteriorSpatialFunction() override = default; 77 78 void PrintSelf(std::ostream & os, Indent indent) const override; 79 80 private: 81 SymmetricEllipsoidInteriorExteriorSpatialFunction(const Self &) = delete; 82 void operator=(const Self &) = delete; 83 84 /** The center of the ellipsoid. */ 85 InputType m_Center; 86 87 /** The unique axis length of the ellipsoid. */ 88 double m_UniqueAxis{10}; 89 90 /** The symmetric axes lengths of the ellipsoid. */ 91 double m_SymmetricAxes{5}; 92 93 /** The orientation vector of the ellipsoid's unique axis. */ 94 Vector< double, VDimension > m_Orientation; 95 96 /** The vector ratio. */ 97 double m_VectorRatio{0.0}; 98 }; 99 } // end namespace itk 100 101 #ifndef ITK_MANUAL_INSTANTIATION 102 #include "itkSymmetricEllipsoidInteriorExteriorSpatialFunction.hxx" 103 #endif 104 105 #endif 106