diff --git a/configure b/configure index bc60ae7c41c..4b9a63f7947 100755 --- a/configure +++ b/configure @@ -666,10 +666,6 @@ USE_PTHREAD PTHREADLIB PTHREADLIBPATH PTHREADINCPATH -USE_OPENDWG -OPENDWGLIB -OPENDWGLIBPATH -OPENDWGINCPATH HAVE_NLS INTLLIB FTLIB @@ -912,7 +908,6 @@ with_cairo with_freetype with_nls with_readline -with_opendwg with_regex with_pthread with_openmp @@ -964,8 +959,6 @@ with_freetype_libs with_proj_includes with_proj_libs with_proj_share -with_opendwg_includes -with_opendwg_libs with_regex_includes with_regex_libs with_pthread_includes @@ -1647,7 +1640,6 @@ Optional Packages: --with-freetype support FreeType functionality (default: yes) --with-nls support NLS functionality (default: no) --with-readline support Readline functionality (default: no) - --with-opendwg support openDWG functionality (default: no) --with-regex support regex functionality (default: yes) --with-pthread support POSIX threads functionality (default: no) --with-openmp support OpenMP functionality (default: no) @@ -1734,10 +1726,6 @@ Optional Packages: External PROJ.4 include files are in DIRS --with-proj-libs=DIRS External PROJ.4 library files are in DIRS --with-proj-share=DIR External PROJ.4 data files are in DIR - --with-opendwg-includes=DIRS - openDWG include files are in DIRS - --with-opendwg-libs=DIRS - openDWG library files are in DIRS --with-regex-includes=DIRS regex include files are in DIRS --with-regex-libs=DIRS regex library files are in DIRS @@ -5566,17 +5554,6 @@ fi -# Check whether --with-opendwg was given. -if test ${with_opendwg+y} -then : - withval=$with_opendwg; -else $as_nop - with_opendwg=no -fi - - - - # Check whether --with-regex was given. if test ${with_regex+y} then : @@ -6069,25 +6046,6 @@ fi -# Check whether --with-opendwg-includes was given. -if test ${with_opendwg_includes+y} -then : - withval=$with_opendwg_includes; -fi - - - - -# Check whether --with-opendwg-libs was given. -if test ${with_opendwg_libs+y} -then : - withval=$with_opendwg_libs; -fi - - - - - # Check whether --with-regex-includes was given. if test ${with_regex_includes+y} then : @@ -15207,113 +15165,6 @@ fi -# Enable openDWG option - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use openDWG" >&5 -printf %s "checking whether to use openDWG... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: \"$with_opendwg\"" >&5 -printf "%s\n" "\"$with_opendwg\"" >&6; } -case "$with_opendwg" in - "no") USE_OPENDWG= ;; - "yes") USE_OPENDWG="1" ;; - *) as_fn_error $? "*** You must answer yes or no." "$LINENO" 5 ;; -esac - - - -OPENDWGINCPATH= -OPENDWGLIBPATH= -OPENDWGLIB= - -if test -n "${USE_OPENDWG}"; then - -# With OPENDWG includes directory - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of openDGW includes" >&5 -printf %s "checking for location of openDGW includes... " >&6; } -case "$with_opendwg_includes" in -y | ye | yes | n | no) - as_fn_error $? "*** You must supply a directory to --with-opendwg-includes." "$LINENO" 5 - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_opendwg_includes" >&5 -printf "%s\n" "$with_opendwg_includes" >&6; } - -if test -n "$with_opendwg_includes" ; then - for dir in $with_opendwg_includes; do - if test -d "$dir"; then - OPENDWGINCPATH="$OPENDWGINCPATH -I$dir" - else - as_fn_error $? "*** openDGW includes directory $dir does not exist." "$LINENO" 5 - fi - done -fi - - - -ac_save_cppflags="$CPPFLAGS" -CPPFLAGS="$OPENDWGINCPATH $CPPFLAGS" - for ac_header in ad2.h -do : - ac_fn_c_check_header_compile "$LINENO" "ad2.h" "ac_cv_header_ad2_h" "$ac_includes_default" -if test "x$ac_cv_header_ad2_h" = xyes -then : - printf "%s\n" "#define HAVE_AD2_H 1" >>confdefs.h - -else $as_nop - - as_fn_error $? "*** Unable to locate openDWG includes." "$LINENO" 5 - -fi - -done -CPPFLAGS=$ac_save_cppflags - - -# With OPENDWG library directory - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of openDWG library" >&5 -printf %s "checking for location of openDWG library... " >&6; } -case "$with_opendwg_libs" in -y | ye | yes | n | no) - as_fn_error $? "*** You must supply a directory to --with-opendwg-libs." "$LINENO" 5 - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_opendwg_libs" >&5 -printf "%s\n" "$with_opendwg_libs" >&6; } - -if test -n "$with_opendwg_libs"; then - for dir in $with_opendwg_libs; do - if test -d "$dir"; then - OPENDWGLIBPATH="$OPENDWGLIBPATH -L$dir" - else - as_fn_error $? "*** openDWG library directory $dir does not exist." "$LINENO" 5 - fi - done -fi - - -#search for ad2.a, ad3.a ... in openDWG toolkit directory: -#FIX ME how to program this test?? -#LOC_CHECK_LIBS(ad?.a,adSeekLayer,openDWG,$OPENDWGLIBPATH,OPENDWGLIB,,) -# -#for now hack (but working): -TRUEOPENDWGLIBPATH=`echo "$OPENDWGLIBPATH" | cut -b3-` -adlib=`ls -1 "$TRUEOPENDWGLIBPATH"/ad?.a | tail -1` -OPENDWGLIB="$adlib" - -fi # $USE_OPENDWG - - - - - - -# Done checking OPENDWG - # Enable pthread option @@ -17688,8 +17539,6 @@ echo " C++ support: `if test -n "${USE_CXX}" ; then echo yes ; e echo " Cairo support: `if test -n "${USE_CAIRO}" ; then echo yes ; else echo no ; fi`" -echo " DWG support: `if test -n "${USE_OPENDWG}" ; then echo yes ; else echo no ; fi`" - echo " FFTW support: `if test -n "${USE_FFTW}" ; then echo yes ; else echo no ; fi`" echo " FreeType support: `if test -n "${USE_FREETYPE}" ; then echo yes ; else echo no ; fi`" diff --git a/configure.ac b/configure.ac index b38a2a5936c..00403f1e665 100644 --- a/configure.ac +++ b/configure.ac @@ -312,7 +312,6 @@ LOC_ARG_WITH(cairo, Cairo) LOC_ARG_WITH(freetype, FreeType) LOC_ARG_WITH(nls, NLS, no) LOC_ARG_WITH(readline, Readline, no) -LOC_ARG_WITH(opendwg, openDWG, no) LOC_ARG_WITH(regex, regex) LOC_ARG_WITH(pthread, POSIX threads, no) LOC_ARG_WITH(openmp, OpenMP, no) @@ -411,9 +410,6 @@ LOC_ARG_WITH_INC(proj, External PROJ.4) LOC_ARG_WITH_LIB(proj, External PROJ.4) LOC_ARG_WITH_SHARE(proj, External PROJ.4) -LOC_ARG_WITH_INC(opendwg, openDWG) -LOC_ARG_WITH_LIB(opendwg, openDWG) - LOC_ARG_WITH_INC(regex, regex) LOC_ARG_WITH_LIB(regex, regex) @@ -1860,44 +1856,6 @@ fi AC_SUBST(INTLLIB) AC_SUBST(HAVE_NLS) -# Enable openDWG option - -LOC_CHECK_USE(opendwg,openDWG,USE_OPENDWG) - -OPENDWGINCPATH= -OPENDWGLIBPATH= -OPENDWGLIB= - -if test -n "${USE_OPENDWG}"; then - -# With OPENDWG includes directory - -LOC_CHECK_INC_PATH(opendwg,openDGW,OPENDWGINCPATH) - -LOC_CHECK_INCLUDES(ad2.h,openDWG,$OPENDWGINCPATH) - -# With OPENDWG library directory - -LOC_CHECK_LIB_PATH(opendwg,openDWG,OPENDWGLIBPATH) - -#search for ad2.a, ad3.a ... in openDWG toolkit directory: -#FIX ME how to program this test?? -#LOC_CHECK_LIBS(ad?.a,adSeekLayer,openDWG,$OPENDWGLIBPATH,OPENDWGLIB,,) -# -#for now hack (but working): -TRUEOPENDWGLIBPATH=`echo "$OPENDWGLIBPATH" | cut -b3-` -adlib=`ls -1 "$TRUEOPENDWGLIBPATH"/ad?.a | tail -1` -OPENDWGLIB="$adlib" - -fi # $USE_OPENDWG - -AC_SUBST(OPENDWGINCPATH) -AC_SUBST(OPENDWGLIBPATH) -AC_SUBST(OPENDWGLIB) -AC_SUBST(USE_OPENDWG) - -# Done checking OPENDWG - # Enable pthread option LOC_CHECK_USE(pthread,POSIX threads,USE_PTHREAD) @@ -2072,7 +2030,6 @@ LOC_MSG_USE(BLAS support,USE_BLAS) LOC_MSG_USE(BZIP2 support,USE_BZIP2) LOC_MSG_USE(C++ support,USE_CXX) LOC_MSG_USE(Cairo support,USE_CAIRO) -LOC_MSG_USE(DWG support,USE_OPENDWG) LOC_MSG_USE(FFTW support,USE_FFTW) LOC_MSG_USE(FreeType support,USE_FREETYPE) LOC_MSG_USE(GDAL support,USE_GDAL) diff --git a/include/Make/Platform.make.in b/include/Make/Platform.make.in index c65ed28c686..a66ddf801d3 100644 --- a/include/Make/Platform.make.in +++ b/include/Make/Platform.make.in @@ -203,12 +203,6 @@ PROJINC = @PROJINC@ PROJLIB = @PROJLIB@ PROJSHARE = @PROJSHARE@ -#OPENDWG: -OPENDWGINCPATH = @OPENDWGINCPATH@ -OPENDWGLIBPATH = @OPENDWGLIBPATH@ -OPENDWGLIB = @OPENDWGLIB@ -USE_OPENDWG = @USE_OPENDWG@ - #cairo CAIROINC = @CAIROINC@ CAIROLIB = @CAIROLIB@ diff --git a/vector/Makefile b/vector/Makefile index f195ce3aafb..7244ac59af5 100644 --- a/vector/Makefile +++ b/vector/Makefile @@ -102,7 +102,6 @@ SUBDIRS = \ v.out.ogr \ v.in.ogr \ v.external \ - v.in.dwg \ v.in.lidar \ v.external.out diff --git a/vector/v.in.dwg/Makefile b/vector/v.in.dwg/Makefile deleted file mode 100644 index c5c30c1dde7..00000000000 --- a/vector/v.in.dwg/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -MODULE_TOPDIR = ../.. - -PGM=v.in.dwg -ADINIT = $(ETC)/adinit.dat -ADINITSRC := $(shell echo $(OPENDWGINCPATH) | cut -b3- )/adinit/adinit.dat - -DEPENDENCIES = $(VECTORDEP) $(DBMIDEP) $(GISDEP) -LIBES = $(VECTORLIB) $(DBMILIB) $(GISLIB) $(OPENDWGLIBPATH) $(OPENDWGLIB) -EXTRA_INC = $(VECT_INC) $(OPENDWGINCPATH) -EXTRA_CFLAGS = $(VECT_CFLAGS) - -include $(MODULE_TOPDIR)/include/Make/Module.make - -ifneq ($(USE_OPENDWG),) -default: check - $(MAKE) cmd $(ADINIT) -endif - -check: -ifneq ($(strip $(MINGW)),) - cat WARNING -else - cat WARNING >/dev/tty -endif - @read IN ." diff --git a/vector/v.in.dwg/entity.c b/vector/v.in.dwg/entity.c deleted file mode 100644 index c70bc308fe0..00000000000 --- a/vector/v.in.dwg/entity.c +++ /dev/null @@ -1,540 +0,0 @@ -/* ************************************************************** - * - * MODULE: v.in.dwg - * - * AUTHOR(S): Radim Blazek - * - * PURPOSE: Import of DWG/DXF files - * - * COPYRIGHT: (C) 2001 by the GRASS Development Team - * - * This program is free software under the - * GNU General Public License (>=v2). - * Read the file COPYING that comes with GRASS - * for details. - * - * In addition, as a special exception, Radim Blazek gives permission - * to link the code of this program with the OpenDWG libraries (or with - * modified versions of the OpenDWG libraries that use the same license - * as OpenDWG libraries), and distribute linked combinations including the two. - * You must obey the GNU General Public License in all respects for all - * of the code used other than. If you modify this file, you may extend - * this exception to your version of the file, but you are not obligated - * to do so. If you do not wish to do so, delete this exception statement - * from your version. - * - * **************************************************************/ - -/* Documentation: - * http://www.opendwg.org - * -> OpenDWG Toolkit Reference - * - * Unsupported entities must be added in wrentity() - * - * TODO: 3rd dimension is not functional for CIRCLE and ARC - * -> required updated of transformation in INSERT - * (how to do that??) - */ - -#define AD_PROTOTYPES -#define AD_VM_PC - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ad2.h" -#include "global.h" - -#define exampleprintf printf -#define LOCPI M_PI - -char buf[1000]; -char buf2[1000]; - -void getEntTypeName(PAD_ENT_HDR adenhd, char *name) -{ - switch (adenhd->enttype) { - case AD_ENT_LINE: - strcpy(name, "LINE"); - break; - case AD_ENT_POINT: - strcpy(name, "POINT"); - break; - case AD_ENT_CIRCLE: - strcpy(name, "CIRCLE"); - break; - case AD_ENT_SHAPE: - strcpy(name, "SHAPE"); - break; - case AD_ENT_ELLIPSE: - strcpy(name, "ELLIPSE"); - break; - case AD_ENT_SPLINE: - strcpy(name, "SPLINE"); - break; - case AD_ENT_TEXT: - strcpy(name, "TEXT"); - break; - case AD_ENT_ARC: - strcpy(name, "ARC"); - break; - case AD_ENT_TRACE: - strcpy(name, "TRACE"); - break; - case AD_ENT_SOLID: - strcpy(name, "SOLID"); - break; - case AD_ENT_BLOCK: - strcpy(name, "BLOCK"); - break; - case AD_ENT_ENDBLK: - strcpy(name, "ENDBLK"); - break; - case AD_ENT_INSERT: - strcpy(name, "INSERT"); - break; - case AD_ENT_ATTDEF: - strcpy(name, "ATTDEF"); - break; - case AD_ENT_ATTRIB: - strcpy(name, "ATTRIB"); - break; - case AD_ENT_SEQEND: - strcpy(name, "SEQEND"); - break; - case AD_ENT_POLYLINE: - strcpy(name, "POLYLINE"); - break; - case AD_ENT_VERTEX: - strcpy(name, "VERTEX"); - break; - case AD_ENT_LINE3D: - strcpy(name, "3DLINE"); - break; - case AD_ENT_FACE3D: - strcpy(name, "3DFACE"); - break; - case AD_ENT_DIMENSION: - strcpy(name, "DIMENSION"); - break; - case AD_ENT_VIEWPORT: - strcpy(name, "VIEWPORT"); - break; - case AD_ENT_SOLID3D: - strcpy(name, "SOLID3D"); - break; - case AD_ENT_RAY: - strcpy(name, "RAY"); - break; - case AD_ENT_XLINE: - strcpy(name, "XLINE"); - break; - case AD_ENT_MTEXT: - strcpy(name, "MTEXT"); - break; - case AD_ENT_LEADER: - strcpy(name, "LEADER"); - break; - case AD_ENT_TOLERANCE: - strcpy(name, "TOLERANCE"); - break; - case AD_ENT_MLINE: - strcpy(name, "MLINE"); - break; - case AD_ENT_BODY: - strcpy(name, "BODY"); - break; - case AD_ENT_REGION: - strcpy(name, "REGION"); - break; - default: - if (adenhd->enttype == adOle2frameEnttype(dwghandle)) - strcpy(name, "OLE2FRAME"); - else if (adenhd->enttype == adLwplineEnttype(dwghandle)) - strcpy(name, "LWPOLYLINE"); - else if (adenhd->enttype == adHatchEnttype(dwghandle)) - strcpy(name, "HATCH"); - else if (adenhd->enttype == adImageEnttype(dwghandle)) - strcpy(name, "IMAGE"); - else if (adenhd->enttype == adArcAlignedTextEnttype(dwghandle)) - strcpy(name, "ArcAlignedText"); - else if (adenhd->enttype == adWipeoutEnttype(dwghandle)) - strcpy(name, "Wipeout"); - else if (adenhd->enttype == adRtextEnttype(dwghandle)) - strcpy(name, "Rtext"); - else { /* regular proxy */ - - G_debug(3, "adenhd->enttype: %d", adenhd->enttype); - strcpy(name, "Proxy"); - } - break; - } -} - -int write_line(PAD_ENT_HDR adenhd, int type, int level) -{ - int i, l; - double x, y, z, r, ang; - - adSeekLayer(dwghandle, adenhd->entlayerobjhandle, Layer); - - /* Transformation, go up through all levels of transformation */ - /* not sure what is the right order of transformation */ - for (l = level; l >= 0; l--) { - for (i = 0; i < Points->n_points; i++) { - /* scale */ - x = Points->x[i] * Trans[l].xscale; - y = Points->y[i] * Trans[l].yscale; - z = Points->z[i] * Trans[l].zscale; - /* rotate */ - r = sqrt(x * x + y * y); - ang = atan2(y, x) + Trans[l].rotang; - x = r * cos(ang); - y = r * sin(ang); - /* move */ - x += Trans[l].dx; - y += Trans[l].dy; - z += Trans[l].dz; - Points->x[i] = x; - Points->y[i] = y; - Points->z[i] = z; - } - } - - Vect_reset_cats(Cats); - Vect_cat_set(Cats, 1, cat); - Vect_write_line(&Map, type, Points, Cats); - - /* Cat */ - sprintf(buf, "insert into %s values ( %d", Fi->table, cat); - db_set_string(&sql, buf); - - /* Entity name */ - getEntTypeName(adenhd, buf2); - sprintf(buf, ", '%s'", buf2); - db_append_string(&sql, buf); - - /* Color */ - sprintf(buf, ", %d", adenhd->entcolor); - db_append_string(&sql, buf); - - /* Weight */ - sprintf(buf, ", %d", adenhd->lineweight); - db_append_string(&sql, buf); - - /* Layer name */ - if (!Layer->purgedflag && Layer->name != NULL) { - db_set_string(&str, Layer->name); - db_double_quote_string(&str); - sprintf(buf, ", '%s'", db_get_string(&str)); - } - else { - sprintf(buf, ", ''"); - } - db_append_string(&sql, buf); - - /* Block name */ - if (Block != NULL) { - db_set_string(&str, Block); - db_double_quote_string(&str); - } - else { - db_set_string(&str, ""); - } - sprintf(buf, ", '%s'", db_get_string(&str)); - db_append_string(&sql, buf); - - /* Text */ - if (Txt != NULL) { - db_set_string(&str, Txt); - db_double_quote_string(&str); - } - else { - db_set_string(&str, ""); - } - sprintf(buf, ", '%s'", db_get_string(&str)); - db_append_string(&sql, buf); - - db_append_string(&sql, ")"); - G_debug(3, db_get_string(&sql)); - - if (db_execute_immediate(driver, &sql) != DB_OK) { - db_close_database(driver); - db_shutdown_driver(driver); - G_fatal_error("Cannot insert new row: %s", db_get_string(&sql)); - } - - cat++; - return 0; -} - -/* Returns 1 if element has geometry and may be written to vector */ -int is_low_level(PAD_ENT_HDR adenhd) -{ - if (adenhd->enttype == AD_ENT_BLOCK || adenhd->enttype == AD_ENT_ENDBLK || - adenhd->enttype == AD_ENT_SEQEND || adenhd->enttype == AD_ENT_INSERT) { - return 0; - } - return 1; -} - -void wrentity(PAD_ENT_HDR adenhd, PAD_ENT aden, int level, AD_VMADDR entlist, - int circle_as_point) -{ - short ret; - PAD_BLOB_CTRL bcptr; - PAD_ENT_HDR adenhd2; - PAD_ENT aden2; - OdaLong il; - double tempdouble[3], tempbulge, tempwidth[3]; - double x, y, z, ang; - PAD_BLKH adblkh; - int layer_found = 1; - - if (is_low_level(adenhd)) - n_elements++; - - /* Check layer name */ - if (layers_opt->answers) { - int i = 0; - - adSeekLayer(dwghandle, adenhd->entlayerobjhandle, Layer); - - layer_found = 0; - if (!Layer->purgedflag) { - while (layers_opt->answers[i]) { - if (strcmp(Layer->name, layers_opt->answers[i]) == 0) { - layer_found = 1; - break; - } - i++; - } - } - - if ((!invert_flag->answer && !layer_found) || - (invert_flag->answer && layer_found)) { - if (is_low_level(adenhd)) - n_skipped++; - if (adenhd->enttype != AD_ENT_INSERT && - adenhd->enttype != AD_ENT_POLYLINE) - return; - } - } - - getEntTypeName(adenhd, buf); - G_debug(1, "Entity: %s", buf); - - Txt = NULL; - adenhd2 = (PAD_ENT_HDR)G_malloc(sizeof(AD_ENT_HDR)); - aden2 = (PAD_ENT)G_malloc(sizeof(AD_ENT)); - adblkh = (PAD_BLKH)G_malloc(sizeof(AD_BLKH)); - Vect_reset_line(Points); - - /* Check space for lower level */ - if (level + 1 == atrans) { - atrans += 10; - Trans = (TRANS *)G_realloc(Trans, atrans * sizeof(TRANS)); - } - - switch (adenhd->enttype) { - case AD_ENT_LINE: - Vect_append_point(Points, aden->line.pt0[0], aden->line.pt0[1], - aden->line.pt0[2]); - Vect_append_point(Points, aden->line.pt1[0], aden->line.pt1[1], - aden->line.pt1[2]); - write_line(adenhd, GV_LINE, level); - break; - - case AD_ENT_FACE3D: - Vect_append_point(Points, aden->face3d.pt0[0], aden->face3d.pt0[1], - aden->face3d.pt0[2]); - Vect_append_point(Points, aden->face3d.pt1[0], aden->face3d.pt1[1], - aden->face3d.pt1[2]); - Vect_append_point(Points, aden->face3d.pt2[0], aden->face3d.pt2[1], - aden->face3d.pt2[2]); - Vect_append_point(Points, aden->face3d.pt3[0], aden->face3d.pt3[1], - aden->face3d.pt3[2]); - write_line(adenhd, GV_FACE, level); - break; - - case AD_ENT_SOLID: - Vect_append_point(Points, aden->solid.pt0[0], aden->solid.pt0[1], - aden->solid.pt0[2]); - Vect_append_point(Points, aden->solid.pt1[0], aden->solid.pt1[1], - aden->solid.pt1[2]); - Vect_append_point(Points, aden->solid.pt2[0], aden->solid.pt2[1], - aden->solid.pt2[2]); - Vect_append_point(Points, aden->solid.pt3[0], aden->solid.pt3[1], - aden->solid.pt3[2]); - write_line(adenhd, GV_FACE, level); - break; - - case AD_ENT_TEXT: - Txt = aden->text.textstr; - Vect_append_point(Points, aden->text.pt0[0], aden->text.pt0[1], - aden->line.pt0[2]); - write_line(adenhd, GV_POINT, level); - break; - - case AD_ENT_POINT: - Vect_append_point(Points, aden->point.pt0[0], aden->point.pt0[1], - aden->line.pt0[2]); - write_line(adenhd, GV_POINT, level); - break; - - case AD_ENT_ARC: - for (ang = aden->arc.stang; ang < aden->arc.endang; - ang += 2 * LOCPI / 360) { - x = aden->arc.pt0[0] + aden->arc.radius * cos(ang); - y = aden->arc.pt0[1] + aden->arc.radius * sin(ang); - z = aden->arc.pt0[2]; - Vect_append_point(Points, x, y, z); - } - x = aden->arc.pt0[0] + aden->arc.radius * cos(aden->arc.endang); - y = aden->arc.pt0[1] + aden->arc.radius * sin(aden->arc.endang); - z = aden->arc.pt0[2]; - Vect_append_point(Points, x, y, z); - write_line(adenhd, GV_LINE, level); - break; - - case AD_ENT_CIRCLE: - if (circle_as_point) { - Vect_append_point(Points, aden->circle.pt0[0], aden->circle.pt0[1], - aden->circle.pt0[3]); - write_line(adenhd, GV_POINT, level); - } - else { - for (ang = 0; ang < 2 * LOCPI; ang += 2 * LOCPI / 360) { - x = aden->circle.pt0[0] + aden->circle.radius * cos(ang); - y = aden->circle.pt0[1] + aden->circle.radius * sin(ang); - z = aden->circle.pt0[3]; - Vect_append_point(Points, x, y, z); - } - Vect_append_point(Points, Points->x[0], Points->y[0], Points->z[0]); - write_line(adenhd, GV_LINE, level); - } - break; - - /* BLOCK starts block of entities but makes no transformation - is it - * right ? - * -> do nothing just warn for xref */ - case AD_ENT_BLOCK: - if (aden->block.xrefpath[0]) { - G_warning("External reference for block not supported.\n xref: %s", - aden->block.xrefpath); - } - Block = G_store(aden->block.name2); - break; - - case AD_ENT_ENDBLK: /* endblk - no data */ - G_free(Block); - Block = NULL; - break; - - case AD_ENT_INSERT: /* insert */ - /* get transformation */ - /* TODO: fix rotation for CIRCLE and ARC */ - G_debug(3, " x,y,z: %f, %f, %f", aden->insert.pt0[0], - aden->insert.pt0[1], aden->insert.pt0[2]); - G_debug(3, " xscale, yscale, zscale: %f, %f, %f", aden->insert.xscale, - aden->insert.yscale, aden->insert.zscale); - G_debug(3, " rotang: %f", aden->insert.rotang); - G_debug(3, " ncols, nrows: %d, %d", aden->insert.numcols, - aden->insert.numrows); - G_debug(3, " coldist, rowdist: %f, %f", aden->insert.coldist, - aden->insert.rowdist); - - /* write block entities */ - adSeekBlockheader(dwghandle, aden->insert.blockheaderobjhandle, adblkh); - if (!adblkh->purgedflag) { - adStartEntityGet(adblkh->entitylist); - while (1) { - ret = adGetEntity(adblkh->entitylist, adenhd2, aden2); - if (adenhd2->enttype == AD_ENT_ENDBLK) - break; - if (ret) { - /* Set transformation for lower level */ - Trans[level + 1].dx = aden->insert.pt0[0]; - Trans[level + 1].dy = aden->insert.pt0[1]; - Trans[level + 1].dz = aden->insert.pt0[2]; - Trans[level + 1].xscale = aden->insert.xscale; - Trans[level + 1].yscale = aden->insert.yscale; - Trans[level + 1].zscale = aden->insert.zscale; - Trans[level + 1].rotang = aden->insert.rotang; - wrentity(adenhd2, aden2, level + 1, adblkh->entitylist, - circle_as_point); - } - } - } - break; - - case AD_ENT_SEQEND: /* seqend */ - break; - - case AD_ENT_POLYLINE: - while (1) { - ret = adGetEntity(entlist, adenhd2, aden2); - if (ret != 1) { - G_warning("Cannot get entity: %d: %s.", adError(), - adErrorStr(adError())); - break; - } - - if (adenhd2->enttype == AD_ENT_SEQEND) - break; - if (adenhd2->enttype != AD_ENT_VERTEX) { - getEntTypeName(adenhd2, buf); - G_warning("Expected VERTEX got %s in POLYLINE -> skip", buf); - } - else { - Vect_append_point(Points, aden2->vertex.pt0[0], - aden2->vertex.pt0[1], aden2->vertex.pt0[2]); - } - }; - if ((!invert_flag->answer && layer_found) || - (invert_flag->answer && !layer_found)) - write_line(adenhd, GV_LINE, level); - break; - - default: - if (adenhd->enttype == adLwplineEnttype(dwghandle)) { - G_debug(3, "Npoints: %ld\n", aden->lwpline.numpoints); - bcptr = adStartBlobRead(aden->lwpline.ldblob); - for (il = 0; il < aden->lwpline.numpoints; il++) { - adReadBlob2Double(bcptr, tempdouble); - Vect_append_point(Points, tempdouble[0], tempdouble[1], - tempdouble[2]); - tempbulge = tempwidth[0] = tempwidth[1] = tempwidth[2] = 0.0; - if (aden->lwpline.flag & AD_LWPLINE_HAS_BULGES) { - adReadBlobDouble(bcptr, &tempbulge); - } - if (aden->lwpline.flag & AD_LWPLINE_HAS_WIDTHS) { - adReadBlob2Double(bcptr, tempwidth); - } - } - G_debug(3, "flag = %d", aden->lwpline.flag); - if (aden->lwpline.flag & AD_LWPLINE_IS_CLOSED) { - G_debug(3, " -> is closed"); - Vect_append_point(Points, Points->x[0], Points->y[0], - Points->z[0]); - } - write_line(adenhd, GV_LINE, level); - adEndBlobRead(bcptr); - } - else { - getEntTypeName(adenhd, buf); - G_warning("%s entity not supported", buf); - } - break; - - } /* end of switch */ - - G_free(aden2); - G_free(adenhd2); -} diff --git a/vector/v.in.dwg/global.h b/vector/v.in.dwg/global.h deleted file mode 100644 index 39e46f17856..00000000000 --- a/vector/v.in.dwg/global.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ************************************************************** - * - * MODULE: v.in.dwg - * - * AUTHOR(S): Radim Blazek - * - * PURPOSE: Import of DWG/DXF files - * - * COPYRIGHT: (C) 2001 by the GRASS Development Team - * - * This program is free software under the - * GNU General Public License (>=v2). - * Read the file COPYING that comes with GRASS - * for details. - * - * In addition, as a special exception, Radim Blazek gives permission - * to link the code of this program with the OpenDWG libraries (or with - * modified versions of the OpenDWG libraries that use the same license - * as OpenDWG libraries), and distribute linked combinations including the two. - * You must obey the GNU General Public License in all respects for all - * of the code used other than. If you modify this file, you may extend - * this exception to your version of the file, but you are not obligated - * to do so. If you do not wish to do so, delete this exception statement - * from your version. - * - * **************************************************************/ - -/* transformation, first level is 0 ( called from main ) and transformation - * for this level is 0,0,0, 1,1,1, 0 so that no transformation is done on first - * level (not effective but better readable?) */ -typedef struct { - double dx, dy, dz; - double xscale, yscale, zscale; - double rotang; -} TRANS; - -extern int cat; -extern int - n_elements; /* number of processed elements (only low level elements) */ -extern int - n_skipped; /* number of skipped low level elements (different layer name) */ -extern struct Map_info Map; -extern dbDriver *driver; -extern dbString sql; -extern dbString str; -extern struct line_pnts *Points; -extern struct line_cats *Cats; -extern PAD_LAY Layer; -extern char *Txt; -extern char *Block; -extern struct field_info *Fi; -extern AD_DB_HANDLE dwghandle; -extern TRANS *Trans; /* transformation */ -extern int atrans; /* number of allocated levels */ -extern struct Option *layers_opt; -extern struct Flag *invert_flag; - -void wrentity(PAD_ENT_HDR adenhd, PAD_ENT aden, int level, AD_VMADDR entlist, - int circle_as_point); diff --git a/vector/v.in.dwg/main.c b/vector/v.in.dwg/main.c deleted file mode 100644 index cc7b9a217b1..00000000000 --- a/vector/v.in.dwg/main.c +++ /dev/null @@ -1,295 +0,0 @@ -/* ************************************************************** - * - * MODULE: v.in.dwg - * - * AUTHOR(S): Radim Blazek - * - * PURPOSE: Import of DWG/DXF files - * - * COPYRIGHT: (C) 2001-2008 by the GRASS Development Team - * - * This program is free software under the - * GNU General Public License (>=v2). - * Read the file COPYING that comes with GRASS - * for details. - * - * In addition, as a special exception, Radim Blazek gives permission - * to link the code of this program with the OpenDWG libraries (or with - * modified versions of the OpenDWG libraries that use the same license - * as OpenDWG libraries), and distribute linked combinations including the two. - * You must obey the GNU General Public License in all respects for all - * of the code used other than. If you modify this file, you may extend - * this exception to your version of the file, but you are not obligated - * to do so. If you do not wish to do so, delete this exception statement - * from your version. - * - * **************************************************************/ -#define AD_PROTOTYPES -#define AD_VM_PC -#define OD_GENERIC_READ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ad2.h" -#include "io/odio.h" -#include "global.h" - -int cat; -int n_elements; /* number of processed elements (only low level elements) */ -int n_skipped; /* number of skipped low level elements (different layer name) */ -struct Map_info Map; -dbDriver *driver; -dbString sql; -dbString str; -struct line_pnts *Points; -struct line_cats *Cats; -PAD_LAY Layer; -char *Txt; -char *Block; -struct field_info *Fi; -AD_DB_HANDLE dwghandle; -TRANS *Trans; /* transformation */ -int atrans; /* number of allocated levels */ -struct Option *layers_opt; -struct Flag *invert_flag; - -int main(int argc, char *argv[]) -{ - struct GModule *module; - struct Option *out_opt, *in_opt; - struct Flag *z_flag, *circle_flag, *l_flag, *int_flag; - const size_t BUFSIZE = 2000; - char buf[BUFSIZE]; - - /* DWG */ - char path[2000]; - short initerror, entset, retval; - AD_OBJHANDLE pspace, mspace; - PAD_ENT_HDR adenhd; - PAD_ENT aden; - AD_VMADDR entlist; - - G_gisinit(argv[0]); - - module = G_define_module(); - G_add_keyword(_("vector")); - G_add_keyword(_("import")); - module->description = _("Converts DWG/DXF to GRASS vector map"); - - in_opt = G_define_standard_option(G_OPT_F_INPUT); - in_opt->description = _("Name of DWG or DXF file"); - - out_opt = G_define_standard_option(G_OPT_V_OUTPUT); - out_opt->required = YES; - - layers_opt = G_define_option(); - layers_opt->key = "layers"; - layers_opt->type = TYPE_STRING; - layers_opt->required = NO; - layers_opt->multiple = YES; - layers_opt->description = _("List of layers to import"); - - invert_flag = G_define_flag(); - invert_flag->key = 'i'; - invert_flag->description = - _("Invert selection by layers (don't import layers in list)"); - - z_flag = G_define_flag(); - z_flag->key = 'z'; - z_flag->description = _("Create 3D vector map"); - - circle_flag = G_define_flag(); - circle_flag->key = 'c'; - circle_flag->description = _("Write circles as points (centre)"); - - l_flag = G_define_flag(); - l_flag->key = 'l'; - l_flag->description = _("List available layers and exit"); - - int_flag = G_define_flag(); - int_flag->key = 'n'; - int_flag->description = _("Use numeric type for attribute \"layer\""); - - if (G_parser(argc, argv)) - exit(EXIT_FAILURE); - - db_init_string(&sql); - db_init_string(&str); - adenhd = (PAD_ENT_HDR)G_malloc(sizeof(AD_ENT_HDR)); - aden = (PAD_ENT)G_malloc(sizeof(AD_ENT)); - Layer = (PAD_LAY)G_malloc(sizeof(AD_LAY)); - Points = Vect_new_line_struct(); - Cats = Vect_new_cats_struct(); - Block = NULL; - - atrans = 20; /* nested, recursive levels */ - Trans = (TRANS *)G_malloc(atrans * sizeof(TRANS)); - - /* Init OpenDWG */ - sprintf(path, "%s/etc/adinit.dat", G_gisbase()); - if (!adInitAd2(path, &initerror)) { - snprintf(buf, BUFSIZE, - _("Unable to initialize OpenDWG Toolkit, error: %d: %s."), - initerror, adErrorStr(initerror)); - size_t buflen = strlen(buf); - if (initerror == AD_UNABLE_TO_OPEN_INIT_FILE) - snprintf(buf + buflen, BUFSIZE - buflen, _(" Cannot open %s"), - path); - G_fatal_error(buf); - } - adSetupDwgRead(); - adSetupDxfRead(); - - /* Open input file */ - if ((dwghandle = adLoadFile(in_opt->answer, AD_PRELOAD_ALL, 1)) == NULL) { - G_fatal_error(_("Unable to open input file <%s>. Error %d: %s"), - in_opt->answer, adError(), adErrorStr(adError())); - } - - if (l_flag->answer) { /* List layers */ - PAD_TB adtb; - AD_DWGHDR adhd; - int i; - char on, frozen, vpfrozen, locked; - - adtb = (PAD_TB)G_malloc(sizeof(AD_TB)); - - G_debug(2, "%d layers", (int)adNumLayers(dwghandle)); - adReadHeaderBlock(dwghandle, &adhd); - adStartLayerGet(dwghandle); - - fprintf(stdout, "%d layers:\n", (int)adNumLayers(dwghandle)); - for (i = 0; i < (int)adNumLayers(dwghandle); i++) { - adGetLayer(dwghandle, &(adtb->lay)); - if (!adtb->lay.purgedflag) { - fprintf(stdout, "%s COLOR %d, ", adtb->lay.name, - adtb->lay.color); - } - adGetLayerState(dwghandle, adtb->lay.objhandle, &on, &frozen, - &vpfrozen, &locked); - if (on) - fprintf(stdout, "ON, "); - else - fprintf(stdout, "OFF, "); - if (frozen) - fprintf(stdout, "FROZEN, "); - else - fprintf(stdout, "THAWED, "); - if (vpfrozen) - fprintf(stdout, "VPFROZEN, "); - else - fprintf(stdout, "VPTHAWED, "); - if (locked) - fprintf(stdout, "LOCKED\n"); - else - fprintf(stdout, "UNLOCKED\n"); - } - adCloseFile(dwghandle); - adCloseAd2(); - exit(EXIT_SUCCESS); - } - - /* open output vector */ - if (Vect_open_new(&Map, out_opt->answer, z_flag->answer) < 0) - G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer); - - Vect_hist_command(&Map); - - /* Add DB link */ - Fi = Vect_default_field_info(&Map, 1, NULL, GV_1TABLE); - Vect_map_add_dblink(&Map, 1, NULL, Fi->table, GV_KEY_COLUMN, Fi->database, - Fi->driver); - - driver = db_start_driver_open_database(Fi->driver, - Vect_subst_var(Fi->database, &Map)); - if (driver == NULL) { - G_fatal_error(_("Unable to open database <%s> by driver <%s>"), - Vect_subst_var(Fi->database, &Map), Fi->driver); - } - db_set_error_handler_driver(driver); - - db_begin_transaction(driver); - - /* Create table */ - if (int_flag->answer) { /* List layers */ - sprintf(buf, - "create table %s ( cat integer, entity_name varchar(20), color " - "int, weight int, " - "layer real, block varchar(100), txt varchar(100) )", - Fi->table); - } - else { - sprintf(buf, - "create table %s ( cat integer, entity_name varchar(20), color " - "int, weight int, " - "layer varchar(100), block varchar(100), txt varchar(100) )", - Fi->table); - } - db_set_string(&sql, buf); - G_debug(3, db_get_string(&sql)); - - if (db_execute_immediate(driver, &sql) != DB_OK) { - db_close_database(driver); - db_shutdown_driver(driver); - G_fatal_error(_("Unable to create table: '%s'"), db_get_string(&sql)); - } - - if (db_create_index2(driver, Fi->table, GV_KEY_COLUMN) != DB_OK) - G_warning(_("Unable to create index for table <%s>, key <%s>"), - Fi->table, GV_KEY_COLUMN); - - if (db_grant_on_table(driver, Fi->table, DB_PRIV_SELECT, - DB_GROUP | DB_PUBLIC) != DB_OK) - G_fatal_error(_("Unable to grant privileges on table <%s>"), Fi->table); - - cat = 1; - n_elements = n_skipped = 0; - /* Write each entity. Some entities may be composed by other entities (like - * INSERT or BLOCK) */ - /* Set transformation for first (index 0) level */ - Trans[0].dx = Trans[0].dy = Trans[0].dz = 0; - Trans[0].xscale = Trans[0].yscale = Trans[0].zscale = 1; - Trans[0].rotang = 0; - if (adGetBlockHandle(dwghandle, pspace, AD_PAPERSPACE_HANDLE)) { - entlist = adEntityList(dwghandle, pspace); - adStartEntityGet(entlist); - for (entset = 0; entset < 2; entset++) { - do { - if (!(retval = adGetEntity(entlist, adenhd, aden))) - continue; - wrentity(adenhd, aden, 0, entlist, circle_flag->answer); - } while (retval == 1); - if (entset == 0) { - if (adGetBlockHandle(dwghandle, mspace, AD_MODELSPACE_HANDLE)) { - entlist = adEntityList(dwghandle, mspace); - adStartEntityGet(entlist); - } - } - } - } - - db_commit_transaction(driver); - db_close_database_shutdown_driver(driver); - - adCloseFile(dwghandle); - adCloseAd2(); - - Vect_build(&Map, stderr); - Vect_close(&Map); - - if (n_skipped > 0) - G_message(_("%d elements skipped (layer name was not in list)"), - n_skipped); - - G_done_msg(_("%d elements processed"), n_elements); - - exit(EXIT_SUCCESS); -} diff --git a/vector/v.in.dwg/v.in.dwg.html b/vector/v.in.dwg/v.in.dwg.html deleted file mode 100644 index 60f00966f9d..00000000000 --- a/vector/v.in.dwg/v.in.dwg.html +++ /dev/null @@ -1,32 +0,0 @@ -

DESCRIPTION

- -v.in.dwg imports DWG/DXF file into GRASS. - -

EXAMPLE

- -
-v.in.dwg input=map.dwg output=map
-
- -

NOTES

- -v.in.dwg requires OpenDWG toolkit. To get this toolkit you must become at -least "Associate Member" of OpenDWG Alliance (http://www.opendesign.com/). -

The toolkit, for example ad27linx.tar, unpack in a directory -(e.g. /home/usr1/opendwg27) and use the related configure options -to tell GRASS about it: - -

-   ./configure \
-   ... \
-   --with-opendwg \
-   --with-opendwg-includes=/home/usr1/opendwg27 \
-   --with-opendwg-libs=/home/usr1/opendwg27
-
- -Then you can compile this module. -

Not all entity types are supported (warning printed). - -

AUTHOR

- -Radim Blazek, ITC-Irst, Trento, Italy