00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkPolygonGroupSpatialObjectXMLFile.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/01/21 20:19: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 __tkPolygonGroupSpatialObjectXMLFile_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: 00058 virtual int CanReadFile(const char* name); 00059 protected: 00060 virtual void StartElement(const char * name,const char **atts); 00061 virtual void EndElement(const char *name); 00062 virtual void CharacterDataHandler(const char *inData, int inLength); 00063 private: 00064 PGroupSpatialObjectType::Pointer m_PGroup; 00065 PolygonSpatialObjectType::Pointer m_CurPoly; 00066 PointListType m_CurPointList; 00067 std::string m_CurCharacterData; 00068 }; 00069 00075 class PolygonGroupSpatialObjectXMLFileWriter : 00076 public XMLWriterBase<PGroupSpatialObjectType> 00077 { 00078 public: 00080 typedef XMLWriterBase<PGroupSpatialObjectType> Superclass; 00081 typedef PolygonGroupSpatialObjectXMLFileWriter Self; 00082 typedef SmartPointer<Self> Pointer; 00084 itkNewMacro(Self); 00086 itkTypeMacro(PolygonGroupSpatialObjectXMLFileWriter, 00087 XMLWriterBase<PGroupSpatialObjectType>); 00088 typedef PGroupSpatialObjectType PolygonGroupType; 00089 typedef PolygonSpatialObject<3> PolygonSpatialObjectType; 00091 virtual int CanWriteFile(const char* name); 00093 virtual int WriteFile(); 00094 }; 00095 00096 } 00097 #endif