#ifndef _GG_DXF_H
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define _GG_DXF_H
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#define GAIA_DXF_IMPORT_BY_LAYER 1
#define GAIA_DXF_IMPORT_MIXED 2
#define GAIA_DXF_AUTO_2D_3D 3
#define GAIA_DXF_FORCE_2D 4
#define GAIA_DXF_FORCE_3D 5
#define GAIA_DXF_RING_NONE 6
#define GAIA_DXF_RING_LINKED 7
#define GAIA_DXF_RING_UNLINKED 8
#define GAIA_DXF_V12 1000
typedef struct gaia_dxf_extra_attr
{
char *key;
char *value;
struct gaia_dxf_extra_attr *next;
} gaiaDxfExtraAttr;
typedef gaiaDxfExtraAttr *gaiaDxfExtraAttrPtr;
typedef struct gaia_dxf_insert
{
char *block_id;
double x;
double y;
double z;
double scale_x;
double scale_y;
double scale_z;
double angle;
int hasText;
int hasPoint;
int hasLine;
int hasPolyg;
int hasHatch;
int is3Dtext;
int is3Dpoint;
int is3Dline;
int is3Dpolyg;
gaiaDxfExtraAttrPtr first;
gaiaDxfExtraAttrPtr last;
struct gaia_dxf_insert *next;
} gaiaDxfInsert;
typedef gaiaDxfInsert *gaiaDxfInsertPtr;
typedef struct gaia_dxf_text
{
char *label;
double x;
double y;
double z;
double angle;
gaiaDxfExtraAttrPtr first;
gaiaDxfExtraAttrPtr last;
struct gaia_dxf_text *next;
} gaiaDxfText;
typedef gaiaDxfText *gaiaDxfTextPtr;
typedef struct gaia_dxf_point
{
double x;
double y;
double z;
gaiaDxfExtraAttrPtr first;
gaiaDxfExtraAttrPtr last;
struct gaia_dxf_point *next;
} gaiaDxfPoint;
typedef gaiaDxfPoint *gaiaDxfPointPtr;
typedef struct gaia_dxf_circle
{
double cx;
double cy;
double cz;
double radius;
} gaiaDxfCircle;
typedef gaiaDxfCircle *gaiaDxfCirclePtr;
typedef struct gaia_dxf_arc
{
double cx;
double cy;
double cz;
double radius;
double start;
double stop;
} gaiaDxfArc;
typedef gaiaDxfArc *gaiaDxfArcPtr;
typedef struct gaia_dxf_hole
{
int points;
double *x;
double *y;
double *z;
struct gaia_dxf_hole *next;
} gaiaDxfHole;
typedef gaiaDxfHole *gaiaDxfHolePtr;
typedef struct gaia_dxf_polyline
{
int is_closed;
int points;
double *x;
double *y;
double *z;
gaiaDxfHolePtr first_hole;
gaiaDxfHolePtr last_hole;
gaiaDxfExtraAttrPtr first;
gaiaDxfExtraAttrPtr last;
struct gaia_dxf_polyline *next;
} gaiaDxfPolyline;
typedef gaiaDxfPolyline *gaiaDxfPolylinePtr;
typedef struct gaia_dxf_hatch_segm
{
double x0;
double y0;
double x1;
double y1;
struct gaia_dxf_hatch_segm *next;
} gaiaDxfHatchSegm;
typedef gaiaDxfHatchSegm *gaiaDxfHatchSegmPtr;
typedef struct gaia_dxf_boundary_path
{
gaiaDxfHatchSegmPtr first;
gaiaDxfHatchSegmPtr last;
struct gaia_dxf_boundary_path *next;
} gaiaDxfBoundaryPath;
typedef gaiaDxfBoundaryPath *gaiaDxfBoundaryPathPtr;
typedef struct gaia_dxf_hatch
{
double spacing;
double angle;
double base_x;
double base_y;
double offset_x;
double offset_y;
gaiaDxfBoundaryPathPtr first;
gaiaDxfBoundaryPathPtr last;
gaiaGeomCollPtr boundary;
gaiaDxfHatchSegmPtr first_out;
gaiaDxfHatchSegmPtr last_out;
struct gaia_dxf_hatch *next;
} gaiaDxfHatch;
typedef gaiaDxfHatch *gaiaDxfHatchPtr;
typedef struct gaia_dxf_block
{
int hasInsert;
char *layer_name;
char *block_id;
gaiaDxfTextPtr first_text;
gaiaDxfTextPtr last_text;
gaiaDxfPointPtr first_point;
gaiaDxfPointPtr last_point;
gaiaDxfPolylinePtr first_line;
gaiaDxfPolylinePtr last_line;
gaiaDxfPolylinePtr first_polyg;
gaiaDxfPolylinePtr last_polyg;
gaiaDxfHatchPtr first_hatch;
gaiaDxfHatchPtr last_hatch;
int is3Dtext;
int is3Dpoint;
int is3Dline;
int is3Dpolyg;
struct gaia_dxf_block *next;
} gaiaDxfBlock;
typedef gaiaDxfBlock *gaiaDxfBlockPtr;
typedef struct gaia_dxf_layer
{
char *layer_name;
gaiaDxfTextPtr first_text;
gaiaDxfTextPtr last_text;
gaiaDxfPointPtr first_point;
gaiaDxfPointPtr last_point;
gaiaDxfPolylinePtr first_line;
gaiaDxfPolylinePtr last_line;
gaiaDxfPolylinePtr first_polyg;
gaiaDxfPolylinePtr last_polyg;
gaiaDxfHatchPtr first_hatch;
gaiaDxfHatchPtr last_hatch;
gaiaDxfInsertPtr first_ins_text;
gaiaDxfInsertPtr last_ins_text;
gaiaDxfInsertPtr first_ins_point;
gaiaDxfInsertPtr last_ins_point;
gaiaDxfInsertPtr first_ins_line;
gaiaDxfInsertPtr last_ins_line;
gaiaDxfInsertPtr first_ins_polyg;
gaiaDxfInsertPtr last_ins_polyg;
gaiaDxfInsertPtr first_ins_hatch;
gaiaDxfInsertPtr last_ins_hatch;
int is3Dtext;
int is3Dpoint;
int is3Dline;
int is3Dpolyg;
int is3DinsText;
int is3DinsPoint;
int is3DinsLine;
int is3DinsPolyg;
int hasExtraText;
int hasExtraPoint;
int hasExtraLine;
int hasExtraPolyg;
int hasExtraInsText;
int hasExtraInsPoint;
int hasExtraInsLine;
int hasExtraInsPolyg;
struct gaia_dxf_layer *next;
} gaiaDxfLayer;
typedef gaiaDxfLayer *gaiaDxfLayerPtr;
typedef struct gaia_dxf_parser
{
char *filename;
gaiaDxfLayerPtr first_layer;
gaiaDxfLayerPtr last_layer;
gaiaDxfBlockPtr first_block;
gaiaDxfBlockPtr last_block;
int force_dims;
int srid;
const char *selected_layer;
const char *prefix;
int linked_rings;
int unlinked_rings;
int line_no;
int op_code_line;
int op_code;
int section;
int tables;
int blocks;
int entities;
int is_layer;
int is_block;
int is_text;
int is_point;
int is_polyline;
int is_lwpolyline;
int is_line;
int is_circle;
int is_arc;
int is_vertex;
int is_hatch;
int is_hatch_boundary;
int is_insert;
int eof;
int error;
char *curr_layer_name;
gaiaDxfText curr_text;
gaiaDxfInsert curr_insert;
gaiaDxfBlock curr_block;
gaiaDxfPoint curr_point;
gaiaDxfPoint curr_end_point;
gaiaDxfCircle curr_circle;
gaiaDxfArc curr_arc;
int is_closed_polyline;
gaiaDxfPointPtr first_pt;
gaiaDxfPointPtr last_pt;
char *extra_key;
char *extra_value;
gaiaDxfExtraAttrPtr first_ext;
gaiaDxfExtraAttrPtr last_ext;
gaiaDxfHatchPtr curr_hatch;
int undeclared_layers;
} gaiaDxfParser;
typedef gaiaDxfParser *gaiaDxfParserPtr;
typedef struct gaia_dxf_write
{
FILE *out;
int precision;
int version;
int count;
int error;
} gaiaDxfWriter;
typedef gaiaDxfWriter *gaiaDxfWriterPtr;
GAIAGEO_DECLARE gaiaDxfParserPtr gaiaCreateDxfParser (int srid,
int force_dims,
const char *prefix,
const char
*selected_layer,
int special_rings);
GAIAGEO_DECLARE void gaiaDestroyDxfParser (gaiaDxfParserPtr parser);
GAIAGEO_DECLARE int gaiaParseDxfFile (gaiaDxfParserPtr parser,
const char *dxf_path);
GAIAGEO_DECLARE int gaiaParseDxfFile_r (const void *p_cache,
gaiaDxfParserPtr parser,
const char *dxf_path);
GAIAGEO_DECLARE int gaiaLoadFromDxfParser (sqlite3 * db_handle,
gaiaDxfParserPtr parser,
int mode, int append);
GAIAGEO_DECLARE int gaiaDxfWriterInit (gaiaDxfWriterPtr dxf,
FILE * out, int precision,
int version);
GAIAGEO_DECLARE int
gaiaDxfWriteHeader (gaiaDxfWriterPtr dxf, double minx, double miny,
double minz, double maxx, double maxy, double maxz);
GAIAGEO_DECLARE int gaiaDxfWriteFooter (gaiaDxfWriterPtr dxf);
GAIAGEO_DECLARE int gaiaDxfWriteTables (gaiaDxfWriterPtr dxf);
GAIAGEO_DECLARE int gaiaDxfWriteLayer (gaiaDxfWriterPtr dxf,
const char *layer_name);
GAIAGEO_DECLARE int gaiaDxfWriteEntities (gaiaDxfWriterPtr dxf);
GAIAGEO_DECLARE int gaiaDxfWriteEndSection (gaiaDxfWriterPtr dxf);
GAIAGEO_DECLARE int gaiaDxfWritePoint (gaiaDxfWriterPtr dxf,
const char *layer_name, double x,
double y, double z);
GAIAGEO_DECLARE int gaiaDxfWriteText (gaiaDxfWriterPtr dxf,
const char *layer_name, double x,
double y, double z, const char *label,
double text_height, double angle);
GAIAGEO_DECLARE int
gaiaDxfWriteLine (gaiaDxfWriterPtr dxf, const char *layer_name,
gaiaLinestringPtr line);
GAIAGEO_DECLARE int
gaiaDxfWriteRing (gaiaDxfWriterPtr dxf, const char *layer_name,
gaiaRingPtr ring);
GAIAGEO_DECLARE int
gaiaDxfWriteGeometry (gaiaDxfWriterPtr dxf, const char *layer_name,
const char *label, double text_height,
double text_rotation, gaiaGeomCollPtr geometry);
GAIAGEO_DECLARE int
gaiaExportDxf (gaiaDxfWriterPtr dxf, sqlite3 * db_handle,
const char *sql, const char *layer_col_name,
const char *geom_col_name, const char *label_col_name,
const char *text_height_col_name,
const char *text_rotation_col_name,
gaiaGeomCollPtr geom_filter);
#ifdef __cplusplus
}
#endif
#endif