|
SpatiaLite 4.3.0a
|
00001 /* 00002 gg_dxf.h -- Gaia common support for DXF files 00003 00004 version 4.3, 2015 June 29 00005 00006 Author: Sandro Furieri a.furieri@lqt.it 00007 00008 ------------------------------------------------------------------------------ 00009 00010 Version: MPL 1.1/GPL 2.0/LGPL 2.1 00011 00012 The contents of this file are subject to the Mozilla Public License Version 00013 1.1 (the "License"); you may not use this file except in compliance with 00014 the License. You may obtain a copy of the License at 00015 http://www.mozilla.org/MPL/ 00016 00017 Software distributed under the License is distributed on an "AS IS" basis, 00018 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00019 for the specific language governing rights and limitations under the 00020 License. 00021 00022 The Original Code is the SpatiaLite library 00023 00024 The Initial Developer of the Original Code is Alessandro Furieri 00025 00026 Portions created by the Initial Developer are Copyright (C) 2008-2015 00027 the Initial Developer. All Rights Reserved. 00028 00029 Contributor(s): 00030 00031 Alternatively, the contents of this file may be used under the terms of 00032 either the GNU General Public License Version 2 or later (the "GPL"), or 00033 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00034 in which case the provisions of the GPL or the LGPL are applicable instead 00035 of those above. If you wish to allow use of your version of this file only 00036 under the terms of either the GPL or the LGPL, and not to allow others to 00037 use your version of this file under the terms of the MPL, indicate your 00038 decision by deleting the provisions above and replace them with the notice 00039 and other provisions required by the GPL or the LGPL. If you do not delete 00040 the provisions above, a recipient may use your version of this file under 00041 the terms of any one of the MPL, the GPL or the LGPL. 00042 00043 */ 00044 00045 00052 #ifndef _GG_DXF_H 00053 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00054 #define _GG_DXF_H 00055 #endif 00056 00057 #ifdef __cplusplus 00058 extern "C" 00059 { 00060 #endif 00061 00062 /* constant values for DXF */ 00063 00065 #define GAIA_DXF_IMPORT_BY_LAYER 1 00066 00067 #define GAIA_DXF_IMPORT_MIXED 2 00068 00069 #define GAIA_DXF_AUTO_2D_3D 3 00070 00071 #define GAIA_DXF_FORCE_2D 4 00072 00073 #define GAIA_DXF_FORCE_3D 5 00074 00075 #define GAIA_DXF_RING_NONE 6 00076 00077 #define GAIA_DXF_RING_LINKED 7 00078 00079 #define GAIA_DXF_RING_UNLINKED 8 00080 00081 00083 #define GAIA_DXF_V12 1000 00084 00085 /* data structs */ 00086 00087 00091 typedef struct gaia_dxf_extra_attr 00092 { 00094 char *key; 00096 char *value; 00098 struct gaia_dxf_extra_attr *next; 00099 } gaiaDxfExtraAttr; 00105 typedef gaiaDxfExtraAttr *gaiaDxfExtraAttrPtr; 00106 00110 typedef struct gaia_dxf_insert 00111 { 00113 char *block_id; 00115 double x; 00117 double y; 00119 double z; 00121 double scale_x; 00123 double scale_y; 00125 double scale_z; 00127 double angle; 00129 int hasText; 00131 int hasPoint; 00133 int hasLine; 00135 int hasPolyg; 00137 int hasHatch; 00139 int is3Dtext; 00141 int is3Dpoint; 00143 int is3Dline; 00145 int is3Dpolyg; 00147 gaiaDxfExtraAttrPtr first; 00149 gaiaDxfExtraAttrPtr last; 00151 struct gaia_dxf_insert *next; 00152 } gaiaDxfInsert; 00158 typedef gaiaDxfInsert *gaiaDxfInsertPtr; 00159 00163 typedef struct gaia_dxf_text 00164 { 00166 char *label; 00168 double x; 00170 double y; 00172 double z; 00174 double angle; 00176 gaiaDxfExtraAttrPtr first; 00178 gaiaDxfExtraAttrPtr last; 00180 struct gaia_dxf_text *next; 00181 } gaiaDxfText; 00187 typedef gaiaDxfText *gaiaDxfTextPtr; 00188 00192 typedef struct gaia_dxf_point 00193 { 00195 double x; 00197 double y; 00199 double z; 00201 gaiaDxfExtraAttrPtr first; 00203 gaiaDxfExtraAttrPtr last; 00205 struct gaia_dxf_point *next; 00206 } gaiaDxfPoint; 00212 typedef gaiaDxfPoint *gaiaDxfPointPtr; 00213 00217 typedef struct gaia_dxf_circle 00218 { 00220 double cx; 00222 double cy; 00224 double cz; 00226 double radius; 00227 } gaiaDxfCircle; 00233 typedef gaiaDxfCircle *gaiaDxfCirclePtr; 00234 00238 typedef struct gaia_dxf_arc 00239 { 00241 double cx; 00243 double cy; 00245 double cz; 00247 double radius; 00249 double start; 00251 double stop; 00252 } gaiaDxfArc; 00258 typedef gaiaDxfArc *gaiaDxfArcPtr; 00259 00263 typedef struct gaia_dxf_hole 00264 { 00266 int points; 00268 double *x; 00270 double *y; 00272 double *z; 00274 struct gaia_dxf_hole *next; 00275 } gaiaDxfHole; 00281 typedef gaiaDxfHole *gaiaDxfHolePtr; 00282 00287 typedef struct gaia_dxf_polyline 00288 { 00290 int is_closed; 00292 int points; 00294 double *x; 00296 double *y; 00298 double *z; 00300 gaiaDxfHolePtr first_hole; 00302 gaiaDxfHolePtr last_hole; 00304 gaiaDxfExtraAttrPtr first; 00306 gaiaDxfExtraAttrPtr last; 00308 struct gaia_dxf_polyline *next; 00309 } gaiaDxfPolyline; 00315 typedef gaiaDxfPolyline *gaiaDxfPolylinePtr; 00319 typedef struct gaia_dxf_hatch_segm 00320 { 00322 double x0; 00324 double y0; 00326 double x1; 00328 double y1; 00330 struct gaia_dxf_hatch_segm *next; 00331 } gaiaDxfHatchSegm; 00337 typedef gaiaDxfHatchSegm *gaiaDxfHatchSegmPtr; 00338 00342 typedef struct gaia_dxf_boundary_path 00343 { 00345 gaiaDxfHatchSegmPtr first; 00347 gaiaDxfHatchSegmPtr last; 00349 struct gaia_dxf_boundary_path *next; 00350 } gaiaDxfBoundaryPath; 00356 typedef gaiaDxfBoundaryPath *gaiaDxfBoundaryPathPtr; 00357 00361 typedef struct gaia_dxf_hatch 00362 { 00364 double spacing; 00366 double angle; 00368 double base_x; 00370 double base_y; 00372 double offset_x; 00374 double offset_y; 00376 gaiaDxfBoundaryPathPtr first; 00378 gaiaDxfBoundaryPathPtr last; 00380 gaiaGeomCollPtr boundary; 00382 gaiaDxfHatchSegmPtr first_out; 00384 gaiaDxfHatchSegmPtr last_out; 00386 struct gaia_dxf_hatch *next; 00387 } gaiaDxfHatch; 00393 typedef gaiaDxfHatch *gaiaDxfHatchPtr; 00394 00398 typedef struct gaia_dxf_block 00399 { 00401 int hasInsert; 00403 char *layer_name; 00405 char *block_id; 00407 gaiaDxfTextPtr first_text; 00409 gaiaDxfTextPtr last_text; 00411 gaiaDxfPointPtr first_point; 00413 gaiaDxfPointPtr last_point; 00415 gaiaDxfPolylinePtr first_line; 00417 gaiaDxfPolylinePtr last_line; 00419 gaiaDxfPolylinePtr first_polyg; 00421 gaiaDxfPolylinePtr last_polyg; 00423 gaiaDxfHatchPtr first_hatch; 00425 gaiaDxfHatchPtr last_hatch; 00427 int is3Dtext; 00429 int is3Dpoint; 00431 int is3Dline; 00433 int is3Dpolyg; 00435 struct gaia_dxf_block *next; 00436 } gaiaDxfBlock; 00442 typedef gaiaDxfBlock *gaiaDxfBlockPtr; 00443 00447 typedef struct gaia_dxf_layer 00448 { 00450 char *layer_name; 00452 gaiaDxfTextPtr first_text; 00454 gaiaDxfTextPtr last_text; 00456 gaiaDxfPointPtr first_point; 00458 gaiaDxfPointPtr last_point; 00460 gaiaDxfPolylinePtr first_line; 00462 gaiaDxfPolylinePtr last_line; 00464 gaiaDxfPolylinePtr first_polyg; 00466 gaiaDxfPolylinePtr last_polyg; 00468 gaiaDxfHatchPtr first_hatch; 00470 gaiaDxfHatchPtr last_hatch; 00472 gaiaDxfInsertPtr first_ins_text; 00474 gaiaDxfInsertPtr last_ins_text; 00476 gaiaDxfInsertPtr first_ins_point; 00478 gaiaDxfInsertPtr last_ins_point; 00480 gaiaDxfInsertPtr first_ins_line; 00482 gaiaDxfInsertPtr last_ins_line; 00484 gaiaDxfInsertPtr first_ins_polyg; 00486 gaiaDxfInsertPtr last_ins_polyg; 00488 gaiaDxfInsertPtr first_ins_hatch; 00490 gaiaDxfInsertPtr last_ins_hatch; 00492 int is3Dtext; 00494 int is3Dpoint; 00496 int is3Dline; 00498 int is3Dpolyg; 00500 int is3DinsText; 00502 int is3DinsPoint; 00504 int is3DinsLine; 00506 int is3DinsPolyg; 00508 int hasExtraText; 00510 int hasExtraPoint; 00512 int hasExtraLine; 00514 int hasExtraPolyg; 00516 int hasExtraInsText; 00518 int hasExtraInsPoint; 00520 int hasExtraInsLine; 00522 int hasExtraInsPolyg; 00524 struct gaia_dxf_layer *next; 00525 } gaiaDxfLayer; 00531 typedef gaiaDxfLayer *gaiaDxfLayerPtr; 00532 00536 typedef struct gaia_dxf_parser 00537 { 00539 char *filename; 00541 gaiaDxfLayerPtr first_layer; 00543 gaiaDxfLayerPtr last_layer; 00545 gaiaDxfBlockPtr first_block; 00547 gaiaDxfBlockPtr last_block; 00549 int force_dims; 00551 int srid; 00553 const char *selected_layer; 00555 const char *prefix; 00557 int linked_rings; 00559 int unlinked_rings; 00561 int line_no; 00563 int op_code_line; 00565 int op_code; 00567 int section; 00569 int tables; 00571 int blocks; 00573 int entities; 00575 int is_layer; 00577 int is_block; 00579 int is_text; 00581 int is_point; 00583 int is_polyline; 00585 int is_lwpolyline; 00587 int is_line; 00589 int is_circle; 00591 int is_arc; 00593 int is_vertex; 00595 int is_hatch; 00597 int is_hatch_boundary; 00599 int is_insert; 00601 int eof; 00603 int error; 00605 char *curr_layer_name; 00607 gaiaDxfText curr_text; 00609 gaiaDxfInsert curr_insert; 00611 gaiaDxfBlock curr_block; 00613 gaiaDxfPoint curr_point; 00615 gaiaDxfPoint curr_end_point; 00617 gaiaDxfCircle curr_circle; 00619 gaiaDxfArc curr_arc; 00621 int is_closed_polyline; 00623 gaiaDxfPointPtr first_pt; 00625 gaiaDxfPointPtr last_pt; 00627 char *extra_key; 00629 char *extra_value; 00631 gaiaDxfExtraAttrPtr first_ext; 00633 gaiaDxfExtraAttrPtr last_ext; 00635 gaiaDxfHatchPtr curr_hatch; 00637 int undeclared_layers; 00638 } gaiaDxfParser; 00644 typedef gaiaDxfParser *gaiaDxfParserPtr; 00645 00649 typedef struct gaia_dxf_write 00650 { 00652 FILE *out; 00654 int precision; 00656 int version; 00658 int count; 00660 int error; 00661 } gaiaDxfWriter; 00665 typedef gaiaDxfWriter *gaiaDxfWriterPtr; 00666 00667 00668 /* function prototypes */ 00669 00670 00692 GAIAGEO_DECLARE gaiaDxfParserPtr gaiaCreateDxfParser (int srid, 00693 int force_dims, 00694 const char *prefix, 00695 const char 00696 *selected_layer, 00697 int special_rings); 00698 00709 GAIAGEO_DECLARE void gaiaDestroyDxfParser (gaiaDxfParserPtr parser); 00710 00727 GAIAGEO_DECLARE int gaiaParseDxfFile (gaiaDxfParserPtr parser, 00728 const char *dxf_path); 00729 00747 GAIAGEO_DECLARE int gaiaParseDxfFile_r (const void *p_cache, 00748 gaiaDxfParserPtr parser, 00749 const char *dxf_path); 00750 00769 GAIAGEO_DECLARE int gaiaLoadFromDxfParser (sqlite3 * db_handle, 00770 gaiaDxfParserPtr parser, 00771 int mode, int append); 00772 00785 GAIAGEO_DECLARE int gaiaDxfWriterInit (gaiaDxfWriterPtr dxf, 00786 FILE * out, int precision, 00787 int version); 00788 00804 GAIAGEO_DECLARE int 00805 gaiaDxfWriteHeader (gaiaDxfWriterPtr dxf, double minx, double miny, 00806 double minz, double maxx, double maxy, double maxz); 00807 00817 GAIAGEO_DECLARE int gaiaDxfWriteFooter (gaiaDxfWriterPtr dxf); 00818 00828 GAIAGEO_DECLARE int gaiaDxfWriteTables (gaiaDxfWriterPtr dxf); 00829 00840 GAIAGEO_DECLARE int gaiaDxfWriteLayer (gaiaDxfWriterPtr dxf, 00841 const char *layer_name); 00842 00853 GAIAGEO_DECLARE int gaiaDxfWriteEntities (gaiaDxfWriterPtr dxf); 00854 00864 GAIAGEO_DECLARE int gaiaDxfWriteEndSection (gaiaDxfWriterPtr dxf); 00865 00880 GAIAGEO_DECLARE int gaiaDxfWritePoint (gaiaDxfWriterPtr dxf, 00881 const char *layer_name, double x, 00882 double y, double z); 00883 00901 GAIAGEO_DECLARE int gaiaDxfWriteText (gaiaDxfWriterPtr dxf, 00902 const char *layer_name, double x, 00903 double y, double z, const char *label, 00904 double text_height, double angle); 00905 00918 GAIAGEO_DECLARE int 00919 gaiaDxfWriteLine (gaiaDxfWriterPtr dxf, const char *layer_name, 00920 gaiaLinestringPtr line); 00921 00934 GAIAGEO_DECLARE int 00935 gaiaDxfWriteRing (gaiaDxfWriterPtr dxf, const char *layer_name, 00936 gaiaRingPtr ring); 00937 00953 GAIAGEO_DECLARE int 00954 gaiaDxfWriteGeometry (gaiaDxfWriterPtr dxf, const char *layer_name, 00955 const char *label, double text_height, 00956 double text_rotation, gaiaGeomCollPtr geometry); 00957 00980 GAIAGEO_DECLARE int 00981 gaiaExportDxf (gaiaDxfWriterPtr dxf, sqlite3 * db_handle, 00982 const char *sql, const char *layer_col_name, 00983 const char *geom_col_name, const char *label_col_name, 00984 const char *text_height_col_name, 00985 const char *text_rotation_col_name, 00986 gaiaGeomCollPtr geom_filter); 00987 00988 #ifdef __cplusplus 00989 } 00990 #endif 00991 00992 #endif /* _GG_DXF_H */
1.7.3