1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGDBIMAGEFILETYPE_H_
40 #define _OSGDBIMAGEFILETYPE_H_
45 #include "OSGImageFileIODef.h"
46 #include "OSGImageFileType.h"
48 #include "boost/shared_ptr.hpp"
53 class DBImageFileType
;
55 /*! \ingroup GrpImageFileIODB
59 class DBHeaderParameter
67 DBHeaderParameter(void);
68 virtual ~DBHeaderParameter(void);
70 void setLastParam(void);
71 bool isLastParam (void);
73 virtual void convert(const Char8
*str
) = 0;
76 /*! \ingroup GrpImageFileIODB
80 class DBHeaderIntParameter
: public DBHeaderParameter
82 typedef DBHeaderParameter Inherited
;
90 DBHeaderIntParameter(UInt32
&uiParam
);
91 virtual ~DBHeaderIntParameter(void);
93 virtual void convert(const Char8
*str
);
96 /*! \ingroup GrpImageFileIODB
100 class DBHeaderFloatParameter
: public DBHeaderParameter
102 typedef DBHeaderParameter Inherited
;
110 DBHeaderFloatParameter(Real32
&rParam
);
111 virtual ~DBHeaderFloatParameter(void);
113 virtual void convert(const Char8
*str
);
116 /*! \ingroup GrpImageFileIODB
122 UInt32 uiMagic
; //=13048 ::: magic number
123 UInt32 uiXSize
; //=%u ::: mandatory width
124 UInt32 uiYSize
; //=%u ::: mandatory height for 2+D, 1 for 1D data
125 UInt32 uiZSize
; //=%u ::: mandatory depth for 3+D, 1 for 1D and 2D data
126 UInt32 uiTSteps
; //=%u ::: mandatory number of time steps for 4D,
127 // 1 for 1D, 2D and 3D data
129 UInt32 uiType
; //=%u ::: mandatory cell type: 0 = unsigned byte, 1 =
130 //signed short, 2 = float, 3 = RGB, 4 = RGBA, 5 =
131 //compressed RGB (S3TC DXT1), 6 = compressed RGBA (S3TC
132 //DXT1 with 1-bit alpha)
134 Real32 rSWx
; //%g ::: x-component of south west corner (should
135 //%be supplied for tile sets)
136 Real32 rSWy
; //=%g ::: y-component of south west corner (should
137 //be supplied for tile sets)
138 Real32 rNWx
; //=%g ::: x-component of north west corner (should
139 //be supplied for tile sets)
140 Real32 rNWy
; //=%g ::: y-component of north west corner (should
141 //be supplied for tile sets)
143 Real32 rNEx
; //=%g ::: x-component of north east corner (should
144 //be supplied for tile sets)
145 Real32 rNEy
; //=%g ::: y-component of north east corner (should
146 //be supplied for tile sets)
147 Real32 rSEx
; //=%g ::: x-component of south east corner (should
148 //be supplied for tile sets)
149 Real32 rSEy
; //=%g ::: y-component of south east corner (should
150 //be supplied for tile sets)
151 Real32 rH0
; //=%g ::: base elevation of 3D or 4D data cube
152 Real32 rDh
; //=%g ::: height of the 3D or 4D cube
153 Real32 rT0
; //=%g ::: starting time of 4D series
154 Real32 rDt
; //=%g ::: time step of 4D series
156 Real32 rScaling
; //=%g ::: elevation scaling parameter for height fields
158 Real32 rBias
; //=%g ::: elevation bias parameter for height fields
161 UInt32 uiExtFormat
; //=%u ::: external format indicator: a value!=0
162 //triggers conversion hook (default 0, 1 reserved for
164 UInt32 uiImplFormat
;//implicit format indicator
167 Real32 LLWGS84_rSWx
;//%g ::: x-component of south west corner (should
168 //%be supplied for tile sets)
169 Real32 LLWGS84_rSWy
;//=%g ::: y-component of south west corner (should
170 //be supplied for tile sets)
171 Real32 LLWGS84_rNWx
;//=%g ::: x-component of north west corner (should
172 //be supplied for tile sets)
173 Real32 LLWGS84_rNWy
;//=%g ::: y-component of north west corner (should
174 //be supplied for tile sets)
176 Real32 LLWGS84_rNEx
;//=%g ::: x-component of north east corner (should
177 //be supplied for tile sets)
178 Real32 LLWGS84_rNEy
;//=%g ::: y-component of north east corner (should
179 //be supplied for tile sets)
180 Real32 LLWGS84_rSEx
;//=%g ::: x-component of south east corner (should
181 //be supplied for tile sets)
182 Real32 LLWGS84_rSEy
;//=%g ::: y-component of south east corner (should
183 //be supplied for tile sets)
185 UInt32 uiBytes
; //=%u ::: mandatory byte length of the following
188 typedef std::map
<std::string
, DBHeaderParameter
*> ParameterMap
;
190 ParameterMap _mParams
;
195 bool read(FILE *pIn
);
196 void dump(void ) const;
199 /*! \ingroup GrpImageFileIODB
200 \ingroup GrpLibOSGImageFileIO
203 class OSG_IMGFILEIO_DLLMAPPING DBBlockAccessor
: public ImageBlockAccessor
206 /*========================== PUBLIC =================================*/
210 typedef ImageBlockAccessor Inherited
;
212 /*---------------------------------------------------------------------*/
213 /*! \name Destructor */
216 virtual ~DBBlockAccessor(void);
219 /*---------------------------------------------------------------------*/
220 /*! \name Read/Write */
223 virtual bool isOpen(void);
226 /*---------------------------------------------------------------------*/
227 /*! \name Read/Write */
230 virtual bool readBlockA16(Vec2i vSampleOrigin
,
233 Int32 iTargetSizeBytes
);
235 virtual bool readBlockA16(Vec2i vSampleOrigin
,
238 Int32 iTargetSizeBytes
);
241 /*========================= PROTECTED ===============================*/
245 /*---------------------------------------------------------------------*/
246 /*! \name Default Constructor */
249 DBBlockAccessor(void);
252 /*---------------------------------------------------------------------*/
253 /*! \name Read/Write */
256 void open(const Char8
*szFilename
);
259 /*---------------------------------------------------------------------*/
260 /*! \name Read/Write */
264 /*========================== PRIVATE ================================*/
268 friend class DBImageFileType
;
271 /*! \ingroup GrpImageFileIODB
274 typedef boost::shared_ptr
<DBBlockAccessor
> DBBlockAccessorPtr
;
276 /*! \brief GDAL File Handler. Used to read/write TIFF files.
277 See \ref PageSystemImage for a detailed description.
279 \ingroup GrpImageFileIODB
280 \ingroup GrpLibOSGImageFileIO
283 class OSG_IMGFILEIO_DLLMAPPING DBImageFileType
: public ImageFileType
285 /*========================== PUBLIC =================================*/
289 /*---------------------------------------------------------------------*/
290 /*! \name Destructor */
293 virtual ~DBImageFileType(void);
296 /*---------------------------------------------------------------------*/
297 /*! \name Read/Write */
300 virtual bool read ( Image
*pImage
,
301 const Char8
*fileName
) ;
303 virtual bool write (const Image
*pImage
,
304 const Char8
*fileName
) ;
306 virtual bool validateHeader(const Char8
*fileName
,
310 /*---------------------------------------------------------------------*/
315 virtual ImageBlockAccessorPtr
open(const Char8
*fileName
);
319 /*========================= PROTECTED ===============================*/
323 /*---------------------------------------------------------------------*/
324 /*! \name Default Constructor */
327 DBImageFileType (const Char8
*mimeType
,
328 const Char8
*suffixArray
[],
329 UInt16 suffixByteCount
,
333 /*---------------------------------------------------------------------*/
337 DBImageFileType (const DBImageFileType
&obj
);
338 const DBImageFileType
&operator =(const DBImageFileType
&obj
);
341 /*========================== PRIVATE ================================*/
345 typedef ImageFileType Inherited
;
347 static DBImageFileType _the
;
350 typedef DBImageFileType
*DBImageFileTypeP
;
354 #endif // _OSGDBIMAGEFILETYPE_H_