ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkContourSpatialObject.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 __itkContourSpatialObject_h
00019 #define __itkContourSpatialObject_h
00020 
00021 #include <list>
00022 
00023 #include "itkPointBasedSpatialObject.h"
00024 #include "itkContourSpatialObjectPoint.h"
00025 
00026 namespace itk
00027 {
00038 template< unsigned int TDimension = 3 >
00039 class ITK_EXPORT ContourSpatialObject:
00040   public PointBasedSpatialObject<  TDimension >
00041 {
00042 public:
00043 
00044   typedef ContourSpatialObject                    Self;
00045   typedef PointBasedSpatialObject< TDimension >   Superclass;
00046   typedef SmartPointer< Self >                    Pointer;
00047   typedef SmartPointer< const Self >              ConstPointer;
00048   typedef double                                  ScalarType;
00049   typedef ContourSpatialObjectPoint< TDimension > ControlPointType;
00050   typedef SpatialObjectPoint< TDimension >        InterpolatedPointType;
00051   typedef std::vector< ControlPointType >         ControlPointListType;
00052   typedef std::vector< InterpolatedPointType >    InterpolatedPointListType;
00053 
00054   typedef typename Superclass::SpatialObjectPointType  SpatialObjectPointType;
00055   typedef typename Superclass::PointType               PointType;
00056   typedef typename Superclass::TransformType           TransformType;
00057   typedef typename Superclass::BoundingBoxType         BoundingBoxType;
00058   typedef VectorContainer< IdentifierType, PointType > PointContainerType;
00059   typedef SmartPointer< PointContainerType >           PointContainerPointer;
00060 
00062   itkNewMacro(Self);
00063 
00065   itkTypeMacro(ContourSpatialObject, PointBasedSpatialObject);
00066 
00068   ControlPointListType & GetControlPoints(void);
00069 
00071   const ControlPointListType & GetControlPoints(void) const;
00072 
00074   void SetControlPoints(ControlPointListType & newPoints);
00075 
00077   const ControlPointType * GetControlPoint(IdentifierType id) const
00078   { return &( m_ControlPoints[id] ); }
00079 
00081   ControlPointType * GetControlPoint(IdentifierType id)
00082   { return &( m_ControlPoints[id] ); }
00083 
00085   SizeValueType GetNumberOfControlPoints(void) const
00086   { return m_ControlPoints.size(); }
00087 
00089   InterpolatedPointListType & GetInterpolatedPoints(void);
00090 
00092   const InterpolatedPointListType & GetInterpolatedPoints(void) const;
00093 
00095   void SetInterpolatedPoints(InterpolatedPointListType & newPoints);
00096 
00098   const InterpolatedPointType * GetInterpolatedPoint(IdentifierType id) const
00099   { return &( m_InterpolatedPoints[id] ); }
00100 
00102   InterpolatedPointType * GetInterpolatedPoint(IdentifierType id)
00103   { return &( m_InterpolatedPoints[id] ); }
00104 
00106   SizeValueType GetNumberOfInterpolatedPoints(void) const
00107   { return m_InterpolatedPoints.size(); }
00108 
00109   enum InterpolationType { NO_INTERPOLATION = 0,
00110                            EXPLICIT_INTERPOLATION, BEZIER_INTERPOLATION,
00111                            LINEAR_INTERPOLATION };
00112 
00114   InterpolationType GetInterpolationType() const
00115   { return m_InterpolationType; }
00116   void SetInterpolationType(InterpolationType interpolation)
00117   { m_InterpolationType = interpolation; }
00119 
00121   itkSetMacro(Closed, bool);
00122   itkGetConstMacro(Closed, bool);
00124 
00126   itkSetMacro(DisplayOrientation, int);
00127   itkGetConstMacro(DisplayOrientation, int);
00129 
00132   itkSetMacro(AttachedToSlice, int);
00133   itkGetConstMacro(AttachedToSlice, int);
00135 
00141   bool IsEvaluableAt(const PointType & point,
00142                      unsigned int depth = 0, char *name = NULL) const;
00143 
00148   bool ValueAt(const PointType & point, double & value,
00149                unsigned int depth = 0, char *name = NULL) const;
00150 
00152   bool IsInside(const PointType & point,
00153                 unsigned int depth, char *name) const;
00154 
00158   virtual bool IsInside(const PointType & point) const;
00159 
00161   bool ComputeLocalBoundingBox(void) const;
00162 
00163 protected:
00164   ContourSpatialObject(const Self &); //purposely not implemented
00165   void operator=(const Self &);       //purposely not implemented
00166 
00167   ControlPointListType      m_ControlPoints;
00168   InterpolatedPointListType m_InterpolatedPoints;
00169   InterpolationType         m_InterpolationType;
00170   bool                      m_Closed;
00171   int                       m_DisplayOrientation;
00172   int                       m_AttachedToSlice;
00173 
00174   ContourSpatialObject();
00175   virtual ~ContourSpatialObject();
00176 
00178   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00179 };
00180 } // end namespace itk
00181 
00182 #ifndef ITK_MANUAL_INSTANTIATION
00183 #include "itkContourSpatialObject.hxx"
00184 #endif
00185 
00186 #endif // __itkContourSpatialObject_h
00187