00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkPolygonGroupSpatialObjectXMLFile.h,v $ 00005 Language: C++ 00006 Date: $Date: 2008-05-13 18:48:32 $ 00007 Version: $1.0$ 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 __itkPolygonGroupSpatialObjectXMLFile_h 00018 #define __itkPolygonGroupSpatialObjectXMLFile_h 00019 00020 #ifdef _MSC_VER 00021 #pragma warning ( disable : 4786 ) 00022 #endif 00023 00024 #include "itkPolygonGroupSpatialObject.h" 00025 #include "itkXMLFile.h" 00026 namespace itk 00027 { 00028 00029 /* 3D Polygon Groups only ones that make sense for this data type */ 00030 typedef PolygonGroupSpatialObject<3> PGroupSpatialObjectType; 00031 00037 class PolygonGroupSpatialObjectXMLFileReader : 00038 public XMLReader<PGroupSpatialObjectType> 00039 { 00040 public: 00042 typedef PolygonGroupSpatialObjectXMLFileReader Self; 00043 typedef XMLReader<PGroupSpatialObjectType> Superclass; 00044 typedef SmartPointer<Self> Pointer; 00045 00046 typedef PGroupSpatialObjectType PolygonGroupType; 00047 typedef PolygonSpatialObject<3> PolygonSpatialObjectType; 00048 typedef SpatialObjectPoint<3> PointType; 00049 typedef std::vector<PointType> PointListType; 00050 00052 itkTypeMacro(PolygonGroupSpatialObjectXMLFileReader, XMLReader); 00053 00055 itkNewMacro(Self); 00056 public: 00057 00059 virtual int CanReadFile(const char* name); 00060 protected: 00061 PolygonGroupSpatialObjectXMLFileReader() {}; 00062 virtual ~PolygonGroupSpatialObjectXMLFileReader() {}; 00064 00065 virtual void StartElement(const char * name,const char **atts); 00066 virtual void EndElement(const char *name); 00067 virtual void CharacterDataHandler(const char *inData, int inLength); 00068 private: 00069 PolygonGroupSpatialObjectXMLFileReader(const Self&); //purposely not implemented 00070 void operator=(const Self&); //purposely not implemented 00071 00072 PGroupSpatialObjectType::Pointer m_PGroup; 00073 PolygonSpatialObjectType::Pointer m_CurPoly; 00074 PointListType m_CurPointList; 00075 std::string m_CurCharacterData; 00076 }; 00077 00083 class PolygonGroupSpatialObjectXMLFileWriter : 00084 public XMLWriterBase<PGroupSpatialObjectType> 00085 { 00086 public: 00088 typedef XMLWriterBase<PGroupSpatialObjectType> Superclass; 00089 typedef PolygonGroupSpatialObjectXMLFileWriter Self; 00090 typedef SmartPointer<Self> Pointer; 00091 00093 itkNewMacro(Self); 00094 00096 itkTypeMacro(PolygonGroupSpatialObjectXMLFileWriter, 00097 XMLWriterBase<PGroupSpatialObjectType>); 00098 typedef PGroupSpatialObjectType PolygonGroupType; 00099 typedef PolygonSpatialObject<3> PolygonSpatialObjectType; 00100 00102 virtual int CanWriteFile(const char* name); 00103 00105 virtual int WriteFile(); 00106 protected: 00107 PolygonGroupSpatialObjectXMLFileWriter() {}; 00108 virtual ~PolygonGroupSpatialObjectXMLFileWriter() {}; 00109 private: 00110 PolygonGroupSpatialObjectXMLFileWriter(const Self&); //purposely not implemented 00111 void operator=(const Self&); //purposely not implemented 00113 00114 }; 00115 00116 } 00117 #endif 00118