ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkPolygonGroupSpatialObjectXMLFile_h 00019 #define __itkPolygonGroupSpatialObjectXMLFile_h 00020 00021 00022 #include "itkPolygonGroupSpatialObject.h" 00023 #include "itkXMLFile.h" 00024 namespace itk 00025 { 00026 /* 3D Polygon Groups only ones that make sense for this data type */ 00027 typedef PolygonGroupSpatialObject< 3 > PGroupSpatialObjectType; 00028 00035 class ITK_EXPORT PolygonGroupSpatialObjectXMLFileReader: 00036 public XMLReader< PGroupSpatialObjectType > 00037 { 00038 public: 00040 typedef PolygonGroupSpatialObjectXMLFileReader Self; 00041 typedef XMLReader< PGroupSpatialObjectType > Superclass; 00042 typedef SmartPointer< Self > Pointer; 00043 00044 typedef PGroupSpatialObjectType PolygonGroupType; 00045 typedef PolygonSpatialObject< 3 > PolygonSpatialObjectType; 00046 typedef SpatialObjectPoint< 3 > PointType; 00047 typedef std::vector< PointType > PointListType; 00048 00050 itkTypeMacro(PolygonGroupSpatialObjectXMLFileReader, XMLReader); 00051 00053 itkNewMacro(Self); 00054 public: 00055 00057 virtual int CanReadFile(const char *name); 00058 00059 protected: 00060 PolygonGroupSpatialObjectXMLFileReader() {} 00061 virtual ~PolygonGroupSpatialObjectXMLFileReader() {} 00062 00063 virtual void StartElement(const char *name, const char **atts); 00064 00065 virtual void EndElement(const char *name); 00066 00067 virtual void CharacterDataHandler(const char *inData, int inLength); 00068 00069 private: 00070 PolygonGroupSpatialObjectXMLFileReader(const Self &); //purposely not 00071 // implemented 00072 void operator=(const Self &); //purposely not 00073 // implemented 00074 00075 PGroupSpatialObjectType::Pointer m_PGroup; 00076 PolygonSpatialObjectType::Pointer m_CurPoly; 00077 PointListType m_CurPointList; 00078 std::string m_CurCharacterData; 00079 }; 00080 00087 class ITK_EXPORT PolygonGroupSpatialObjectXMLFileWriter: 00088 public XMLWriterBase< PGroupSpatialObjectType > 00089 { 00090 public: 00092 typedef XMLWriterBase< PGroupSpatialObjectType > Superclass; 00093 typedef PolygonGroupSpatialObjectXMLFileWriter Self; 00094 typedef SmartPointer< Self > Pointer; 00095 00097 itkNewMacro(Self); 00098 00100 itkTypeMacro(PolygonGroupSpatialObjectXMLFileWriter, 00101 XMLWriterBase< PGroupSpatialObjectType > ); 00102 typedef PGroupSpatialObjectType PolygonGroupType; 00103 typedef PolygonSpatialObject< 3 > PolygonSpatialObjectType; 00104 00106 virtual int CanWriteFile(const char *name); 00107 00109 virtual int WriteFile(); 00110 00111 protected: 00112 PolygonGroupSpatialObjectXMLFileWriter() {} 00113 virtual ~PolygonGroupSpatialObjectXMLFileWriter() {} 00114 private: 00115 PolygonGroupSpatialObjectXMLFileWriter(const Self &); //purposely not 00116 // implemented 00117 void operator=(const Self &); //purposely not 00118 // implemented 00119 }; 00120 } 00121 #endif 00122