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 15 #ifndef ITKMetaIO_METADTITUBE_H 16 # define ITKMetaIO_METADTITUBE_H 17 18 19 # if defined(_MSC_VER) 20 # pragma warning(disable : 4786) 21 # pragma warning(disable : 4251) 22 # endif 23 24 # include "metaUtils.h" 25 # include "metaObject.h" 26 27 # include <list> 28 29 30 /*! MetaDTITube (.h and .cpp) 31 * 32 * Description: 33 * Reads and Writes MetaDTITubeFiles. 34 * 35 * \author Julien Jomier 36 * 37 * \date May 22, 2002 38 */ 39 40 # if (METAIO_USE_NAMESPACE) 41 namespace METAIO_NAMESPACE 42 { 43 # endif 44 45 class METAIO_EXPORT DTITubePnt 46 { 47 public: 48 typedef std::pair<std::string, float> FieldType; 49 typedef std::vector<FieldType> FieldListType; 50 51 explicit DTITubePnt(int dim); 52 53 ~DTITubePnt(); 54 55 const FieldListType & 56 GetExtraFields() const; 57 58 void 59 AddField(const char * name, float value); 60 61 float 62 GetField(const char * name) const; 63 64 unsigned int m_Dim; 65 float * m_X; 66 float * m_TensorMatrix; 67 68 FieldListType m_ExtraFields; 69 }; 70 71 72 class METAIO_EXPORT MetaDTITube : public MetaObject 73 { 74 75 // PUBLIC 76 public: 77 typedef std::list<DTITubePnt *> PointListType; 78 typedef std::pair<std::string, unsigned int> PositionType; 79 80 // Constructors & Destructor 81 MetaDTITube(); 82 83 explicit MetaDTITube(const char * _headerName); 84 85 explicit MetaDTITube(const MetaDTITube * _dtiTube); 86 87 explicit MetaDTITube(unsigned int dim); 88 89 ~MetaDTITube() override; 90 91 void 92 PrintInfo() const override; 93 94 void 95 CopyInfo(const MetaObject * _object) override; 96 97 // NPoints(...) 98 // Required Field 99 // Number of points which compose the DTITube 100 void 101 NPoints(int npnt); 102 int 103 NPoints() const; 104 105 // PointDim(...) 106 // Required Field 107 // Definition of points 108 void 109 PointDim(const char * pointDim); 110 const char * 111 PointDim() const; 112 113 // Root(...) 114 // Optional Field 115 // Set if this DTITube is a root 116 void 117 Root(bool root); 118 bool 119 Root() const; 120 121 122 // ParentPoint(...) 123 // Optional Field 124 // Set the point number of the parent DTITube where the branch occurs 125 void 126 ParentPoint(int parentpoint); 127 int 128 ParentPoint() const; 129 130 void 131 Clear() override; 132 133 PointListType & GetPoints()134 GetPoints() 135 { 136 return m_PointList; 137 } 138 const PointListType & GetPoints()139 GetPoints() const 140 { 141 return m_PointList; 142 } 143 144 MET_ValueEnumType 145 ElementType() const; 146 void 147 ElementType(MET_ValueEnumType _elementType); 148 149 // PROTECTED 150 protected: 151 bool m_ElementByteOrderMSB{}; 152 153 void 154 M_SetupReadFields() override; 155 156 void 157 M_SetupWriteFields() override; 158 159 bool 160 M_Read() override; 161 162 bool 163 M_Write() override; 164 165 int m_ParentPoint{}; // "ParentPoint = " -1 166 167 bool m_Root{}; // "Root = " False 168 169 int m_NPoints{}; // "NPoints = " 0 170 171 std::string m_PointDim; // "PointDim = " "x y z r" 172 173 PointListType m_PointList; 174 MET_ValueEnumType m_ElementType; 175 std::vector<PositionType> m_Positions; 176 177 int 178 GetPosition(const char *) const; 179 }; 180 181 # if (METAIO_USE_NAMESPACE) 182 }; 183 # endif 184 185 186 #endif 187