GDAL
gdal_alg_priv.h
1 /******************************************************************************
2  * $Id: gdal_alg_priv.h fe2d81c8819bf9794bce0210098e637565728350 2018-05-06 00:49:51 +0200 Even 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 typedef enum {
65  GRO_Raster = 0,
66  GRO_Vector = 1,
67  GRO_Auto = 2,
68 } GDALRasterizeOptim;
69 
70 
71 /************************************************************************/
72 /* Low level rasterizer API. */
73 /************************************************************************/
74 
75 typedef void (*llScanlineFunc)( void *, int, int, int, double );
76 typedef void (*llPointFunc)( void *, int, int, double );
77 
78 void GDALdllImagePoint( int nRasterXSize, int nRasterYSize,
79  int nPartCount, int *panPartSize,
80  double *padfX, double *padfY, double *padfVariant,
81  llPointFunc pfnPointFunc, void *pCBData );
82 
83 void GDALdllImageLine( int nRasterXSize, int nRasterYSize,
84  int nPartCount, int *panPartSize,
85  double *padfX, double *padfY, double *padfVariant,
86  llPointFunc pfnPointFunc, void *pCBData );
87 
88 void GDALdllImageLineAllTouched( int nRasterXSize, int nRasterYSize,
89  int nPartCount, int *panPartSize,
90  double *padfX, double *padfY,
91  double *padfVariant,
92  llPointFunc pfnPointFunc, void *pCBData );
93 
94 void GDALdllImageFilledPolygon( int nRasterXSize, int nRasterYSize,
95  int nPartCount, int *panPartSize,
96  double *padfX, double *padfY,
97  double *padfVariant,
98  llScanlineFunc pfnScanlineFunc, void *pCBData );
99 
100 CPL_C_END
101 
102 /************************************************************************/
103 /* Polygon Enumerator */
104 /************************************************************************/
105 
106 #define GP_NODATA_MARKER -51502112
107 
108 template<class DataType, class EqualityTest> class GDALRasterPolygonEnumeratorT
109 
110 {
111 private:
112  void MergePolygon( int nSrcId, int nDstId );
113  int NewPolygon( DataType nValue );
114 
115  CPL_DISALLOW_COPY_ASSIGN(GDALRasterPolygonEnumeratorT)
116 
117 public: // these are intended to be readonly.
118 
119  GInt32 *panPolyIdMap = nullptr;
120  DataType *panPolyValue = nullptr;
121 
122  int nNextPolygonId = 0;
123  int nPolyAlloc = 0;
124 
125  int nConnectedness = 0;
126 
127 public:
128  explicit GDALRasterPolygonEnumeratorT( int nConnectedness=4 );
129  ~GDALRasterPolygonEnumeratorT();
130 
131  void ProcessLine( DataType *panLastLineVal, DataType *panThisLineVal,
132  GInt32 *panLastLineId, GInt32 *panThisLineId,
133  int nXSize );
134 
135  void CompleteMerges();
136 
137  void Clear();
138 };
139 
140 struct IntEqualityTest
141 {
142  bool operator()(GInt32 a, GInt32 b) const { return a == b; }
143 };
144 
145 typedef GDALRasterPolygonEnumeratorT<GInt32, IntEqualityTest> GDALRasterPolygonEnumerator;
146 
147 typedef void* (*GDALTransformDeserializeFunc)( CPLXMLNode *psTree );
148 
149 void CPL_DLL *GDALRegisterTransformDeserializer(const char* pszTransformName,
150  GDALTransformerFunc pfnTransformerFunc,
151  GDALTransformDeserializeFunc pfnDeserializeFunc);
152 void CPL_DLL GDALUnregisterTransformDeserializer(void* pData);
153 
154 void GDALCleanupTransformDeserializerMutex();
155 
156 /* Transformer cloning */
157 
158 void* GDALCreateTPSTransformerInt( int nGCPCount, const GDAL_GCP *pasGCPList,
159  int bReversed, char** papszOptions );
160 
161 void CPL_DLL * GDALCloneTransformer( void *pTransformerArg );
162 
163 /************************************************************************/
164 /* Color table related */
165 /************************************************************************/
166 
167 // Definitions exists for T = GUInt32 and T = GUIntBig.
168 template<class T> int
169 GDALComputeMedianCutPCTInternal( GDALRasterBandH hRed,
170  GDALRasterBandH hGreen,
171  GDALRasterBandH hBlue,
172  GByte* pabyRedBand,
173  GByte* pabyGreenBand,
174  GByte* pabyBlueBand,
175  int (*pfnIncludePixel)(int,int,void*),
176  int nColors,
177  int nBits,
178  T* panHistogram,
179  GDALColorTableH hColorTable,
180  GDALProgressFunc pfnProgress,
181  void * pProgressArg );
182 
183 int GDALDitherRGB2PCTInternal( GDALRasterBandH hRed,
184  GDALRasterBandH hGreen,
185  GDALRasterBandH hBlue,
186  GDALRasterBandH hTarget,
187  GDALColorTableH hColorTable,
188  int nBits,
189  GInt16* pasDynamicColorMap,
190  int bDither,
191  GDALProgressFunc pfnProgress,
192  void * pProgressArg );
193 
194 #define PRIME_FOR_65536 98317
195 
196 // See HashHistogram structure in gdalmediancut.cpp and ColorIndex structure in
197 // gdaldither.cpp 6 * sizeof(int) should be the size of the largest of both
198 // structures.
199 #define MEDIAN_CUT_AND_DITHER_BUFFER_SIZE_65536 (6 * sizeof(int) * PRIME_FOR_65536)
200 
201 /************************************************************************/
202 /* Float comparison function. */
203 /************************************************************************/
204 
211 #define MAX_ULPS 10
212 
213 GBool GDALFloatEquals(float A, float B);
214 
215 struct FloatEqualityTest
216 {
217  bool operator()(float a, float b) { return GDALFloatEquals(a,b) == TRUE; }
218 };
219 
220 #endif /* #ifndef DOXYGEN_SKIP */
221 
222 #endif /* ndef GDAL_ALG_PRIV_H_INCLUDED */
GDALDataType
Definition: gdal.h:60
Document node structure.
Definition: cpl_minixml.h:66
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
int GBool
Type for boolean values (alias to int)
Definition: cpl_port.h:223
int GInt32
Int32 type.
Definition: cpl_port.h:205
short GInt16
Int16 type.
Definition: cpl_port.h:211
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:258
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:339
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:264
Ground Control Point.
Definition: gdal.h:560
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:989

Generated for GDAL by doxygen 1.8.13.