00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkLabelObject.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-05-23 19:04:36 $ 00007 Version: $Revision: 1.3 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkLabelObject_h 00018 #define __itkLabelObject_h 00019 00020 #include <deque> 00021 #include "itkLightObject.h" 00022 #include "itkLabelObjectLine.h" 00023 #include "itkWeakPointer.h" 00024 #include "itkObjectFactory.h" 00025 00026 namespace itk 00027 { 00028 00054 template < class TLabel, unsigned int VImageDimension > 00055 class ITK_EXPORT LabelObject : public LightObject 00056 { 00057 public: 00059 typedef LabelObject Self; 00060 typedef LightObject Superclass; 00061 typedef Self LabelObjectType; 00062 typedef SmartPointer<Self> Pointer; 00063 typedef SmartPointer<const Self> ConstPointer; 00064 typedef WeakPointer<const Self> ConstWeakPointer; 00065 00067 itkNewMacro(Self); 00068 00070 itkTypeMacro(LabelObject, LightObject); 00071 00072 itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension); 00073 00074 typedef Index< VImageDimension > IndexType; 00075 typedef TLabel LabelType; 00076 typedef LabelObjectLine< VImageDimension > LineType; 00077 typedef typename LineType::LengthType LengthType; 00078 typedef typename std::deque< LineType > LineContainerType; 00079 typedef unsigned int AttributeType; 00080 00081 enum 00082 { 00083 LABEL = 0 00084 }; 00085 00086 static AttributeType GetAttributeFromName( const std::string & s ); 00087 static std::string GetNameFromAttribute( const AttributeType & a ); 00088 00092 const LabelType & GetLabel() const; 00093 void SetLabel( const LabelType & label ); 00095 00100 bool HasIndex( const IndexType & idx ) const; 00101 00106 void AddIndex( const IndexType & idx ); 00107 00111 void AddLine( const IndexType & idx, const LengthType & length ); 00112 00116 void AddLine( const LineType & line ); 00117 00119 const LineContainerType & GetLineContainer() const; 00120 00121 LineContainerType & GetLineContainer(); 00122 00123 void SetLineContainer( const LineContainerType & lineContainer ); 00124 00125 int GetNumberOfLines() const; 00126 00127 const LineType & GetLine( int i ) const; 00128 00129 LineType & GetLine( int i ); 00130 00131 int Size() const; 00132 00133 IndexType GetIndex( int offset ) const; 00134 00136 virtual void CopyAttributesFrom( const Self * src ); 00137 00139 void CopyAllFrom( const Self * src ); 00140 00144 void Optimize(); 00145 00146 protected: 00147 LabelObject(); 00148 void PrintSelf(std::ostream& os, Indent indent) const; 00149 00150 private: 00151 LabelObject(const Self&); //purposely not implemented 00152 void operator=(const Self&); //purposely not implemented 00153 00154 LineContainerType m_LineContainer; 00155 LabelType m_Label; 00156 }; 00157 00158 } // end namespace itk 00159 00160 #ifndef ITK_MANUAL_INSTANTIATION 00161 #include "itkLabelObject.txx" 00162 #endif 00163 00164 #endif 00165