GDAL
gdal_alg_priv.h
1 /******************************************************************************
2  * $Id: gdal_alg_priv.h 36411 2016-11-21 22:03:48Z rouault $
3  *
4  * Project: GDAL Image Processing Algorithms
5  * Purpose: Prototypes and definitions for various GDAL based algorithms:
6  * private declarations.
7  * Author: Andrey Kiselev, dron@ak4719.spb.edu
8  *
9  ******************************************************************************
10  * Copyright (c) 2008, Andrey Kiselev <dron@ak4719.spb.edu>
11  * Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org>
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef GDAL_ALG_PRIV_H_INCLUDED
33 #define GDAL_ALG_PRIV_H_INCLUDED
34 
35 #ifndef DOXYGEN_SKIP
36 
37 #include "gdal_alg.h"
38 
40 
42 typedef enum { GBV_UserBurnValue = 0, GBV_Z = 1, GBV_M = 2
46 } GDALBurnValueSrc;
47 
48 typedef enum {
49  GRMA_Replace = 0,
50  GRMA_Add = 1,
51 } GDALRasterMergeAlg;
52 
53 typedef struct {
54  unsigned char * pabyChunkBuf;
55  int nXSize;
56  int nYSize;
57  int nBands;
58  GDALDataType eType;
59  double *padfBurnValue;
60  GDALBurnValueSrc eBurnValueSource;
61  GDALRasterMergeAlg eMergeAlg;
62 } GDALRasterizeInfo;
63 
64 /************************************************************************/
65 /* Low level rasterizer API. */
66 /************************************************************************/
67 
68 typedef void (*llScanlineFunc)( void *, int, int, int, double );
69 typedef void (*llPointFunc)( void *, int, int, double );
70 
71 void GDALdllImagePoint( int nRasterXSize, int nRasterYSize,
72  int nPartCount, int *panPartSize,
73  double *padfX, double *padfY, double *padfVariant,
74  llPointFunc pfnPointFunc, void *pCBData );
75 
76 void GDALdllImageLine( int nRasterXSize, int nRasterYSize,
77  int nPartCount, int *panPartSize,
78  double *padfX, double *padfY, double *padfVariant,
79  llPointFunc pfnPointFunc, void *pCBData );
80 
81 void GDALdllImageLineAllTouched( int nRasterXSize, int nRasterYSize,
82  int nPartCount, int *panPartSize,
83  double *padfX, double *padfY,
84  double *padfVariant,
85  llPointFunc pfnPointFunc, void *pCBData );
86 
87 void GDALdllImageFilledPolygon( int nRasterXSize, int nRasterYSize,
88  int nPartCount, int *panPartSize,
89  double *padfX, double *padfY,
90  double *padfVariant,
91  llScanlineFunc pfnScanlineFunc, void *pCBData );
92 
94 
95 /************************************************************************/
96 /* Polygon Enumerator */
97 /************************************************************************/
98 
99 #define GP_NODATA_MARKER -51502112
100 
101 template<class DataType, class EqualityTest> class GDALRasterPolygonEnumeratorT
102 
103 {
104 private:
105  void MergePolygon( int nSrcId, int nDstId );
106  int NewPolygon( DataType nValue );
107 
108 public: // these are intended to be readonly.
109 
110  GInt32 *panPolyIdMap;
111  DataType *panPolyValue;
112 
113  int nNextPolygonId;
114  int nPolyAlloc;
115 
116  int nConnectedness;
117 
118 public:
119  explicit GDALRasterPolygonEnumeratorT( int nConnectedness=4 );
120  ~GDALRasterPolygonEnumeratorT();
121 
122  void ProcessLine( DataType *panLastLineVal, DataType *panThisLineVal,
123  GInt32 *panLastLineId, GInt32 *panThisLineId,
124  int nXSize );
125 
126  void CompleteMerges();
127 
128  void Clear();
129 };
130 
131 struct IntEqualityTest
132 {
133  bool operator()(GInt32 a, GInt32 b) { return a == b; }
134 };
135 
136 typedef GDALRasterPolygonEnumeratorT<GInt32, IntEqualityTest> GDALRasterPolygonEnumerator;
137 
138 typedef void* (*GDALTransformDeserializeFunc)( CPLXMLNode *psTree );
139 
140 void* GDALRegisterTransformDeserializer(const char* pszTransformName,
141  GDALTransformerFunc pfnTransformerFunc,
142  GDALTransformDeserializeFunc pfnDeserializeFunc);
143 void GDALUnregisterTransformDeserializer(void* pData);
144 
145 void GDALCleanupTransformDeserializerMutex();
146 
147 /* Transformer cloning */
148 
149 void* GDALCreateTPSTransformerInt( int nGCPCount, const GDAL_GCP *pasGCPList,
150  int bReversed, char** papszOptions );
151 
152 void CPL_DLL * GDALCloneTransformer( void *pTransformerArg );
153 
154 /************************************************************************/
155 /* Color table related */
156 /************************************************************************/
157 
158 // Definitions exists for T = GUInt32 and T = GUIntBig.
159 template<class T> int
160 GDALComputeMedianCutPCTInternal( GDALRasterBandH hRed,
161  GDALRasterBandH hGreen,
162  GDALRasterBandH hBlue,
163  GByte* pabyRedBand,
164  GByte* pabyGreenBand,
165  GByte* pabyBlueBand,
166  int (*pfnIncludePixel)(int,int,void*),
167  int nColors,
168  int nBits,
169  T* panHistogram,
170  GDALColorTableH hColorTable,
171  GDALProgressFunc pfnProgress,
172  void * pProgressArg );
173 
174 int GDALDitherRGB2PCTInternal( GDALRasterBandH hRed,
175  GDALRasterBandH hGreen,
176  GDALRasterBandH hBlue,
177  GDALRasterBandH hTarget,
178  GDALColorTableH hColorTable,
179  int nBits,
180  GInt16* pasDynamicColorMap,
181  int bDither,
182  GDALProgressFunc pfnProgress,
183  void * pProgressArg );
184 
185 #define PRIME_FOR_65536 98317
186 
187 // See HashHistogram structure in gdalmediancut.cpp and ColorIndex structure in
188 // gdaldither.cpp 6 * sizeof(int) should be the size of the largest of both
189 // structures.
190 #define MEDIAN_CUT_AND_DITHER_BUFFER_SIZE_65536 (6 * sizeof(int) * PRIME_FOR_65536)
191 
192 /************************************************************************/
193 /* Float comparison function. */
194 /************************************************************************/
195 
202 #define MAX_ULPS 10
203 
204 GBool GDALFloatEquals(float A, float B);
205 
206 struct FloatEqualityTest
207 {
208  bool operator()(float a, float b) { return GDALFloatEquals(a,b) == TRUE; }
209 };
210 
211 #endif /* #ifndef DOXYGEN_SKIP */
212 
213 #endif /* ndef GDAL_ALG_PRIV_H_INCLUDED */
GDALDataType
Definition: gdal.h:57
Document node structure.
Definition: cpl_minixml.h:66
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:352
int GBool
Type for boolean values (alias to int)
Definition: cpl_port.h:215
int GInt32
Int32 type.
Definition: cpl_port.h:197
short GInt16
Int16 type.
Definition: cpl_port.h:203
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:207
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:244
int(* GDALTransformerFunc)(void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess)
Definition: gdal_alg.h:114
Public (C callable) GDAL algorithm entry points, and definitions.
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:354
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:250
Ground Control Point.
Definition: gdal.h:515

Generated for GDAL by doxygen 1.8.8.