ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkArrowSpatialObject.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkArrowSpatialObject_h
00019 #define __itkArrowSpatialObject_h
00020 
00021 
00022 #include "itkSpatialObject.h"
00023 
00024 namespace itk
00025 {
00037 template< unsigned int TDimension = 3 >
00038 class ITK_EXPORT ArrowSpatialObject:
00039   public SpatialObject< TDimension >
00040 {
00041 public:
00042 
00043   typedef ArrowSpatialObject                 Self;
00044   typedef SpatialObject< TDimension >        Superclass;
00045   typedef SmartPointer< Self >               Pointer;
00046   typedef SmartPointer< const Self >         ConstPointer;
00047   typedef double                             ScalarType;
00048   typedef Vector< double, TDimension >       VectorType;
00049   typedef Point< double, TDimension >        PointType;
00050   typedef typename Superclass::TransformType TransformType;
00051   typedef typename TransformType::MatrixType MatrixType;
00052 
00054   itkNewMacro(Self);
00055 
00057   itkTypeMacro(ArrowSpatialObject, SpatialObject);
00058 
00060   void SetPosition(const PointType & p)
00061   {
00062     m_Position = p;
00063     this->UpdateTransform();
00064   }
00066 
00067   itkGetConstMacro(Position, PointType);
00068 
00069   void SetPosition(float x, float y)
00070   {
00071     m_Position[0] = x;
00072     m_Position[1] = y;
00073     this->UpdateTransform();
00074   }
00075 
00076   void SetPosition(float x, float y, float z)
00077   {
00078     m_Position[0] = x;
00079     m_Position[1] = y;
00080     m_Position[2] = z;
00081     this->UpdateTransform();
00082   }
00083 
00085   void SetDirection(const VectorType & d)
00086   {
00087     m_Direction = d;
00088     this->UpdateTransform();
00089   }
00091 
00092   itkGetConstMacro(Direction, VectorType);
00093 
00094   void SetDirection(float x, float y)
00095   {
00096     m_Direction[0] = x;
00097     m_Direction[1] = y;
00098     this->UpdateTransform();
00099   }
00100 
00101   void SetDirection(float x, float y, float z)
00102   {
00103     m_Direction[0] = x;
00104     m_Direction[1] = y;
00105     m_Direction[2] = z;
00106     this->UpdateTransform();
00107   }
00108 
00110   void SetLength(double length);
00111 
00113   itkGetConstReferenceMacro(Length, double);
00114 
00116   bool ComputeLocalBoundingBox() const;
00117 
00119   bool IsInside(const PointType & point,
00120                 unsigned int depth, char *name) const;
00121 
00125   virtual bool IsInside(const PointType & point) const;
00126 
00127 protected:
00128 
00129   ArrowSpatialObject();
00130   virtual ~ArrowSpatialObject();
00131 
00133   void UpdateTransform();
00134 
00136   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00137 
00138 private:
00139   ArrowSpatialObject(const Self &); //purposely not implemented
00140   void operator=(const Self &);     //purposely not implemented
00141 
00142   VectorType m_Direction;
00143   PointType  m_Position;
00144   double     m_Length;
00145 };
00146 } // end namespace itk
00147 
00148 #ifndef ITK_MANUAL_INSTANTIATION
00149 #include "itkArrowSpatialObject.hxx"
00150 #endif
00151 
00152 #endif // __itkArrowSpatialObject_h
00153