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 #endif
40 
41 class TubeGraphPnt
42 {
43 public:
44 
TubeGraphPnt(int dim)45   TubeGraphPnt(int dim)
46   {
47     m_Dim = 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()
55   {
56     delete [] m_T;
57   }
58 
59   unsigned int m_Dim;
60   int    m_GraphNode;
61   float  m_R;
62   float  m_P;
63   float* m_T;
64 };
65 
66 
67 
68 
69 class METAIO_EXPORT MetaTubeGraph : public MetaObject
70   {
71 
72   /////
73   //
74   // PUBLIC
75   //
76   ////
77   public:
78 
79    typedef METAIO_STL::vector<TubeGraphPnt*> PointListType;
80     ////
81     //
82     // Constructors & Destructor
83     //
84     ////
85     MetaTubeGraph(void);
86 
87     MetaTubeGraph(const char *_headerName);
88 
89     MetaTubeGraph(const MetaTubeGraph *_tube);
90 
91     MetaTubeGraph(unsigned int dim);
92 
93     ~MetaTubeGraph(void) MET_OVERRIDE;
94 
95     void PrintInfo(void) const MET_OVERRIDE;
96 
97     void CopyInfo(const MetaObject * _object) MET_OVERRIDE;
98 
99     //    NPoints(...)
100     //       Required Field
101     //       Number of points wich compose the tube
102     void  NPoints(int npnt);
103     int   NPoints(void) const;
104 
105     //    PointDim(...)
106     //       Required Field
107     //       Definition of points
108     void        PointDim(const char* pointDim);
109     const char* PointDim(void) const;
110 
111     //    Root(...)
112     //       Optional Field
113     //       Set if this tube is a root
114     void  Root(int root);
115     int   Root(void) const;
116 
117 
118     void  Clear(void) MET_OVERRIDE;
119 
GetPoints(void)120     PointListType &  GetPoints(void) {return m_PointList;}
GetPoints(void)121     const PointListType &  GetPoints(void) const {return m_PointList;}
122 
123     MET_ValueEnumType ElementType(void) const;
124     void  ElementType(MET_ValueEnumType _elementType);
125 
126   ////
127   //
128   // PROTECTED
129   //
130   ////
131   protected:
132 
133     void  M_Destroy(void) MET_OVERRIDE;
134 
135     void  M_SetupReadFields(void) MET_OVERRIDE;
136 
137     void  M_SetupWriteFields(void) MET_OVERRIDE;
138 
139     bool  M_Read(void) MET_OVERRIDE;
140 
141     bool  M_Write(void) MET_OVERRIDE;
142 
143     int m_Root;         // "Root = "            0
144 
145     int m_NPoints;      // "NPoints = "         0
146 
147     char m_PointDim[255]; // "PointDim = "       "x y z r"
148 
149     PointListType m_PointList;
150 
151     MET_ValueEnumType m_ElementType;
152   };
153 
154 #if (METAIO_USE_NAMESPACE)
155 };
156 #endif
157 
158 #endif
159