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_METABLOB_H
15 #  define ITKMetaIO_METABLOB_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 /*!    MetaBlob (.h and .cxx)
28  *
29  * Description:
30  *    Reads and Writes MetaBlobFiles.
31  *
32  * \author Julien Jomier
33  *
34  * \date July 02, 2002
35  *
36  * Depends on:
37  *    MetaUtils.h
38  *    MetaFileLib.h
39  */
40 
41 #  if (METAIO_USE_NAMESPACE)
42 namespace METAIO_NAMESPACE
43 {
44 #  endif
45 
46 class METAIO_EXPORT BlobPnt
47 {
48 public:
49   explicit BlobPnt(int dim);
50   ~BlobPnt();
51 
52   unsigned int m_Dim;
53   float *      m_X;
54   float        m_Color[4]{};
55 };
56 
57 
58 class METAIO_EXPORT MetaBlob : public MetaObject
59 {
60 
61   // PUBLIC
62 public:
63   typedef std::list<BlobPnt *> PointListType;
64   // Constructors & Destructor
65   MetaBlob();
66 
67   explicit MetaBlob(const char * _headerName);
68 
69   explicit MetaBlob(const MetaBlob * _blob);
70 
71   explicit MetaBlob(unsigned int dim);
72 
73   ~MetaBlob() override;
74 
75   void
76   PrintInfo() const override;
77 
78   void
79   CopyInfo(const MetaObject * _object) override;
80 
81   //    NPoints(...)
82   //       Required Field
83   //       Number of points which compose the blob
84   void
85   NPoints(size_t npnt);
86   size_t
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   size_t 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 #endif
147