GDAL
|
00001 /****************************************************************************** 00002 * $Id: gdal_alg_priv.h 28826 2015-03-30 17:51:14Z rouault $ 00003 * 00004 * Project: GDAL Image Processing Algorithms 00005 * Purpose: Prototypes and definitions for various GDAL based algorithms: 00006 * private declarations. 00007 * Author: Andrey Kiselev, dron@ak4719.spb.edu 00008 * 00009 ****************************************************************************** 00010 * Copyright (c) 2008, Andrey Kiselev <dron@ak4719.spb.edu> 00011 * Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org> 00012 * 00013 * Permission is hereby granted, free of charge, to any person obtaining a 00014 * copy of this software and associated documentation files (the "Software"), 00015 * to deal in the Software without restriction, including without limitation 00016 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00017 * and/or sell copies of the Software, and to permit persons to whom the 00018 * Software is furnished to do so, subject to the following conditions: 00019 * 00020 * The above copyright notice and this permission notice shall be included 00021 * in all copies or substantial portions of the Software. 00022 * 00023 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00024 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00025 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00026 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00027 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00028 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00029 * DEALINGS IN THE SOFTWARE. 00030 ****************************************************************************/ 00031 00032 #ifndef GDAL_ALG_PRIV_H_INCLUDED 00033 #define GDAL_ALG_PRIV_H_INCLUDED 00034 00035 #include "gdal_alg.h" 00036 00037 CPL_C_START 00038 00040 typedef enum { GBV_UserBurnValue = 0, GBV_Z = 1, GBV_M = 2 00044 } GDALBurnValueSrc; 00045 00046 typedef enum { 00047 GRMA_Replace = 0, 00048 GRMA_Add = 1, 00049 } GDALRasterMergeAlg; 00050 00051 typedef struct { 00052 unsigned char * pabyChunkBuf; 00053 int nXSize; 00054 int nYSize; 00055 int nBands; 00056 GDALDataType eType; 00057 double *padfBurnValue; 00058 GDALBurnValueSrc eBurnValueSource; 00059 GDALRasterMergeAlg eMergeAlg; 00060 } GDALRasterizeInfo; 00061 00062 /************************************************************************/ 00063 /* Low level rasterizer API. */ 00064 /************************************************************************/ 00065 00066 typedef void (*llScanlineFunc)( void *, int, int, int, double ); 00067 typedef void (*llPointFunc)( void *, int, int, double ); 00068 00069 void GDALdllImagePoint( int nRasterXSize, int nRasterYSize, 00070 int nPartCount, int *panPartSize, 00071 double *padfX, double *padfY, double *padfVariant, 00072 llPointFunc pfnPointFunc, void *pCBData ); 00073 00074 void GDALdllImageLine( int nRasterXSize, int nRasterYSize, 00075 int nPartCount, int *panPartSize, 00076 double *padfX, double *padfY, double *padfVariant, 00077 llPointFunc pfnPointFunc, void *pCBData ); 00078 00079 void GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize, 00080 int nPartCount, int *panPartSize, 00081 double *padfX, double *padfY, 00082 double *padfVariant, 00083 llPointFunc pfnPointFunc, void *pCBData ); 00084 00085 void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize, 00086 int nPartCount, int *panPartSize, 00087 double *padfX, double *padfY, 00088 double *padfVariant, 00089 llScanlineFunc pfnScanlineFunc, void *pCBData ); 00090 00091 CPL_C_END 00092 00093 /************************************************************************/ 00094 /* Polygon Enumerator */ 00095 /************************************************************************/ 00096 00097 #define GP_NODATA_MARKER -51502112 00098 00099 class GDALRasterPolygonEnumerator 00100 00101 { 00102 private: 00103 void MergePolygon( int nSrcId, int nDstId ); 00104 int NewPolygon( GInt32 nValue ); 00105 00106 public: // these are intended to be readonly. 00107 00108 GInt32 *panPolyIdMap; 00109 GInt32 *panPolyValue; 00110 00111 int nNextPolygonId; 00112 int nPolyAlloc; 00113 00114 int nConnectedness; 00115 00116 public: 00117 GDALRasterPolygonEnumerator( int nConnectedness=4 ); 00118 ~GDALRasterPolygonEnumerator(); 00119 00120 void ProcessLine( GInt32 *panLastLineVal, GInt32 *panThisLineVal, 00121 GInt32 *panLastLineId, GInt32 *panThisLineId, 00122 int nXSize ); 00123 00124 void CompleteMerges(); 00125 00126 void Clear(); 00127 }; 00128 00129 #ifdef OGR_ENABLED 00130 /************************************************************************/ 00131 /* Polygon Enumerator */ 00132 /* */ 00133 /* Buffers has float values instead og GInt32 */ 00134 /************************************************************************/ 00135 class GDALRasterFPolygonEnumerator 00136 00137 { 00138 private: 00139 void MergePolygon( int nSrcId, int nDstId ); 00140 int NewPolygon( float fValue ); 00141 00142 public: // these are intended to be readonly. 00143 00144 GInt32 *panPolyIdMap; 00145 float *pafPolyValue; 00146 00147 int nNextPolygonId; 00148 int nPolyAlloc; 00149 00150 int nConnectedness; 00151 00152 public: 00153 GDALRasterFPolygonEnumerator( int nConnectedness=4 ); 00154 ~GDALRasterFPolygonEnumerator(); 00155 00156 void ProcessLine( float *pafLastLineVal, float *pafThisLineVal, 00157 GInt32 *panLastLineId, GInt32 *panThisLineId, 00158 int nXSize ); 00159 00160 void CompleteMerges(); 00161 00162 void Clear(); 00163 }; 00164 #endif 00165 00166 typedef void* (*GDALTransformDeserializeFunc)( CPLXMLNode *psTree ); 00167 00168 void* GDALRegisterTransformDeserializer(const char* pszTransformName, 00169 GDALTransformerFunc pfnTransformerFunc, 00170 GDALTransformDeserializeFunc pfnDeserializeFunc); 00171 void GDALUnregisterTransformDeserializer(void* pData); 00172 00173 void GDALCleanupTransformDeserializerMutex(); 00174 00175 /* Transformer cloning */ 00176 00177 void* GDALCreateTPSTransformerInt( int nGCPCount, const GDAL_GCP *pasGCPList, 00178 int bReversed, char** papszOptions ); 00179 00180 void CPL_DLL * GDALCloneTransformer( void *pTranformerArg ); 00181 00182 /************************************************************************/ 00183 /* Color table related */ 00184 /************************************************************************/ 00185 00186 int 00187 GDALComputeMedianCutPCTInternal( GDALRasterBandH hRed, 00188 GDALRasterBandH hGreen, 00189 GDALRasterBandH hBlue, 00190 GByte* pabyRedBand, 00191 GByte* pabyGreenBand, 00192 GByte* pabyBlueBand, 00193 int (*pfnIncludePixel)(int,int,void*), 00194 int nColors, 00195 int nBits, 00196 int* panHistogram, 00197 GDALColorTableH hColorTable, 00198 GDALProgressFunc pfnProgress, 00199 void * pProgressArg ); 00200 00201 int GDALDitherRGB2PCTInternal( GDALRasterBandH hRed, 00202 GDALRasterBandH hGreen, 00203 GDALRasterBandH hBlue, 00204 GDALRasterBandH hTarget, 00205 GDALColorTableH hColorTable, 00206 int nBits, 00207 GInt16* pasDynamicColorMap, 00208 int bDither, 00209 GDALProgressFunc pfnProgress, 00210 void * pProgressArg ); 00211 00212 #define PRIME_FOR_65536 98317 00213 #define MEDIAN_CUT_AND_DITHER_BUFFER_SIZE_65536 (6 * sizeof(int) * PRIME_FOR_65536) 00214 00215 /************************************************************************/ 00216 /* Float comparison function. */ 00217 /************************************************************************/ 00218 00225 #define MAX_ULPS 10 00226 00227 GBool GDALFloatEquals(float A, float B); 00228 00229 #endif /* ndef GDAL_ALG_PRIV_H_INCLUDED */