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_METALINE_H
15 #  define ITKMetaIO_METALINE_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 <list>
25 
26 
27 /*!    MetaLine (.h and .cxx)
28  *
29  * Description:
30  *    Reads and Writes MetaLineFiles.
31  *
32  * \author Julien Jomier
33  *
34  * \date July 02, 2002
35  *
36  */
37 
38 #  if (METAIO_USE_NAMESPACE)
39 namespace METAIO_NAMESPACE
40 {
41 #  endif
42 
43 class LinePnt
44 {
45 public:
46   explicit LinePnt(int dim);
47 
48   ~LinePnt();
49 
50   unsigned int m_Dim;
51   float *      m_X;
52   float **     m_V;
53   float        m_Color[4]{};
54 };
55 
56 
57 class METAIO_EXPORT MetaLine : public MetaObject
58 {
59 
60   // PUBLIC
61 public:
62   typedef std::list<LinePnt *> PointListType;
63   // Constructors & Destructor
64   MetaLine();
65 
66   explicit MetaLine(const char * _headerName);
67 
68   explicit MetaLine(const MetaLine * _line);
69 
70   explicit MetaLine(unsigned int dim);
71 
72   ~MetaLine() override;
73 
74   void
75   PrintInfo() const override;
76 
77   void
78   CopyInfo(const MetaObject * _object) override;
79 
80 
81   //    NPoints(...)
82   //       Required Field
83   //       Number of points which compose the line
84   void
85   NPoints(int npnt);
86   int
87   NPoints() const;
88 
89   //    PointDim(...)
90   //       Required Field
91   //       Definition of points
92   void
93   PointDim(const char * pointDim);
94   const char *
95   PointDim() const;
96 
97 
98   void
99   Clear() override;
100 
101   PointListType &
GetPoints()102   GetPoints()
103   {
104     return m_PointList;
105   }
106   const PointListType &
GetPoints()107   GetPoints() const
108   {
109     return m_PointList;
110   }
111 
112   MET_ValueEnumType
113   ElementType() const;
114   void
115   ElementType(MET_ValueEnumType _elementType);
116 
117   // PROTECTED
118 protected:
119   bool m_ElementByteOrderMSB{};
120 
121   void
122   M_SetupReadFields() override;
123 
124   void
125   M_SetupWriteFields() override;
126 
127   bool
128   M_Read() override;
129 
130   bool
131   M_Write() override;
132 
133   int m_NPoints{}; // "NPoints = "         0
134 
135   char m_PointDim[255]{}; // "PointDim = "       "x y z r"
136 
137   PointListType m_PointList;
138 
139   MET_ValueEnumType m_ElementType;
140 };
141 
142 #  if (METAIO_USE_NAMESPACE)
143 };
144 #  endif
145 
146 
147 #endif
148