1 /*============================================================================ 2 MetaIO 3 Copyright 2000-2010 Insight Software Consortium 4 5 Distributed under the OSI-approved BSD License (the "License"); 6 see accompanying file Copyright.txt for details. 7 8 This software is distributed WITHOUT ANY WARRANTY; without even the 9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 See the License for more information. 11 ============================================================================*/ 12 #include "metaTypes.h" 13 14 #ifndef ITKMetaIO_METATUBEGRAPH_H 15 # define ITKMetaIO_METATUBEGRAPH_H 16 17 # include "metaUtils.h" 18 # include "metaObject.h" 19 20 # ifdef _MSC_VER 21 # pragma warning(disable : 4251) 22 # endif 23 24 # include <vector> 25 26 27 /*! MetaTubeGraph (.h and .cpp) 28 * 29 * Description: 30 * Reads and Writes MetaTubeGraph Files. 31 * 32 * \author Julien Jomier 33 * 34 * \date May 22, 2002 35 */ 36 37 # if (METAIO_USE_NAMESPACE) 38 namespace METAIO_NAMESPACE 39 { 40 # endif 41 42 class TubeGraphPnt 43 { 44 public: TubeGraphPnt(int dim)45 explicit TubeGraphPnt(int dim) 46 { 47 m_Dim = static_cast<unsigned int>(dim); 48 m_GraphNode = -1; 49 m_R = 0; 50 m_P = 0; 51 m_T = new float[m_Dim * m_Dim]; 52 } 53 ~TubeGraphPnt()54 ~TubeGraphPnt() { delete[] m_T; } 55 56 unsigned int m_Dim; 57 int m_GraphNode; 58 float m_R; 59 float m_P; 60 float * m_T; 61 }; 62 63 64 class METAIO_EXPORT MetaTubeGraph : public MetaObject 65 { 66 67 // PUBLIC 68 public: 69 typedef std::vector<TubeGraphPnt *> PointListType; 70 // Constructors & Destructor 71 MetaTubeGraph(); 72 73 explicit MetaTubeGraph(const char * _headerName); 74 75 explicit MetaTubeGraph(const MetaTubeGraph * _tube); 76 77 explicit MetaTubeGraph(unsigned int dim); 78 79 ~MetaTubeGraph() override; 80 81 void 82 PrintInfo() const override; 83 84 void 85 CopyInfo(const MetaObject * _object) override; 86 87 // NPoints(...) 88 // Required Field 89 // Number of points which compose the tube 90 void 91 NPoints(int npnt); 92 int 93 NPoints() const; 94 95 // PointDim(...) 96 // Required Field 97 // Definition of points 98 void 99 PointDim(const char * pointDim); 100 const char * 101 PointDim() const; 102 103 // Root(...) 104 // Optional Field 105 // Set if this tube is a root 106 void 107 Root(int root); 108 int 109 Root() const; 110 111 112 void 113 Clear() override; 114 115 PointListType & GetPoints()116 GetPoints() 117 { 118 return m_PointList; 119 } 120 const PointListType & GetPoints()121 GetPoints() const 122 { 123 return m_PointList; 124 } 125 126 MET_ValueEnumType 127 ElementType() const; 128 void 129 ElementType(MET_ValueEnumType _elementType); 130 131 // PROTECTED 132 protected: 133 134 void 135 M_SetupReadFields() override; 136 137 void 138 M_SetupWriteFields() override; 139 140 bool 141 M_Read() override; 142 143 bool 144 M_Write() override; 145 146 int m_Root{}; // "Root = " 0 147 148 int m_NPoints{}; // "NPoints = " 0 149 150 char m_PointDim[255]{}; // "PointDim = " "x y z r" 151 152 PointListType m_PointList; 153 154 MET_ValueEnumType m_ElementType; 155 }; 156 157 # if (METAIO_USE_NAMESPACE) 158 }; 159 # endif 160 161 #endif 162