nullmask.h

Go to the documentation of this file.
00001 /***
00002  * \file rvc/nullmask.h 
00003  * \brief interface for the RVC::NULLMASK class.
00004  *
00005  * \if NODOC
00006  * $Id: nullmask.h_v 1.19 2005/08/19 14:39:10 scowan Exp $
00007  *
00008  * $Log: nullmask.h_v $
00009  * Revision 1.19  2005/08/19 14:39:10  scowan
00010  * Impolemented special copy object virtual method.
00011  *
00012  * Revision 1.18  2004/09/01 12:43:24  mju
00013  * Add 'allvalid' parm to Make().
00014  *
00015  * Revision 1.17  2004/08/31 17:46:14  scowan
00016  * Support cache size virtual methods.
00017  *
00018  * Revision 1.16  2004/07/20 17:23:07  scowan
00019  *  Added write method that takes a bool.
00020  *
00021  * Revision 1.15  2004/02/24 18:34:08  scowan
00022  * Simplified to only use binary masks.
00023  *
00024  * Revision 1.14  2003/11/21 22:17:07  scowan
00025  * Support new Capabilities system.
00026  *
00027  * Revision 1.13  2003/10/31 17:17:28  scowan
00028  * Added get object filter.
00029  *
00030  * Revision 1.12  2003/10/30 18:27:35  scowan
00031  * Updated pyramid creation.
00032  *
00033  * Revision 1.11  2003/10/23 21:25:15  scowan
00034  * Changed get pyramid list function.
00035  *
00036  * Revision 1.10  2003/10/07 17:32:19  scowan
00037  * Object virtual method changes.
00038  *
00039  * Revision 1.9  2003/09/30 16:52:06  dwilliss
00040  * Doxygen
00041  *
00042  * Revision 1.8  2003/09/25 21:20:04  dwilliss
00043  * Fixed doxygen comment
00044  *
00045  * Revision 1.7  2003/09/15 23:17:33  scowan
00046  * Support new set null value virtual method.
00047  *
00048  * Revision 1.6  2003/09/15 13:49:45  fileserver!dwilliss
00049  * Doxygen
00050  *
00051  * Revision 1.5  2003/08/27 21:26:37  scowan
00052  * Supports usage of rgba and argb raster cell types.
00053  *
00054  * Revision 1.4  2003/06/27 20:37:18  scowan
00055  * Updated to actually be useful.
00056  *
00057  * Revision 1.3  2003/05/07 15:20:30  scowan
00058  * Updated to new virtual method setting.
00059  *
00060  * Revision 1.2  2003/03/17 21:42:40  scowan
00061  * nc.
00062  *
00063  * Revision 1.1  2002/03/12 17:33:35  scowan
00064  * Initial revision
00065  *
00066  * \endif
00067 ***/
00068 
00069 //!   \class RVC::NULLMASK rvc/nullmask.h
00070 //!   \brief Manages RVC::OBJTYPE_Raster RVC::RASTER::USAGE_NullBand child 1-bit raster objects.
00071 //!   
00072 //!   RVC Object Types that this class supports: RVC::OBJTYPE_Raster (RVC::RASTER::USAGE_NullBand).
00073 //!
00074 //!   Default RVC Object Type for this class: RVC::OBJTYPE_Raster.
00075 //!
00076 //!   Valid parents for this class:
00077 //!      - RVC::OBJTYPE_Raster
00078 //!      - RVC::OBJTYPE_Hyperspectral
00079 //!      - RVC::OBJTYPE_RasterSet
00080 //!      - RVC::OBJTYPE_Thumbnail
00081 
00082 #ifndef INC_RVC_NULLMASK_H
00083 #define INC_RVC_NULLMASK_H
00084 
00085 #ifndef INC_RVC_RASTER_H
00086    #include <rvc/raster.h>
00087 #endif
00088 
00089 #ifndef INC_MI32_SIMPLEAR_H
00090    #include <mi32/simplear.h>
00091 #endif
00092 
00093 #ifndef GENERATING_DOXYGEN_OUTPUT
00094 class BITSET_UNOWNED;
00095 #endif // GENERATING_DOXYGEN_OUTPUT
00096 
00097 namespace RVC {
00098 
00099 class NULLMASK : public RVC::IMAGE {
00100    public:
00101       
00102       #ifndef GENERATING_DOXYGEN_OUTPUT
00103       class GETOBJFILTER_ISVALIDNULLMASK;
00104       class OBJECT_FILTER;
00105       #endif // GENERATING_DOXYGEN_OUTPUT
00106 
00107       //! Default constructor.
00108       NULLMASK (
00109          );
00110 
00111       //! Copy constructor.
00112       NULLMASK (
00113          const RVC::NULLMASK& rhs
00114          );
00115 
00116       //! Destructor
00117       virtual ~NULLMASK (
00118          );
00119 
00120       //! Assignment.
00121       RVC::NULLMASK& operator= (
00122          const RVC::NULLMASK& rhs
00123          );
00124 
00125       //! Obtain nullmask cell type.
00126       //! @return RVC::IMAGE::CELLTYPE of the raster
00127       IMAGE::CELLTYPE GetCellType (
00128          ) const { return (IMAGE::CELLTYPE_Binary); }
00129          
00130       //! Obtain number of columns in a nullmask tile
00131       //! @return number of columns in the nullmask tile
00132       INT32 GetNumTileColumns (
00133          ) const;
00134 
00135       //! Obtain number of lines in a nullmask tile
00136       //! @return number of lines in the nullmask tile
00137       INT32 GetNumTileLines (
00138          ) const;
00139 
00140       //! Obtain number of tiles in a nullmask row
00141       //! @return number of row tiles
00142       INT32 GetNumXTiles (
00143          ) const;
00144 
00145       //! Obtain number of tiles in a nullmask column
00146       //! @return number of column tiles
00147       INT32 GetNumYTiles (
00148          ) const;
00149 
00150       //! Return list of available raster pyramid sub-rasters.
00151       //!   The sample rate list will be sorted in ascending order and the array and list are aligned.
00152       ERRVALUE GetPyramidList (
00153          SIMPLE_ARRAY<INT32>& SampleList,       //!< Simple array of available sample rates RETURNED
00154          RVC::OBJITEMLIST& PyramidList          //!< List of pyramid raster NullMask ObjItem's RETURNED
00155          );
00156          
00157       //! Obtain number of bytes in a nullmask tile
00158       //! @return size of nullmask tile in bytes
00159       INT32 GetTileSizeBytes (
00160          ) const;
00161 
00162       //! Determine if a mask is present or the image has a null value defined
00163       //! @return 'True' if a meaningful null value or mask exists, 'false' otherwise
00164       bool HasNullValues (
00165          ) const;
00166 
00167       //! Create a null mask object under the RVC::IMAGE parent.
00168       //! If a null mask raster already exists, it will perform an Open(*this, OBJECT::OPENMODE_Write).
00169       //! If the parent raster has a null value set it will be used to initialize the mask, otherwise
00170       //! the initvalue parameter will determine the initial mask state.
00171       //! CellType == RVC::IMAGE::CELLTYPE_Binary
00172       //! Compression type == RVC::RASTER::COMPTYPE_RLE
00173       //! Tile Size == Same as parent
00174       //! Scale == Same as parent
00175       ERRVALUE Make (
00176          const RVC::IMAGE& parent,              //!< Parent object to create nullmask under
00177          bool initvalid,                        //!< Initialize to be all 'valid' if cannot determine from parent
00178          const char* Source = 0                 //!< Source of nullmask creation, default is GetAppName()
00179          );
00180 
00181       //! Create a null mask object under the RVC::IMAGE parent.
00182       //! If a null mask raster already exists, it will perform an Open(*this, OBJECT::OPENMODE_Write).
00183       //! If the parent raster has a null value set it will be used to initialize the mask, otherwise
00184       //! the initvalue parameter will determine the initial mask state.
00185       //! CellType == RVC::IMAGE::CELLTYPE_Binary
00186       //! Compression type == RVC::RASTER::COMPTYPE_RLE
00187       //! Tile Size == Same as parent
00188       //! Scale == Same as parent
00189       ERRVALUE Make (
00190          const RVC::OBJITEM& ObjItem,           //!< Parent object to create nullmask under
00191          bool initvalid,                        //!< Initialize to be all 'valid' if cannot determine from parent
00192          const char* Source = 0                 //!< Source of nullmask creation, default is GetAppName()
00193          );
00194 
00195       //! Create pyramid null mask set under the existing raster pyramids
00196       ERRVALUE MakePyramidSet (
00197          IMAGE::PYRAMID flags = IMAGE::PYRAMID_None
00198          );
00199 
00200       //! Open a null mask under the RVC::IMAGE parent.
00201       //! If a null mask cannot be found, it will use the null value from the parent 
00202       //! and treat it like a null mask
00203       ERRVALUE Open (
00204          const RVC::IMAGE& parent,              //!< Parent image object to open null mask under
00205          OBJECT::OPENMODE OpenMode = OBJECT::OPENMODE_Read
00206          );       
00207 
00208       //! Read a line of nullmask cells up to a certain length
00209       //! False values in the bitset are nulls
00210       //! @return '>0' if there can exist null values, '0' if all values are known to be not null, '<0' error
00211       int Read (
00212          INT32 Line,                            //!< Raster line to read
00213          INT32 StartColumn,                     //!< Raster column to start reading on
00214          BITSET_UNOWNED& data,                  //!< Buffer to read into
00215          INT32 Length = 1                       //!< Number of columns to read
00216          ) const;
00217 
00218       //! Read a line of nullmask cells up to a certain length
00219       //! Values == 0 are nulls, values == 255 are not
00220       //! @return '>0' if there can exist null values, '0' if all values are known to be not null, '<0' error
00221       int Read (
00222          INT32 Line,                            //!< Raster line to read
00223          INT32 StartColumn,                     //!< Raster column to start reading on
00224          UINT8 *data,                           //!< Buffer to read into
00225          INT32 Length = 1                       //!< Number of columns to read
00226          ) const;
00227 
00228       //! Read a column of nullmask cells up to a certain length
00229       //! False values in the bitset are nulls
00230       //! @return '>0' if there can exist null values, '0' if all values are known to be not null, '<0' error
00231       int ReadColumn (
00232          INT32 StartLine,                       //!< Raster line to start reading on
00233          INT32 Column,                          //!< Raster column to read
00234          BITSET_UNOWNED& data,                  //!< Buffer to read into
00235          INT32 Length = 1                       //!< Number of lines to read
00236          ) const;
00237 
00238       //! Read a column of nullmask cells up to a certain length
00239       //! Values == 0 are nulls, values == 255 are not
00240       //! @return '>0' if there can exist null values, '0' if all values are known to be not null, '<0' error
00241       int ReadColumn (
00242          INT32 StartLine,                       //!< Raster line to start reading on
00243          INT32 Column,                          //!< Raster column to read
00244          UINT8 *data,                           //!< Buffer to read into
00245          INT32 Length = 1                       //!< Number of lines to read
00246          ) const;
00247 
00248       //! Write a line of nullmask cells up to a certain length
00249       //! If the null values are from the parent image, a NullMask raster will
00250       //! be created under the parent image with a celltype of IMAGE::CELLTYPE_Binary, the
00251       //! current null values setup in the new object, then the buffer will be written
00252       ERRVALUE Write (
00253          INT32 Line,                            //!< Raster line to write
00254          INT32 StartColumn,                     //!< Raster column to start writing on
00255          BITSET_UNOWNED& data,            //!< Buffer to write from
00256          INT32 Length = 1                       //!< Number of columns to write
00257          );
00258 
00259       //! Write a line of nullmask cells up to a certain length.
00260       //! If the null values are from the parent image, a NullMask raster will
00261       //! be created under the parent image with a celltype of IMAGE::CELLTYPE_Binary, the
00262       //! current null values setup in the new object, then the buffer will be written
00263       ERRVALUE Write (
00264          INT32 Line,                            //!< Raster line to write
00265          INT32 StartColumn,                     //!< Raster column to start writing on
00266          UINT8* data,                  //!< Buffer to write from
00267          INT32 Length = 1                       //!< Number of columns to write
00268          );
00269 
00270       //! Write a line of nullmask values up to a certain length
00271       //! If the null values are from the parent image, a NullMask raster will
00272       //! be created under the parent image with a celltype of IMAGE::CELLTYPE_Binary, the
00273       //! current null values setup in the new object, then the buffer will be written
00274       ERRVALUE Write (
00275          INT32 Line,                            //!< Raster line to write
00276          INT32 StartColumn,                     //!< Raster column to start writing on
00277          bool valid,                            //!< Value to write, 'true' for valid, 'false' for not valid
00278          INT32 Length = 1                       //!< Number of columns to write
00279          );
00280 
00281    private:
00282       #ifndef GENERATING_DOXYGEN_OUTPUT
00283 
00284       IMAGE* m_Image;         //!< Open image object
00285       RASTER m_MaskObj;       //!< Open raster mask object
00286       NULLVALUE m_NullValue;
00287       bool m_HasNullValue;
00288       IMAGE::CELLTYPE m_ParentCellType;
00289       mutable SIMPLE_ARRAY<UINT8> m_Buffer;
00290       class NULLOBSERVER;
00291       friend class NULLOBSERVER;
00292       NULLOBSERVER* m_Observer;
00293       SIMPLE_ARRAY<UINT8> m_TrueBuffer;
00294       SIMPLE_ARRAY<UINT8> m_FalseBuffer;
00295       
00296       //! Implementation of RVC::OBJECT virtual methods
00297       virtual ERRVALUE v_CloseObject ();
00298       virtual ERRVALUE v_CopyObject (RVC::OBJECT& DestParentObj, RVC::OBJECT& DestObj, FILTER* filter, COPYFLAGS CopyFlags) const;
00299       virtual RVC::OBJTYPE v_GetDftObjectType () const;
00300       virtual bool v_IsObjectOpen () const;              
00301       virtual ERRVALUE v_OpenObject (OPENMODE OpenFlags, MDLGPARENT parent);
00302          
00303       //! Implementation of RVC::GEOSPATIAL virtual methods
00304       virtual void v_GetExtents (DRECT3D &extents) const;
00305       virtual void v_GetScale (double& xscale, double& yscale) const;
00306       virtual double v_GetZScale () const;
00307       virtual double v_GetZOffset () const;
00308       virtual bool v_HasCapability (int Capability) const;
00309       virtual void v_SetScale (double xscale, double yscale);
00310       virtual void v_SetZScale (double zscale);
00311       virtual void v_SetZOffset (double zoffset);
00312       
00313       //! Implementation of RVC::IMAGE virtual methods
00314       virtual ERRVALUE v_GetBandParms (INT32 BandNum, BANDPARMS& BandParms) const;
00315       virtual double v_GetColumnScale () const;
00316       virtual double v_GetLineScale () const;
00317       virtual ERRVALUE v_GetNullValue (INT32 BandNum, NULLVALUE& NullValue) const;
00318       virtual INT32 v_GetNumBands () const;
00319       virtual INT32 v_GetNumColumns () const;
00320       virtual INT32 v_GetNumLines () const;
00321       virtual bool v_HasNullValue (INT32 BandNum) const;
00322       virtual ERRVALUE v_ReadBand (INT32 Band, INT32 Line, INT32 StartColumn, void *data, INT32 Length, CONVMODE Convert) const;
00323       virtual ERRVALUE v_ReadColumnBand (INT32 Band, INT32 Line, INT32 StartColumn, void *data, INT32 Length, CONVMODE Convert) const;
00324       virtual ERRVALUE v_SetCacheSize (INT32 NumTiles);
00325       virtual ERRVALUE v_SetCacheSize (CACHEMODE CacheFlags);
00326       virtual ERRVALUE v_SetNullValue (INT32 BandNum, const NULLVALUE* NullValue);
00327       virtual ERRVALUE v_WriteBand (INT32 Band, INT32 Line, INT32 StartColumn, void *data, INT32 Length, CONVMODE Convert);
00328       #endif // GENERATING_DOXYGEN_OUTPUT
00329 
00330    };
00331 
00332 
00333 //! Convenience filter for raster null mask selection.  
00334 //! Valid null mask raster selection is based on the size of the image to select for
00335 class NULLMASK::GETOBJFILTER_ISVALIDNULLMASK : public GETOBJFILTER {
00336    public:
00337       explicit GETOBJFILTER_ISVALIDNULLMASK (
00338          const RASTER& RastObj
00339          );
00340          
00341       explicit GETOBJFILTER_ISVALIDNULLMASK (
00342          const RASTER::MAKEPARMS& MakeParms
00343          );
00344          
00345       GETOBJFILTER_ISVALIDNULLMASK (
00346          INT32 NumLines,
00347          INT32 NumColumns
00348          );
00349          
00350    private:
00351       INT32 m_NumLines;
00352       INT32 m_NumColumns;
00353       
00354       virtual bool v_HasSelectableSubObjects (const RVC::OBJITEM& objitem);
00355       virtual bool v_IsSelectable (const RVC::OBJITEM& objitem, int position = -1);
00356    };
00357    
00358 
00359 //! Object filter for finding NULLMASK raster objects
00360 class NULLMASK::OBJECT_FILTER : public OBJECT::FILTER {
00361    public:
00362       OBJECT_FILTER () {}
00363    private:
00364       #ifndef GENERATING_DOXYGEN_OUTPUT
00365       virtual bool Filter (const RVC::OBJECT& obj);
00366       #endif // GENERATING_DOXYGEN_OUTPUT
00367    };
00368 
00369 }     //! End of RVC namespace
00370 
00371 #endif      //!< INC_RVC_NULLMASK_H
00372 

Generated on Wed May 31 15:27:25 2006 for TNTsdk by  doxygen 1.3.8-20040913