[qgis] 04/08: Imported Upstream version 2.8.1+dfsg
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Sat Feb 28 21:38:43 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository qgis.
commit 0ee8ff46b8d6ae0486d1372c784f8bf5041dfcc2
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Sat Feb 28 20:42:22 2015 +0100
Imported Upstream version 2.8.1+dfsg
---
src/plugins/dxf2shp_converter/CMakeLists.txt | 54 -
src/plugins/dxf2shp_converter/README | 27 -
src/plugins/dxf2shp_converter/builder.cpp | 621 ---
src/plugins/dxf2shp_converter/builder.h | 88 -
.../dxf2shp_converter/dxf2shp_converter.png | Bin 805 -> 0 bytes
src/plugins/dxf2shp_converter/dxf2shpconverter.cpp | 220 -
src/plugins/dxf2shp_converter/dxf2shpconverter.h | 88 -
src/plugins/dxf2shp_converter/dxf2shpconverter.qrc | 5 -
.../dxf2shp_converter/dxf2shpconvertergui.cpp | 193 -
.../dxf2shp_converter/dxf2shpconvertergui.h | 50 -
.../dxf2shp_converter/dxf2shpconvertergui.ui | 151 -
src/plugins/dxf2shp_converter/dxflib/confdefs.h | 3 -
.../dxf2shp_converter/dxflib/src/dl_attributes.h | 201 -
.../dxf2shp_converter/dxflib/src/dl_codes.h | 545 --
.../dxflib/src/dl_creationadapter.h | 103 -
.../dxflib/src/dl_creationinterface.h | 266 -
.../dxf2shp_converter/dxflib/src/dl_dxf.cpp | 5600 --------------------
src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h | 431 --
.../dxf2shp_converter/dxflib/src/dl_entities.h | 1434 -----
.../dxf2shp_converter/dxflib/src/dl_exception.h | 59 -
.../dxf2shp_converter/dxflib/src/dl_extrusion.h | 161 -
.../dxf2shp_converter/dxflib/src/dl_writer.h | 685 ---
.../dxflib/src/dl_writer_ascii.cpp | 170 -
.../dxf2shp_converter/dxflib/src/dl_writer_ascii.h | 80 -
src/plugins/dxf2shp_converter/getInsertions.cpp | 81 -
src/plugins/dxf2shp_converter/getInsertions.h | 60 -
.../dxf2shp_converter/shapelib-1.2.10/LICENSE.LGPL | 483 --
.../dxf2shp_converter/shapelib-1.2.10/dbfopen.c | 1502 ------
.../dxf2shp_converter/shapelib-1.2.10/shapefil.h | 486 --
.../dxf2shp_converter/shapelib-1.2.10/shapelib.def | 42 -
.../dxf2shp_converter/shapelib-1.2.10/shpopen.c | 1878 -------
.../dxf2shp_converter/shapelib-1.2.10/shprewind.c | 108 -
32 files changed, 15875 deletions(-)
diff --git a/src/plugins/dxf2shp_converter/CMakeLists.txt b/src/plugins/dxf2shp_converter/CMakeLists.txt
deleted file mode 100644
index 6e03db4..0000000
--- a/src/plugins/dxf2shp_converter/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-
-########################################################
-# Files
-
-SET (dxf2shpconverter_SRCS
- dxf2shpconverter.cpp
- dxf2shpconvertergui.cpp
- builder.cpp
- getInsertions.cpp
- dxflib/src/dl_dxf.cpp
- dxflib/src/dl_writer_ascii.cpp
- )
-
-SET (dxf2shpconverter_UIS dxf2shpconvertergui.ui)
-
-SET (dxf2shpconverter_MOC_HDRS
- dxf2shpconverter.h
- dxf2shpconvertergui.h
- )
-
-SET (dxf2shpconverter_RCCS dxf2shpconverter.qrc)
-
-########################################################
-# Build
-
-QT4_WRAP_UI (dxf2shpconverter_UIS_H ${dxf2shpconverter_UIS})
-
-QT4_WRAP_CPP (dxf2shpconverter_MOC_SRCS ${dxf2shpconverter_MOC_HDRS})
-
-QT4_ADD_RESOURCES(dxf2shpconverter_RCC_SRCS ${dxf2shpconverter_RCCS})
-
-ADD_LIBRARY (dxf2shpconverterplugin MODULE ${dxf2shpconverter_SRCS} ${dxf2shpconverter_MOC_SRCS} ${dxf2shpconverter_RCC_SRCS} ${dxf2shpconverter_UIS_H})
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_BINARY_DIR}
- ../../core
- ../../core/raster
- ../../gui
- ..
-)
-
-TARGET_LINK_LIBRARIES(dxf2shpconverterplugin
- qgis_core
- qgis_gui
-)
-
-
-########################################################
-# Install
-
-INSTALL(TARGETS dxf2shpconverterplugin
- RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
- LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
-
diff --git a/src/plugins/dxf2shp_converter/README b/src/plugins/dxf2shp_converter/README
deleted file mode 100644
index bc53cea..0000000
--- a/src/plugins/dxf2shp_converter/README
+++ /dev/null
@@ -1,27 +0,0 @@
-/***************************************************************************
- *Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
- * CNR, Milan Unit (Information Technology), *
- * Construction Technologies Institute.\n"; *
- * *
- * email : Paolo L. Scala <scala at itc.cnr.it> *
- * *
- * This is a plugin generated from the QGIS plugin template *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
- DXF2SHP Plugin converter
-
-We've just developed and partially tested this plugin that converts a DXF file
-into one or more vector layers in QGIS; it can also extract labels from the
-DXF file and inserts the data (string, x, y, z, angle) in the dbf file of a new
-point layer populated with points located where the labels should be rendered.
-The purpose is to let Mapserver render them.
-
-The plugin uses shapelib and dxflib to convert and create the shp files.
-For any suggestion or criticism, please contact us at:
-
-scala at itc.cnr.it
-barricelli at itc.cnr.it
diff --git a/src/plugins/dxf2shp_converter/builder.cpp b/src/plugins/dxf2shp_converter/builder.cpp
deleted file mode 100644
index af56db4..0000000
--- a/src/plugins/dxf2shp_converter/builder.cpp
+++ /dev/null
@@ -1,621 +0,0 @@
-// The code is heavily based on Christopher Michaelis' DXF to Shapefile Converter
-// (http://www.wanderingidea.com/content/view/12/25/), released under GPL License
-//
-// This code is based on two other products:
-// DXFLIB (http://www.ribbonsoft.com/dxflib.html)
-// This is a library for reading DXF files, also GPL.
-// SHAPELIB (http://shapelib.maptools.org/)
-// Used for the Shapefile functionality.
-// It is Copyright (c) 1999, Frank Warmerdam, released under the following "MIT Style" license:
-//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
-//documentation files (the "Software"), to deal in the Software without restriction, including without limitation
-//the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
-//and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-//OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-//LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-//IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#include <cmath>
-#include <string>
-
-#include "builder.h"
-
-#include "qgslogger.h"
-
-Builder::Builder( std::string theFname,
- int theShapefileType,
- double *theGrpXVals, double *theGrpYVals,
- std::string *theGrpNames,
- int theInsertCount,
- bool theConvertText )
- : fname( theFname )
- , shapefileType( theShapefileType )
- , grpXVals( theGrpXVals )
- , grpYVals( theGrpYVals )
- , grpNames( theGrpNames )
- , insertCount( theInsertCount )
- , convertText( theConvertText )
- , fetchedprims( 0 )
- , fetchedtexts( 0 )
- , ignoringBlock( false )
- , current_polyline_willclose( false )
- , store_next_vertex_for_polyline_close( false )
- , current_polyline_pointcount( 0 )
- , closePolyX( 0.0 )
- , closePolyY( 0.0 )
- , closePolyZ( 0.0 )
- , currentBlockX( 0.0 )
- , currentBlockY( 0.0 )
-{
-}
-
-Builder::~Builder()
-{
- polyVertex.clear();
- shpObjects.clear();
- textObjects.clear();
-}
-
-int Builder::textObjectsSize()
-{
- return textObjects.size();
-}
-
-std::string Builder::outputShp()
-{
- return outputshp;
-}
-
-std::string Builder::outputTShp()
-{
- return outputtshp;
-}
-
-void Builder::addBlock( const DL_BlockData& data )
-{
- QgsDebugMsg( "start block." );
-
- if ( data.name.compare( "ADCADD_ZZ" ) == 0 )
- {
- QgsDebugMsg( QString( "Ignoring block %1" ).arg( data.name.c_str() ) );
- ignoringBlock = true;
- }
- else
- {
- for ( int i = 0; i < insertCount; i++ )
- {
- if ( grpNames[i] == data.name )
- {
- currentBlockX = grpXVals[i];
- currentBlockY = grpYVals[i];
- QgsDebugMsg( QString( "Found coord for block: (%1,%2)" ).arg( grpXVals[i] ).arg( grpYVals[i] ) );
- }
- }
- }
-}
-
-void Builder::endBlock()
-{
- FinalizeAnyPolyline();
-
- currentBlockX = 0.0;
- currentBlockY = 0.0;
- ignoringBlock = false;
-
- QgsDebugMsg( "end block." );
-}
-
-void Builder::addLayer( const DL_LayerData& data )
-{
- Q_UNUSED( data );
- QgsDebugMsg( QString( "Layer: %1" ).arg( data.name.c_str() ) );
-}
-
-void Builder::addPoint( const DL_PointData& data )
-{
- if ( shapefileType != SHPT_POINT )
- {
- QgsDebugMsg( "ignoring point" );
- return;
- }
-
- QgsDebugMsg( QString( "point (%1,%2,%3)" ).arg( data.x ).arg( data.y ).arg( data.z ) );
-
- if ( ignoringBlock )
- {
- QgsDebugMsg( "skipping point in block." );
- return;
- }
-
-
- double x = data.x + currentBlockX;
- double y = data.y + currentBlockY;
- double z = data.z;
-
- SHPObject *psObject;
- psObject = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, 1, &x, &y, &z, NULL );
-
- shpObjects.push_back( psObject );
-
- fetchedprims++;
-}
-
-void Builder::addLine( const DL_LineData& data )
-{
- //data.x1, data.y1, data.z1
- //data.x2, data.y2, data.z2
-
- if ( shapefileType != SHPT_ARC )
- {
- QgsDebugMsg( "ignoring line" );
- return;
- }
-
- QgsDebugMsg( QString( "line %1,%2,%3 %4,%5,%6" )
- .arg( data.x1 ).arg( data.y1 ).arg( data.z1 )
- .arg( data.x2 ).arg( data.y2 ).arg( data.z2 ) );
-
- if ( ignoringBlock )
- {
- QgsDebugMsg( "skipping line in block." );
- return;
- }
-
-
- double xv[2], yv[2], zv[2];
- xv[0] = data.x1 + currentBlockX;
- yv[0] = data.y1 + currentBlockY;
- zv[0] = data.z1;
-
- xv[1] = data.x2 + currentBlockX;
- yv[1] = data.y2 + currentBlockY;
- zv[1] = data.z2;
-
- SHPObject *psObject;
-
- psObject = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, 2, xv, yv, zv, NULL );
-
- shpObjects.push_back( psObject );
-
- fetchedprims++;
-}
-
-
-void Builder::addPolyline( const DL_PolylineData& data )
-{
- if ( shapefileType != SHPT_ARC && shapefileType != SHPT_POLYGON )
- {
- QgsDebugMsg( "ignoring polyline" );
- return;
- }
-
- QgsDebugMsg( "reading polyline - expecting vertices" );
-
- if ( ignoringBlock )
- {
- QgsDebugMsg( "skipping polyline in block" );
- return;
- }
-
- // Add previously created polyline if not finalized yet
- if ( current_polyline_pointcount > 0 )
- {
- if ( current_polyline_willclose )
- {
-
- DL_VertexData myVertex;
-
- myVertex.x = closePolyX;
- myVertex.y = closePolyY;
- myVertex.z = closePolyZ;
-
- polyVertex.push_back( myVertex );
-
- }
-
- SHPObject *psShape;
- int dim = polyVertex.size();
- double *xv = new double[dim];
- double *yv = new double[dim];
- double *zv = new double[dim];
-
- for ( int i = 0; i < dim; i++ )
- {
- xv[i] = polyVertex[i].x;
- yv[i] = polyVertex[i].y;
- zv[i] = polyVertex[i].z;
- }
-
- psShape = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, dim, xv, yv, zv, NULL );
-
- delete [] xv;
- delete [] yv;
- delete [] zv;
-
- shpObjects.push_back( psShape );
-
-
- fetchedprims++;
-
- polyVertex.clear();
-
- QgsDebugMsg( QString( "polyline prepared: %1" ).arg( fetchedprims - 1 ) );
- current_polyline_pointcount = 0;
- }
-
- // Now that the currently-adding polyline (if any) is
- // finalized, parse out the flag options
-
- if ( data.flags == 1 || data.flags == 32 )
- {
- current_polyline_willclose = true;
- store_next_vertex_for_polyline_close = true;
- }
- else
- {
- current_polyline_willclose = false;
- store_next_vertex_for_polyline_close = false;
- }
-
- current_polyline_pointcount = 0;
-
-}
-
-
-void Builder::addVertex( const DL_VertexData& data )
-{
- if ( shapefileType != SHPT_ARC && shapefileType != SHPT_POLYGON )
- {
- QgsDebugMsg( "ignoring vertex" );
- return;
- }
-
- QgsDebugMsg( QString( "vertex (%1,%2,%3)" ).arg( data.x ).arg( data.y ).arg( data.z ) );
-
- if ( ignoringBlock )
- {
- QgsDebugMsg( "skipping vertex in block" );
- return;
- }
-
- DL_VertexData myVertex;
- myVertex.x = data.x + currentBlockX;
- myVertex.y = data.y + currentBlockY;
- myVertex.z = data.z;
-
- polyVertex.push_back( myVertex );
-
- current_polyline_pointcount++;
-
- if ( store_next_vertex_for_polyline_close )
- {
- store_next_vertex_for_polyline_close = false;
- closePolyX = data.x + currentBlockX;
- closePolyY = data.y + currentBlockY;
- closePolyZ = data.z;
- }
-}
-
-
-void Builder::endSequence()
-{
- QgsDebugMsg( "endSequence" );
-}
-
-void Builder::addArc( const DL_ArcData& data )
-{
- if ( shapefileType != SHPT_ARC )
- {
- QgsDebugMsg( "ignoring arc" );
- return;
- }
-
- int fromAngle = ( int ) data.angle1 + 1;
- int toAngle = ( int ) data.angle2 + 1;
-
- QgsDebugMsg( QString( "arc (%1,%2,%3 r=%4 a1=%5 a2=%6)" )
- .arg( data.cx ).arg( data.cy ).arg( data.cz )
- .arg( data.radius )
- .arg( data.angle1 ).arg( data.angle2 ) );
-
- if ( ignoringBlock )
- {
- QgsDebugMsg( "skipping arc in block" );
- return;
- }
-
- int i = 0;
- long shpIndex = 0;
-
- // Approximate the arc
-
- double radianMeasure;
-
- std::vector <DL_PointData> arcPoints;
- DL_PointData myPoint;
-
- for ( i = fromAngle; ; i++, shpIndex++ )
- {
- if ( i > 360 )
- i = 0;
-
- if ( shpIndex > 1000 )
- break;
-
- radianMeasure = i * M_PI / 180.0;
-
- myPoint.x = data.radius * cos( radianMeasure ) + data.cx + currentBlockX;
- myPoint.y = data.radius * sin( radianMeasure ) + data.cy + currentBlockY;
- myPoint.z = data.cz;
-
- arcPoints.push_back( myPoint );
-
- if ( i == toAngle )
- break;
- }
-
- // Finalize
-
- SHPObject *psShape;
- int dim = arcPoints.size();
- double *xv = new double[dim];
- double *yv = new double[dim];
- double *zv = new double[dim];
-
- for ( int i = 0; i < dim; i++ )
- {
- xv[i] = arcPoints[i].x;
- yv[i] = arcPoints[i].y;
- zv[i] = arcPoints[i].z;
-
- }
-
- psShape = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, dim, xv, yv, zv, NULL );
-
- delete [] xv;
- delete [] yv;
- delete [] zv;
-
- shpObjects.push_back( psShape );
-
- fetchedprims++;
-
- arcPoints.clear();
-
-}
-
-
-void Builder::addCircle( const DL_CircleData& data )
-{
- if ( shapefileType != SHPT_ARC && shapefileType != SHPT_POLYGON )
- {
- QgsDebugMsg( "ignoring circle" );
- return;
- }
-
- QgsDebugMsg( QString( "circle (%1,%2,%3 r=%4)" ).arg( data.cx ).arg( data.cy ).arg( data.cz ).arg( data.radius ) );
-
- if ( ignoringBlock )
- {
- QgsDebugMsg( "skipping circle in block" );
- return;
- }
-
-
- std::vector <DL_PointData> circlePoints;
- DL_PointData myPoint;
-
- // Approximate the circle with 360 line segments connecting points along that circle
- long shpIndex = 0;
- for ( double i = 0.0; i <= 2*M_PI; i += M_PI / 180.0, shpIndex++ )
- {
- myPoint.x = data.radius * cos( i ) + data.cx + currentBlockX;
- myPoint.y = data.radius * sin( i ) + data.cy + currentBlockY;
- myPoint.z = data.cz;
-
- circlePoints.push_back( myPoint );
- }
-
- SHPObject *psShape;
- int dim = circlePoints.size();
- double *xv = new double[dim];
- double *yv = new double[dim];
- double *zv = new double[dim];
-
- for ( int i = 0; i < dim; i++ )
- {
- xv[i] = circlePoints[i].x;
- yv[i] = circlePoints[i].y;
- zv[i] = circlePoints[i].z;
- }
-
- psShape = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, dim, xv, yv, zv, NULL );
-
- delete [] xv;
- delete [] yv;
- delete [] zv;
-
- shpObjects.push_back( psShape );
-
- fetchedprims++;
-
- circlePoints.clear();
-}
-
-void Builder::addText( const DL_TextData &data )
-{
- if ( convertText )
- {
- DL_TextData myText(
- data.ipx + currentBlockX, data.ipy + currentBlockY, data.ipz,
- data.apx, data.apy, data.apz,
- data.height, data.xScaleFactor, data.textGenerationFlags,
- data.hJustification, data.vJustification,
- data.text, data.style, data.angle
- );
-
- textObjects.push_back( myText );
-
- QgsDebugMsg( QString( "text: %1" ).arg( data.text.c_str() ) );
- fetchedtexts++;
- }
-}
-
-void Builder::FinalizeAnyPolyline()
-{
- // Save the last polyline / polygon if one exists.
- if ( current_polyline_pointcount > 0 )
- {
- if ( current_polyline_willclose )
- {
- DL_VertexData myVertex;
- myVertex.x = closePolyX;
- myVertex.y = closePolyY;
- myVertex.z = closePolyZ;
-
- polyVertex.push_back( myVertex );
- }
-
- SHPObject *psObject;
- int dim = polyVertex.size();
- double *xv = new double[dim];
- double *yv = new double[dim];
- double *zv = new double[dim];
-
- for ( int i = 0; i < dim; i++ )
- {
- xv[i] = polyVertex[i].x;
- yv[i] = polyVertex[i].y;
- zv[i] = polyVertex[i].z;
- }
-
- psObject = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, dim, xv, yv, zv, NULL );
-
- delete [] xv;
- delete [] yv;
- delete [] zv;
-
- shpObjects.push_back( psObject );
-
- polyVertex.clear();
-
- fetchedprims++;
-
- QgsDebugMsg( QString( "Finalized adding of polyline shape %1" ).arg( fetchedprims - 1 ) );
- current_polyline_pointcount = 0;
- }
-}
-
-void Builder::print_shpObjects()
-{
- int dim = shpObjects.size();
- int dimTexts = textObjects.size();
-
- QgsDebugMsg( QString( "Number of primitives: %1" ).arg( dim ) );
- QgsDebugMsg( QString( "Number of text fields: %1" ).arg( dimTexts ) );
-
- SHPHandle hSHP;
-
- if ( fname.substr( fname.length() - 4 ).compare( ".shp" ) == 0 )
- {
- outputdbf = fname;
- outputdbf = outputdbf.replace(( outputdbf.length() - 3 ), outputdbf.length(), "dbf" );
- outputshp = fname;
- outputshp = outputshp.replace(( outputshp.length() - 3 ), outputshp.length(), "shp" );
- outputtdbf = fname;
- outputtdbf = outputtdbf.replace(( outputtdbf.length() - 4 ), outputtdbf.length(), "_texts.dbf" );
- outputtshp = fname;
- outputtshp = outputtshp.replace(( outputtshp.length() - 4 ), outputtshp.length(), "_texts.shp" );
- }
- else
- {
- outputdbf = outputtdbf = fname + ".dbf";
- outputshp = outputtshp = fname + ".shp";
- }
-
- DBFHandle dbffile = DBFCreate( outputdbf.c_str() );
- DBFAddField( dbffile, "myid", FTInteger, 10, 0 );
-
- hSHP = SHPCreate( outputshp.c_str(), shapefileType );
-
- QgsDebugMsg( "Writing to main shp file..." );
-
- for ( int i = 0; i < dim; i++ )
- {
- SHPWriteObject( hSHP, -1, shpObjects[i] );
- SHPDestroyObject( shpObjects[i] );
- DBFWriteIntegerAttribute( dbffile, i, 0, i );
- }
-
- SHPClose( hSHP );
- DBFClose( dbffile );
-
- QgsDebugMsg( "Done!" );
-
- if ( convertText && dimTexts > 0 )
- {
- SHPHandle thSHP;
-
- DBFHandle Tdbffile = DBFCreate( outputtdbf.c_str() );
- thSHP = SHPCreate( outputtshp.c_str(), SHPT_POINT );
-
- DBFAddField( Tdbffile, "tipx", FTDouble, 20, 10 );
- DBFAddField( Tdbffile, "tipy", FTDouble, 20, 10 );
- DBFAddField( Tdbffile, "tipz", FTDouble, 20, 10 );
- DBFAddField( Tdbffile, "tapx", FTDouble, 20, 10 );
- DBFAddField( Tdbffile, "tapy", FTDouble, 20, 10 );
- DBFAddField( Tdbffile, "tapz", FTDouble, 20, 10 );
- DBFAddField( Tdbffile, "height", FTDouble, 20, 10 );
- DBFAddField( Tdbffile, "scale", FTDouble, 20, 10 );
- DBFAddField( Tdbffile, "flags", FTInteger, 10, 0 );
- DBFAddField( Tdbffile, "hjust", FTInteger, 10, 0 );
- DBFAddField( Tdbffile, "vjust", FTInteger, 10, 0 );
- DBFAddField( Tdbffile, "text", FTString, 50, 0 );
- DBFAddField( Tdbffile, "style", FTString, 50, 0 );
- DBFAddField( Tdbffile, "angle", FTDouble, 20, 10 );
-
- QgsDebugMsg( "Writing Texts' shp File..." );
-
- for ( int i = 0; i < dimTexts; i++ )
- {
- SHPObject *psObject;
- double x = textObjects[i].ipx;
- double y = textObjects[i].ipy;
- double z = textObjects[i].ipz;
- psObject = SHPCreateObject( SHPT_POINT, i, 0, NULL, NULL, 1, &x, &y, &z, NULL );
-
- SHPWriteObject( thSHP, -1, psObject );
-
- DBFWriteDoubleAttribute( Tdbffile, i, 0, textObjects[i].ipx );
- DBFWriteDoubleAttribute( Tdbffile, i, 1, textObjects[i].ipy );
- DBFWriteDoubleAttribute( Tdbffile, i, 2, textObjects[i].ipz );
-
- DBFWriteDoubleAttribute( Tdbffile, i, 3, textObjects[i].apx );
- DBFWriteDoubleAttribute( Tdbffile, i, 4, textObjects[i].apy );
- DBFWriteDoubleAttribute( Tdbffile, i, 5, textObjects[i].apz );
-
- DBFWriteDoubleAttribute( Tdbffile, i, 6, textObjects[i].height );
- DBFWriteDoubleAttribute( Tdbffile, i, 7, textObjects[i].xScaleFactor );
- DBFWriteIntegerAttribute( Tdbffile, i, 8, textObjects[i].textGenerationFlags );
-
- DBFWriteIntegerAttribute( Tdbffile, i, 9, textObjects[i].hJustification );
- DBFWriteIntegerAttribute( Tdbffile, i, 10, textObjects[i].vJustification );
-
- DBFWriteStringAttribute( Tdbffile, i, 11, textObjects[i].text.c_str() );
- DBFWriteStringAttribute( Tdbffile, i, 12, textObjects[i].style.c_str() );
-
- DBFWriteDoubleAttribute( Tdbffile, i, 13, textObjects[i].angle );
-
- SHPDestroyObject( psObject );
- }
- SHPClose( thSHP );
- DBFClose( Tdbffile );
-
- QgsDebugMsg( "Done!" );
- }
-}
diff --git a/src/plugins/dxf2shp_converter/builder.h b/src/plugins/dxf2shp_converter/builder.h
deleted file mode 100644
index 0f6a412..0000000
--- a/src/plugins/dxf2shp_converter/builder.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// The code is heavily based on Christopher Michaelis' DXF to Shapefile Converter
-// (http://www.wanderingidea.com/content/view/12/25/), released under GPL License
-//
-// This code is based on two other products:
-// DXFLIB (http://www.ribbonsoft.com/dxflib.html)
-// This is a library for reading DXF files, also GPL.
-// SHAPELIB (http://shapelib.maptools.org/)
-// Used for the Shapefile functionality.
-// It is Copyright (c) 1999, Frank Warmerdam, released under the following "MIT Style" license:
-//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
-//documentation files (the "Software"), to deal in the Software without restriction, including without limitation
-//the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
-//and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-//OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-//LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-//IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#include "dxflib/src/dl_creationadapter.h"
-#include "shapelib-1.2.10/shapefil.h"
-#include "getInsertions.h"
-#include <vector>
-
-class Builder: public DL_CreationAdapter
-{
- public:
- Builder( std::string theFname,
- int theShapefileType,
- double *theGrpXVals, double *theGrpYVals,
- std::string *theGrpNames,
- int theInsertCount,
- bool theConvertText );
- ~Builder();
-
- void FinalizeAnyPolyline();
-
- virtual void addLayer( const DL_LayerData &data ) override;
- virtual void addPoint( const DL_PointData &data ) override;
- virtual void addLine( const DL_LineData &data ) override;
- virtual void addPolyline( const DL_PolylineData &data ) override;
- virtual void addArc( const DL_ArcData &data ) override;
- virtual void addCircle( const DL_CircleData &data ) override;
- virtual void addVertex( const DL_VertexData &data ) override;
- virtual void addBlock( const DL_BlockData &data ) override;
- virtual void endBlock() override;
- virtual void endSequence() override;
- virtual void addText( const DL_TextData &data ) override;
-
- void print_shpObjects();
-
- int textObjectsSize();
- std::string outputShp();
- std::string outputTShp();
-
- private:
- std::string fname;
- int shapefileType; // SHPT_POINT, ...
- double *grpXVals;
- double *grpYVals;
- std::string *grpNames;
- int insertCount;
- bool convertText;
-
- std::string outputdbf;
- std::string outputshp;
- std::string outputtdbf;
- std::string outputtshp;
-
- std::vector <DL_VertexData> polyVertex;
- std::vector <SHPObject *> shpObjects; // all read objects are stored here
- std::vector <DL_TextData> textObjects;
-
- int fetchedprims;
- int fetchedtexts;
-
- bool ignoringBlock;
- bool current_polyline_willclose;
- bool store_next_vertex_for_polyline_close;
-
- long current_polyline_pointcount;
-
- double closePolyX, closePolyY, closePolyZ;
- double currentBlockX, currentBlockY;
-};
diff --git a/src/plugins/dxf2shp_converter/dxf2shp_converter.png b/src/plugins/dxf2shp_converter/dxf2shp_converter.png
deleted file mode 100644
index 1e63301..0000000
Binary files a/src/plugins/dxf2shp_converter/dxf2shp_converter.png and /dev/null differ
diff --git a/src/plugins/dxf2shp_converter/dxf2shpconverter.cpp b/src/plugins/dxf2shp_converter/dxf2shpconverter.cpp
deleted file mode 100644
index 64409c2..0000000
--- a/src/plugins/dxf2shp_converter/dxf2shpconverter.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-/***************************************************************************
- *Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
- * CNR, Milan Unit (Information Technology), *
- * Construction Technologies Institute.\n"; *
- * *
- * email : Paolo L. Scala <scala at itc.cnr.it> *
- * *
- * This is a plugin generated from the QGIS plugin template *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
-
-//
-// QGIS Specific includes
-//
-
-#include <qgisinterface.h>
-#include <qgisgui.h>
-#include <qgsapplication.h>
-#include <qgsvectorlayer.h>
-
-#include "dxf2shpconverter.h"
-#include "dxf2shpconvertergui.h"
-
-//
-// Qt4 Related Includes
-//
-
-#include <QAction>
-#include <QFile>
-#include <QToolBar>
-
-static const QString sName = QObject::tr( "Dxf2Shp Converter" );
-static const QString sDescription = QObject::tr( "Converts from dxf to shp file format" );
-static const QString sCategory = QObject::tr( "Vector" );
-static const QString sPluginVersion = QObject::tr( "Version 0.1" );
-static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
-static const QString sPluginIcon = ":/dxf2shp_converter.png";
-
-//////////////////////////////////////////////////////////////////////
-//
-// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
-//
-//////////////////////////////////////////////////////////////////////
-
-/**
- * Constructor for the plugin. The plugin is passed a pointer
- * an interface object that provides access to exposed functions in QGIS.
- * @param theQGisInterface - Pointer to the QGIS interface object
- */
-dxf2shpConverter::dxf2shpConverter( QgisInterface *theQgisInterface )
- : QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
- , mQGisIface( theQgisInterface )
- , mQActionPointer( 0 )
-{}
-
-dxf2shpConverter::~dxf2shpConverter()
-{
-
-}
-
-/*
- * Initialize the GUI interface for the plugin - this is only called once when the plugin is
- * added to the plugin registry in the QGIS application.
- */
-void dxf2shpConverter::initGui()
-{
- // Create the action for tool
- delete mQActionPointer;
- mQActionPointer = new QAction( QIcon(), "Dxf2Shp Converter", this );
- mQActionPointer->setObjectName( "mQActionPointer" );
-
- // Set the icon
- setCurrentTheme( "" );
-
- // Set the what's this text
- mQActionPointer->setWhatsThis( tr( "Converts DXF files in Shapefile format" ) );
-
- // Connect the action to the run
- connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) );
-
- // Add the icon to the toolbar
- mQGisIface->addVectorToolBarIcon( mQActionPointer );
- mQGisIface->addPluginToVectorMenu( tr( "&Dxf2Shp" ), mQActionPointer );
-
- // this is called when the icon theme is changed
- connect( mQGisIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );
-}
-
-//method defined in interface
-void dxf2shpConverter::help()
-{
- //implement me!
-}
-
-// Slot called when the menu item is activated
-// If you created more menu items / toolbar buttons in initiGui, you should
-// create a separate handler for each action - this single run() method will
-// not be enough
-void dxf2shpConverter::run()
-{
- dxf2shpConverterGui *myPluginGui =
- new dxf2shpConverterGui( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
-
- myPluginGui->setAttribute( Qt::WA_DeleteOnClose );
-
- connect( myPluginGui, SIGNAL( createLayer( QString, QString ) ), this, SLOT( addMyLayer( QString, QString ) ) );
-
- myPluginGui->show();
-}
-
-// Unload the plugin by cleaning up the GUI
-void dxf2shpConverter::unload()
-{
- // remove the GUI
- mQGisIface->removePluginVectorMenu( tr( "&Dxf2Shp" ), mQActionPointer );
- mQGisIface->removeVectorToolBarIcon( mQActionPointer );
- delete mQActionPointer;
- mQActionPointer = 0;
-}
-
-void dxf2shpConverter::addMyLayer( QString myfname, QString mytitle )
-{
- mQGisIface->addVectorLayer( myfname, mytitle, "ogr" );
-}
-
-//! Set icons to the current theme
-void dxf2shpConverter::setCurrentTheme( QString theThemeName )
-{
- Q_UNUSED( theThemeName );
- QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/dxf2shp_converter.png";
- QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/dxf2shp_converter.png";
- QString myQrcPath = ":/dxf2shp_converter.png";
- if ( mQActionPointer )
- {
- if ( QFile::exists( myCurThemePath ) )
- {
- mQActionPointer->setIcon( QIcon( myCurThemePath ) );
- }
- else if ( QFile::exists( myDefThemePath ) )
- {
- mQActionPointer->setIcon( QIcon( myDefThemePath ) );
- }
- else if ( QFile::exists( myQrcPath ) )
- {
- mQActionPointer->setIcon( QIcon( myQrcPath ) );
- }
- else
- {
- mQActionPointer->setIcon( QIcon() );
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-//
-//
-// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
-// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
-// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
-//
-//
-//////////////////////////////////////////////////////////////////////////
-
-
-/**
- * Required extern functions needed for every plugin
- * These functions can be called prior to creating an instance
- * of the plugin class
- */
-// Class factory to return a new instance of the plugin class
-QGISEXTERN QgisPlugin *classFactory( QgisInterface *theQgisInterfacePointer )
-{
- return new dxf2shpConverter( theQgisInterfacePointer );
-}
-
-// Return the name of the plugin - note that we do not user class members as
-// the class may not yet be insantiated when this method is called.
-QGISEXTERN QString name()
-{
- return sName;
-}
-
-// Return the description
-QGISEXTERN QString description()
-{
- return sDescription;
-}
-
-// Return the category
-QGISEXTERN QString category()
-{
- return sCategory;
-}
-
-// Return the type (either UI or MapLayer plugin)
-QGISEXTERN int type()
-{
- return sPluginType;
-}
-
-// Return the version number for the plugin
-QGISEXTERN QString version()
-{
- return sPluginVersion;
-}
-
-QGISEXTERN QString icon()
-{
- return sPluginIcon;
-}
-
-// Delete ourself
-QGISEXTERN void unload( QgisPlugin *thePluginPointer )
-{
- delete thePluginPointer;
-}
diff --git a/src/plugins/dxf2shp_converter/dxf2shpconverter.h b/src/plugins/dxf2shp_converter/dxf2shpconverter.h
deleted file mode 100644
index ec58a27..0000000
--- a/src/plugins/dxf2shp_converter/dxf2shpconverter.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
- * CNR, Milan Unit (Information Technology), *
- * Construction Technologies Institute.\n"; *
- * *
- * email : Paolo L. Scala <scala at itc.cnr.it> *
- * *
- * This is a plugin generated from the QGIS plugin template *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * **************************************************************************/
-#ifndef dxf2shpConverter_H
-#define dxf2shpConverter_H
-
-//QT4 includes
-#include <QObject>
-
-//QGIS includes
-#include "../qgisplugin.h"
-
-//forward declarations
-class QAction;
-
-class QgisInterface;
-
-/**
- * \class dxf2shpConverter:
- * \brief DXF importer plugin for QGIS
- */
-class dxf2shpConverter: public QObject, public QgisPlugin
-{
- Q_OBJECT
- public:
-
- //////////////////////////////////////////////////////////////////////
- //
- // MANDATORY PLUGIN METHODS FOLLOW
- //
- //////////////////////////////////////////////////////////////////////
-
- /**
- * Constructor for a plugin. The QgisInterface pointer is passed by
- * QGIS when it attempts to instantiate the plugin.
- * @param theInterface Pointer to the QgisInterface object.
- */
- dxf2shpConverter( QgisInterface *theInterface );
- //! Destructor
- virtual ~dxf2shpConverter();
-
- public slots:
- //! init the gui
- virtual void initGui() override;
- //! Show the dialog box
- void run();
- //! unload the plugin
- void unload() override;
- //! show the help document
- void help();
- //! update the plugins theme when the app tells us its theme is changed
- void setCurrentTheme( QString theThemeName );
-
- void addMyLayer( QString, QString );
-
- private:
-
- ////////////////////////////////////////////////////////////////////
- //
- // MANDATORY PLUGIN PROPERTY DECLARATIONS .....
- //
- ////////////////////////////////////////////////////////////////////
-
- //! Pointer to the QGIS interface object
- QgisInterface *mQGisIface;
- //!pointer to the qaction for this plugin
- QAction *mQActionPointer;
- ////////////////////////////////////////////////////////////////////
- //
- // ADD YOUR OWN PROPERTY DECLARATIONS AFTER THIS POINT.....
- //
- ////////////////////////////////////////////////////////////////////
- QString mQString;
-};
-
-#endif //dxf2shpConverter_H
diff --git a/src/plugins/dxf2shp_converter/dxf2shpconverter.qrc b/src/plugins/dxf2shp_converter/dxf2shpconverter.qrc
deleted file mode 100644
index 2680a8b..0000000
--- a/src/plugins/dxf2shp_converter/dxf2shpconverter.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>dxf2shp_converter.png</file>
- </qresource>
-</RCC>
diff --git a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp b/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp
deleted file mode 100644
index 3541936..0000000
--- a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/***************************************************************************
- *Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
- * CNR, Milan Unit (Information Technology), *
- * Construction Technologies Institute.\n"; *
- * *
- * email : Paolo L. Scala <scala at itc.cnr.it> *
- * *
- * This is a plugin generated from the QGIS plugin template *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
-#include "dxf2shpconvertergui.h"
-#include "qgscontexthelp.h"
-
-#include "builder.h"
-#include "getInsertions.h"
-#include "dxflib/src/dl_dxf.h"
-
-//qt includes
-#include <qmessagebox.h>
-#include <QSettings>
-#include <QFileDialog>
-#include <QFile>
-#include <QDir>
-
-#include "qgslogger.h"
-
-dxf2shpConverterGui::dxf2shpConverterGui( QWidget *parent, Qt::WindowFlags fl ):
- QDialog( parent, fl )
-{
- setupUi( this );
- restoreState();
-}
-
-dxf2shpConverterGui::~dxf2shpConverterGui()
-{
- QSettings settings;
- settings.setValue( "/Plugin-DXF/geometry", saveGeometry() );
-}
-
-void dxf2shpConverterGui::on_buttonBox_accepted()
-{
- QString inf = name->text();
- QString outd = dirout->text();
-
- if ( inf.isEmpty() )
- {
- QMessageBox::information( this, tr( "Warning" ), tr( "Please specify a file to convert." ) );
- return;
- }
-
- if ( outd.isEmpty() )
- {
- QMessageBox::information( this, tr( "Warning" ), tr( "Please specify an output file" ) );
- return;
- }
-
- int type = SHPT_POINT;
- bool convtexts = convertTextCheck->checkState();
-
- if ( polyline->isChecked() )
- type = SHPT_ARC;
-
- if ( polygon->isChecked() )
- type = SHPT_POLYGON;
-
- if ( point->isChecked() )
- type = SHPT_POINT;
-
- InsertRetrClass *insertRetr = new InsertRetrClass();
-
- DL_Dxf *dxf_inserts = new DL_Dxf();
-
- if ( !dxf_inserts->in( inf.toStdString(), insertRetr ) )
- {
- // if file open failed
- QgsDebugMsg( "Aborting: The input file could not be opened." );
- delete dxf_inserts;
- return;
- }
-
- Builder *parser = new Builder(
- outd.toStdString(),
- type,
- insertRetr->XVals, insertRetr->YVals,
- insertRetr->Names,
- insertRetr->countInserts,
- convtexts );
-
- QgsDebugMsg( QString( "Finished getting insertions. Count: %1" ).arg( insertRetr->countInserts ) );
- delete dxf_inserts;
-
- DL_Dxf *dxf_Main = new DL_Dxf();
-
- if ( !dxf_Main->in( inf.toStdString(), parser ) )
- {
- // if file open failed
- delete dxf_Main;
- QgsDebugMsg( "Aborting: The input file could not be opened." );
- return;
- }
-
- delete insertRetr;
- delete dxf_Main;
-
- parser->print_shpObjects();
-
- emit createLayer( QString(( parser->outputShp() ).c_str() ), QString( "Data layer" ) );
-
- if ( convtexts && parser->textObjectsSize() > 0 )
- {
- emit createLayer( QString(( parser->outputTShp() ).c_str() ), QString( "Text layer" ) );
- }
-
- delete parser;
-
- accept();
-}
-
-void dxf2shpConverterGui::on_buttonBox_rejected()
-{
- reject();
-}
-
-void dxf2shpConverterGui::on_buttonBox_helpRequested()
-{
- QString s = tr( "Fields description:\n"
- "* Input DXF file: path to the DXF file to be converted\n"
- "* Output Shp file: desired name of the shape file to be created\n"
- "* Shp output file type: specifies the type of the output shape file\n"
- "* Export text labels checkbox: if checked, an additional shp points layer will be created, "
- "and the associated dbf table will contain information about the \"TEXT\" fields found"
- " in the dxf file, and the text strings themselves\n\n"
- "---\n"
- "Developed by Paolo L. Scala, Barbara Rita Barricelli, Marco Padula\n"
- "CNR, Milan Unit (Information Technology), Construction Technologies Institute.\n"
- "For support send a mail to scala at itc.cnr.it\n" );
-
- QMessageBox::information( this, "Help", s );
-}
-
-void dxf2shpConverterGui::on_btnBrowseForFile_clicked()
-{
- getInputFileName();
-}
-
-void dxf2shpConverterGui::on_btnBrowseOutputDir_clicked()
-{
- getOutputDir();
-}
-
-void dxf2shpConverterGui::getInputFileName()
-{
- QSettings settings;
- QString s = QFileDialog::getOpenFileName( this,
- tr( "Choose a DXF file to open" ),
- settings.value( "/Plugin-DXF/text_path", "./" ).toString(),
- tr( "DXF files" ) + " (*.dxf)" );
-
- if ( !s.isEmpty() )
- {
- name->setText( s );
- settings.setValue( "/Plugin-DXF/text_path", QFileInfo( s ).absolutePath() );
- }
-}
-
-void dxf2shpConverterGui::getOutputDir()
-{
- QSettings settings;
- QString s = QFileDialog::getSaveFileName( this,
- tr( "Choose a file name to save to" ),
- settings.value( "/UI/lastShapefileDir", "./" ).toString(),
- tr( "Shapefile" ) + " (*.shp)" );
-
- if ( !s.isEmpty() )
- {
- if ( !s.toLower().endsWith( ".shp" ) )
- {
- s += ".shp";
- }
- dirout->setText( s );
- settings.setValue( "/UI/lastShapefileDir", QFileInfo( s ).absolutePath() );
- }
-}
-
-void dxf2shpConverterGui::restoreState()
-{
- QSettings settings;
- restoreGeometry( settings.value( "/Plugin-DXF/geometry" ).toByteArray() );
-}
diff --git a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.h b/src/plugins/dxf2shp_converter/dxf2shpconvertergui.h
deleted file mode 100644
index 4b1bc66..0000000
--- a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/***************************************************************************
- *Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
- * CNR, Milan Unit (Information Technology), *
- * Construction Technologies Institute.\n"; *
- * *
- * email : Paolo L. Scala <scala at itc.cnr.it> *
- * *
- * This is a plugin generated from the QGIS plugin template *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
-#ifndef dxf2shpConverterGUI_H
-#define dxf2shpConverterGUI_H
-
-#include <QDialog>
-#include <ui_dxf2shpconvertergui.h>
-
-/**
- @author Tim Sutton
- */
-class dxf2shpConverterGui: public QDialog, private Ui::dxf2shpConverterGui
-{
- Q_OBJECT
-
- public:
- dxf2shpConverterGui( QWidget *parent = 0, Qt::WindowFlags fl = 0 );
- ~dxf2shpConverterGui();
-
- private:
- void getInputFileName();
- void getOutputFileName();
- void getOutputDir();
-
- void restoreState();
-
- private slots:
- void on_buttonBox_accepted();
- void on_buttonBox_rejected();
- void on_buttonBox_helpRequested();
- void on_btnBrowseForFile_clicked();
- void on_btnBrowseOutputDir_clicked();
-
- signals:
- void createLayer( QString, QString );
-};
-
-#endif
diff --git a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.ui b/src/plugins/dxf2shp_converter/dxf2shpconvertergui.ui
deleted file mode 100644
index d3c3b34..0000000
--- a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.ui
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>dxf2shpConverterGui</class>
- <widget class="QDialog" name="dxf2shpConverterGui">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>353</width>
- <height>263</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Dxf Importer</string>
- </property>
- <property name="windowIcon">
- <iconset>
- <normaloff/>
- </iconset>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>Input and output</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Input DXF file</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="name"/>
- </item>
- <item row="0" column="2">
- <widget class="QToolButton" name="btnBrowseForFile">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Output file</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="dirout"/>
- </item>
- <item row="1" column="2">
- <widget class="QToolButton" name="btnBrowseOutputDir">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QCheckBox" name="convertTextCheck">
- <property name="text">
- <string>Export text labels</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Output file type</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QRadioButton" name="polyline">
- <property name="text">
- <string>Polyline</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="polygon">
- <property name="text">
- <string>Polygon</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="point">
- <property name="text">
- <string>Point</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="dxf2shpconverter.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>dxf2shpConverterGui</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>dxf2shpConverterGui</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/src/plugins/dxf2shp_converter/dxflib/confdefs.h b/src/plugins/dxf2shp_converter/dxflib/confdefs.h
deleted file mode 100644
index f74e15c..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/confdefs.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; version 2 of the License */
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h
deleted file mode 100644
index f4e33a1..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/****************************************************************************
-** $Id: dl_attributes.h 2334 2005-03-27 23:37:52Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_ATTRIBUTES_H
-#define DL_ATTRIBUTES_H
-
-#include <string>
-using std::string;
-
-#include "dl_codes.h"
-
-/**
- * Storing and passing around attributes. Attributes
- * are the layer name, color, width and line type.
- *
- * @author Andrew Mustun
- */
-class DL_Attributes
-{
-
- public:
-
- /**
- * Default constructor.
- */
- DL_Attributes()
- {
- setLayer( "" );
- setColor( 0 );
- setWidth( 0 );
- setLineType( "BYLAYER" );
- }
-
-
-
- /**
- * Constructor for DXF attributes.
- *
- * @param layer Layer name for this entity or NULL for no layer
- * (every entity should be on a named layer!).
- * @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER.
- * @param width Line thickness. Defaults to zero. -1 = BYLAYER,
- * -2 = BYBLOCK, -3 = default width
- * @param lineType Line type name or "BYLAYER" or "BYBLOCK". Defaults
- * to "BYLAYER"
- */
- DL_Attributes( const string& layer,
- int color, int width,
- const string& lineType )
- {
- setLayer( layer );
- setColor( color );
- setWidth( width );
- setLineType( lineType );
- }
-
-
-
- /**
- * Sets the layer. If the given pointer points to NULL, the
- * new layer name will be an empty but valid string.
- */
- void setLayer( const string& layer )
- {
- this->layer = layer;
- }
-
-
-
- /**
- * @return Layer name.
- */
- string getLayer() const
- {
- return layer;
- }
-
-
-
- /**
- * Sets the color.
- *
- * @see DL_Codes, dxfColors
- */
- void setColor( int color )
- {
- this->color = color;
- }
-
-
-
- /**
- * @return Color.
- *
- * @see DL_Codes, dxfColors
- */
- int getColor() const
- {
- return color;
- }
-
-
-
- /**
- * Sets the width.
- */
- void setWidth( int width )
- {
- this->width = width;
- }
-
-
-
- /**
- * @return Width.
- */
- int getWidth() const
- {
- return width;
- }
-
-
-
- /**
- * Sets the line type. This can be any string and is not
- * checked to be a valid line type.
- */
- void setLineType( const string& lineType )
- {
- this->lineType = lineType;
- }
-
-
-
- /**
- * @return Line type.
- */
- string getLineType() const
- {
- if ( lineType.length() == 0 )
- {
- return "BYLAYER";
- }
- else
- {
- return lineType;
- }
- }
-
-
-
- /**
- * Copies attributes (deep copies) from another attribute object.
- */
- DL_Attributes &operator= ( const DL_Attributes& attrib )
- {
- setLayer( attrib.layer );
- setColor( attrib.color );
- setWidth( attrib.width );
- setLineType( attrib.lineType );
-
- return *this;
- }
-
- private:
- string layer;
- int color;
- int width;
- string lineType;
-};
-
-#endif
-
-// EOF
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_codes.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_codes.h
deleted file mode 100644
index 4be58e2..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_codes.h
+++ /dev/null
@@ -1,545 +0,0 @@
-/****************************************************************************
-** $Id: dl_codes.h 273 2005-02-28 18:14:39Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-** Copyright (C) 2001 Robert J. Campbell Jr.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-/**
- * Defines common DXF codes and constants.
- */
-
-#ifndef DXF_CODES_H
-#define DXF_CODES_H
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#if defined(__OS2__)||defined(__EMX__)||defined(_WIN32)
-#define strcasecmp(s,t) stricmp(s,t)
-#endif
-
-#ifdef _WIN32
-#undef M_PI
-#define M_PI 3.14159265358979323846
-#pragma warning(disable : 4800)
-#endif
-
-#ifndef M_PI
-#define M_PI 3.1415926535897932384626433832795
-#endif
-
-#define DL_DXF_MAXLINE 1024
-#define DL_DXF_MAXGROUPCODE 1100
-
-// used to mark invalid vectors:
-//#define DL_DXF_MAXDOUBLE 1.0E+10
-
-/**
- * Codes for colors and DXF versions.
- */
-class DL_Codes
-{
- public:
- /**
- * Standard DXF colors.
- */
- enum color
- {
- black = 250,
- green = 3,
- red = 1,
- brown = 15,
- yellow = 2,
- cyan = 4,
- magenta = 6,
- gray = 8,
- blue = 5,
- l_blue = 163,
- l_green = 121,
- l_cyan = 131,
- l_red = 23,
- l_magenta = 221,
- l_gray = 252,
- white = 7,
- bylayer = 256,
- byblock = 0
- };
-
- /**
- * Version numbers for the DXF Format.
- */
- enum version
- {
- AC1009, AC1012, AC1014, AC1015
- };
-};
-
-
-// Extended color palette:
-// The first entry is only for direct indexing starting with [1]
-// Color 1 is red (1,0,0)
-const double dxfColors[][3] =
-{
- {0, 0, 0}, // unused
- {1, 0, 0}, // 1
- {1, 1, 0},
- {0, 1, 0},
- {0, 1, 1},
- {0, 0, 1},
- {1, 0, 1},
- {1, 1, 1}, // black or white
- {0.5, 0.5, 0.5},
- {0.75, 0.75, 0.75},
- {1, 0, 0}, // 10
- {1, 0.5, 0.5},
- {0.65, 0, 0},
- {0.65, 0.325, 0.325},
- {0.5, 0, 0},
- {0.5, 0.25, 0.25},
- {0.3, 0, 0},
- {0.3, 0.15, 0.15},
- {0.15, 0, 0},
- {0.15, 0.075, 0.075},
- {1, 0.25, 0}, // 20
- {1, 0.625, 0.5},
- {0.65, 0.1625, 0},
- {0.65, 0.4063, 0.325},
- {0.5, 0.125, 0},
- {0.5, 0.3125, 0.25},
- {0.3, 0.075, 0},
- {0.3, 0.1875, 0.15},
- {0.15, 0.0375, 0},
- {0.15, 0.0938, 0.075},
- {1, 0.5, 0}, // 30
- {1, 0.75, 0.5},
- {0.65, 0.325, 0},
- {0.65, 0.4875, 0.325},
- {0.5, 0.25, 0},
- {0.5, 0.375, 0.25},
- {0.3, 0.15, 0},
- {0.3, 0.225, 0.15},
- {0.15, 0.075, 0},
- {0.15, 0.1125, 0.075},
- {1, 0.75, 0}, // 40
- {1, 0.875, 0.5},
- {0.65, 0.4875, 0},
- {0.65, 0.5688, 0.325},
- {0.5, 0.375, 0},
- {0.5, 0.4375, 0.25},
- {0.3, 0.225, 0},
- {0.3, 0.2625, 0.15},
- {0.15, 0.1125, 0},
- {0.15, 0.1313, 0.075},
- {1, 1, 0}, // 50
- {1, 1, 0.5},
- {0.65, 0.65, 0},
- {0.65, 0.65, 0.325},
- {0.5, 0.5, 0},
- {0.5, 0.5, 0.25},
- {0.3, 0.3, 0},
- {0.3, 0.3, 0.15},
- {0.15, 0.15, 0},
- {0.15, 0.15, 0.075},
- {0.75, 1, 0}, // 60
- {0.875, 1, 0.5},
- {0.4875, 0.65, 0},
- {0.5688, 0.65, 0.325},
- {0.375, 0.5, 0},
- {0.4375, 0.5, 0.25},
- {0.225, 0.3, 0},
- {0.2625, 0.3, 0.15},
- {0.1125, 0.15, 0},
- {0.1313, 0.15, 0.075},
- {0.5, 1, 0}, // 70
- {0.75, 1, 0.5},
- {0.325, 0.65, 0},
- {0.4875, 0.65, 0.325},
- {0.25, 0.5, 0},
- {0.375, 0.5, 0.25},
- {0.15, 0.3, 0},
- {0.225, 0.3, 0.15},
- {0.075, 0.15, 0},
- {0.1125, 0.15, 0.075},
- {0.25, 1, 0}, // 80
- {0.625, 1, 0.5},
- {0.1625, 0.65, 0},
- {0.4063, 0.65, 0.325},
- {0.125, 0.5, 0},
- {0.3125, 0.5, 0.25},
- {0.075, 0.3, 0},
- {0.1875, 0.3, 0.15},
- {0.0375, 0.15, 0},
- {0.0938, 0.15, 0.075},
- {0, 1, 0}, // 90
- {0.5, 1, 0.5},
- {0, 0.65, 0},
- {0.325, 0.65, 0.325},
- {0, 0.5, 0},
- {0.25, 0.5, 0.25},
- {0, 0.3, 0},
- {0.15, 0.3, 0.15},
- {0, 0.15, 0},
- {0.075, 0.15, 0.075},
- {0, 1, 0.25}, // 100
- {0.5, 1, 0.625},
- {0, 0.65, 0.1625},
- {0.325, 0.65, 0.4063},
- {0, 0.5, 0.125},
- {0.25, 0.5, 0.3125},
- {0, 0.3, 0.075},
- {0.15, 0.3, 0.1875},
- {0, 0.15, 0.0375},
- {0.075, 0.15, 0.0938},
- {0, 1, 0.5}, // 110
- {0.5, 1, 0.75},
- {0, 0.65, 0.325},
- {0.325, 0.65, 0.4875},
- {0, 0.5, 0.25},
- {0.25, 0.5, 0.375},
- {0, 0.3, 0.15},
- {0.15, 0.3, 0.225},
- {0, 0.15, 0.075},
- {0.075, 0.15, 0.1125},
- {0, 1, 0.75}, // 120
- {0.5, 1, 0.875},
- {0, 0.65, 0.4875},
- {0.325, 0.65, 0.5688},
- {0, 0.5, 0.375},
- {0.25, 0.5, 0.4375},
- {0, 0.3, 0.225},
- {0.15, 0.3, 0.2625},
- {0, 0.15, 0.1125},
- {0.075, 0.15, 0.1313},
- {0, 1, 1}, // 130
- {0.5, 1, 1},
- {0, 0.65, 0.65},
- {0.325, 0.65, 0.65},
- {0, 0.5, 0.5},
- {0.25, 0.5, 0.5},
- {0, 0.3, 0.3},
- {0.15, 0.3, 0.3},
- {0, 0.15, 0.15},
- {0.075, 0.15, 0.15},
- {0, 0.75, 1}, // 140
- {0.5, 0.875, 1},
- {0, 0.4875, 0.65},
- {0.325, 0.5688, 0.65},
- {0, 0.375, 0.5},
- {0.25, 0.4375, 0.5},
- {0, 0.225, 0.3},
- {0.15, 0.2625, 0.3},
- {0, 0.1125, 0.15},
- {0.075, 0.1313, 0.15},
- {0, 0.5, 1}, // 150
- {0.5, 0.75, 1},
- {0, 0.325, 0.65},
- {0.325, 0.4875, 0.65},
- {0, 0.25, 0.5},
- {0.25, 0.375, 0.5},
- {0, 0.15, 0.3},
- {0.15, 0.225, 0.3},
- {0, 0.075, 0.15},
- {0.075, 0.1125, 0.15},
- {0, 0.25, 1}, // 160
- {0.5, 0.625, 1},
- {0, 0.1625, 0.65},
- {0.325, 0.4063, 0.65},
- {0, 0.125, 0.5},
- {0.25, 0.3125, 0.5},
- {0, 0.075, 0.3},
- {0.15, 0.1875, 0.3},
- {0, 0.0375, 0.15},
- {0.075, 0.0938, 0.15},
- {0, 0, 1}, // 170
- {0.5, 0.5, 1},
- {0, 0, 0.65},
- {0.325, 0.325, 0.65},
- {0, 0, 0.5},
- {0.25, 0.25, 0.5},
- {0, 0, 0.3},
- {0.15, 0.15, 0.3},
- {0, 0, 0.15},
- {0.075, 0.075, 0.15},
- {0.25, 0, 1}, // 180
- {0.625, 0.5, 1},
- {0.1625, 0, 0.65},
- {0.4063, 0.325, 0.65},
- {0.125, 0, 0.5},
- {0.3125, 0.25, 0.5},
- {0.075, 0, 0.3},
- {0.1875, 0.15, 0.3},
- {0.0375, 0, 0.15},
- {0.0938, 0.075, 0.15},
- {0.5, 0, 1}, // 190
- {0.75, 0.5, 1},
- {0.325, 0, 0.65},
- {0.4875, 0.325, 0.65},
- {0.25, 0, 0.5},
- {0.375, 0.25, 0.5},
- {0.15, 0, 0.3},
- {0.225, 0.15, 0.3},
- {0.075, 0, 0.15},
- {0.1125, 0.075, 0.15},
- {0.75, 0, 1}, // 200
- {0.875, 0.5, 1},
- {0.4875, 0, 0.65},
- {0.5688, 0.325, 0.65},
- {0.375, 0, 0.5},
- {0.4375, 0.25, 0.5},
- {0.225, 0, 0.3},
- {0.2625, 0.15, 0.3},
- {0.1125, 0, 0.15},
- {0.1313, 0.075, 0.15},
- {1, 0, 1}, // 210
- {1, 0.5, 1},
- {0.65, 0, 0.65},
- {0.65, 0.325, 0.65},
- {0.5, 0, 0.5},
- {0.5, 0.25, 0.5},
- {0.3, 0, 0.3},
- {0.3, 0.15, 0.3},
- {0.15, 0, 0.15},
- {0.15, 0.075, 0.15},
- {1, 0, 0.75}, // 220
- {1, 0.5, 0.875},
- {0.65, 0, 0.4875},
- {0.65, 0.325, 0.5688},
- {0.5, 0, 0.375},
- {0.5, 0.25, 0.4375},
- {0.3, 0, 0.225},
- {0.3, 0.15, 0.2625},
- {0.15, 0, 0.1125},
- {0.15, 0.075, 0.1313},
- {1, 0, 0.5}, // 230
- {1, 0.5, 0.75},
- {0.65, 0, 0.325},
- {0.65, 0.325, 0.4875},
- {0.5, 0, 0.25},
- {0.5, 0.25, 0.375},
- {0.3, 0, 0.15},
- {0.3, 0.15, 0.225},
- {0.15, 0, 0.075},
- {0.15, 0.075, 0.1125},
- {1, 0, 0.25}, // 240
- {1, 0.5, 0.625},
- {0.65, 0, 0.1625},
- {0.65, 0.325, 0.4063},
- {0.5, 0, 0.125},
- {0.5, 0.25, 0.3125},
- {0.3, 0, 0.075},
- {0.3, 0.15, 0.1875},
- {0.15, 0, 0.0375},
- {0.15, 0.075, 0.0938},
- {0.33, 0.33, 0.33}, // 250
- {0.464, 0.464, 0.464},
- {0.598, 0.598, 0.598},
- {0.732, 0.732, 0.732},
- {0.866, 0.866, 0.866},
- {1, 1, 1} // 255
-}
-;
-
-
-// AutoCAD VERSION aliases
-#define VER_R12 DL_Codes::AC1009
-#define VER_LT2 DL_Codes::AC1009
-#define VER_R13 DL_Codes::AC1012 // not supported yet
-#define VER_LT95 DL_Codes::AC1012 // not supported yet
-#define VER_R14 DL_Codes::AC1014 // not supported yet
-#define VER_LT97 DL_Codes::AC1014 // not supported yet
-#define VER_LT98 DL_Codes::AC1014 // not supported yet
-#define VER_2000 DL_Codes::AC1015
-#define VER_2002 DL_Codes::AC1015
-
-
-// DXF Group Codes:
-
-// Strings
-#define STRGRP_START 0
-#define STRGRP_END 9
-
-// Coordinates
-#define CRDGRP_START 10
-#define CRDGRP_END 19
-
-// Real values
-#define RLGRP_START 38
-#define RLGRP_END 59
-
-// Short integer values
-#define SHOGRP_START 60
-#define SHOGRP_END 79
-
-// New in Release 13,
-#define SUBCLASS 100
-
-// More coordinates
-#define CRD2GRP_START 210
-#define CRD2GRP_END 239
-
-// Extended data strings
-#define ESTRGRP_START 1000
-#define ESTRGRP_END 1009
-
-// Extended data reals
-#define ERLGRP_START 1010
-#define ERLGRP_END 1059
-
-
-#define Y8_COORD_CODE 28
-#define Z0_COORD_CODE 30
-#define Z8_COORD_CODE 38
-
-#define POINT_COORD_CODE 10
-#define INSERT_COORD_CODE 10
-
-#define CRD2GRP_START 210
-#define CRD2GRP_END 239
-
-#define THICKNESS 39
-#define FIRST_REAL_CODE THICKNESS
-#define LAST_REAL_CODE 59
-#define FIRST_INT_CODE 60
-#define ATTFLAGS_CODE 70
-#define PLINE_FLAGS_CODE 70
-#define LAYER_FLAGS_CODE 70
-#define FLD_LEN_CODE 73 // Inside ATTRIB resbuf
-#define LAST_INT_CODE 79
-#define X_EXTRU_CODE 210
-#define Y_EXTRU_CODE 220
-#define Z_EXTRU_CODE 230
-#define COMMENT_CODE 999
-
-// Start and endpoints of a line
-#define LINE_START_CODE 10 // Followed by x coord
-#define LINE_END_CODE 11 // Followed by x coord
-
-// Some codes used by blocks
-#define BLOCK_FLAGS_CODE 70 // An int containing flags
-#define BLOCK_BASE_CODE 10 // Origin of block definition
-#define XREF_DEPENDENT 16 // If a block contains an XREF
-#define XREF_RESOLVED 32 // If a XREF resolved ok
-#define REFERENCED 64 // If a block is ref'd in DWG
-
-#define XSCALE_CODE 41
-#define YSCALE_CODE 42
-#define ANGLE_CODE 50
-#define INS_POINT_CODE 10 // Followed by x of ins pnt
-#define NAME2_CODE 3 // Second appearance of name
-
-// Some codes used by circle entities
-#define CENTER_CODE 10 // Followed by x of center
-#define RADIUS_CODE 40 // Followd by radius of circle
-
-#define COND_OP_CODE -4 // Conditional op,ads_ssget
-
-// When using ads_buildlist you MUST use RTDXF0 instead of these
-#define ENTITY_TYPE_CODE 0 // Then there is LINE, 3DFACE..
-#define SES_CODE 0 // Start End String Code
-#define FILE_SEP_CODE 0 // File separator
-#define SOT_CODE 0 // Start Of Table
-#define TEXTVAL_CODE 1
-#define NAME_CODE 2
-#define BLOCK_NAME_CODE 2
-#define SECTION_NAME_CODE 2
-#define ENT_HAND_CODE 5 // What follows is hexa string
-#define TXT_STYLE_CODE 7 // Inside attributes
-#define LAYER_NAME_CODE 8 // What follows is layer name
-#define FIRST_XCOORD_CODE 10 // Group code x of 1st coord
-#define FIRST_YCOORD_CODE 20 // Group code y of 1st coord
-#define FIRST_ZCOORD_CODE 30 // Group code z of 1st coord
-#define L_START_CODE 10
-#define L_END_CODE 11
-#define TXTHI_CODE 40
-#define SCALE_X_CODE 41
-#define SCALE_Y_CODE 42
-#define SCALE_Z_CODE 43
-#define BULGE_CODE 42 // Used in PLINE verts for arcs
-#define ROTATION_CODE 50
-#define COLOR_CODE 62 // What follows is a color int
-#define LTYPE_CODE 6 // What follows is a linetype
-
-
-// Attribute flags
-#define ATTS_FOLLOW_CODE 66
-#define ATT_TAG_CODE 2
-#define ATT_VAL_CODE 1
-#define ATT_FLAGS_CODE 70 // 4 1 bit flags as follows...
-#define ATT_INVIS_FLAG 1
-#define ATT_CONST_FLAG 2
-#define ATT_VERIFY_FLAG 4 // Prompt and verify
-#define ATT_PRESET_FLAG 8 // No prompt and no verify
-
-// PLINE defines
-// Flags
-#define OPEN_PLINE 0x00
-#define CLOSED_PLINE 0x01
-#define POLYLINE3D 0x80
-#define PFACE_MESH 0x40
-#define PGON_MESH 0x10
-// Vertices follow entity, required in POLYLINES
-#define VERTS_FOLLOW_CODE 66 // Value should always be 1
-#define VERTEX_COORD_CODE 10
-
-
-// LAYER flags
-#define FROZEN 1
-#define FROZEN_BY_DEF 2
-#define LOCKED 4
-#define OBJECT_USED 64 // Object is ref'd in the dwg
-
-#define BLOCK_EN_CODE -2 // Block entity definition
-#define E_NAME -1 // Entity name
-
-// Extended data codes
-#define EXTD_SENTINEL (-3)
-#define EXTD_STR 1000
-#define EXTD_APP_NAME 1001
-#define EXTD_CTL_STR 1002
-#define EXTD_LYR_STR 1003
-#define EXTD_CHUNK 1004
-#define EXTD_HANDLE 1005
-#define EXTD_POINT 1010
-#define EXTD_POS 1011
-#define EXTD_DISP 1012
-#define EXTD_DIR 1013
-#define EXTD_FLOAT 1040
-#define EXTD_DIST 1041
-#define EXTD_SCALE 1042
-#define EXTD_INT16 1070
-#define EXTD_INT32 1071
-
-// UCS codes for use in ads_trans
-#define WCS_TRANS_CODE 0
-#define UCS_TRANS_CODE 1
-#define DCS_TRANS_CODE 2
-#define PCS_TRANS_CODE 3
-
-#endif
-
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_creationadapter.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_creationadapter.h
deleted file mode 100644
index 10f748a..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_creationadapter.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-** $Id: dl_creationadapter.h 2398 2005-06-06 18:12:14Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_CREATIONADAPTER_H
-#define DL_CREATIONADAPTER_H
-
-#include "dl_creationinterface.h"
-
-/**
- * An abstract adapter class for receiving DXF events when a DXF file is being read.
- * The methods in this class are empty. This class exists as convenience for creating
- * listener objects.
- *
- * @author Andrew Mustun
- */
-class DL_CreationAdapter : public DL_CreationInterface
-{
- public:
- DL_CreationAdapter() {}
- virtual ~DL_CreationAdapter() {}
- virtual void addLayer( const DL_LayerData& ) override {}
- virtual void addBlock( const DL_BlockData& ) override {}
- virtual void endBlock() override {}
- virtual void addPoint( const DL_PointData& ) override {}
- virtual void addLine( const DL_LineData& ) override {}
- virtual void addArc( const DL_ArcData& ) override {}
- virtual void addCircle( const DL_CircleData& ) override {}
- virtual void addEllipse( const DL_EllipseData& ) override {}
-
- virtual void addPolyline( const DL_PolylineData& ) override {}
- virtual void addVertex( const DL_VertexData& ) override {}
-
- virtual void addSpline( const DL_SplineData& ) override {}
- virtual void addControlPoint( const DL_ControlPointData& ) override {}
- virtual void addKnot( const DL_KnotData& ) override {}
-
- virtual void addInsert( const DL_InsertData& ) override {}
-
- virtual void addMText( const DL_MTextData& ) override {}
- virtual void addMTextChunk( const char* ) override {}
- virtual void addText( const DL_TextData& ) override {}
-
- virtual void addDimAlign( const DL_DimensionData&,
- const DL_DimAlignedData& ) override {}
- virtual void addDimLinear( const DL_DimensionData&,
- const DL_DimLinearData& ) override {}
- virtual void addDimRadial( const DL_DimensionData&,
- const DL_DimRadialData& ) override {}
- virtual void addDimDiametric( const DL_DimensionData&,
- const DL_DimDiametricData& ) override {}
- virtual void addDimAngular( const DL_DimensionData&,
- const DL_DimAngularData& ) override {}
- virtual void addDimAngular3P( const DL_DimensionData&,
- const DL_DimAngular3PData& ) override {}
- virtual void addLeader( const DL_LeaderData& ) override {}
- virtual void addLeaderVertex( const DL_LeaderVertexData& ) override {}
-
- virtual void addHatch( const DL_HatchData& ) override {}
-
- virtual void addTrace( const DL_TraceData& ) override {}
- virtual void addSolid( const DL_SolidData& ) override {}
-
- virtual void addImage( const DL_ImageData& ) override {}
- virtual void linkImage( const DL_ImageDefData& ) override {}
- virtual void addHatchLoop( const DL_HatchLoopData& ) override {}
- virtual void addHatchEdge( const DL_HatchEdgeData& ) override {}
- virtual void endEntity() override {}
- virtual void setVariableVector( const char*,
- double, double, double, int ) override {}
- virtual void setVariableString( const char*, const char*, int ) override {}
- virtual void setVariableInt( const char*, int, int ) override {}
- virtual void setVariableDouble( const char*, double, int ) override {}
- virtual void endSequence() override {}
-};
-
-#endif
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_creationinterface.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_creationinterface.h
deleted file mode 100644
index 3e7b162..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_creationinterface.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/****************************************************************************
-** $Id: dl_creationinterface.h 2397 2005-06-06 18:11:14Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_CREATIONINTERFACE_H
-#define DL_CREATIONINTERFACE_H
-
-#include <string.h>
-
-#include "dl_attributes.h"
-#include "dl_codes.h"
-#include "dl_entities.h"
-#include "dl_extrusion.h"
-
-/**
- * Abstract class (interface) for the creation of new entities.
- * Inherit your class which takes care of the entities in the
- * processed DXF file from this interface.
- *
- * Double arrays passed to your implementation contain 3 double
- * values for x, y, z coordinates unless stated differently.
- *
- * @author Andrew Mustun
- */
-class DL_CreationInterface
-{
- public:
- DL_CreationInterface()
- {
- extrusion = new DL_Extrusion;
- }
- virtual ~DL_CreationInterface()
- {
- delete extrusion;
- }
-
- /**
- * Called for every layer.
- */
- virtual void addLayer( const DL_LayerData& data ) = 0;
-
- /**
- * Called for every block. Note: all entities added after this
- * command go into this block until endBlock() is called.
- *
- * @see endBlock()
- */
- virtual void addBlock( const DL_BlockData& data ) = 0;
-
- /** Called to end the current block */
- virtual void endBlock() = 0;
-
- /** Called for every point */
- virtual void addPoint( const DL_PointData& data ) = 0;
-
- /** Called for every line */
- virtual void addLine( const DL_LineData& data ) = 0;
-
- /** Called for every arc */
- virtual void addArc( const DL_ArcData& data ) = 0;
-
- /** Called for every circle */
- virtual void addCircle( const DL_CircleData& data ) = 0;
-
- /** Called for every ellipse */
- virtual void addEllipse( const DL_EllipseData& data ) = 0;
-
- /** Called for every polyline start */
- virtual void addPolyline( const DL_PolylineData& data ) = 0;
-
- /** Called for every polyline vertex */
- virtual void addVertex( const DL_VertexData& data ) = 0;
-
- /** Called for every spline */
- virtual void addSpline( const DL_SplineData& data ) = 0;
-
- /** Called for every spline control point */
- virtual void addControlPoint( const DL_ControlPointData& data ) = 0;
-
- /** Called for every spline knot value */
- virtual void addKnot( const DL_KnotData& data ) = 0;
-
- /** Called for every insert. */
- virtual void addInsert( const DL_InsertData& data ) = 0;
-
- /** Called for every trace start */
- virtual void addTrace( const DL_TraceData& data ) = 0;
-
- /** Called for every solid start */
- virtual void addSolid( const DL_SolidData& data ) = 0;
-
-
- /** Called for every Multi Text entity. */
- virtual void addMText( const DL_MTextData& data ) = 0;
-
- /**
- * Called for additional text chunks for MTEXT entities.
- * The chunks come at 250 character in size each. Note that
- * those chunks come <b>before</b> the actual MTEXT entity.
- */
- virtual void addMTextChunk( const char* text ) = 0;
-
- /** Called for every Text entity. */
- virtual void addText( const DL_TextData& data ) = 0;
-
- /**
- * Called for every aligned dimension entity.
- */
- virtual void addDimAlign( const DL_DimensionData& data,
- const DL_DimAlignedData& edata ) = 0;
- /**
- * Called for every linear or rotated dimension entity.
- */
- virtual void addDimLinear( const DL_DimensionData& data,
- const DL_DimLinearData& edata ) = 0;
-
- /**
- * Called for every radial dimension entity.
- */
- virtual void addDimRadial( const DL_DimensionData& data,
- const DL_DimRadialData& edata ) = 0;
-
- /**
- * Called for every diametric dimension entity.
- */
- virtual void addDimDiametric( const DL_DimensionData& data,
- const DL_DimDiametricData& edata ) = 0;
-
- /**
- * Called for every angular dimension (2 lines version) entity.
- */
- virtual void addDimAngular( const DL_DimensionData& data,
- const DL_DimAngularData& edata ) = 0;
-
- /**
- * Called for every angular dimension (3 points version) entity.
- */
- virtual void addDimAngular3P( const DL_DimensionData& data,
- const DL_DimAngular3PData& edata ) = 0;
-
- /**
- * Called for every leader start.
- */
- virtual void addLeader( const DL_LeaderData& data ) = 0;
-
- /**
- * Called for every leader vertex
- */
- virtual void addLeaderVertex( const DL_LeaderVertexData& data ) = 0;
-
- /**
- * Called for every hatch entity.
- */
- virtual void addHatch( const DL_HatchData& data ) = 0;
-
- /**
- * Called for every image entity.
- */
- virtual void addImage( const DL_ImageData& data ) = 0;
-
- /**
- * Called for every image definition.
- */
- virtual void linkImage( const DL_ImageDefData& data ) = 0;
-
- /**
- * Called for every hatch loop.
- */
- virtual void addHatchLoop( const DL_HatchLoopData& data ) = 0;
-
- /**
- * Called for every hatch edge entity.
- */
- virtual void addHatchEdge( const DL_HatchEdgeData& data ) = 0;
-
- /**
- * Called after an entity has been completed.
- */
- virtual void endEntity() = 0;
-
- /**
- * Called for every vector variable in the DXF file (e.g. "$EXTMIN").
- */
- virtual void setVariableVector( const char* key,
- double v1, double v2, double v3, int code ) = 0;
-
- /**
- * Called for every string variable in the DXF file (e.g. "$ACADVER").
- */
- virtual void setVariableString( const char* key, const char* value, int code ) = 0;
-
- /**
- * Called for every int variable in the DXF file (e.g. "$ACADMAINTVER").
- */
- virtual void setVariableInt( const char* key, int value, int code ) = 0;
-
- /**
- * Called for every double variable in the DXF file (e.g. "$DIMEXO").
- */
- virtual void setVariableDouble( const char* key, double value, int code ) = 0;
-
- /**
- * Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done)
- */
- virtual void endSequence() = 0;
-
- /** Sets the current attributes for entities. */
- void setAttributes( const DL_Attributes& attrib )
- {
- attributes = attrib;
- }
-
- /** @return the current attributes used for new entities. */
- DL_Attributes getAttributes()
- {
- return attributes;
- }
-
- /** Sets the current attributes for entities. */
- void setExtrusion( double dx, double dy, double dz, double elevation )
- {
- extrusion->setDirection( dx, dy, dz );
- extrusion->setElevation( elevation );
- }
-
- /** @return the current attributes used for new entities. */
- DL_Extrusion* getExtrusion()
- {
- return extrusion;
- }
-
- protected:
- DL_Attributes attributes;
- DL_Extrusion *extrusion;
-
- DL_CreationInterface(const DL_CreationInterface &);
- DL_CreationInterface&operator=(const DL_CreationInterface&);
-};
-
-#endif
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp b/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp
deleted file mode 100644
index 33361e5..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp
+++ /dev/null
@@ -1,5600 +0,0 @@
-/****************************************************************************
-** $Id: dl_dxf.cpp 2719 2005-09-24 20:41:23Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#include "dl_dxf.h"
-
-#include <algorithm>
-#include <string>
-#include <cstdio>
-#include <cassert>
-#include <cmath>
-
-#include "dl_attributes.h"
-#include "dl_codes.h"
-#include "dl_creationinterface.h"
-#include "dl_writer_ascii.h"
-#include "qgslogger.h"
-
-
-/**
- * Default constructor.
- */
-DL_Dxf::DL_Dxf()
-{
- styleHandleStd = 0;
- version = VER_2000;
-
- vertices = NULL;
- maxVertices = 0;
- vertexIndex = 0;
-
- knots = NULL;
- maxKnots = 0;
- knotIndex = 0;
-
- controlPoints = NULL;
- maxControlPoints = 0;
- controlPointIndex = 0;
-
- leaderVertices = NULL;
- maxLeaderVertices = 0;
- leaderVertexIndex = 0;
-
- hatchLoops = NULL;
- maxHatchLoops = 0;
- hatchLoopIndex = -1;
- hatchEdges = NULL;
- maxHatchEdges = NULL;
- hatchEdgeIndex = NULL;
- dropEdges = false;
-
- groupCode = 0;
- currentEntity = DL_Unknown;
- firstCall = true;
- libVersion = 0;
-
- //bulge = 0.0;
-}
-
-
-
-/**
- * Destructor.
- */
-DL_Dxf::~DL_Dxf()
-{
- if ( vertices != NULL )
- {
- delete[] vertices;
- }
- if ( knots != NULL )
- {
- delete[] knots;
- }
- if ( controlPoints != NULL )
- {
- delete[] controlPoints;
- }
- if ( leaderVertices != NULL )
- {
- delete[] leaderVertices;
- }
- if ( hatchLoops != NULL )
- {
- delete[] hatchLoops;
- }
- if ( hatchEdges != NULL )
- {
- for ( int i = 0; i < maxHatchLoops; ++i )
- {
- if ( hatchEdges[i] != NULL )
- {
- delete[] hatchEdges[i];
- }
- }
- delete[] hatchEdges;
- }
- if ( maxHatchEdges != NULL )
- {
- delete[] maxHatchEdges;
- }
- if ( hatchEdgeIndex != NULL )
- {
- delete[] hatchEdgeIndex;
- }
-}
-
-
-
-/**
- * @brief Reads the given file and calls the appropriate functions in
- * the given creation interface for every entity found in the file.
- *
- * @param file Input
- * Path and name of file to read
- * @param creationInterface
- * Pointer to the class which takes care of the entities in the file.
- *
- * @retval true If \p file could be opened.
- * @retval false If \p file could not be opened.
- */
-bool DL_Dxf::in( const string& file, DL_CreationInterface* creationInterface )
-{
- FILE *fp;
- firstCall = true;
- currentEntity = DL_Unknown;
- int errorCounter = 0;
-
- fp = fopen( file.c_str(), "rt" );
- if ( fp )
- {
- while ( readDxfGroups( fp, creationInterface, &errorCounter ) ) {}
- fclose( fp );
- if ( errorCounter > 0 )
- {
- QgsDebugMsg( QString( "DXF Filter: There have been %1 errors. The drawing might be incomplete / incorrect." ).arg( errorCounter ) );
- }
- return true;
- }
-
- return false;
-}
-
-
-
-/**
- * Reads a DXF file from an existing stream.
- *
- * @param stream The string stream.
- * @param creationInterface
- * Pointer to the class which takes care of the entities in the file.
- *
- * @retval true If \p file could be opened.
- * @retval false If \p file could not be opened.
- */
-#ifndef __GCC2x__
-bool DL_Dxf::in( std::stringstream& stream,
- DL_CreationInterface* creationInterface )
-{
-
- int errorCounter = 0;
-
- if ( stream.good() )
- {
- firstCall = true;
- currentEntity = DL_Unknown;
- while ( readDxfGroups( stream, creationInterface, &errorCounter ) ) {}
- if ( errorCounter > 0 )
- {
- QgsDebugMsg( QString( "DXF Filter: There have been %1 errors. The drawing might be incomplete / incorrect." ).arg( errorCounter ) );
- }
- return true;
- }
- return false;
-}
-#endif
-
-
-
-/**
- * @brief Reads a group couplet from a DXF file. Calls another function
- * to process it.
- *
- * A group couplet consists of two lines that represent a single
- * piece of data. An integer constant on the first line indicates
- * the type of data. The value is on the next line.\n
- *
- * This function reads a couplet, determines the type of data, and
- * passes the value to the appropriate handler function of
- * \p creationInterface.\n
- *
- * \p fp is advanced so that the next call to \p readDXFGroups() reads
- * the next couplet in the file.
- *
- * @param fp Handle of input file
- * @param creationInterface Handle of class which processes entities
- * in the file
- *
- * @retval true If EOF not reached.
- * @retval false If EOF reached.
- */
-bool DL_Dxf::readDxfGroups( FILE *fp, DL_CreationInterface* creationInterface,
- int* errorCounter )
-{
-
- bool ok = true;
- static int line = 1;
-
- // Read one group of the DXF file and chop the lines:
- if ( DL_Dxf::getChoppedLine( groupCodeTmp, DL_DXF_MAXLINE, fp ) &&
- DL_Dxf::getChoppedLine( groupValue, DL_DXF_MAXLINE, fp ) )
- {
-
- groupCode = ( unsigned int )stringToInt( groupCodeTmp, &ok );
-
- if ( ok )
- {
-// QgsDebugMsg(groupCode);
-// QgsDebugMsg(groupValue);
- line += 2;
- processDXFGroup( creationInterface, groupCode, groupValue );
- }
- else
- {
- QgsDebugMsg( QString( "DXF read error: Line: %1" ).arg( line ) );
- if ( errorCounter != NULL )
- {
- ( *errorCounter )++;
- }
- // try to fix:
- QgsDebugMsg( "DXF read error: trying to fix.." );
- // drop a line to sync:
- DL_Dxf::getChoppedLine( groupCodeTmp, DL_DXF_MAXLINE, fp );
- }
- }
-
- return !feof( fp );
-}
-
-
-
-/**
- * Same as above but for stringstreams.
- */
-#ifndef __GCC2x__
-bool DL_Dxf::readDxfGroups( std::stringstream& stream,
- DL_CreationInterface* creationInterface,
- int* errorCounter )
-{
-
- bool ok = true;
- static int line = 1;
-
- // Read one group of the DXF file and chop the lines:
- if ( DL_Dxf::getChoppedLine( groupCodeTmp, DL_DXF_MAXLINE, stream ) &&
- DL_Dxf::getChoppedLine( groupValue, DL_DXF_MAXLINE, stream ) )
- {
-
- groupCode = ( unsigned int )stringToInt( groupCodeTmp, &ok );
-
- if ( ok )
- {
-// QgsDebugMsg(groupCode);
-// QgsDebugMsg(groupValue);
- line += 2;
- processDXFGroup( creationInterface, groupCode, groupValue );
- }
- else
- {
- QgsDebugMsg( QString( "DXF read error: Line: %1" ).arg( line ) );
- if ( errorCounter != NULL )
- {
- ( *errorCounter )++;
- }
- // try to fix:
- QgsDebugMsg( "DXF read error: trying to fix.." );
- // drop a line to sync:
- DL_Dxf::getChoppedLine( groupCodeTmp, DL_DXF_MAXLINE, stream );
- }
- }
- return !stream.eof();
-}
-#endif
-
-
-
-/**
- * @brief Reads line from file & strips whitespace at start and newline
- * at end.
- *
- * @param s Output\n
- * Pointer to character array that chopped line will be returned in.
- * @param size Size of \p s. (Including space for NULL.)
- * @param fp Input\n
- * Handle of input file.
- *
- * @retval true if line could be read
- * @retval false if \p fp is already at end of file
- *
- * @todo Change function to use safer FreeBSD strl* functions
- * @todo Is it a problem if line is blank (i.e., newline only)?
- * Then, when function returns, (s==NULL).
- */
-bool DL_Dxf::getChoppedLine( char *s, unsigned int size, FILE *fp )
-{
- if ( !feof( fp ) )
- {
- // The whole line in the file. Includes space for NULL.
- char* wholeLine = new char[size];
- // Only the useful part of the line
- char* line;
-
- line = fgets( wholeLine, size, fp );
-
- if ( line != NULL && line[0] != '\0' ) // Evaluates to fgets() retval
- {
- // line == wholeLine at this point.
- // Both guaranteed to be NULL terminated.
-
- // Strip leading whitespace and trailing CR/LF.
- stripWhiteSpace( &line );
-
- strncpy( s, line, size );
- s[size] = '\0';
- // s should always be NULL terminated, because:
- assert( size > strlen( line ) );
- }
-
- delete[] wholeLine; // Done with wholeLine
-
- return true;
- }
- else
- {
- s[0] = '\0';
- return false;
- }
-}
-
-
-
-/**
- * Same as above but for stringstreams.
- */
-#ifndef __GCC2x__
-bool DL_Dxf::getChoppedLine( char *s, unsigned int size,
- std::stringstream& stream )
-{
-
- if ( !stream.eof() )
- {
- // Only the useful part of the line
- stream.getline( s, size );
- stripWhiteSpace( &s );
- assert( size > strlen( s ) );
- return true;
- }
- else
- {
- s[0] = '\0';
- return false;
- }
-}
-#endif
-
-
-
-/**
- * @brief Strips leading whitespace and trailing Carriage Return (CR)
- * and Line Feed (LF) from NULL terminated string.
- *
- * @param s Input and output.
- * NULL terminates string.
- *
- * @retval true if \p s is non-NULL
- * @retval false if \p s is NULL
- */
-bool DL_Dxf::stripWhiteSpace( char** s )
-{
- if ( !s || !( *s ) )
- return false;
-
- // last non-NULL char:
- int lastChar = strlen( *s ) - 1;
- if ( lastChar < 0 )
- return false;
-
-// QgsDebugMsg(QString("lastChar: %1").arg(lastChar));
-
- // Is last character CR or LF?
- while (( lastChar >= 0 ) &&
- ((( *s )[lastChar] == 10 ) || (( *s )[lastChar] == 13 ) ||
- (( *s )[lastChar] == ' ' || (( *s )[lastChar] == '\t' ) ) ) )
- {
- ( *s )[lastChar] = '\0';
- lastChar--;
- }
-
- // Skip whitespace, excluding \n, at beginning of line
- while (( *s )[0] == ' ' || ( *s )[0] == '\t' )
- {
- ++( *s );
- }
-
- return (( *s ) ? true : false );
-}
-
-
-
-/**
- * Processes a group (pair of group code and value).
- *
- * @param creationInterface Handle to class that creates entities and
- * other CAD data from DXF group codes
- *
- * @param groupCode Constant indicating the data type of the group.
- * @param groupValue The data value.
- *
- * @retval true if done processing current entity and new entity begun
- * @retval false if not done processing current entity
-*/
-bool DL_Dxf::processDXFGroup( DL_CreationInterface* creationInterface,
- int groupCode, const char *groupValue )
-{
-
-
-// QgsDebugMsg(QString("groupCode=%1 groupValue=%2").arg(groupCode).arg(groupValue));
-
- // Init on first call
- if ( firstCall )
- {
- for ( int i = 0; i < DL_DXF_MAXGROUPCODE; ++i )
- {
- values[i][0] = '\0';
- }
- settingValue[0] = '\0';
- firstCall = false;
- }
-
- // Indicates comment or dxflib version:
- if ( groupCode == 999 )
- {
-// QgsDebugMsg(QString("999: %1").arg(groupValue));
- if ( groupValue != NULL )
- {
- if ( !strncmp( groupValue, "dxflib", 6 ) )
- {
-// QgsDebugMsg("dxflib version found");
- libVersion = getLibVersion( &groupValue[7] );
- }
- }
- }
-
- // Indicates start of new entity or var
- else if ( groupCode == 0 || groupCode == 9 )
- {
-
- // If new entity is encountered, the last one must be complete
- // prepare attributes which can be used for most entities:
- char name[DL_DXF_MAXLINE+1];
- if (( values[8] )[0] != '\0' )
- {
- strcpy( name, values[8] );
- }
- // defaults to layer '0':
- else
- {
- strcpy( name, "0" );
- }
-
- int width;
- // Compatibillity with qcad1:
- if (( values[39] )[0] != '\0' &&
- ( values[370] )[0] == '\0' )
- {
- width = toInt( values[39], -1 );
- }
- // since autocad 2002:
- else if (( values[370] )[0] != '\0' )
- {
- width = toInt( values[370], -1 );
- }
- // default to BYLAYER:
- else
- {
- width = -1;
- }
-
- int color;
- color = toInt( values[62], 256 );
-
- char linetype[DL_DXF_MAXLINE+1];
- strncpy( linetype, toString( values[6], "BYLAYER" ), DL_DXF_MAXLINE );
-
- attrib = DL_Attributes( values[8], // layer
- color, // color
- width, // width
- linetype ); // linetype
- creationInterface->setAttributes( attrib );
-
- creationInterface->setExtrusion( toReal( values[210], 0.0 ),
- toReal( values[220], 0.0 ),
- toReal( values[230], 1.0 ),
- toReal( values[30], 0.0 ) );
-
- // Add the last entity via creationInterface
- switch ( currentEntity )
- {
- case DL_SETTING:
- addSetting( creationInterface );
- break;
-
- case DL_LAYER:
- addLayer( creationInterface );
- break;
-
- case DL_BLOCK:
- addBlock( creationInterface );
- break;
-
- case DL_ENDBLK:
- endBlock( creationInterface );
- break;
-
- case DL_ENTITY_POINT:
- addPoint( creationInterface );
- break;
-
- case DL_ENTITY_LINE:
- addLine( creationInterface );
- break;
-
- case DL_ENTITY_POLYLINE:
- //bulge = toReal(values[42]);
- // fall through
- case DL_ENTITY_LWPOLYLINE:
- addPolyline( creationInterface );
- break;
-
- case DL_ENTITY_VERTEX:
- addVertex( creationInterface );
- break;
-
- case DL_ENTITY_SPLINE:
- addSpline( creationInterface );
- break;
-
- case DL_ENTITY_ARC:
- addArc( creationInterface );
- break;
-
- case DL_ENTITY_CIRCLE:
- addCircle( creationInterface );
- break;
-
- case DL_ENTITY_ELLIPSE:
- addEllipse( creationInterface );
- break;
-
- case DL_ENTITY_INSERT:
- addInsert( creationInterface );
- break;
-
- case DL_ENTITY_MTEXT:
- addMText( creationInterface );
- break;
-
- case DL_ENTITY_TEXT:
- addText( creationInterface );
- break;
-
- case DL_ENTITY_ATTRIB:
- addAttrib( creationInterface );
- break;
-
- case DL_ENTITY_DIMENSION:
- {
- int type = ( toInt( values[70], 0 ) & 0x07 );
-
- switch ( type )
- {
- case 0:
- addDimLinear( creationInterface );
- break;
-
- case 1:
- addDimAligned( creationInterface );
- break;
-
- case 2:
- addDimAngular( creationInterface );
- break;
-
- case 3:
- addDimDiametric( creationInterface );
- break;
-
- case 4:
- addDimRadial( creationInterface );
- break;
-
- case 5:
- addDimAngular3P( creationInterface );
- break;
-
- default:
- break;
- }
- }
- break;
-
- case DL_ENTITY_LEADER:
- addLeader( creationInterface );
- break;
-
- case DL_ENTITY_HATCH:
- addHatch( creationInterface );
- break;
-
- case DL_ENTITY_IMAGE:
- addImage( creationInterface );
- break;
-
- case DL_ENTITY_IMAGEDEF:
- addImageDef( creationInterface );
- break;
-
- case DL_ENTITY_TRACE:
- addTrace( creationInterface );
- break;
-
- case DL_ENTITY_SOLID:
- addSolid( creationInterface );
- break;
-
- case DL_ENTITY_SEQEND:
- endSequence( creationInterface );
- break;
-
- default:
- break;
- }
-
-
- // reset all values (they are not persistent and only this
- // way we can detect default values for unstored settings)
- for ( int i = 0; i < DL_DXF_MAXGROUPCODE; ++i )
- {
- values[i][0] = '\0';
- }
- settingValue[0] = '\0';
- settingKey[0] = '\0';
-
-
- // Last DXF entity or setting has been handled
- // Now determine what the next entity or setting type is
-
- int prevEntity = currentEntity;
-
- // Read DXF settings:
- if ( groupValue[0] == '$' )
- {
- currentEntity = DL_SETTING;
- strncpy( settingKey, groupValue, DL_DXF_MAXLINE );
- settingKey[DL_DXF_MAXLINE] = '\0';
- }
- // Read Layers:
- else if ( !strcmp( groupValue, "LAYER" ) )
- {
- currentEntity = DL_LAYER;
-
- }
- // Read Blocks:
- else if ( !strcmp( groupValue, "BLOCK" ) )
- {
- currentEntity = DL_BLOCK;
- }
- else if ( !strcmp( groupValue, "ENDBLK" ) )
- {
- currentEntity = DL_ENDBLK;
-
- }
- // Read entities:
- else if ( !strcmp( groupValue, "POINT" ) )
- {
- currentEntity = DL_ENTITY_POINT;
- }
- else if ( !strcmp( groupValue, "LINE" ) )
- {
- currentEntity = DL_ENTITY_LINE;
- }
- else if ( !strcmp( groupValue, "POLYLINE" ) )
- {
- currentEntity = DL_ENTITY_POLYLINE;
- }
- else if ( !strcmp( groupValue, "LWPOLYLINE" ) )
- {
- currentEntity = DL_ENTITY_LWPOLYLINE;
- }
- else if ( !strcmp( groupValue, "VERTEX" ) )
- {
- currentEntity = DL_ENTITY_VERTEX;
- }
- else if ( !strcmp( groupValue, "SPLINE" ) )
- {
- currentEntity = DL_ENTITY_SPLINE;
- }
- else if ( !strcmp( groupValue, "ARC" ) )
- {
- currentEntity = DL_ENTITY_ARC;
- }
- else if ( !strcmp( groupValue, "ELLIPSE" ) )
- {
- currentEntity = DL_ENTITY_ELLIPSE;
- }
- else if ( !strcmp( groupValue, "CIRCLE" ) )
- {
- currentEntity = DL_ENTITY_CIRCLE;
- }
- else if ( !strcmp( groupValue, "INSERT" ) )
- {
- currentEntity = DL_ENTITY_INSERT;
- }
- else if ( !strcmp( groupValue, "TEXT" ) )
- {
- currentEntity = DL_ENTITY_TEXT;
- }
- else if ( !strcmp( groupValue, "MTEXT" ) )
- {
- currentEntity = DL_ENTITY_MTEXT;
- }
- else if ( !strcmp( groupValue, "ATTRIB" ) )
- {
- currentEntity = DL_ENTITY_ATTRIB;
- }
- else if ( !strcmp( groupValue, "DIMENSION" ) )
- {
- currentEntity = DL_ENTITY_DIMENSION;
- }
- else if ( !strcmp( groupValue, "LEADER" ) )
- {
- currentEntity = DL_ENTITY_LEADER;
- }
- else if ( !strcmp( groupValue, "HATCH" ) )
- {
- currentEntity = DL_ENTITY_HATCH;
- }
- else if ( !strcmp( groupValue, "IMAGE" ) )
- {
- currentEntity = DL_ENTITY_IMAGE;
- }
- else if ( !strcmp( groupValue, "IMAGEDEF" ) )
- {
- currentEntity = DL_ENTITY_IMAGEDEF;
- }
- else if ( !strcmp( groupValue, "TRACE" ) )
- {
- currentEntity = DL_ENTITY_TRACE;
- }
- else if ( !strcmp( groupValue, "SOLID" ) )
- {
- currentEntity = DL_ENTITY_SOLID;
- }
- else if ( !strcmp( groupValue, "SEQEND" ) )
- {
- currentEntity = DL_ENTITY_SEQEND;
- }
- else
- {
- currentEntity = DL_Unknown;
- }
-
- // end of old style POLYLINE entity
- if ( prevEntity == DL_ENTITY_VERTEX && currentEntity != DL_ENTITY_VERTEX )
- {
- endEntity( creationInterface );
- }
-
- return true;
-
- }
- else
- {
- // Group code does not indicate start of new entity or setting,
- // so this group must be continuation of data for the current
- // one.
- if ( groupCode < DL_DXF_MAXGROUPCODE )
- {
-
- bool handled = false;
-
- switch ( currentEntity )
- {
- case DL_ENTITY_MTEXT:
- handled = handleMTextData( creationInterface );
- break;
-
- case DL_ENTITY_LWPOLYLINE:
- handled = handleLWPolylineData( creationInterface );
- break;
-
- case DL_ENTITY_SPLINE:
- handled = handleSplineData( creationInterface );
- break;
-
- case DL_ENTITY_LEADER:
- handled = handleLeaderData( creationInterface );
- break;
-
- case DL_ENTITY_HATCH:
- handled = handleHatchData( creationInterface );
- break;
-
- default:
- break;
- }
-
- if ( !handled )
- {
- // Normal group / value pair:
- strncpy( values[groupCode], groupValue, DL_DXF_MAXLINE );
- values[groupCode][DL_DXF_MAXLINE] = '\0';
- }
- }
-
- return false;
- }
- return false;
-}
-
-
-
-/**
- * Adds a variable from the DXF file.
- */
-void DL_Dxf::addSetting( DL_CreationInterface* creationInterface )
-{
- int c = -1;
- for ( int i = 0; i <= 380; ++i )
- {
- if ( values[i][0] != '\0' )
- {
- c = i;
- break;
- }
- }
-
- // string
- if ( c >= 0 && c <= 9 )
- {
- creationInterface->setVariableString( settingKey,
- values[c], c );
- }
- // vector
- else if ( c >= 10 && c <= 39 )
- {
- if ( c == 10 )
- {
- creationInterface->setVariableVector(
- settingKey,
- toReal( values[c] ),
- toReal( values[c+10] ),
- toReal( values[c+20] ),
- c );
- }
- }
- // double
- else if ( c >= 40 && c <= 59 )
- {
- creationInterface->setVariableDouble( settingKey,
- toReal( values[c] ),
- c );
- }
- // int
- else if ( c >= 60 && c <= 99 )
- {
- creationInterface->setVariableInt( settingKey,
- toInt( values[c] ),
- c );
- }
- // misc
- else if ( c >= 0 )
- {
- creationInterface->setVariableString( settingKey,
- values[c],
- c );
- }
-}
-
-
-
-/**
- * Adds a layer that was read from the file via the creation interface.
- */
-void DL_Dxf::addLayer( DL_CreationInterface* creationInterface )
-{
- // correct some impossible attributes for layers:
- attrib = creationInterface->getAttributes();
- if ( attrib.getColor() == 256 || attrib.getColor() == 0 )
- {
- attrib.setColor( 7 );
- }
- if ( attrib.getWidth() < 0 )
- {
- attrib.setWidth( 1 );
- }
- if ( !strcasecmp( attrib.getLineType().c_str(), "BYLAYER" ) ||
- !strcasecmp( attrib.getLineType().c_str(), "BYBLOCK" ) )
- {
- attrib.setLineType( "CONTINUOUS" );
- }
-
- // add layer
- creationInterface->addLayer( DL_LayerData( values[2],
- toInt( values[70] ) ) );
-}
-
-
-
-/**
- * Adds a block that was read from the file via the creation interface.
- */
-void DL_Dxf::addBlock( DL_CreationInterface* creationInterface )
-{
- DL_BlockData d(
- // Name:
- values[2],
- // flags:
- toInt( values[70] ),
- // base point:
- toReal( values[10] ),
- toReal( values[20] ),
- toReal( values[30] ) );
-
- creationInterface->addBlock( d );
-}
-
-
-
-/**
- * Ends a block that was read from the file via the creation interface.
- */
-void DL_Dxf::endBlock( DL_CreationInterface* creationInterface )
-{
- creationInterface->endBlock();
-}
-
-
-
-/**
- * Adds a point entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addPoint( DL_CreationInterface* creationInterface )
-{
- DL_PointData d( toReal( values[10] ),
- toReal( values[20] ),
- toReal( values[30] ) );
- creationInterface->addPoint( d );
-}
-
-
-
-/**
- * Adds a line entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addLine( DL_CreationInterface* creationInterface )
-{
- DL_LineData d( toReal( values[10] ),
- toReal( values[20] ),
- toReal( values[30] ),
- toReal( values[11] ),
- toReal( values[21] ),
- toReal( values[31] ) );
-
- creationInterface->addLine( d );
-}
-
-
-
-/**
- * Adds a polyline entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addPolyline( DL_CreationInterface* creationInterface )
-{
- DL_PolylineData pd( maxVertices, toInt( values[71], 0 ), toInt( values[72], 0 ), toInt( values[70], 0 ) );
- creationInterface->addPolyline( pd );
-
- if ( currentEntity == DL_ENTITY_LWPOLYLINE )
- {
- for ( int i = 0; i < maxVertices; i++ )
- {
- DL_VertexData d( vertices[i*4],
- vertices[i*4+1],
- vertices[i*4+2],
- vertices[i*4+3] );
-
- creationInterface->addVertex( d );
- }
- creationInterface->endEntity();
- }
-}
-
-
-
-/**
- * Adds a polyline vertex entity that was read from the file
- * via the creation interface.
- */
-void DL_Dxf::addVertex( DL_CreationInterface* creationInterface )
-{
- DL_VertexData d( toReal( values[10] ),
- toReal( values[20] ),
- toReal( values[30] ),
- //bulge);
- toReal( values[42] ) );
-
- //bulge = toReal(values[42]);
-
- creationInterface->addVertex( d );
-}
-
-
-
-/**
- * Adds a spline entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addSpline( DL_CreationInterface* creationInterface )
-{
- DL_SplineData sd( toInt( values[71], 3 ),
- maxKnots,
- maxControlPoints,
- toInt( values[70], 4 ) );
- /*DL_SplineData sd(toInt(values[71], 3), toInt(values[72], 0),
- toInt(values[73], 0), toInt(values[70], 4));*/
- creationInterface->addSpline( sd );
-
- int i;
- for ( i = 0; i < maxControlPoints; i++ )
- {
- DL_ControlPointData d( controlPoints[i*3],
- controlPoints[i*3+1],
- controlPoints[i*3+2] );
-
- creationInterface->addControlPoint( d );
- }
- for ( i = 0; i < maxKnots; i++ )
- {
- DL_KnotData k( knots[i] );
-
- creationInterface->addKnot( k );
- }
-}
-
-
-
-#if 0
-/**
- * Adds a knot to the previously added spline.
- */
-void DL_Dxf::addKnot( DL_CreationInterface* creationInterface )
-{
- QgsDebugMsg( "entered." );
-}
-#endif
-
-#if 0
-/**
- * Adds a control point to the previously added spline.
- */
-void DL_Dxf::addControlPoint( DL_CreationInterface* creationInterface )
-{
- QgsDebugMsg( "entered." );
-}
-#endif
-
-
-
-/**
- * Adds an arc entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addArc( DL_CreationInterface* creationInterface )
-{
- DL_ArcData d( toReal( values[10] ),
- toReal( values[20] ),
- toReal( values[30] ),
- toReal( values[40] ),
- toReal( values[50] ),
- toReal( values[51] ) );
-
- creationInterface->addArc( d );
-}
-
-
-
-/**
- * Adds a circle entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addCircle( DL_CreationInterface* creationInterface )
-{
- DL_CircleData d( toReal( values[10] ),
- toReal( values[20] ),
- toReal( values[30] ),
- toReal( values[40] ) );
-
- creationInterface->addCircle( d );
-}
-
-
-
-/**
- * Adds an ellipse entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addEllipse( DL_CreationInterface* creationInterface )
-{
- DL_EllipseData d( toReal( values[10] ),
- toReal( values[20] ),
- toReal( values[30] ),
- toReal( values[11] ),
- toReal( values[21] ),
- toReal( values[31] ),
- toReal( values[40], 1.0 ),
- toReal( values[41], 0.0 ),
- toReal( values[42], 2*M_PI ) );
-
- creationInterface->addEllipse( d );
-}
-
-
-
-/**
- * Adds an insert entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addInsert( DL_CreationInterface* creationInterface )
-{
- DL_InsertData d( values[2],
- // insertion point
- toReal( values[10], 0.0 ),
- toReal( values[20], 0.0 ),
- toReal( values[30], 0.0 ),
- // scale:
- toReal( values[41], 1.0 ),
- toReal( values[42], 1.0 ),
- toReal( values[43], 1.0 ),
- // angle:
- toReal( values[50], 0.0 ),
- // cols / rows:
- toInt( values[70], 1 ),
- toInt( values[71], 1 ),
- // spacing:
- toReal( values[44], 0.0 ),
- toReal( values[45], 0.0 ) );
-
- creationInterface->addInsert( d );
-}
-
-
-/**
- * Adds a trace entity (4 edge closed polyline) that was read from the file via the creation interface.
- *
- * @author AHM
- */
-void DL_Dxf::addTrace( DL_CreationInterface* creationInterface )
-{
- DL_TraceData td;
-
- for ( int k = 0; k < 4; k++ )
- {
- td.x[k] = toReal( values[10 + k] );
- td.y[k] = toReal( values[20 + k] );
- td.z[k] = toReal( values[30 + k] );
- }
- creationInterface->addTrace( td );
-}
-
-/**
- * Adds a solid entity (filled trace) that was read from the file via the creation interface.
- *
- * @author AHM
- */
-void DL_Dxf::addSolid( DL_CreationInterface* creationInterface )
-{
- DL_SolidData sd;
-
- for ( int k = 0; k < 4; k++ )
- {
- sd.x[k] = toReal( values[10 + k] );
- sd.y[k] = toReal( values[20 + k] );
- sd.z[k] = toReal( values[30 + k] );
- }
- creationInterface->addSolid( sd );
-}
-
-
-/**
- * Adds an MText entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addMText( DL_CreationInterface* creationInterface )
-{
- double angle = 0.0;
-
- if ( values[50][0] != '\0' )
- {
- if ( libVersion <= 0x02000200 )
- {
- // wrong but compatible with dxflib <=2.0.2.0:
- angle = toReal( values[50], 0.0 );
- }
- else
- {
- angle = ( toReal( values[50], 0.0 ) * 2 * M_PI ) / 360.0;
- }
- }
- else if ( values[11][0] != '\0' && values[21][0] != '\0' )
- {
- double x = toReal( values[11], 0.0 );
- double y = toReal( values[21], 0.0 );
-
- if ( qAbs( x ) < 1.0e-6 )
- {
- if ( y > 0.0 )
- {
- angle = M_PI / 2.0;
- }
- else
- {
- angle = M_PI / 2.0 * 3.0;
- }
- }
- else
- {
- angle = atan( y / x );
- }
- }
-
- DL_MTextData d(
- // insertion point
- toReal( values[10], 0.0 ),
- toReal( values[20], 0.0 ),
- toReal( values[30], 0.0 ),
- // height
- toReal( values[40], 2.5 ),
- // width
- toReal( values[41], 100.0 ),
- // attachment point
- toInt( values[71], 1 ),
- // drawing direction
- toInt( values[72], 1 ),
- // line spacing style
- toInt( values[73], 1 ),
- // line spacing factor
- toReal( values[44], 1.0 ),
- // text
- values[1],
- // style
- values[7],
- // angle
- angle );
- creationInterface->addMText( d );
-}
-
-
-
-/**
- * Handles additional MText data.
- */
-bool DL_Dxf::handleMTextData( DL_CreationInterface* creationInterface )
-{
- // Special handling of text chunks for MTEXT entities:
- if ( groupCode == 3 )
- {
- creationInterface->addMTextChunk( groupValue );
- return true;
- }
-
- return false;
-}
-
-
-
-/**
- * Handles additional polyline data.
- */
-bool DL_Dxf::handleLWPolylineData( DL_CreationInterface* /*creationInterface*/ )
-{
- // Allocate LWPolyline vertices (group code 90):
- if ( groupCode == 90 )
- {
- maxVertices = toInt( groupValue );
- if ( maxVertices > 0 )
- {
- if ( vertices != NULL )
- {
- delete[] vertices;
- }
- vertices = new double[4*maxVertices];
- for ( int i = 0; i < maxVertices; ++i )
- {
- vertices[i*4] = 0.0;
- vertices[i*4+1] = 0.0;
- vertices[i*4+2] = 0.0;
- vertices[i*4+3] = 0.0;
- }
- }
- vertexIndex = -1;
- return true;
- }
-
- // Compute LWPolylines vertices (group codes 10/20/30/42):
- else if ( groupCode == 10 || groupCode == 20 ||
- groupCode == 30 || groupCode == 42 )
- {
-
- if ( vertexIndex < maxVertices - 1 && groupCode == 10 )
- {
- vertexIndex++;
- }
-
- if ( groupCode <= 30 )
- {
- if ( vertexIndex >= 0 && vertexIndex < maxVertices )
- {
- vertices[4*vertexIndex + ( groupCode/10-1 )]
- = toReal( groupValue );
- }
- }
- else if ( groupCode == 42 && vertexIndex < maxVertices )
- {
- vertices[4*vertexIndex + 3] = toReal( groupValue );
- }
- return true;
- }
- return false;
-}
-
-
-
-/**
- * Handles additional spline data.
- */
-bool DL_Dxf::handleSplineData( DL_CreationInterface* /*creationInterface*/ )
-{
- // Allocate Spline knots (group code 72):
- if ( groupCode == 72 )
- {
- maxKnots = toInt( groupValue );
- if ( maxKnots > 0 )
- {
- if ( knots != NULL )
- {
- delete[] knots;
- }
- knots = new double[maxKnots];
- for ( int i = 0; i < maxKnots; ++i )
- {
- knots[i] = 0.0;
- }
- }
- knotIndex = -1;
- return true;
- }
-
- // Allocate Spline control points (group code 73):
- else if ( groupCode == 73 )
- {
- maxControlPoints = toInt( groupValue );
- if ( maxControlPoints > 0 )
- {
- if ( controlPoints != NULL )
- {
- delete[] controlPoints;
- }
- controlPoints = new double[3*maxControlPoints];
- for ( int i = 0; i < maxControlPoints; ++i )
- {
- controlPoints[i*3] = 0.0;
- controlPoints[i*3+1] = 0.0;
- controlPoints[i*3+2] = 0.0;
- }
- }
- controlPointIndex = -1;
- return true;
- }
-
- // Compute spline knot vertices (group code 40):
- else if ( groupCode == 40 )
- {
- if ( knotIndex < maxKnots - 1 )
- {
- knotIndex++;
- knots[knotIndex] = toReal( groupValue );
- }
- return true;
- }
-
- // Compute spline control points (group codes 10/20/30):
- else if ( groupCode == 10 || groupCode == 20 ||
- groupCode == 30 )
- {
-
- if ( controlPointIndex < maxControlPoints - 1 && groupCode == 10 )
- {
- controlPointIndex++;
- }
-
- if ( controlPointIndex >= 0 && controlPointIndex < maxControlPoints )
- {
- controlPoints[3*controlPointIndex + ( groupCode/10-1 )]
- = toReal( groupValue );
- }
- return true;
- }
- return false;
-}
-
-
-
-/**
- * Handles additional leader data.
- */
-bool DL_Dxf::handleLeaderData( DL_CreationInterface* /*creationInterface*/ )
-{
- // Allocate Leader vertices (group code 76):
- if ( groupCode == 76 )
- {
- maxLeaderVertices = toInt( groupValue );
- if ( maxLeaderVertices > 0 )
- {
- if ( leaderVertices != NULL )
- {
- delete[] leaderVertices;
- }
- leaderVertices = new double[3*maxLeaderVertices];
- for ( int i = 0; i < maxLeaderVertices; ++i )
- {
- leaderVertices[i*3] = 0.0;
- leaderVertices[i*3+1] = 0.0;
- leaderVertices[i*3+2] = 0.0;
- }
- }
- leaderVertexIndex = -1;
- return true;
- }
-
- // Compute Leader vertices (group codes 10/20/30):
- else if ( groupCode == 10 || groupCode == 20 || groupCode == 30 )
- {
-
- if ( leaderVertexIndex < maxLeaderVertices - 1 && groupCode == 10 )
- {
- leaderVertexIndex++;
- }
-
- if ( groupCode <= 30 )
- {
- if ( leaderVertexIndex >= 0 &&
- leaderVertexIndex < maxLeaderVertices )
- {
- leaderVertices[3*leaderVertexIndex + ( groupCode/10-1 )]
- = toReal( groupValue );
- }
- }
- return true;
- }
-
- return false;
-}
-
-
-
-/**
- * Handles additional hatch data.
- */
-bool DL_Dxf::handleHatchData( DL_CreationInterface* /*creationInterface*/ )
-{
- // Allocate hatch loops (group code 91):
- if ( groupCode == 91 && toInt( groupValue ) > 0 )
- {
-
-// QgsDebugMsg(QString("allocating %1 loops").arg(toInt(groupValue)));
-
- if ( hatchLoops != NULL )
- {
- delete[] hatchLoops;
- hatchLoops = NULL;
- }
- if ( maxHatchEdges != NULL )
- {
- delete[] maxHatchEdges;
- maxHatchEdges = NULL;
- }
- if ( hatchEdgeIndex != NULL )
- {
- delete[] hatchEdgeIndex;
- hatchEdgeIndex = NULL;
- }
- if ( hatchEdges != NULL )
- {
- for ( int i = 0; i < maxHatchLoops; ++i )
- {
- delete[] hatchEdges[i];
- }
- delete[] hatchEdges;
- hatchEdges = NULL;
- }
- maxHatchLoops = toInt( groupValue );
-
-// QgsDebugMsg(QString("maxHatchLoops: %1").arg(maxHatchLoops));
-
- if ( maxHatchLoops > 0 )
- {
- hatchLoops = new DL_HatchLoopData[maxHatchLoops];
- maxHatchEdges = new int[maxHatchLoops];
- hatchEdgeIndex = new int[maxHatchLoops];
- hatchEdges = new DL_HatchEdgeData*[maxHatchLoops];
-// QgsDebugMsg(QString("new hatchEdges[%1]").arg(maxHatchLoops));
- for ( int i = 0; i < maxHatchLoops; ++i )
- {
- hatchEdges[i] = NULL;
-// QgsDebugMsg(QString("hatchEdges[%1] = NULL").arg(i));
- maxHatchEdges[i] = 0;
- }
- hatchLoopIndex = -1;
- dropEdges = false;
- }
-// QgsDebugMsg("done");
- return true;
- }
-
- // Allocate hatch edges, group code 93
- if ( groupCode == 93 && toInt( groupValue ) > 0 )
- {
- if ( hatchLoopIndex < maxHatchLoops - 1 && hatchLoops != NULL &&
- maxHatchEdges != NULL && hatchEdgeIndex != NULL &&
- hatchEdges != NULL )
- {
-
-// QgsDebugMsg(QString(" allocating %1 edges").arg(toInt(groupValue)));
- dropEdges = false;
-
- hatchLoopIndex++;
- hatchLoops[hatchLoopIndex] = DL_HatchLoopData( toInt( groupValue ) );
-
- maxHatchEdges[hatchLoopIndex] = toInt( groupValue );
- hatchEdgeIndex[hatchLoopIndex] = -1;
- hatchEdges[hatchLoopIndex] = new DL_HatchEdgeData[toInt( groupValue )];
-
-// QgsDebugMsg(QString("hatchEdges[%1] = new %2").arg(hatchLoopIndex).arg(toInt(groupValue)));
- }
- else
- {
-// QgsDebugMsg(QString("dropping %1 edges").arg(toInt(groupValue)));
- dropEdges = true;
- }
-// QgsDebugMsg("done");
- return true;
- }
-
- // Init hatch edge for non-polyline boundary (group code 72)
- if ( hatchEdges != NULL &&
- hatchEdgeIndex != NULL &&
- maxHatchEdges != NULL &&
- hatchLoopIndex >= 0 &&
- hatchLoopIndex < maxHatchLoops &&
- hatchEdgeIndex[hatchLoopIndex] <
- maxHatchEdges[hatchLoopIndex] &&
- ( atoi( values[92] )&2 ) == 0 && // not a polyline
- groupCode == 72 &&
- !dropEdges )
- {
-
-// QgsDebugMsg("Init hatch edge for non-polyline boundary");
-// QgsDebugMsg(QString("hatchLoopIndex: %1").arg(hatchLoopIndex));
-// QgsDebugMsg(QString("maxHatchLoops: %1").arg(maxHatchLoops));
-
- hatchEdgeIndex[hatchLoopIndex]++;
-
-// QgsDebugMsg(QString(" init edge: type: %1 index: %2").arg(toInt(groupValue)).arg(hatchEdgeIndex[hatchLoopIndex]));
-
- hatchEdges[hatchLoopIndex][hatchEdgeIndex[hatchLoopIndex]]
- .type = toInt( groupValue );
- hatchEdges[hatchLoopIndex][hatchEdgeIndex[hatchLoopIndex]]
- .defined = false;
-
-// QgsDebugMsg("done");
- return true;
- }
-
- // Handle hatch edges for non-polyline boundaries
- // (group codes 10, 20, 11, 21, 40, 50, 51, 73)
- if ( !dropEdges &&
- hatchEdges != NULL &&
- hatchEdgeIndex != NULL &&
- hatchLoopIndex >= 0 &&
- maxHatchEdges != NULL &&
- hatchLoopIndex < maxHatchLoops &&
- hatchEdges[hatchLoopIndex] != NULL &&
- hatchEdgeIndex[hatchLoopIndex] >= 0 &&
- hatchEdgeIndex[hatchLoopIndex] <
- maxHatchEdges[hatchLoopIndex] &&
- (( atoi( values[92] )&2 ) == 0 ) && // not a polyline
- ( groupCode == 10 || groupCode == 20 ||
- groupCode == 11 || groupCode == 21 ||
- groupCode == 40 || groupCode == 50 ||
- groupCode == 51 || groupCode == 73 ) )
- {
-
-// QgsDebugMsg("Handle hatch edge for non-polyline boundary");
-// QgsDebugMsg(QString(" found edge data: %1").arg(groupCode));
-// QgsDebugMsg(QString(" value: %1").arg(toReal(groupValue)));
-
- // can crash:
-// QgsDebugMsg(QString(" defined: %1").arg((int)hatchEdges[hatchLoopIndex][hatchEdgeIndex[hatchLoopIndex]].defined));
-
-// QgsDebugMsg(QString("92 flag: '%1'").arg(values[92]));
-// QgsDebugMsg(QString("92 flag (int): '%1'").arg(atoi(values[92])));
-
- if ( !hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].defined )
- {
- if ( hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].type == 1 )
- {
- switch ( groupCode )
- {
- case 10:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].x1
- = toReal( groupValue );
- break;
- case 20:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].y1
- = toReal( groupValue );
- break;
- case 11:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].x2
- = toReal( groupValue );
- break;
- case 21:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].y2
- = toReal( groupValue );
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].defined = true;
- break;
- default:
- break;
- }
- }
-
- if ( hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].type == 2 )
- {
- switch ( groupCode )
- {
- case 10:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].cx
- = toReal( groupValue );
- break;
- case 20:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].cy
- = toReal( groupValue );
- break;
- case 40:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].radius
- = toReal( groupValue );
- break;
- case 50:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].angle1
- = toReal( groupValue ) / 360.0 * 2 * M_PI;
- break;
- case 51:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].angle2
- = toReal( groupValue ) / 360.0 * 2 * M_PI;
- break;
- case 73:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].ccw
- = ( bool )toInt( groupValue );
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].defined = true;
- break;
- default:
- break;
- }
- }
- }
- return true;
- }
-
-#if 0
- // 2003/12/31: polyline hatches can be extremely slow and are rarely used
- //
- // Handle hatch edges for polyline boundaries
- // (group codes 10, 20, 42)
- if ( !dropEdges &&
- hatchEdges != NULL &&
- hatchEdgeIndex != NULL &&
- hatchLoopIndex >= 0 &&
- hatchLoopIndex < maxHatchLoops &&
- hatchEdges[hatchLoopIndex] != NULL &&
- //hatchEdgeIndex[hatchLoopIndex]>=0 &&
- hatchEdgeIndex[hatchLoopIndex] <
- maxHatchEdges[hatchLoopIndex] &&
- (( atoi( values[92] )&2 ) == 2 ) ) // a polyline
- {
-
- if ( groupCode == 10 || groupCode == 20 ||
- groupCode == 42 )
- {
-
- QgsDebugMsg( QString( " found polyline edge data: %1" ).arg( groupCode ) );
- QgsDebugMsg( QString( " value: %1" ).arg( toReal( groupValue ) ) );
-
- static double lastX = 0.0;
- static double lastY = 0.0;
- static double lastB = 0.0;
-
- if ( firstPolylineStatus < 2 )
- {
- switch ( groupCode )
- {
- case 10:
- firstPolylineStatus++;
- if ( firstPolylineStatus == 1 )
- {
- lastX = toReal( groupValue );
- QgsDebugMsg( QString( " firstX: %1" ).arg( lastX ) );
- }
- break;
-
- case 20:
- lastY = toReal( groupValue );
- QgsDebugMsg( QString( " firstY: %1" ).arg( lastY ) );
- break;
-
- case 42:
- lastB = toReal( groupValue );
- break;
-
- default:
- break;
- }
-
- if ( firstPolylineStatus != 2 )
- {
- return true;
- }
- }
-
-
- switch ( groupCode )
- {
- case 10:
- hatchEdgeIndex[hatchLoopIndex]++;
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].type = 1;
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].x1
- = lastX;
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].x2
- = lastX = toReal( groupValue );
- QgsDebugMsg( QString( " X: %1" ).arg( lastX ) );
- break;
- case 20:
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].y1
- = lastY;
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].y2
- = lastY = toReal( groupValue );
- QgsDebugMsg( QString( " Y: %1" ).arg( lastY ) );
- break;
- / *
- case 42:
- {
- // convert to arc:
- double x1 = hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].x1;
- double y1 = hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].y1;
- double x2 = hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].x2;
- double y2 = hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].y2;
-
- double bulge = toReal( groupValue );
-
- bool reversed = ( bulge < 0.0 );
- double alpha = atan( bulge ) * 4.0;
- double radius;
- double cx;
- double cy;
- double a1;
- double a2;
- double mx = ( x2 + x1 ) / 2.0;
- double my = ( y2 + y1 ) / 2.0;
- double dist = sqrt( pow( x2 - x1, 2 ) + pow( y2 - y1, 2 ) ) / 2.0;
-
- // alpha can't be 0.0 at this point
- radius = qAbs( dist / sin( alpha / 2.0 ) );
-
- double wu = qAbs( pow( radius, 2.0 ) - pow( dist, 2.0 ) );
- double h = sqrt( wu );
- double angle = acos(( x2 - x1 ) / dist );
-
- if ( bulge > 0.0 )
- {
- angle += M_PI / 2.0;
- }
- else
- {
- angle -= M_PI / 2.0;
- }
-
- if ( qAbs( alpha ) > M_PI )
- {
- h *= -1.0;
- }
-
- cx = mx + cos( angle ) * h;
- cy = my + sin( angle ) * h;
-
- a1 = hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].type = 2;
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].ccw = ( toReal( groupValue ) > 0.0 );
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].cx = cx;
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].cy = cy;
- hatchEdges[hatchLoopIndex]
- [hatchEdgeIndex[hatchLoopIndex]].radius = radius;
- }
- break;
- * /
-
- default:
- break;
- }
- }
- else
- {
- // end polyline boundary
- dropEdges = true;
- }
-
- return true;
- }
-#endif
-
- return false;
-}
-
-
-
-
-/**
- * Adds an text entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addText( DL_CreationInterface* creationInterface )
-{
- DL_TextData d(
- // insertion point
- toReal( values[10], 0.0 ),
- toReal( values[20], 0.0 ),
- toReal( values[30], 0.0 ),
- // alignment point
- toReal( values[11], 0.0 ),
- toReal( values[21], 0.0 ),
- toReal( values[31], 0.0 ),
- // height
- toReal( values[40], 2.5 ),
- // x scale
- toReal( values[41], 1.0 ),
- // generation flags
- toInt( values[71], 0 ),
- // h just
- toInt( values[72], 0 ),
- // v just
- toInt( values[73], 0 ),
- // text
- values[1],
- // style
- values[7],
- // angle
- ( toReal( values[50], 0.0 )*2*M_PI ) / 360.0 );
-
- creationInterface->addText( d );
-}
-
-
-
-/**
- * Adds an attrib entity that was read from the file via the creation interface.
- * @todo add attrib instead of normal text
- */
-void DL_Dxf::addAttrib( DL_CreationInterface* creationInterface )
-{
- DL_TextData d(
- // insertion point
- toReal( values[10], 0.0 ),
- toReal( values[20], 0.0 ),
- toReal( values[30], 0.0 ),
- // alignment point
- toReal( values[11], 0.0 ),
- toReal( values[21], 0.0 ),
- toReal( values[31], 0.0 ),
- // height
- toReal( values[40], 2.5 ),
- // x scale
- toReal( values[41], 1.0 ),
- // generation flags
- toInt( values[71], 0 ),
- // h just
- toInt( values[72], 0 ),
- // v just
- toInt( values[74], 0 ),
- // text
- values[1],
- // style
- values[7],
- // angle
- ( toReal( values[50], 0.0 )*2*M_PI ) / 360.0 );
-
- creationInterface->addText( d );
-}
-
-
-
-/**
- * @return dimension data from current values.
- */
-DL_DimensionData DL_Dxf::getDimData()
-{
- // generic dimension data:
- return DL_DimensionData(
- // def point
- toReal( values[10], 0.0 ),
- toReal( values[20], 0.0 ),
- toReal( values[30], 0.0 ),
- // text middle point
- toReal( values[11], 0.0 ),
- toReal( values[21], 0.0 ),
- toReal( values[31], 0.0 ),
- // type
- toInt( values[70], 0 ),
- // attachment point
- toInt( values[71], 5 ),
- // line sp. style
- toInt( values[72], 1 ),
- // line sp. factor
- toReal( values[41], 1.0 ),
- // text
- values[1],
- // style
- values[3],
- // angle
- toReal( values[53], 0.0 ) );
-}
-
-
-
-/**
- * Adds a linear dimension entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addDimLinear( DL_CreationInterface* creationInterface )
-{
- DL_DimensionData d = getDimData();
-
- // horizontal / vertical / rotated dimension:
- DL_DimLinearData dl(
- // definition point 1
- toReal( values[13], 0.0 ),
- toReal( values[23], 0.0 ),
- toReal( values[33], 0.0 ),
- // definition point 2
- toReal( values[14], 0.0 ),
- toReal( values[24], 0.0 ),
- toReal( values[34], 0.0 ),
- // angle
- toReal( values[50], 0.0 ),
- // oblique
- toReal( values[52], 0.0 ) );
- creationInterface->addDimLinear( d, dl );
-}
-
-
-
-/**
- * Adds an aligned dimension entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addDimAligned( DL_CreationInterface* creationInterface )
-{
- DL_DimensionData d = getDimData();
-
- // aligned dimension:
- DL_DimAlignedData da(
- // extension point 1
- toReal( values[13], 0.0 ),
- toReal( values[23], 0.0 ),
- toReal( values[33], 0.0 ),
- // extension point 2
- toReal( values[14], 0.0 ),
- toReal( values[24], 0.0 ),
- toReal( values[34], 0.0 ) );
- creationInterface->addDimAlign( d, da );
-}
-
-
-
-/**
- * Adds a radial dimension entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addDimRadial( DL_CreationInterface* creationInterface )
-{
- DL_DimensionData d = getDimData();
-
- DL_DimRadialData dr(
- // definition point
- toReal( values[15], 0.0 ),
- toReal( values[25], 0.0 ),
- toReal( values[35], 0.0 ),
- // leader length:
- toReal( values[40], 0.0 ) );
- creationInterface->addDimRadial( d, dr );
-}
-
-
-
-/**
- * Adds a diametric dimension entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addDimDiametric( DL_CreationInterface* creationInterface )
-{
- DL_DimensionData d = getDimData();
-
- // diametric dimension:
- DL_DimDiametricData dr(
- // definition point
- toReal( values[15], 0.0 ),
- toReal( values[25], 0.0 ),
- toReal( values[35], 0.0 ),
- // leader length:
- toReal( values[40], 0.0 ) );
- creationInterface->addDimDiametric( d, dr );
-}
-
-
-
-/**
- * Adds an angular dimension entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addDimAngular( DL_CreationInterface* creationInterface )
-{
- DL_DimensionData d = getDimData();
-
- // angular dimension:
- DL_DimAngularData da(
- // definition point 1
- toReal( values[13], 0.0 ),
- toReal( values[23], 0.0 ),
- toReal( values[33], 0.0 ),
- // definition point 2
- toReal( values[14], 0.0 ),
- toReal( values[24], 0.0 ),
- toReal( values[34], 0.0 ),
- // definition point 3
- toReal( values[15], 0.0 ),
- toReal( values[25], 0.0 ),
- toReal( values[35], 0.0 ),
- // definition point 4
- toReal( values[16], 0.0 ),
- toReal( values[26], 0.0 ),
- toReal( values[36], 0.0 ) );
- creationInterface->addDimAngular( d, da );
-}
-
-
-/**
- * Adds an angular dimension entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addDimAngular3P( DL_CreationInterface* creationInterface )
-{
- DL_DimensionData d = getDimData();
-
- // angular dimension (3P):
- DL_DimAngular3PData da(
- // definition point 1
- toReal( values[13], 0.0 ),
- toReal( values[23], 0.0 ),
- toReal( values[33], 0.0 ),
- // definition point 2
- toReal( values[14], 0.0 ),
- toReal( values[24], 0.0 ),
- toReal( values[34], 0.0 ),
- // definition point 3
- toReal( values[15], 0.0 ),
- toReal( values[25], 0.0 ),
- toReal( values[35], 0.0 ) );
- creationInterface->addDimAngular3P( d, da );
-}
-
-
-
-/**
- * Adds a leader entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addLeader( DL_CreationInterface* creationInterface )
-{
- // leader (arrow)
- DL_LeaderData le(
- // arrow head flag
- toInt( values[71], 1 ),
- // leader path type
- toInt( values[72], 0 ),
- // Leader creation flag
- toInt( values[73], 3 ),
- // Hookline direction flag
- toInt( values[74], 1 ),
- // Hookline flag
- toInt( values[75], 0 ),
- // Text annotation height
- toReal( values[40], 1.0 ),
- // Text annotation width
- toReal( values[41], 1.0 ),
- // Number of vertices in leader
- toInt( values[76], 0 )
- );
- creationInterface->addLeader( le );
-
- for ( int i = 0; i < maxLeaderVertices; i++ )
- {
- DL_LeaderVertexData d( leaderVertices[i*3],
- leaderVertices[i*3+1],
- leaderVertices[i*3+2] );
-
- creationInterface->addLeaderVertex( d );
- }
-}
-
-
-
-/**
- * Adds a hatch entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addHatch( DL_CreationInterface* creationInterface )
-{
- DL_HatchData hd( toInt( values[91], 1 ),
- toInt( values[70], 0 ),
- toReal( values[41], 1.0 ),
- toReal( values[52], 0.0 ),
- values[2] );
- creationInterface->addHatch( hd );
-
- for ( int l = 0; l < maxHatchLoops; l++ )
- {
- DL_HatchLoopData ld( maxHatchEdges[l] );
- creationInterface->addHatchLoop( ld );
- for ( int b = 0; b < maxHatchEdges[l]; b++ )
- {
- creationInterface->addHatchEdge( hatchEdges[l][b] );
- }
- }
- creationInterface->endEntity();
- currentEntity = DL_Unknown;
-}
-
-
-
-/**
- * Adds an image entity that was read from the file via the creation interface.
- */
-void DL_Dxf::addImage( DL_CreationInterface* creationInterface )
-{
- DL_ImageData id( // pass ref insead of name we don't have yet
- values[340],
- // ins point:
- toReal( values[10], 0.0 ),
- toReal( values[20], 0.0 ),
- toReal( values[30], 0.0 ),
- // u vector:
- toReal( values[11], 1.0 ),
- toReal( values[21], 0.0 ),
- toReal( values[31], 0.0 ),
- // v vector:
- toReal( values[12], 0.0 ),
- toReal( values[22], 1.0 ),
- toReal( values[32], 0.0 ),
- // image size (pixel):
- toInt( values[13], 1 ),
- toInt( values[23], 1 ),
- // brightness, contrast, fade
- toInt( values[281], 50 ),
- toInt( values[282], 50 ),
- toInt( values[283], 0 ) );
-
- creationInterface->addImage( id );
- creationInterface->endEntity();
- currentEntity = DL_Unknown;
-}
-
-
-
-/**
- * Adds an image definition that was read from the file via the creation interface.
- */
-void DL_Dxf::addImageDef( DL_CreationInterface* creationInterface )
-{
- DL_ImageDefData id( // handle
- values[5],
- values[1] );
-
- creationInterface->linkImage( id );
- creationInterface->endEntity();
- currentEntity = DL_Unknown;
-}
-
-
-
-/**
- * Ends some special entities like hatches or old style polylines.
- */
-void DL_Dxf::endEntity( DL_CreationInterface* creationInterface )
-{
- creationInterface->endEntity();
-}
-
-
-/**
- * Ends a sequence and notifies the creation interface.
- */
-void DL_Dxf::endSequence( DL_CreationInterface* creationInterface )
-{
- creationInterface->endSequence();
-}
-
-
-/**
- * Converts the given string into an int.
- * ok is set to false if there was an error.
- */
-int DL_Dxf::stringToInt( const char* s, bool* ok )
-{
- if ( ok != NULL )
- {
- // check string:
- *ok = true;
- int i = 0;
- bool dot = false;
- do
- {
- if ( s[i] == '\0' )
- {
- break;
- }
- else if ( s[i] == '.' )
- {
- if ( dot )
- {
-// QgsDebugMsg("two dots");
- *ok = false;
- }
- else
- {
- dot = true;
- }
- }
- else if ( s[i] < '0' || s[i] > '9' )
- {
-// QgsDebugMsg(QString("NaN: '%1'").arg(s[i]));
- *ok = false;
- }
- i++;
- }
- while ( s[i] != '\0' && *ok );
- }
-
- return atoi( s );
-}
-
-
-/**
- * @brief Opens the given file for writing and returns a pointer
- * to the dxf writer. This pointer needs to be passed on to other
- * writing functions.
- *
- * @param file Full path of the file to open.
- *
- * @return Pointer to an ascii dxf writer object.
- */
-DL_WriterA* DL_Dxf::out( const char* file, DL_Codes::version version )
-{
- char* f = new char[strlen( file )+1];
- strcpy( f, file );
- this->version = version;
-
- DL_WriterA* dw = new DL_WriterA( f, version );
- if ( dw->openFailed() )
- {
- delete dw;
- delete[] f;
- return NULL;
- }
- else
- {
- delete[] f;
- return dw;
- }
-}
-
-
-
-/**
- * @brief Writes a DXF header to the file currently opened
- * by the given DXF writer object.
- */
-void DL_Dxf::writeHeader( DL_WriterA& dw )
-{
- dw.comment( "dxflib " DL_VERSION );
- dw.sectionHeader();
-
- dw.dxfString( 9, "$ACADVER" );
- switch ( version )
- {
- case DL_Codes::AC1009:
- dw.dxfString( 1, "AC1009" );
- break;
- case DL_Codes::AC1012:
- dw.dxfString( 1, "AC1012" );
- break;
- case DL_Codes::AC1014:
- dw.dxfString( 1, "AC1014" );
- break;
- case DL_Codes::AC1015:
- dw.dxfString( 1, "AC1015" );
- break;
- }
-
- // Newer version require that (otherwise a*cad crashes..)
- if ( version == VER_2000 )
- {
- dw.dxfString( 9, "$HANDSEED" );
- dw.dxfHex( 5, 0xFFFF );
- }
-
- //dw.sectionEnd();
-}
-
-
-
-
-/**
- * Writes a point entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writePoint( DL_WriterA& dw,
- const DL_PointData& data,
- const DL_Attributes& attrib )
-{
- dw.entity( "POINT" );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbPoint" );
- }
- dw.entityAttributes( attrib );
- dw.coord( POINT_COORD_CODE, data.x, data.y );
-}
-
-
-
-/**
- * Writes a line entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeLine( DL_WriterA& dw,
- const DL_LineData& data,
- const DL_Attributes& attrib )
-{
- dw.entity( "LINE" );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbLine" );
- }
- dw.entityAttributes( attrib );
- dw.coord( LINE_START_CODE, data.x1, data.y1 );
- dw.coord( LINE_END_CODE, data.x2, data.y2 );
-}
-
-
-
-/**
- * Writes a polyline entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- * @see writeVertex
- */
-void DL_Dxf::writePolyline( DL_WriterA& dw,
- const DL_PolylineData& data,
- const DL_Attributes& attrib )
-{
- if ( version == VER_2000 )
- {
- dw.entity( "LWPOLYLINE" );
- dw.entityAttributes( attrib );
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbPolyline" );
- dw.dxfInt( 90, ( int )data.number );
- dw.dxfInt( 70, data.flags );
- }
- else
- {
- dw.entity( "POLYLINE" );
- dw.entityAttributes( attrib );
- polylineLayer = attrib.getLayer();
- dw.dxfInt( 66, 1 );
- dw.dxfInt( 70, data.flags );
- dw.coord( VERTEX_COORD_CODE, 0.0, 0.0 );
- }
-}
-
-
-
-/**
- * Writes a single vertex of a polyline to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeVertex( DL_WriterA& dw,
- const DL_VertexData& data )
-{
-
-
- if ( version == VER_2000 )
- {
- dw.dxfReal( 10, data.x );
- dw.dxfReal( 20, data.y );
- if ( qAbs( data.bulge ) > 1.0e-10 )
- {
- dw.dxfReal( 42, data.bulge );
- }
- }
- else
- {
- dw.entity( "VERTEX" );
- //dw.entityAttributes(attrib);
- dw.dxfString( 8, polylineLayer );
- dw.coord( VERTEX_COORD_CODE, data.x, data.y );
- if ( qAbs( data.bulge ) > 1.0e-10 )
- {
- dw.dxfReal( 42, data.bulge );
- }
- }
-}
-
-
-
-/**
- * Writes the polyline end. Only needed for DXF R12.
- */
-void DL_Dxf::writePolylineEnd( DL_WriterA& dw )
-{
- if ( version == VER_2000 )
- {
- }
- else
- {
- dw.entity( "SEQEND" );
- }
-}
-
-
-/**
- * Writes a spline entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- * @see writeControlPoint
- */
-void DL_Dxf::writeSpline( DL_WriterA& dw,
- const DL_SplineData& data,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "SPLINE" );
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbSpline" );
- }
- dw.dxfInt( 70, data.flags );
- dw.dxfInt( 71, data.degree );
- dw.dxfInt( 72, data.nKnots ); // number of knots
- dw.dxfInt( 73, data.nControl ); // number of control points
- dw.dxfInt( 74, 0 ); // number of fit points
-}
-
-
-
-/**
- * Writes a single control point of a spline to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeControlPoint( DL_WriterA& dw,
- const DL_ControlPointData& data )
-{
-
- dw.dxfReal( 10, data.x );
- dw.dxfReal( 20, data.y );
- dw.dxfReal( 30, data.z );
-}
-
-
-
-/**
- * Writes a single knot of a spline to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeKnot( DL_WriterA& dw,
- const DL_KnotData& data )
-{
-
- dw.dxfReal( 40, data.k );
-}
-
-
-
-/**
- * Writes a circle entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeCircle( DL_WriterA& dw,
- const DL_CircleData& data,
- const DL_Attributes& attrib )
-{
- dw.entity( "CIRCLE" );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbCircle" );
- }
- dw.entityAttributes( attrib );
- dw.coord( 10, data.cx, data.cy );
- dw.dxfReal( 40, data.radius );
-}
-
-
-
-/**
- * Writes an arc entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeArc( DL_WriterA& dw,
- const DL_ArcData& data,
- const DL_Attributes& attrib )
-{
- dw.entity( "ARC" );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- }
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbCircle" );
- }
- dw.coord( 10, data.cx, data.cy );
- dw.dxfReal( 40, data.radius );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbArc" );
- }
- dw.dxfReal( 50, data.angle1 );
- dw.dxfReal( 51, data.angle2 );
-}
-
-
-
-/**
- * Writes an ellipse entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeEllipse( DL_WriterA& dw,
- const DL_EllipseData& data,
- const DL_Attributes& attrib )
-{
-
- if ( version > VER_R12 )
- {
- dw.entity( "ELLIPSE" );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbEllipse" );
- }
- dw.entityAttributes( attrib );
- dw.coord( 10, data.cx, data.cy );
- dw.coord( 11, data.mx, data.my );
- dw.dxfReal( 40, data.ratio );
- dw.dxfReal( 41, data.angle1 );
- dw.dxfReal( 42, data.angle2 );
- }
-}
-
-
-
-/**
- * Writes an insert to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeInsert( DL_WriterA& dw,
- const DL_InsertData& data,
- const DL_Attributes& attrib )
-{
-
- if ( data.name.empty() )
- {
- QgsDebugMsg( "Block name must not be empty" );
- return;
- }
-
- dw.entity( "INSERT" );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbBlockReference" );
- }
- dw.entityAttributes( attrib );
- dw.dxfString( 2, data.name );
- dw.dxfReal( 10, data.ipx );
- dw.dxfReal( 20, data.ipy );
- dw.dxfReal( 30, 0.0 );
- if ( data.sx != 1.0 || data.sy != 1.0 )
- {
- dw.dxfReal( 41, data.sx );
- dw.dxfReal( 42, data.sy );
- dw.dxfReal( 43, 1.0 );
- }
- if ( data.angle != 0.0 )
- {
- dw.dxfReal( 50, data.angle );
- }
- if ( data.cols != 1 || data.rows != 1 )
- {
- dw.dxfInt( 70, data.cols );
- dw.dxfInt( 71, data.rows );
- }
- if ( data.colSp != 0.0 || data.rowSp != 0.0 )
- {
- dw.dxfReal( 44, data.colSp );
- dw.dxfReal( 45, data.rowSp );
- }
-
-}
-
-
-
-/**
- * Writes a multi text entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeMText( DL_WriterA& dw,
- const DL_MTextData& data,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "MTEXT" );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbMText" );
- }
- dw.entityAttributes( attrib );
- dw.dxfReal( 10, data.ipx );
- dw.dxfReal( 20, data.ipy );
- dw.dxfReal( 30, 0.0 );
- dw.dxfReal( 40, data.height );
- dw.dxfReal( 41, data.width );
-
- dw.dxfInt( 71, data.attachmentPoint );
- dw.dxfInt( 72, data.drawingDirection );
-
- // Creare text chunks of 250 characters each:
- int length = data.text.length();
- char chunk[251];
- int i;
- for ( i = 250; i < length; i += 250 )
- {
- strncpy( chunk, &data.text.c_str()[i-250], 250 );
- chunk[250] = '\0';
- dw.dxfString( 3, chunk );
- }
- strncpy( chunk, &data.text.c_str()[i-250], 250 );
- chunk[250] = '\0';
- dw.dxfString( 1, chunk );
-
- dw.dxfString( 7, data.style );
-
- // since dxflib 2.0.2.1: degrees not rad (error in autodesk dxf doc)
- dw.dxfReal( 50, data.angle / ( 2.0*M_PI )*360.0 );
-
- dw.dxfInt( 73, data.lineSpacingStyle );
- dw.dxfReal( 44, data.lineSpacingFactor );
-}
-
-
-
-/**
- * Writes a text entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeText( DL_WriterA& dw,
- const DL_TextData& data,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "TEXT" );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbText" );
- }
- dw.entityAttributes( attrib );
- dw.dxfReal( 10, data.ipx );
- dw.dxfReal( 20, data.ipy );
- dw.dxfReal( 30, 0.0 );
- dw.dxfReal( 40, data.height );
- dw.dxfString( 1, data.text );
- dw.dxfReal( 50, data.angle / ( 2*M_PI )*360.0 );
- dw.dxfReal( 41, data.xScaleFactor );
- dw.dxfString( 7, data.style );
-
- dw.dxfInt( 71, data.textGenerationFlags );
- dw.dxfInt( 72, data.hJustification );
-
- dw.dxfReal( 11, data.apx );
- dw.dxfReal( 21, data.apy );
- dw.dxfReal( 31, 0.0 );
-
- dw.dxfInt( 73, data.vJustification );
-}
-
-
-/**
- * Writes an aligned dimension entity to the file.
- *
- * @param dw DXF writer
- * @param data Generic dimension data for from the file
- * @param data Specific aligned dimension data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeDimAligned( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimAlignedData& edata,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "DIMENSION" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- }
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbDimension" );
- }
-
- dw.dxfReal( 10, data.dpx );
- dw.dxfReal( 20, data.dpy );
- dw.dxfReal( 30, 0.0 );
-
- dw.dxfReal( 11, data.mpx );
- dw.dxfReal( 21, data.mpy );
- dw.dxfReal( 31, 0.0 );
-
- dw.dxfInt( 70, 1 );
- if ( version > VER_R12 )
- {
- dw.dxfInt( 71, data.attachmentPoint );
- dw.dxfInt( 72, data.lineSpacingStyle ); // opt
- dw.dxfReal( 41, data.lineSpacingFactor ); // opt
- }
-
- dw.dxfReal( 42, data.angle );
-
- dw.dxfString( 1, data.text ); // opt
- //dw.dxfString(3, data.style);
- dw.dxfString( 3, "Standard" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbAlignedDimension" );
- }
-
- dw.dxfReal( 13, edata.epx1 );
- dw.dxfReal( 23, edata.epy1 );
- dw.dxfReal( 33, 0.0 );
-
- dw.dxfReal( 14, edata.epx2 );
- dw.dxfReal( 24, edata.epy2 );
- dw.dxfReal( 34, 0.0 );
-}
-
-
-
-/**
- * Writes a linear dimension entity to the file.
- *
- * @param dw DXF writer
- * @param data Generic dimension data for from the file
- * @param data Specific linear dimension data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeDimLinear( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimLinearData& edata,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "DIMENSION" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- }
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbDimension" );
- }
-
- dw.dxfReal( 10, data.dpx );
- dw.dxfReal( 20, data.dpy );
- dw.dxfReal( 30, 0.0 );
-
- dw.dxfReal( 11, data.mpx );
- dw.dxfReal( 21, data.mpy );
- dw.dxfReal( 31, 0.0 );
-
- dw.dxfInt( 70, 0 );
- if ( version > VER_R12 )
- {
- dw.dxfInt( 71, data.attachmentPoint );
- dw.dxfInt( 72, data.lineSpacingStyle ); // opt
- dw.dxfReal( 41, data.lineSpacingFactor ); // opt
- }
-
- dw.dxfReal( 42, data.angle );
-
- dw.dxfString( 1, data.text ); // opt
- //dw.dxfString(3, data.style);
- dw.dxfString( 3, "Standard" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbAlignedDimension" );
- }
-
- dw.dxfReal( 13, edata.dpx1 );
- dw.dxfReal( 23, edata.dpy1 );
- dw.dxfReal( 33, 0.0 );
-
- dw.dxfReal( 14, edata.dpx2 );
- dw.dxfReal( 24, edata.dpy2 );
- dw.dxfReal( 34, 0.0 );
-
- dw.dxfReal( 50, edata.angle / ( 2.0*M_PI )*360.0 );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbRotatedDimension" );
- /*
- dw.dxfString(1001, "ACAD");
- dw.dxfString(1000, "DSTYLE");
- dw.dxfString(1002, "{");
- dw.dxfInt(1070, 340);
- dw.dxfInt(1005, 11);
- dw.dxfString(1002, "}");
- */
- }
-}
-
-
-
-/**
- * Writes a radial dimension entity to the file.
- *
- * @param dw DXF writer
- * @param data Generic dimension data for from the file
- * @param data Specific radial dimension data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeDimRadial( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimRadialData& edata,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "DIMENSION" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- }
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbDimension" );
- }
-
- dw.dxfReal( 10, data.dpx );
- dw.dxfReal( 20, data.dpy );
- dw.dxfReal( 30, 0.0 );
-
- dw.dxfReal( 11, data.mpx );
- dw.dxfReal( 21, data.mpy );
- dw.dxfReal( 31, 0.0 );
-
- dw.dxfInt( 70, 4 );
- if ( version > VER_R12 )
- {
- dw.dxfInt( 71, data.attachmentPoint );
- dw.dxfInt( 72, data.lineSpacingStyle ); // opt
- dw.dxfReal( 41, data.lineSpacingFactor ); // opt
- }
-
- dw.dxfReal( 42, data.angle );
-
- dw.dxfString( 1, data.text ); // opt
- //dw.dxfString(3, data.style);
- dw.dxfString( 3, "Standard" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbRadialDimension" );
- }
-
- dw.dxfReal( 15, edata.dpx );
- dw.dxfReal( 25, edata.dpy );
- dw.dxfReal( 35, 0.0 );
-
- dw.dxfReal( 40, edata.leader );
-}
-
-
-
-/**
- * Writes a diametric dimension entity to the file.
- *
- * @param dw DXF writer
- * @param data Generic dimension data for from the file
- * @param data Specific diametric dimension data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeDimDiametric( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimDiametricData& edata,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "DIMENSION" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- }
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbDimension" );
- }
-
- dw.dxfReal( 10, data.dpx );
- dw.dxfReal( 20, data.dpy );
- dw.dxfReal( 30, 0.0 );
-
- dw.dxfReal( 11, data.mpx );
- dw.dxfReal( 21, data.mpy );
- dw.dxfReal( 31, 0.0 );
-
- dw.dxfInt( 70, 3 );
- if ( version > VER_R12 )
- {
- dw.dxfInt( 71, data.attachmentPoint );
- dw.dxfInt( 72, data.lineSpacingStyle ); // opt
- dw.dxfReal( 41, data.lineSpacingFactor ); // opt
- }
-
- dw.dxfReal( 42, data.angle );
-
- dw.dxfString( 1, data.text ); // opt
- //dw.dxfString(3, data.style);
- dw.dxfString( 3, "Standard" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbDiametricDimension" );
- }
-
- dw.dxfReal( 15, edata.dpx );
- dw.dxfReal( 25, edata.dpy );
- dw.dxfReal( 35, 0.0 );
-
- dw.dxfReal( 40, edata.leader );
-}
-
-
-
-/**
- * Writes an angular dimension entity to the file.
- *
- * @param dw DXF writer
- * @param data Generic dimension data for from the file
- * @param data Specific angular dimension data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeDimAngular( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimAngularData& edata,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "DIMENSION" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- }
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbDimension" );
- }
-
- dw.dxfReal( 10, data.dpx );
- dw.dxfReal( 20, data.dpy );
- dw.dxfReal( 30, 0.0 );
-
- dw.dxfReal( 11, data.mpx );
- dw.dxfReal( 21, data.mpy );
- dw.dxfReal( 31, 0.0 );
-
- dw.dxfInt( 70, 2 );
- if ( version > VER_R12 )
- {
- dw.dxfInt( 71, data.attachmentPoint );
- dw.dxfInt( 72, data.lineSpacingStyle ); // opt
- dw.dxfReal( 41, data.lineSpacingFactor ); // opt
- }
-
- dw.dxfReal( 42, data.angle );
-
- dw.dxfString( 1, data.text ); // opt
- //dw.dxfString(3, data.style);
- dw.dxfString( 3, "Standard" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDb2LineAngularDimension" );
- }
-
- dw.dxfReal( 13, edata.dpx1 );
- dw.dxfReal( 23, edata.dpy1 );
- dw.dxfReal( 33, 0.0 );
-
- dw.dxfReal( 14, edata.dpx2 );
- dw.dxfReal( 24, edata.dpy2 );
- dw.dxfReal( 34, 0.0 );
-
- dw.dxfReal( 15, edata.dpx3 );
- dw.dxfReal( 25, edata.dpy3 );
- dw.dxfReal( 35, 0.0 );
-
- dw.dxfReal( 16, edata.dpx4 );
- dw.dxfReal( 26, edata.dpy4 );
- dw.dxfReal( 36, 0.0 );
-}
-
-
-
-/**
- * Writes an angular dimension entity (3 points version) to the file.
- *
- * @param dw DXF writer
- * @param data Generic dimension data for from the file
- * @param data Specific angular dimension data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeDimAngular3P( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimAngular3PData& edata,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "DIMENSION" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- }
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbDimension" );
- }
-
- dw.dxfReal( 10, data.dpx );
- dw.dxfReal( 20, data.dpy );
- dw.dxfReal( 30, 0.0 );
-
- dw.dxfReal( 11, data.mpx );
- dw.dxfReal( 21, data.mpy );
- dw.dxfReal( 31, 0.0 );
-
- dw.dxfInt( 70, 5 );
- if ( version > VER_R12 )
- {
- dw.dxfInt( 71, data.attachmentPoint );
- dw.dxfInt( 72, data.lineSpacingStyle ); // opt
- dw.dxfReal( 41, data.lineSpacingFactor ); // opt
- }
-
- dw.dxfReal( 42, data.angle );
-
- dw.dxfString( 1, data.text ); // opt
- //dw.dxfString(3, data.style);
- dw.dxfString( 3, "Standard" );
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDb3PointAngularDimension" );
- }
-
- dw.dxfReal( 13, edata.dpx1 );
- dw.dxfReal( 23, edata.dpy1 );
- dw.dxfReal( 33, 0.0 );
-
- dw.dxfReal( 14, edata.dpx2 );
- dw.dxfReal( 24, edata.dpy2 );
- dw.dxfReal( 34, 0.0 );
-
- dw.dxfReal( 15, edata.dpx3 );
- dw.dxfReal( 25, edata.dpy3 );
- dw.dxfReal( 35, 0.0 );
-}
-
-
-
-/**
- * Writes a leader entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- * @see writeVertex
- */
-void DL_Dxf::writeLeader( DL_WriterA& dw,
- const DL_LeaderData& data,
- const DL_Attributes& attrib )
-{
- if ( version > VER_R12 )
- {
- dw.entity( "LEADER" );
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbLeader" );
- }
- dw.dxfString( 3, "Standard" );
- dw.dxfInt( 71, data.arrowHeadFlag );
- dw.dxfInt( 72, data.leaderPathType );
- dw.dxfInt( 73, data.leaderCreationFlag );
- dw.dxfInt( 74, data.hooklineDirectionFlag );
- dw.dxfInt( 75, data.hooklineFlag );
- dw.dxfReal( 40, data.textAnnotationHeight );
- dw.dxfReal( 41, data.textAnnotationWidth );
- dw.dxfInt( 76, data.number );
- }
-}
-
-
-
-/**
- * Writes a single vertex of a leader to the file.
- *
- * @param dw DXF writer
- * @param data Entity data
- */
-void DL_Dxf::writeLeaderVertex( DL_WriterA& dw,
- const DL_LeaderVertexData& data )
-{
- if ( version > VER_R12 )
- {
- dw.dxfReal( 10, data.x );
- dw.dxfReal( 20, data.y );
- }
-}
-
-
-
-/**
- * Writes the beginning of a hatch entity to the file.
- * This must be followed by one or more writeHatchLoop()
- * calls and a writeHatch2() call.
- *
- * @param dw DXF writer
- * @param data Entity data.
- * @param attrib Attributes
- */
-void DL_Dxf::writeHatch1( DL_WriterA& dw,
- const DL_HatchData& data,
- const DL_Attributes& attrib )
-{
-
- dw.entity( "HATCH" );
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbHatch" );
- }
- dw.dxfReal( 10, 0.0 ); // elevation
- dw.dxfReal( 20, 0.0 );
- dw.dxfReal( 30, 0.0 );
- dw.dxfReal( 210, 0.0 ); // extrusion dir.
- dw.dxfReal( 220, 0.0 );
- dw.dxfReal( 230, 1.0 );
- if ( !data.solid )
- {
- dw.dxfString( 2, data.pattern );
- }
- else
- {
- dw.dxfString( 2, "SOLID" );
- }
- dw.dxfInt( 70, ( int )data.solid );
- dw.dxfInt( 71, 0 ); // associative
- dw.dxfInt( 91, data.numLoops );
-}
-
-
-
-/**
- * Writes the end of a hatch entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data.
- * @param attrib Attributes
- */
-void DL_Dxf::writeHatch2( DL_WriterA& dw,
- const DL_HatchData& data,
- const DL_Attributes& /*attrib*/ )
-{
-
- dw.dxfInt( 75, 0 ); // odd parity
- dw.dxfInt( 76, 1 ); // pattern type
- if ( !data.solid )
- {
- dw.dxfReal( 52, data.angle );
- dw.dxfReal( 41, data.scale );
- dw.dxfInt( 77, 0 ); // not double
- //dw.dxfInt(78, 0);
- dw.dxfInt( 78, 1 );
- dw.dxfReal( 53, 45.0 );
- dw.dxfReal( 43, 0.0 );
- dw.dxfReal( 44, 0.0 );
- dw.dxfReal( 45, -0.0883883476483184 );
- dw.dxfReal( 46, 0.0883883476483185 );
- dw.dxfInt( 79, 0 );
- }
- dw.dxfInt( 98, 0 );
-}
-
-
-
-/**
- * Writes the beginning of a hatch loop to the file. This
- * must happen after writing the beginning of a hatch entity.
- *
- * @param dw DXF writer
- * @param data Entity data.
- * @param attrib Attributes
- */
-void DL_Dxf::writeHatchLoop1( DL_WriterA& dw,
- const DL_HatchLoopData& data )
-{
-
- dw.dxfInt( 92, 1 );
- dw.dxfInt( 93, data.numEdges );
- //dw.dxfInt(97, 0);
-}
-
-
-
-/**
- * Writes the end of a hatch loop to the file.
- *
- * @param dw DXF writer
- * @param data Entity data.
- * @param attrib Attributes
- */
-void DL_Dxf::writeHatchLoop2( DL_WriterA& dw,
- const DL_HatchLoopData& /*data*/ )
-{
-
- dw.dxfInt( 97, 0 );
-}
-
-
-/**
- * Writes the beginning of a hatch entity to the file.
- *
- * @param dw DXF writer
- * @param data Entity data.
- * @param attrib Attributes
- */
-void DL_Dxf::writeHatchEdge( DL_WriterA& dw,
- const DL_HatchEdgeData& data )
-{
-
- dw.dxfInt( 72, data.type );
-
- switch ( data.type )
- {
- case 1:
- dw.dxfReal( 10, data.x1 );
- dw.dxfReal( 20, data.y1 );
- dw.dxfReal( 11, data.x2 );
- dw.dxfReal( 21, data.y2 );
- break;
- case 2:
- dw.dxfReal( 10, data.cx );
- dw.dxfReal( 20, data.cy );
- dw.dxfReal( 40, data.radius );
- dw.dxfReal( 50, data.angle1 / ( 2*M_PI )*360.0 );
- dw.dxfReal( 51, data.angle2 / ( 2*M_PI )*360.0 );
- dw.dxfInt( 73, ( int )( data.ccw ) );
- break;
- default:
- break;
- }
-}
-
-
-
-/**
- * Writes an image entity.
- *
- * @return IMAGEDEF handle. Needed for the IMAGEDEF counterpart.
- */
-int DL_Dxf::writeImage( DL_WriterA& dw,
- const DL_ImageData& data,
- const DL_Attributes& attrib )
-{
-#if 0
- if ( data.file.empty() )
- {
- QgsDebugMsg( "Image file must not be empty" );
- return;
- }
-#endif
-
- dw.entity( "IMAGE" );
-
- dw.entityAttributes( attrib );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbEntity" );
- dw.dxfString( 100, "AcDbRasterImage" );
- dw.dxfInt( 90, 0 );
- }
- // insertion point
- dw.dxfReal( 10, data.ipx );
- dw.dxfReal( 20, data.ipy );
- dw.dxfReal( 30, 0.0 );
-
- // vector along bottom side (1 pixel long)
- dw.dxfReal( 11, data.ux );
- dw.dxfReal( 21, data.uy );
- dw.dxfReal( 31, 0.0 );
-
- // vector along left side (1 pixel long)
- dw.dxfReal( 12, data.vx );
- dw.dxfReal( 22, data.vy );
- dw.dxfReal( 32, 0.0 );
-
- // image size in pixel
- dw.dxfReal( 13, data.width );
- dw.dxfReal( 23, data.height );
-
- // handle of IMAGEDEF object
- int handle = dw.incHandle();
- dw.dxfHex( 340, handle );
-
- // flags
- dw.dxfInt( 70, 15 );
-
- // clipping:
- dw.dxfInt( 280, 0 );
-
- // brightness, contrast, fade
- dw.dxfInt( 281, data.brightness );
- dw.dxfInt( 282, data.contrast );
- dw.dxfInt( 283, data.fade );
-
- return handle;
-}
-
-
-
-/**
- * Writes an image definiition entity.
- */
-void DL_Dxf::writeImageDef( DL_WriterA& dw,
- int handle,
- const DL_ImageData& data )
-{
-
- /*if (data.file.empty()) {
- QgsDebugMsg("DL_Dxf::writeImage: Image file must not be empty");
- return;
- }*/
-
- dw.dxfString( 0, "IMAGEDEF" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, handle );
- }
-
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbRasterImageDef" );
- dw.dxfInt( 90, 0 );
- }
- // file name:
- dw.dxfString( 1, data.ref );
-
- // image size in pixel
- dw.dxfReal( 10, data.width );
- dw.dxfReal( 20, data.height );
-
- dw.dxfReal( 11, 1.0 );
- dw.dxfReal( 21, 1.0 );
-
- // loaded:
- dw.dxfInt( 280, 1 );
- // units:
- dw.dxfInt( 281, 0 );
-}
-
-
-/**
- * Writes a layer to the file. Layers are stored in the
- * tables section of a DXF file.
- *
- * @param dw DXF writer
- * @param data Entity data from the file
- * @param attrib Attributes
- */
-void DL_Dxf::writeLayer( DL_WriterA& dw,
- const DL_LayerData& data,
- const DL_Attributes& attrib )
-{
-
- if ( data.name.empty() )
- {
- QgsDebugMsg( "DL_Dxf::writeLayer: Layer name must not be empty" );
- return;
- }
-
- int color = attrib.getColor();
- if ( color <= 0 || color >= 256 )
- {
- QgsDebugMsg( QString( "Layer color cannot be %1. Changed to 7." ).arg( color ) );
- color = 7;
- }
-
- if ( data.name == "0" )
- {
- dw.tableLayerEntry( 0x10 );
- }
- else
- {
- dw.tableLayerEntry();
- }
-
- dw.dxfString( 2, data.name );
- dw.dxfInt( 70, data.flags );
- dw.dxfInt( 62, color );
-
- dw.dxfString( 6, ( attrib.getLineType().length() == 0 ?
- string( "CONTINUOUS" ) : attrib.getLineType() ) );
-
- if ( version >= VER_2000 )
- {
- // layer defpoints cannot be plotted
- std::string lstr = data.name;
- std::transform( lstr.begin(), lstr.end(), lstr.begin(), tolower );
- if ( lstr == "defpoints" )
- {
- dw.dxfInt( 290, 0 );
- }
- }
- if ( version >= VER_2000 && attrib.getWidth() != -1 )
- {
- dw.dxfInt( 370, attrib.getWidth() );
- }
- if ( version >= VER_2000 )
- {
- dw.dxfHex( 390, 0xF );
- }
-}
-
-
-
-/**
- * Writes a line type to the file. Line types are stored in the
- * tables section of a DXF file.
- */
-void DL_Dxf::writeLineType( DL_WriterA& dw,
- const DL_LineTypeData& data )
-{
- //const char* description,
- //int elements,
- //double patternLength) {
-
- if ( data.name.empty() )
- {
- QgsDebugMsg( "DL_Dxf::writeLineType: Line type name must not be empty" );
- return;
- }
-
- // ignore BYLAYER, BYBLOCK for R12
- if ( version < VER_2000 )
- {
- if ( !strcasecmp( data.name.c_str(), "BYBLOCK" ) ||
- !strcasecmp( data.name.c_str(), "BYLAYER" ) )
- {
- return;
- }
- }
-
- // write id (not for R12)
- if ( !strcasecmp( data.name.c_str(), "BYBLOCK" ) )
- {
- dw.tableLineTypeEntry( 0x14 );
- }
- else if ( !strcasecmp( data.name.c_str(), "BYLAYER" ) )
- {
- dw.tableLineTypeEntry( 0x15 );
- }
- else if ( !strcasecmp( data.name.c_str(), "CONTINUOUS" ) )
- {
- dw.tableLineTypeEntry( 0x16 );
- }
- else
- {
- dw.tableLineTypeEntry();
- }
-
- dw.dxfString( 2, data.name );
- //if (version>=VER_2000) {
- dw.dxfInt( 70, data.flags );
- //}
-
- if ( !strcasecmp( data.name.c_str(), "BYBLOCK" ) )
- {
- dw.dxfString( 3, "" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 0 );
- dw.dxfReal( 40, 0.0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "BYLAYER" ) )
- {
- dw.dxfString( 3, "" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 0 );
- dw.dxfReal( 40, 0.0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "CONTINUOUS" ) )
- {
- dw.dxfString( 3, "Solid line" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 0 );
- dw.dxfReal( 40, 0.0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "ACAD_ISO02W100" ) )
- {
- dw.dxfString( 3, "ISO Dashed __ __ __ __ __ __ __ __ __ __ _" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 2 );
- dw.dxfReal( 40, 15.0 );
- dw.dxfReal( 49, 12.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "ACAD_ISO03W100" ) )
- {
- dw.dxfString( 3, "ISO Dashed with Distance __ __ __ _" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 2 );
- dw.dxfReal( 40, 30.0 );
- dw.dxfReal( 49, 12.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -18.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "ACAD_ISO04W100" ) )
- {
- dw.dxfString( 3, "ISO Long Dashed Dotted ____ . ____ . __" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 4 );
- dw.dxfReal( 40, 30.0 );
- dw.dxfReal( 49, 24.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "ACAD_ISO05W100" ) )
- {
- dw.dxfString( 3, "ISO Long Dashed Double Dotted ____ .. __" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 6 );
- dw.dxfReal( 40, 33.0 );
- dw.dxfReal( 49, 24.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "BORDER" ) )
- {
- dw.dxfString( 3, "Border __ __ . __ __ . __ __ . __ __ . __ __ ." );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 6 );
- dw.dxfReal( 40, 44.45 );
- dw.dxfReal( 49, 12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "BORDER2" ) )
- {
- dw.dxfString( 3, "Border (.5x) __.__.__.__.__.__.__.__.__.__.__." );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 6 );
- dw.dxfReal( 40, 22.225 );
- dw.dxfReal( 49, 6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "BORDERX2" ) )
- {
- dw.dxfString( 3, "Border (2x) ____ ____ . ____ ____ . ___" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 6 );
- dw.dxfReal( 40, 88.9 );
- dw.dxfReal( 49, 25.4 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 25.4 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "CENTER" ) )
- {
- dw.dxfString( 3, "Center ____ _ ____ _ ____ _ ____ _ ____ _ ____" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 4 );
- dw.dxfReal( 40, 50.8 );
- dw.dxfReal( 49, 31.75 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "CENTER2" ) )
- {
- dw.dxfString( 3, "Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 4 );
- dw.dxfReal( 40, 28.575 );
- dw.dxfReal( 49, 19.05 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "CENTERX2" ) )
- {
- dw.dxfString( 3, "Center (2x) ________ __ ________ __ _____" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 4 );
- dw.dxfReal( 40, 101.6 );
- dw.dxfReal( 49, 63.5 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DASHDOT" ) )
- {
- dw.dxfString( 3, "Dash dot __ . __ . __ . __ . __ . __ . __ . __" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 4 );
- dw.dxfReal( 40, 25.4 );
- dw.dxfReal( 49, 12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DASHDOT2" ) )
- {
- dw.dxfString( 3, "Dash dot (.5x) _._._._._._._._._._._._._._._." );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 4 );
- dw.dxfReal( 40, 12.7 );
- dw.dxfReal( 49, 6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DASHDOTX2" ) )
- {
- dw.dxfString( 3, "Dash dot (2x) ____ . ____ . ____ . ___" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 4 );
- dw.dxfReal( 40, 50.8 );
- dw.dxfReal( 49, 25.4 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DASHED" ) )
- {
- dw.dxfString( 3, "Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 2 );
- dw.dxfReal( 40, 19.05 );
- dw.dxfReal( 49, 12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DASHED2" ) )
- {
- dw.dxfString( 3, "Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 2 );
- dw.dxfReal( 40, 9.525 );
- dw.dxfReal( 49, 6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DASHEDX2" ) )
- {
- dw.dxfString( 3, "Dashed (2x) ____ ____ ____ ____ ____ ___" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 2 );
- dw.dxfReal( 40, 38.1 );
- dw.dxfReal( 49, 25.4 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DIVIDE" ) )
- {
- dw.dxfString( 3, "Divide ____ . . ____ . . ____ . . ____ . . ____" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 6 );
- dw.dxfReal( 40, 31.75 );
- dw.dxfReal( 49, 12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DIVIDE2" ) )
- {
- dw.dxfString( 3, "Divide (.5x) __..__..__..__..__..__..__..__.._" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 6 );
- dw.dxfReal( 40, 15.875 );
- dw.dxfReal( 49, 6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DIVIDEX2" ) )
- {
- dw.dxfString( 3, "Divide (2x) ________ . . ________ . . _" );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 6 );
- dw.dxfReal( 40, 63.5 );
- dw.dxfReal( 49, 25.4 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DOT" ) )
- {
- dw.dxfString( 3, "Dot . . . . . . . . . . . . . . . . . . . . . ." );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 2 );
- dw.dxfReal( 40, 6.35 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -6.35 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DOT2" ) )
- {
- dw.dxfString( 3, "Dot (.5x) ....................................." );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 2 );
- dw.dxfReal( 40, 3.175 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -3.175 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else if ( !strcasecmp( data.name.c_str(), "DOTX2" ) )
- {
- dw.dxfString( 3, "Dot (2x) . . . . . . . . . . . . ." );
- dw.dxfInt( 72, 65 );
- dw.dxfInt( 73, 2 );
- dw.dxfReal( 40, 12.7 );
- dw.dxfReal( 49, 0.0 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- dw.dxfReal( 49, -12.7 );
- if ( version >= VER_R13 )
- dw.dxfInt( 74, 0 );
- }
- else
- {
- QgsDebugMsg( "dxflib warning: DL_Dxf::writeLineType: Unknown Line Type" );
- }
-}
-
-
-
-/**
- * Writes the APPID section to the DXF file.
- *
- * @param name Application name
- */
-void DL_Dxf::writeAppid( DL_WriterA& dw, const string& name )
-{
- if ( name.empty() )
- {
- QgsDebugMsg( "DL_Dxf::writeAppid: Application name must not be empty" );
- return;
- }
-
- if ( !strcasecmp( name.c_str(), "ACAD" ) )
- {
- dw.tableAppidEntry( 0x12 );
- }
- else
- {
- dw.tableAppidEntry();
- }
- dw.dxfString( 2, name );
- dw.dxfInt( 70, 0 );
-}
-
-
-
-/**
- * Writes a block's definition (no entities) to the DXF file.
- */
-void DL_Dxf::writeBlock( DL_WriterA& dw, const DL_BlockData& data )
-{
- if ( data.name.empty() )
- {
- QgsDebugMsg( "DL_Dxf::writeBlock: Block name must not be empty" );
- return;
- }
-
- //bool paperSpace = !strcasecmp(name, "*paper_space");
- //!strcasecmp(name, "*paper_space0");
-
- if ( !strcasecmp( data.name.c_str(), "*paper_space" ) )
- {
- dw.sectionBlockEntry( 0x1C );
- }
- else if ( !strcasecmp( data.name.c_str(), "*model_space" ) )
- {
- dw.sectionBlockEntry( 0x20 );
- }
- else if ( !strcasecmp( data.name.c_str(), "*paper_space0" ) )
- {
- dw.sectionBlockEntry( 0x24 );
- }
- else
- {
- dw.sectionBlockEntry();
- }
- dw.dxfString( 2, data.name );
- dw.dxfInt( 70, 0 );
- dw.coord( 10, data.bpx, data.bpy );
- dw.dxfString( 3, data.name );
- dw.dxfString( 1, "" );
-}
-
-
-
-/**
- * Writes a block end.
- *
- * @param name Block name
- */
-void DL_Dxf::writeEndBlock( DL_WriterA& dw, const string& name )
-{
- if ( !strcasecmp( name.c_str(), "*paper_space" ) )
- {
- dw.sectionBlockEntryEnd( 0x1D );
- }
- else if ( !strcasecmp( name.c_str(), "*model_space" ) )
- {
- dw.sectionBlockEntryEnd( 0x21 );
- }
- else if ( !strcasecmp( name.c_str(), "*paper_space0" ) )
- {
- dw.sectionBlockEntryEnd( 0x25 );
- }
- else
- {
- dw.sectionBlockEntryEnd();
- }
-}
-
-
-
-/**
- * Writes a viewport section. This section is needed in VER_R13.
- * Note that this method currently only writes a faked VPORT section
- * to make the file readable by Aut*cad.
- */
-void DL_Dxf::writeVPort( DL_WriterA& dw )
-{
- dw.dxfString( 0, "TABLE" );
- dw.dxfString( 2, "VPORT" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 0x8 );
- }
- //dw.dxfHex(330, 0);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTable" );
- }
- dw.dxfInt( 70, 1 );
- dw.dxfString( 0, "VPORT" );
- //dw.dxfHex(5, 0x2F);
- if ( version == VER_2000 )
- {
- dw.handle();
- }
- //dw.dxfHex(330, 8);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTableRecord" );
- dw.dxfString( 100, "AcDbViewportTableRecord" );
- }
- dw.dxfString( 2, "*Active" );
- dw.dxfInt( 70, 0 );
- dw.dxfReal( 10, 0.0 );
- dw.dxfReal( 20, 0.0 );
- dw.dxfReal( 11, 1.0 );
- dw.dxfReal( 21, 1.0 );
- dw.dxfReal( 12, 286.3055555555555 );
- dw.dxfReal( 22, 148.5 );
- dw.dxfReal( 13, 0.0 );
- dw.dxfReal( 23, 0.0 );
- dw.dxfReal( 14, 10.0 );
- dw.dxfReal( 24, 10.0 );
- dw.dxfReal( 15, 10.0 );
- dw.dxfReal( 25, 10.0 );
- dw.dxfReal( 16, 0.0 );
- dw.dxfReal( 26, 0.0 );
- dw.dxfReal( 36, 1.0 );
- dw.dxfReal( 17, 0.0 );
- dw.dxfReal( 27, 0.0 );
- dw.dxfReal( 37, 0.0 );
- dw.dxfReal( 40, 297.0 );
- dw.dxfReal( 41, 1.92798353909465 );
- dw.dxfReal( 42, 50.0 );
- dw.dxfReal( 43, 0.0 );
- dw.dxfReal( 44, 0.0 );
- dw.dxfReal( 50, 0.0 );
- dw.dxfReal( 51, 0.0 );
- dw.dxfInt( 71, 0 );
- dw.dxfInt( 72, 100 );
- dw.dxfInt( 73, 1 );
- dw.dxfInt( 74, 3 );
- dw.dxfInt( 75, 1 );
- dw.dxfInt( 76, 1 );
- dw.dxfInt( 77, 0 );
- dw.dxfInt( 78, 0 );
-
- if ( version == VER_2000 )
- {
- dw.dxfInt( 281, 0 );
- dw.dxfInt( 65, 1 );
- dw.dxfReal( 110, 0.0 );
- dw.dxfReal( 120, 0.0 );
- dw.dxfReal( 130, 0.0 );
- dw.dxfReal( 111, 1.0 );
- dw.dxfReal( 121, 0.0 );
- dw.dxfReal( 131, 0.0 );
- dw.dxfReal( 112, 0.0 );
- dw.dxfReal( 122, 1.0 );
- dw.dxfReal( 132, 0.0 );
- dw.dxfInt( 79, 0 );
- dw.dxfReal( 146, 0.0 );
- }
- dw.dxfString( 0, "ENDTAB" );
-}
-
-
-
-/**
- * Writes a style section. This section is needed in VER_R13.
- * Note that this method currently only writes a faked STYLE section
- * to make the file readable by Aut*cad.
- */
-void DL_Dxf::writeStyle( DL_WriterA& dw )
-{
- dw.dxfString( 0, "TABLE" );
- dw.dxfString( 2, "STYLE" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 3 );
- }
- //dw.dxfHex(330, 0);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTable" );
- }
- dw.dxfInt( 70, 1 );
- dw.dxfString( 0, "STYLE" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 0x11 );
- }
- //styleHandleStd = dw.handle();
- //dw.dxfHex(330, 3);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTableRecord" );
- dw.dxfString( 100, "AcDbTextStyleTableRecord" );
- }
- dw.dxfString( 2, "Standard" );
- dw.dxfInt( 70, 0 );
- dw.dxfReal( 40, 0.0 );
- dw.dxfReal( 41, 0.75 );
- dw.dxfReal( 50, 0.0 );
- dw.dxfInt( 71, 0 );
- dw.dxfReal( 42, 2.5 );
- dw.dxfString( 3, "txt" );
- dw.dxfString( 4, "" );
- dw.dxfString( 0, "ENDTAB" );
-}
-
-
-
-/**
- * Writes a view section. This section is needed in VER_R13.
- * Note that this method currently only writes a faked VIEW section
- * to make the file readable by Aut*cad.
- */
-void DL_Dxf::writeView( DL_WriterA& dw )
-{
- dw.dxfString( 0, "TABLE" );
- dw.dxfString( 2, "VIEW" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 6 );
- }
- //dw.dxfHex(330, 0);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTable" );
- }
- dw.dxfInt( 70, 0 );
- dw.dxfString( 0, "ENDTAB" );
-}
-
-
-
-/**
- * Writes a ucs section. This section is needed in VER_R13.
- * Note that this method currently only writes a faked UCS section
- * to make the file readable by Aut*cad.
- */
-void DL_Dxf::writeUcs( DL_WriterA& dw )
-{
- dw.dxfString( 0, "TABLE" );
- dw.dxfString( 2, "UCS" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 7 );
- }
- //dw.dxfHex(330, 0);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTable" );
- }
- dw.dxfInt( 70, 0 );
- dw.dxfString( 0, "ENDTAB" );
-}
-
-
-
-/**
- * Writes a dimstyle section. This section is needed in VER_R13.
- * Note that this method currently only writes a faked DIMSTYLE section
- * to make the file readable by Aut*cad.
- */
-void DL_Dxf::writeDimStyle( DL_WriterA& dw,
- double dimasz, double dimexe, double dimexo,
- double dimgap, double dimtxt )
-{
-
- dw.dxfString( 0, "TABLE" );
- dw.dxfString( 2, "DIMSTYLE" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 0xA );
- dw.dxfString( 100, "AcDbSymbolTable" );
- }
- dw.dxfInt( 70, 1 );
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbDimStyleTable" );
- dw.dxfInt( 71, 0 );
- }
-
-
- dw.dxfString( 0, "DIMSTYLE" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 105, 0x27 );
- }
- //dw.handle(105);
- //dw.dxfHex(330, 0xA);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTableRecord" );
- dw.dxfString( 100, "AcDbDimStyleTableRecord" );
- }
- dw.dxfString( 2, "Standard" );
- if ( version == VER_R12 )
- {
- dw.dxfString( 3, "" );
- dw.dxfString( 4, "" );
- dw.dxfString( 5, "" );
- dw.dxfString( 6, "" );
- dw.dxfString( 7, "" );
- dw.dxfReal( 40, 1.0 );
- }
-
- dw.dxfReal( 41, dimasz );
- dw.dxfReal( 42, dimexo );
- dw.dxfReal( 43, 3.75 );
- dw.dxfReal( 44, dimexe );
- if ( version == VER_R12 )
- {
- dw.dxfReal( 45, 0.0 );
- dw.dxfReal( 46, 0.0 );
- dw.dxfReal( 47, 0.0 );
- dw.dxfReal( 48, 0.0 );
- }
- dw.dxfInt( 70, 0 );
- if ( version == VER_R12 )
- {
- dw.dxfInt( 71, 0 );
- dw.dxfInt( 72, 0 );
- }
- dw.dxfInt( 73, 0 );
- dw.dxfInt( 74, 0 );
- if ( version == VER_R12 )
- {
- dw.dxfInt( 75, 0 );
- dw.dxfInt( 76, 0 );
- }
- dw.dxfInt( 77, 1 );
- dw.dxfInt( 78, 8 );
- dw.dxfReal( 140, dimtxt );
- dw.dxfReal( 141, 2.5 );
- if ( version == VER_R12 )
- {
- dw.dxfReal( 142, 0.0 );
- }
- dw.dxfReal( 143, 0.03937007874016 );
- if ( version == VER_R12 )
- {
- dw.dxfReal( 144, 1.0 );
- dw.dxfReal( 145, 0.0 );
- dw.dxfReal( 146, 1.0 );
- }
- dw.dxfReal( 147, dimgap );
- if ( version == VER_R12 )
- {
- dw.dxfInt( 170, 0 );
- }
- dw.dxfInt( 171, 3 );
- dw.dxfInt( 172, 1 );
- if ( version == VER_R12 )
- {
- dw.dxfInt( 173, 0 );
- dw.dxfInt( 174, 0 );
- dw.dxfInt( 175, 0 );
- dw.dxfInt( 176, 0 );
- dw.dxfInt( 177, 0 );
- dw.dxfInt( 178, 0 );
- }
- if ( version == VER_2000 )
- {
- dw.dxfInt( 271, 2 );
- dw.dxfInt( 272, 2 );
- dw.dxfInt( 274, 3 );
- dw.dxfInt( 278, 44 );
- dw.dxfInt( 283, 0 );
- dw.dxfInt( 284, 8 );
- //dw.dxfHex(340, styleHandleStd);
- dw.dxfHex( 340, 0x11 );
- }
- // * /
- dw.dxfString( 0, "ENDTAB" );
-}
-
-
-
-/**
- * Writes a blockrecord section. This section is needed in VER_R13.
- * Note that this method currently only writes a faked BLOCKRECORD section
- * to make the file readable by Aut*cad.
- */
-void DL_Dxf::writeBlockRecord( DL_WriterA& dw )
-{
- dw.dxfString( 0, "TABLE" );
- dw.dxfString( 2, "BLOCK_RECORD" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 1 );
- }
- //dw.dxfHex(330, 0);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTable" );
- }
- dw.dxfInt( 70, 1 );
-
- dw.dxfString( 0, "BLOCK_RECORD" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 0x1F );
- }
- //int msh = dw.handle();
- //dw.setModelSpaceHandle(msh);
- //dw.dxfHex(330, 1);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTableRecord" );
- dw.dxfString( 100, "AcDbBlockTableRecord" );
- }
- dw.dxfString( 2, "*Model_Space" );
- dw.dxfHex( 340, 0x22 );
-
- dw.dxfString( 0, "BLOCK_RECORD" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 0x1B );
- }
- //int psh = dw.handle();
- //dw.setPaperSpaceHandle(psh);
- //dw.dxfHex(330, 1);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTableRecord" );
- dw.dxfString( 100, "AcDbBlockTableRecord" );
- }
- dw.dxfString( 2, "*Paper_Space" );
- dw.dxfHex( 340, 0x1E );
-
- dw.dxfString( 0, "BLOCK_RECORD" );
- if ( version == VER_2000 )
- {
- dw.dxfHex( 5, 0x23 );
- }
- //int ps0h = dw.handle();
- //dw.setPaperSpace0Handle(ps0h);
- //dw.dxfHex(330, 1);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTableRecord" );
- dw.dxfString( 100, "AcDbBlockTableRecord" );
- }
- dw.dxfString( 2, "*Paper_Space0" );
- dw.dxfHex( 340, 0x26 );
-
- //dw.dxfString( 0, "ENDTAB");
-}
-
-
-
-/**
- * Writes a single block record with the given name.
- */
-void DL_Dxf::writeBlockRecord( DL_WriterA& dw, const string& name )
-{
- dw.dxfString( 0, "BLOCK_RECORD" );
- if ( version == VER_2000 )
- {
- dw.handle();
- }
- //dw->dxfHex(330, 1);
- if ( version == VER_2000 )
- {
- dw.dxfString( 100, "AcDbSymbolTableRecord" );
- dw.dxfString( 100, "AcDbBlockTableRecord" );
- }
- dw.dxfString( 2, name );
- dw.dxfHex( 340, 0 );
-}
-
-
-
-/**
- * Writes a objects section. This section is needed in VER_R13.
- * Note that this method currently only writes a faked OBJECTS section
- * to make the file readable by Aut*cad.
- */
-void DL_Dxf::writeObjects( DL_WriterA& dw )
-{
- //int dicId, dicId2, dicId3, dicId4, dicId5;
- //int dicId5;
-
- dw.dxfString( 0, "SECTION" );
- dw.dxfString( 2, "OBJECTS" );
- dw.dxfString( 0, "DICTIONARY" );
- dw.dxfHex( 5, 0xC ); // C
- //dw.dxfHex(330, 0);
- dw.dxfString( 100, "AcDbDictionary" );
- dw.dxfInt( 280, 0 );
- dw.dxfInt( 281, 1 );
- dw.dxfString( 3, "ACAD_GROUP" );
- //dw.dxfHex(350, dw.getNextHandle()); // D
- dw.dxfHex( 350, 0xD ); // D
- dw.dxfString( 3, "ACAD_LAYOUT" );
- dw.dxfHex( 350, 0x1A );
- //dw.dxfHex(350, dw.getNextHandle()+0); // 1A
- dw.dxfString( 3, "ACAD_MLINESTYLE" );
- dw.dxfHex( 350, 0x17 );
- //dw.dxfHex(350, dw.getNextHandle()+1); // 17
- dw.dxfString( 3, "ACAD_PLOTSETTINGS" );
- dw.dxfHex( 350, 0x19 );
- //dw.dxfHex(350, dw.getNextHandle()+2); // 19
- dw.dxfString( 3, "ACAD_PLOTSTYLENAME" );
- dw.dxfHex( 350, 0xE );
- //dw.dxfHex(350, dw.getNextHandle()+3); // E
- dw.dxfString( 3, "AcDbVariableDictionary" );
- dw.dxfHex( 350, dw.getNextHandle() ); // 2C
- dw.dxfString( 0, "DICTIONARY" );
- dw.dxfHex( 5, 0xD );
- //dw.handle(); // D
- //dw.dxfHex(330, 0xC);
- dw.dxfString( 100, "AcDbDictionary" );
- dw.dxfInt( 280, 0 );
- dw.dxfInt( 281, 1 );
- dw.dxfString( 0, "ACDBDICTIONARYWDFLT" );
- dw.dxfHex( 5, 0xE );
- //dicId4 = dw.handle(); // E
- //dw.dxfHex(330, 0xC); // C
- dw.dxfString( 100, "AcDbDictionary" );
- dw.dxfInt( 281, 1 );
- dw.dxfString( 3, "Normal" );
- dw.dxfHex( 350, 0xF );
- //dw.dxfHex(350, dw.getNextHandle()+5); // F
- dw.dxfString( 100, "AcDbDictionaryWithDefault" );
- dw.dxfHex( 340, 0xF );
- //dw.dxfHex(340, dw.getNextHandle()+5); // F
- dw.dxfString( 0, "ACDBPLACEHOLDER" );
- dw.dxfHex( 5, 0xF );
- //dw.handle(); // F
- //dw.dxfHex(330, dicId4); // E
- dw.dxfString( 0, "DICTIONARY" );
- //dicId3 = dw.handle(); // 17
- dw.dxfHex( 5, 0x17 );
- //dw.dxfHex(330, 0xC); // C
- dw.dxfString( 100, "AcDbDictionary" );
- dw.dxfInt( 280, 0 );
- dw.dxfInt( 281, 1 );
- dw.dxfString( 3, "Standard" );
- dw.dxfHex( 350, 0x18 );
- //dw.dxfHex(350, dw.getNextHandle()+5); // 18
- dw.dxfString( 0, "MLINESTYLE" );
- dw.dxfHex( 5, 0x18 );
- //dw.handle(); // 18
- //dw.dxfHex(330, dicId3); // 17
- dw.dxfString( 100, "AcDbMlineStyle" );
- dw.dxfString( 2, "STANDARD" );
- dw.dxfInt( 70, 0 );
- dw.dxfString( 3, "" );
- dw.dxfInt( 62, 256 );
- dw.dxfReal( 51, 90.0 );
- dw.dxfReal( 52, 90.0 );
- dw.dxfInt( 71, 2 );
- dw.dxfReal( 49, 0.5 );
- dw.dxfInt( 62, 256 );
- dw.dxfString( 6, "BYLAYER" );
- dw.dxfReal( 49, -0.5 );
- dw.dxfInt( 62, 256 );
- dw.dxfString( 6, "BYLAYER" );
- dw.dxfString( 0, "DICTIONARY" );
- dw.dxfHex( 5, 0x19 );
- //dw.handle(); // 17
- //dw.dxfHex(330, 0xC); // C
- dw.dxfString( 100, "AcDbDictionary" );
- dw.dxfInt( 280, 0 );
- dw.dxfInt( 281, 1 );
- dw.dxfString( 0, "DICTIONARY" );
- //dicId2 = dw.handle(); // 1A
- dw.dxfHex( 5, 0x1A );
- //dw.dxfHex(330, 0xC);
- dw.dxfString( 100, "AcDbDictionary" );
- dw.dxfInt( 281, 1 );
- dw.dxfString( 3, "Layout1" );
- dw.dxfHex( 350, 0x1E );
- //dw.dxfHex(350, dw.getNextHandle()+2); // 1E
- dw.dxfString( 3, "Layout2" );
- dw.dxfHex( 350, 0x26 );
- //dw.dxfHex(350, dw.getNextHandle()+4); // 26
- dw.dxfString( 3, "Model" );
- dw.dxfHex( 350, 0x22 );
- //dw.dxfHex(350, dw.getNextHandle()+5); // 22
-
- dw.dxfString( 0, "LAYOUT" );
- dw.dxfHex( 5, 0x1E );
- //dw.handle(); // 1E
- //dw.dxfHex(330, dicId2); // 1A
- dw.dxfString( 100, "AcDbPlotSettings" );
- dw.dxfString( 1, "" );
- dw.dxfString( 2, "C:\\Program Files\\AutoCAD 2002\\plotters\\DWF ePlot (optimized for plotting).pc3" );
- dw.dxfString( 4, "" );
- dw.dxfString( 6, "" );
- dw.dxfReal( 40, 0.0 );
- dw.dxfReal( 41, 0.0 );
- dw.dxfReal( 42, 0.0 );
- dw.dxfReal( 43, 0.0 );
- dw.dxfReal( 44, 0.0 );
- dw.dxfReal( 45, 0.0 );
- dw.dxfReal( 46, 0.0 );
- dw.dxfReal( 47, 0.0 );
- dw.dxfReal( 48, 0.0 );
- dw.dxfReal( 49, 0.0 );
- dw.dxfReal( 140, 0.0 );
- dw.dxfReal( 141, 0.0 );
- dw.dxfReal( 142, 1.0 );
- dw.dxfReal( 143, 1.0 );
- dw.dxfInt( 70, 688 );
- dw.dxfInt( 72, 0 );
- dw.dxfInt( 73, 0 );
- dw.dxfInt( 74, 5 );
- dw.dxfString( 7, "" );
- dw.dxfInt( 75, 16 );
- dw.dxfReal( 147, 1.0 );
- dw.dxfReal( 148, 0.0 );
- dw.dxfReal( 149, 0.0 );
- dw.dxfString( 100, "AcDbLayout" );
- dw.dxfString( 1, "Layout1" );
- dw.dxfInt( 70, 1 );
- dw.dxfInt( 71, 1 );
- dw.dxfReal( 10, 0.0 );
- dw.dxfReal( 20, 0.0 );
- dw.dxfReal( 11, 420.0 );
- dw.dxfReal( 21, 297.0 );
- dw.dxfReal( 12, 0.0 );
- dw.dxfReal( 22, 0.0 );
- dw.dxfReal( 32, 0.0 );
- dw.dxfReal( 14, 1.000000000000000E+20 );
- dw.dxfReal( 24, 1.000000000000000E+20 );
- dw.dxfReal( 34, 1.000000000000000E+20 );
- dw.dxfReal( 15, -1.000000000000000E+20 );
- dw.dxfReal( 25, -1.000000000000000E+20 );
- dw.dxfReal( 35, -1.000000000000000E+20 );
- dw.dxfReal( 146, 0.0 );
- dw.dxfReal( 13, 0.0 );
- dw.dxfReal( 23, 0.0 );
- dw.dxfReal( 33, 0.0 );
- dw.dxfReal( 16, 1.0 );
- dw.dxfReal( 26, 0.0 );
- dw.dxfReal( 36, 0.0 );
- dw.dxfReal( 17, 0.0 );
- dw.dxfReal( 27, 1.0 );
- dw.dxfReal( 37, 0.0 );
- dw.dxfInt( 76, 0 );
- //dw.dxfHex(330, dw.getPaperSpaceHandle()); // 1B
- dw.dxfHex( 330, 0x1B );
- dw.dxfString( 0, "LAYOUT" );
- dw.dxfHex( 5, 0x22 );
- //dw.handle(); // 22
- //dw.dxfHex(330, dicId2); // 1A
- dw.dxfString( 100, "AcDbPlotSettings" );
- dw.dxfString( 1, "" );
- dw.dxfString( 2, "C:\\Program Files\\AutoCAD 2002\\plotters\\DWF ePlot (optimized for plotting).pc3" );
- dw.dxfString( 4, "" );
- dw.dxfString( 6, "" );
- dw.dxfReal( 40, 0.0 );
- dw.dxfReal( 41, 0.0 );
- dw.dxfReal( 42, 0.0 );
- dw.dxfReal( 43, 0.0 );
- dw.dxfReal( 44, 0.0 );
- dw.dxfReal( 45, 0.0 );
- dw.dxfReal( 46, 0.0 );
- dw.dxfReal( 47, 0.0 );
- dw.dxfReal( 48, 0.0 );
- dw.dxfReal( 49, 0.0 );
- dw.dxfReal( 140, 0.0 );
- dw.dxfReal( 141, 0.0 );
- dw.dxfReal( 142, 1.0 );
- dw.dxfReal( 143, 1.0 );
- dw.dxfInt( 70, 1712 );
- dw.dxfInt( 72, 0 );
- dw.dxfInt( 73, 0 );
- dw.dxfInt( 74, 0 );
- dw.dxfString( 7, "" );
- dw.dxfInt( 75, 0 );
- dw.dxfReal( 147, 1.0 );
- dw.dxfReal( 148, 0.0 );
- dw.dxfReal( 149, 0.0 );
- dw.dxfString( 100, "AcDbLayout" );
- dw.dxfString( 1, "Model" );
- dw.dxfInt( 70, 1 );
- dw.dxfInt( 71, 0 );
- dw.dxfReal( 10, 0.0 );
- dw.dxfReal( 20, 0.0 );
- dw.dxfReal( 11, 12.0 );
- dw.dxfReal( 21, 9.0 );
- dw.dxfReal( 12, 0.0 );
- dw.dxfReal( 22, 0.0 );
- dw.dxfReal( 32, 0.0 );
- dw.dxfReal( 14, 0.0 );
- dw.dxfReal( 24, 0.0 );
- dw.dxfReal( 34, 0.0 );
- dw.dxfReal( 15, 0.0 );
- dw.dxfReal( 25, 0.0 );
- dw.dxfReal( 35, 0.0 );
- dw.dxfReal( 146, 0.0 );
- dw.dxfReal( 13, 0.0 );
- dw.dxfReal( 23, 0.0 );
- dw.dxfReal( 33, 0.0 );
- dw.dxfReal( 16, 1.0 );
- dw.dxfReal( 26, 0.0 );
- dw.dxfReal( 36, 0.0 );
- dw.dxfReal( 17, 0.0 );
- dw.dxfReal( 27, 1.0 );
- dw.dxfReal( 37, 0.0 );
- dw.dxfInt( 76, 0 );
- //dw.dxfHex(330, dw.getModelSpaceHandle()); // 1F
- dw.dxfHex( 330, 0x1F );
- dw.dxfString( 0, "LAYOUT" );
- //dw.handle(); // 26
- dw.dxfHex( 5, 0x26 );
- //dw.dxfHex(330, dicId2); // 1A
- dw.dxfString( 100, "AcDbPlotSettings" );
- dw.dxfString( 1, "" );
- dw.dxfString( 2, "C:\\Program Files\\AutoCAD 2002\\plotters\\DWF ePlot (optimized for plotting).pc3" );
- dw.dxfString( 4, "" );
- dw.dxfString( 6, "" );
- dw.dxfReal( 40, 0.0 );
- dw.dxfReal( 41, 0.0 );
- dw.dxfReal( 42, 0.0 );
- dw.dxfReal( 43, 0.0 );
- dw.dxfReal( 44, 0.0 );
- dw.dxfReal( 45, 0.0 );
- dw.dxfReal( 46, 0.0 );
- dw.dxfReal( 47, 0.0 );
- dw.dxfReal( 48, 0.0 );
- dw.dxfReal( 49, 0.0 );
- dw.dxfReal( 140, 0.0 );
- dw.dxfReal( 141, 0.0 );
- dw.dxfReal( 142, 1.0 );
- dw.dxfReal( 143, 1.0 );
- dw.dxfInt( 70, 688 );
- dw.dxfInt( 72, 0 );
- dw.dxfInt( 73, 0 );
- dw.dxfInt( 74, 5 );
- dw.dxfString( 7, "" );
- dw.dxfInt( 75, 16 );
- dw.dxfReal( 147, 1.0 );
- dw.dxfReal( 148, 0.0 );
- dw.dxfReal( 149, 0.0 );
- dw.dxfString( 100, "AcDbLayout" );
- dw.dxfString( 1, "Layout2" );
- dw.dxfInt( 70, 1 );
- dw.dxfInt( 71, 2 );
- dw.dxfReal( 10, 0.0 );
- dw.dxfReal( 20, 0.0 );
- dw.dxfReal( 11, 12.0 );
- dw.dxfReal( 21, 9.0 );
- dw.dxfReal( 12, 0.0 );
- dw.dxfReal( 22, 0.0 );
- dw.dxfReal( 32, 0.0 );
- dw.dxfReal( 14, 0.0 );
- dw.dxfReal( 24, 0.0 );
- dw.dxfReal( 34, 0.0 );
- dw.dxfReal( 15, 0.0 );
- dw.dxfReal( 25, 0.0 );
- dw.dxfReal( 35, 0.0 );
- dw.dxfReal( 146, 0.0 );
- dw.dxfReal( 13, 0.0 );
- dw.dxfReal( 23, 0.0 );
- dw.dxfReal( 33, 0.0 );
- dw.dxfReal( 16, 1.0 );
- dw.dxfReal( 26, 0.0 );
- dw.dxfReal( 36, 0.0 );
- dw.dxfReal( 17, 0.0 );
- dw.dxfReal( 27, 1.0 );
- dw.dxfReal( 37, 0.0 );
- dw.dxfInt( 76, 0 );
- //dw.dxfHex(330, dw.getPaperSpace0Handle()); // 23
- dw.dxfHex( 330, 0x23 );
- dw.dxfString( 0, "DICTIONARY" );
- //dw.dxfHex(5, 0x2C);
- //dicId5 =
- dw.handle(); // 2C
- //dw.dxfHex(330, 0xC); // C
- dw.dxfString( 100, "AcDbDictionary" );
- dw.dxfInt( 281, 1 );
- dw.dxfString( 3, "DIMASSOC" );
- //dw.dxfHex(350, 0x2F);
- dw.dxfHex( 350, dw.getNextHandle() + 1 ); // 2E
- dw.dxfString( 3, "HIDETEXT" );
- //dw.dxfHex(350, 0x2E);
- dw.dxfHex( 350, dw.getNextHandle() ); // 2D
- dw.dxfString( 0, "DICTIONARYVAR" );
- //dw.dxfHex(5, 0x2E);
- dw.handle(); // 2E
- //dw.dxfHex(330, dicId5); // 2C
- dw.dxfString( 100, "DictionaryVariables" );
- dw.dxfInt( 280, 0 );
- dw.dxfInt( 1, 2 );
- dw.dxfString( 0, "DICTIONARYVAR" );
- //dw.dxfHex(5, 0x2D);
- dw.handle(); // 2D
- //dw.dxfHex(330, dicId5); // 2C
- dw.dxfString( 100, "DictionaryVariables" );
- dw.dxfInt( 280, 0 );
- dw.dxfInt( 1, 1 );
-}
-
-
-/**
- * Writes the end of the objects section. This section is needed in VER_R13.
- * Note that this method currently only writes a faked OBJECTS section
- * to make the file readable by Aut*cad.
- */
-void DL_Dxf::writeObjectsEnd( DL_WriterA& dw )
-{
- dw.dxfString( 0, "ENDSEC" );
-}
-
-
-
-/**
- * Checks if the given variable is known by the given DXF version.
- */
-bool DL_Dxf::checkVariable( const char* var, DL_Codes::version version )
-{
- if ( version >= VER_2000 )
- {
- return true;
- }
- else if ( version == VER_R12 )
- {
- // these are all the variables recognized by dxf r12:
- if ( !strcmp( var, "$ACADVER" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$ACADVER" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$ANGBASE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$ANGDIR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$ATTDIA" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$ATTMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$ATTREQ" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$AUNITS" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$AUPREC" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$AXISMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$AXISUNIT" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$BLIPMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$CECOLOR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$CELTYPE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$CHAMFERA" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$CHAMFERB" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$CLAYER" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$COORDS" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMALT" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMALTD" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMALTF" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMAPOST" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMASO" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMASZ" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMBLK" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMBLK1" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMBLK2" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMCEN" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMCLRD" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMCLRE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMCLRT" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMDLE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMDLI" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMEXE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMEXO" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMGAP" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMLFAC" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMLIM" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMPOST" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMRND" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMSAH" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMSCALE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMSE1" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMSE2" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMSHO" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMSOXD" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMSTYLE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTAD" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTFAC" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTIH" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTIX" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTM" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTOFL" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTOH" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTOL" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTP" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTSZ" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTVP" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMTXT" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DIMZIN" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DWGCODEPAGE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$DRAGMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$ELEVATION" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$EXTMAX" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$EXTMIN" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$FILLETRAD" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$FILLMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$HANDLING" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$HANDSEED" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$INSBASE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$LIMCHECK" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$LIMMAX" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$LIMMIN" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$LTSCALE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$LUNITS" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$LUPREC" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$MAXACTVP" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$MENU" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$MIRRTEXT" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$ORTHOMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$OSMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PDMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PDSIZE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PELEVATION" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PEXTMAX" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PEXTMIN" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PLIMCHECK" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PLIMMAX" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PLIMMIN" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PLINEGEN" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PLINEWID" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PSLTSCALE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PUCSNAME" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PUCSORG" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PUCSXDIR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$PUCSYDIR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$QTEXTMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$REGENMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SHADEDGE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SHADEDIF" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SKETCHINC" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SKPOLY" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SPLFRAME" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SPLINESEGS" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SPLINETYPE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SURFTAB1" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SURFTAB2" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SURFTYPE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SURFU" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SURFV" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$TDCREATE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$TDINDWG" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$TDUPDATE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$TDUSRTIMER" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$TEXTSIZE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$TEXTSTYLE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$THICKNESS" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$TILEMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$TRACEWID" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$UCSNAME" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$UCSORG" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$UCSXDIR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$UCSYDIR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$UNITMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$USERI1" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$USERR1" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$USRTIMER" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$VISRETAIN" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$WORLDVIEW" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$FASTZOOM" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$GRIDMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$GRIDUNIT" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SNAPANG" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SNAPBASE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SNAPISOPAIR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SNAPMODE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SNAPSTYLE" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$SNAPUNIT" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$VIEWCTR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$VIEWDIR" ) )
- {
- return true;
- }
- if ( !strcmp( var, "$VIEWSIZE" ) )
- {
- return true;
- }
- return false;
- }
-
- return false;
-}
-
-
-
-/**
- * @returns the library version as int (4 bytes, each byte one version number).
- * e.g. if str = "2.0.2.0" getLibVersion returns 0x02000200
- */
-int DL_Dxf::getLibVersion( const char* str )
-{
- int d[4];
- int idx = 0;
- char v[4][5];
- int ret = 0;
-
- for ( unsigned int i = 0; i < strlen( str ) && idx < 3; ++i )
- {
- if ( str[i] == '.' )
- {
- d[idx] = i;
- idx++;
- }
- }
-
- if ( idx == 3 )
- {
- d[3] = strlen( str );
-
- strncpy( v[0], str, d[0] );
- v[0][d[0]] = '\0';
-// QgsDebugMsg(QString("v[0]: %1").arg(atoi(v[0])));
-
- strncpy( v[1], &str[d[0] + 1], d[1] - d[0] - 1 );
- v[1][d[1] - d[0] - 1] = '\0';
-// QgsDebugMsg(QString("v[1]: %1").arg(atoi(v[1])));
-
- strncpy( v[2], &str[d[1] + 1], d[2] - d[1] - 1 );
- v[2][d[2] - d[1] - 1] = '\0';
-// QgsDebugMsg(QString("v[2]: %1").arg(atoi(v[2])));
-
- strncpy( v[3], &str[d[2] + 1], d[3] - d[2] - 1 );
- v[3][d[3] - d[2] - 1] = '\0';
-// QgsDebugMsg(QString("v[3]: %1").arg(atoi(v[3])));
-
- ret = ( atoi( v[0] ) << ( 3 * 8 ) ) +
- ( atoi( v[1] ) << ( 2 * 8 ) ) +
- ( atoi( v[2] ) << ( 1 * 8 ) ) +
- ( atoi( v[3] ) << ( 0 * 8 ) );
-
- return ret;
- }
- else
- {
- QgsDebugMsg( QString( "DL_Dxf::getLibVersion: invalid version number: %1" ).arg( str ) );
- return 0;
- }
-}
-
-
-
-/**
- * Some test routines.
- */
-void DL_Dxf::test()
-{
- char* buf1;
- char* buf2;
- char* buf3;
- char* buf4;
- char* buf5;
- char* buf6;
-
- buf1 = new char[10];
- buf2 = new char[10];
- buf3 = new char[10];
- buf4 = new char[10];
- buf5 = new char[10];
- buf6 = new char[10];
-
- strcpy( buf1, " 10\n" );
- strcpy( buf2, "10" );
- strcpy( buf3, "10\n" );
- strcpy( buf4, " 10 \n" );
- strcpy( buf5, " 10 \r" );
- strcpy( buf6, "\t10 \n" );
-
- QgsDebugMsg( QString( "1 buf1: '%1'" ).arg( buf1 ) );
- stripWhiteSpace( &buf1 );
- QgsDebugMsg( QString( "2 buf1: '%1'" ).arg( buf1 ) );
- //assert(!strcmp(buf1, "10"));
-
- QgsDebugMsg( QString( "1 buf2: '%1'" ).arg( buf2 ) );
- stripWhiteSpace( &buf2 );
- QgsDebugMsg( QString( "2 buf2: '%1'" ).arg( buf2 ) );
-
- QgsDebugMsg( QString( "1 buf3: '%1'" ).arg( buf3 ) );
- stripWhiteSpace( &buf3 );
- QgsDebugMsg( QString( "2 buf3: '%1'" ).arg( buf3 ) );
-
- QgsDebugMsg( QString( "1 buf4: '%1'" ).arg( buf4 ) );
- stripWhiteSpace( &buf4 );
- QgsDebugMsg( QString( "2 buf4: '%1'" ).arg( buf4 ) );
-
- QgsDebugMsg( QString( "1 buf5: '%1'" ).arg( buf5 ) );
- stripWhiteSpace( &buf5 );
- QgsDebugMsg( QString( "2 buf5: '%1'" ).arg( buf5 ) );
-
- QgsDebugMsg( QString( "1 buf6: '%1'" ).arg( buf6 ) );
- stripWhiteSpace( &buf6 );
- QgsDebugMsg( QString( "2 buf6: '%1'" ).arg( buf6 ) );
-
-}
-
-
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h
deleted file mode 100644
index 706d579..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h
+++ /dev/null
@@ -1,431 +0,0 @@
-/****************************************************************************
-** $Id: dl_dxf.h 2398 2005-06-06 18:12:14Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_DXF_H
-#define DL_DXF_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifndef __GCC2x__
-#include <sstream>
-#endif
-
-#include "dl_attributes.h"
-#include "dl_codes.h"
-#include "dl_entities.h"
-#include "dl_writer_ascii.h"
-
-#ifdef _WIN32
-#undef M_PI
-#define M_PI 3.14159265358979323846
-#pragma warning(disable : 4800)
-#endif
-
-#ifndef M_PI
-#define M_PI 3.1415926535897932384626433832795
-#endif
-
-class DL_CreationInterface;
-class DL_WriterA;
-
-
-#define DL_VERSION "2.0.4.8"
-
-#define DL_Unknown 0
-#define DL_LAYER 10
-#define DL_BLOCK 11
-#define DL_ENDBLK 12
-#define DL_LINETYPE 13
-#define DL_SETTING 50
-#define DL_ENTITY_POINT 100
-#define DL_ENTITY_LINE 101
-#define DL_ENTITY_POLYLINE 102
-#define DL_ENTITY_LWPOLYLINE 103
-#define DL_ENTITY_VERTEX 104
-#define DL_ENTITY_SPLINE 105
-#define DL_ENTITY_KNOT 106
-#define DL_ENTITY_CONTROLPOINT 107
-#define DL_ENTITY_ARC 108
-#define DL_ENTITY_CIRCLE 109
-#define DL_ENTITY_ELLIPSE 110
-#define DL_ENTITY_INSERT 111
-#define DL_ENTITY_TEXT 112
-#define DL_ENTITY_MTEXT 113
-#define DL_ENTITY_DIMENSION 114
-#define DL_ENTITY_LEADER 115
-#define DL_ENTITY_HATCH 116
-#define DL_ENTITY_ATTRIB 117
-#define DL_ENTITY_IMAGE 118
-#define DL_ENTITY_IMAGEDEF 119
-#define DL_ENTITY_TRACE 120
-#define DL_ENTITY_SOLID 121
-#define DL_ENTITY_SEQEND 122
-
-
-/**
- * Reading and writing of DXF files.
- *
- * This class can read in a DXF file and calls methods from the
- * interface DL_EntityContainer to add the entities to the
- * contianer provided by the user of the library.
- *
- * It can also be used to write DXF files to a certain extent.
- *
- * When saving entities, special values for colors and linetypes
- * can be used:
- *
- * Special colors are 0 (=BYBLOCK) and 256 (=BYLAYER).
- * Special linetypes are "BYLAYER" and "BYBLOCK".
- *
- * @author Andrew Mustun
- */
-class DL_Dxf
-{
- public:
- DL_Dxf();
- ~DL_Dxf();
-
- bool in( const string& file,
- DL_CreationInterface* creationInterface );
- bool readDxfGroups( FILE* fp,
- DL_CreationInterface* creationInterface,
- int* errorCounter = NULL );
- static bool getChoppedLine( char* s, unsigned int size,
- FILE *stream );
-
-#ifndef __GCC2x__
-
- bool readDxfGroups( std::stringstream &stream,
- DL_CreationInterface* creationInterface,
- int* errorCounter = NULL );
- bool in( std::stringstream &stream,
- DL_CreationInterface* creationInterface );
- static bool getChoppedLine( char *s, unsigned int size,
- std::stringstream &stream );
-#endif
-
- static bool stripWhiteSpace( char** s );
-
- bool processDXFGroup( DL_CreationInterface* creationInterface,
- int groupCode, const char* groupValue );
- void addSetting( DL_CreationInterface* creationInterface );
- void addLayer( DL_CreationInterface* creationInterface );
- void addBlock( DL_CreationInterface* creationInterface );
- void endBlock( DL_CreationInterface* creationInterface );
-
- void addPoint( DL_CreationInterface* creationInterface );
- void addLine( DL_CreationInterface* creationInterface );
-
- void addPolyline( DL_CreationInterface* creationInterface );
- void addVertex( DL_CreationInterface* creationInterface );
-
- void addSpline( DL_CreationInterface* creationInterface );
- //void addKnot(DL_CreationInterface* creationInterface);
- //void addControlPoint(DL_CreationInterface* creationInterface);
-
- void addArc( DL_CreationInterface* creationInterface );
- void addCircle( DL_CreationInterface* creationInterface );
- void addEllipse( DL_CreationInterface* creationInterface );
- void addInsert( DL_CreationInterface* creationInterface );
-
- void addTrace( DL_CreationInterface* creationInterface );
- void addSolid( DL_CreationInterface* creationInterface );
-
- void addMText( DL_CreationInterface* creationInterface );
- bool handleMTextData( DL_CreationInterface* creationInterface );
- bool handleLWPolylineData( DL_CreationInterface* creationInterface );
- bool handleSplineData( DL_CreationInterface* creationInterface );
- bool handleLeaderData( DL_CreationInterface* creationInterface );
- bool handleHatchData( DL_CreationInterface* creationInterface );
-
- void addText( DL_CreationInterface* creationInterface );
- void addAttrib( DL_CreationInterface* creationInterface );
- DL_DimensionData getDimData();
- void addDimLinear( DL_CreationInterface* creationInterface );
- void addDimAligned( DL_CreationInterface* creationInterface );
- void addDimRadial( DL_CreationInterface* creationInterface );
- void addDimDiametric( DL_CreationInterface* creationInterface );
- void addDimAngular( DL_CreationInterface* creationInterface );
- void addDimAngular3P( DL_CreationInterface* creationInterface );
- void addLeader( DL_CreationInterface* creationInterface );
- void addHatch( DL_CreationInterface* creationInterface );
- void addImage( DL_CreationInterface* creationInterface );
- void addImageDef( DL_CreationInterface* creationInterface );
-
- void endEntity( DL_CreationInterface* creationInterface );
-
- void endSequence( DL_CreationInterface* creationInterface );
-
- int stringToInt( const char* s, bool* ok = NULL );
-
- DL_WriterA* out( const char* file,
- DL_Codes::version version = VER_2000 );
-
- void writeHeader( DL_WriterA& dw );
-
- void writePoint( DL_WriterA& dw,
- const DL_PointData& data,
- const DL_Attributes& attrib );
- void writeLine( DL_WriterA& dw,
- const DL_LineData& data,
- const DL_Attributes& attrib );
- void writePolyline( DL_WriterA& dw,
- const DL_PolylineData& data,
- const DL_Attributes& attrib );
- void writeVertex( DL_WriterA& dw,
- const DL_VertexData& data );
- void writePolylineEnd( DL_WriterA& dw );
- void writeSpline( DL_WriterA& dw,
- const DL_SplineData& data,
- const DL_Attributes& attrib );
- void writeControlPoint( DL_WriterA& dw,
- const DL_ControlPointData& data );
- void writeKnot( DL_WriterA& dw,
- const DL_KnotData& data );
- void writeCircle( DL_WriterA& dw,
- const DL_CircleData& data,
- const DL_Attributes& attrib );
- void writeArc( DL_WriterA& dw,
- const DL_ArcData& data,
- const DL_Attributes& attrib );
- void writeEllipse( DL_WriterA& dw,
- const DL_EllipseData& data,
- const DL_Attributes& attrib );
- void writeInsert( DL_WriterA& dw,
- const DL_InsertData& data,
- const DL_Attributes& attrib );
- void writeMText( DL_WriterA& dw,
- const DL_MTextData& data,
- const DL_Attributes& attrib );
- void writeText( DL_WriterA& dw,
- const DL_TextData& data,
- const DL_Attributes& attrib );
- void writeDimAligned( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimAlignedData& edata,
- const DL_Attributes& attrib );
- void writeDimLinear( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimLinearData& edata,
- const DL_Attributes& attrib );
- void writeDimRadial( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimRadialData& edata,
- const DL_Attributes& attrib );
- void writeDimDiametric( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimDiametricData& edata,
- const DL_Attributes& attrib );
- void writeDimAngular( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimAngularData& edata,
- const DL_Attributes& attrib );
- void writeDimAngular3P( DL_WriterA& dw,
- const DL_DimensionData& data,
- const DL_DimAngular3PData& edata,
- const DL_Attributes& attrib );
- void writeLeader( DL_WriterA& dw,
- const DL_LeaderData& data,
- const DL_Attributes& attrib );
- void writeLeaderVertex( DL_WriterA& dw,
- const DL_LeaderVertexData& data );
- void writeHatch1( DL_WriterA& dw,
- const DL_HatchData& data,
- const DL_Attributes& attrib );
- void writeHatch2( DL_WriterA& dw,
- const DL_HatchData& data,
- const DL_Attributes& attrib );
- void writeHatchLoop1( DL_WriterA& dw,
- const DL_HatchLoopData& data );
- void writeHatchLoop2( DL_WriterA& dw,
- const DL_HatchLoopData& data );
- void writeHatchEdge( DL_WriterA& dw,
- const DL_HatchEdgeData& data );
-
- int writeImage( DL_WriterA& dw,
- const DL_ImageData& data,
- const DL_Attributes& attrib );
-
- void writeImageDef( DL_WriterA& dw, int handle,
- const DL_ImageData& data );
-
- void writeLayer( DL_WriterA& dw,
- const DL_LayerData& data,
- const DL_Attributes& attrib );
-
- void writeLineType( DL_WriterA& dw,
- const DL_LineTypeData& data );
-
- void writeAppid( DL_WriterA& dw, const string& name );
-
- void writeBlock( DL_WriterA& dw,
- const DL_BlockData& data );
- void writeEndBlock( DL_WriterA& dw, const string& name );
-
- void writeVPort( DL_WriterA& dw );
- void writeStyle( DL_WriterA& dw );
- void writeView( DL_WriterA& dw );
- void writeUcs( DL_WriterA& dw );
- void writeDimStyle( DL_WriterA& dw,
- double dimasz, double dimexe, double dimexo,
- double dimgap, double dimtxt );
- void writeBlockRecord( DL_WriterA& dw );
- void writeBlockRecord( DL_WriterA& dw, const string& name );
- void writeObjects( DL_WriterA& dw );
- void writeObjectsEnd( DL_WriterA& dw );
-
- /**
- * Converts the given string into a double or returns the given
- * default valud (def) if value is NULL or empty.
- */
- static double toReal( const char* value, double def = 0.0 )
- {
- if ( value != NULL && value[0] != '\0' )
- {
- double ret;
- if ( strchr( value, ',' ) != NULL )
- {
- char* tmp = new char[strlen( value )+1];
- strcpy( tmp, value );
- DL_WriterA::strReplace( tmp, ',', '.' );
- ret = atof( tmp );
- delete[] tmp;
- }
- else
- {
- ret = atof( value );
- }
- return ret;
- }
- else
- {
- return def;
- }
- }
- /**
- * Converts the given string into an int or returns the given
- * default valud (def) if value is NULL or empty.
- */
- static int toInt( const char* value, int def = 0 )
- {
- if ( value != NULL && value[0] != '\0' )
- {
- return atoi( value );
- }
- else
- {
- return def;
- }
- }
- /**
- * Converts the given string into a string or returns the given
- * default valud (def) if value is NULL or empty.
- */
- static const char* toString( const char* value, const char* def = "" )
- {
- if ( value != NULL && value[0] != '\0' )
- {
- return value;
- }
- else
- {
- return def;
- }
- }
-
- static bool checkVariable( const char* var, DL_Codes::version version );
-
- DL_Codes::version getVersion()
- {
- return version;
- }
-
- int getLibVersion( const char* str );
-
- static void test();
-
- private:
- DL_Codes::version version;
- unsigned long styleHandleStd;
-
- string polylineLayer;
- double* vertices;
- int maxVertices;
- int vertexIndex;
-
- double* knots;
- int maxKnots;
- int knotIndex;
-
- double* controlPoints;
- int maxControlPoints;
- int controlPointIndex;
-
- double* leaderVertices;
- int maxLeaderVertices;
- int leaderVertexIndex;
-
- // array of hatch loops
- DL_HatchLoopData* hatchLoops;
- int maxHatchLoops;
- int hatchLoopIndex;
- // array in format [loop#][edge#]
- DL_HatchEdgeData** hatchEdges;
- int* maxHatchEdges;
- int* hatchEdgeIndex;
- bool dropEdges;
-
- // Only the useful part of the group code
- char groupCodeTmp[DL_DXF_MAXLINE+1];
- // ...same as integer
- unsigned int groupCode;
- // Only the useful part of the group value
- char groupValue[DL_DXF_MAXLINE+1];
- // Current entity type
- int currentEntity;
- // Value of the current setting
- char settingValue[DL_DXF_MAXLINE+1];
- // Key of the current setting (e.g. "$ACADVER")
- char settingKey[DL_DXF_MAXLINE+1];
- // Stores the group codes
- char values[DL_DXF_MAXGROUPCODE][DL_DXF_MAXLINE+1];
- // First call of this method. We initialize all group values in
- // the first call.
- bool firstCall;
- // Attributes of the current entity (layer, color, width, line type)
- DL_Attributes attrib;
- // library version. hex: 0x20003001 = 2.0.3.1
- int libVersion;
-};
-
-#endif
-
-// EOF
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_entities.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_entities.h
deleted file mode 100644
index 5d803a6..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_entities.h
+++ /dev/null
@@ -1,1434 +0,0 @@
-/****************************************************************************
-** $Id: dl_entities.h 2398 2005-06-06 18:12:14Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_ENTITIES_H
-#define DL_ENTITIES_H
-
-
-#include <string>
-using std::string;
-
-/**
- * Layer Data.
- *
- * @author Andrew Mustun
- */
-struct DL_LayerData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_LayerData( const string& lName,
- int lFlags )
- {
- name = lName;
- flags = lFlags;
- }
-
- /** Layer name. */
- string name;
- /** Layer flags. (1 = frozen, 2 = frozen by default, 4 = locked) */
- int flags;
-};
-
-
-
-/**
- * Block Data.
- *
- * @author Andrew Mustun
- */
-struct DL_BlockData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_BlockData( const string& bName,
- int bFlags,
- double bbpx, double bbpy, double bbpz )
- {
- name = bName;
- flags = bFlags;
- bpx = bbpx;
- bpy = bbpy;
- bpz = bbpz;
- }
-
- /** Block name. */
- string name;
- /** Block flags. (not used currently) */
- int flags;
- /** X Coordinate of base point. */
- double bpx;
- /** Y Coordinate of base point. */
- double bpy;
- /** Z Coordinate of base point. */
- double bpz;
-};
-
-
-
-/**
- * Line Type Data.
- *
- * @author Andrew Mustun
- */
-struct DL_LineTypeData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_LineTypeData( const string& lName,
- int lFlags )
- {
- name = lName;
- flags = lFlags;
- }
-
- /** Line type name. */
- string name;
- /** Line type flags. */
- int flags;
-};
-
-
-
-/**
- * Point Data.
- *
- * @author Andrew Mustun
- */
-struct DL_PointData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_PointData( double px = 0.0, double py = 0.0, double pz = 0.0 )
- {
- x = px;
- y = py;
- z = pz;
- }
-
- /*! X Coordinate of the point. */
- double x;
- /*! Y Coordinate of the point. */
- double y;
- /*! Z Coordinate of the point. */
- double z;
-};
-
-
-
-/**
- * Line Data.
- *
- * @author Andrew Mustun
- */
-struct DL_LineData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_LineData( double lx1, double ly1, double lz1,
- double lx2, double ly2, double lz2 )
- {
- x1 = lx1;
- y1 = ly1;
- z1 = lz1;
-
- x2 = lx2;
- y2 = ly2;
- z2 = lz2;
- }
-
- /*! X Start coordinate of the point. */
- double x1;
- /*! Y Start coordinate of the point. */
- double y1;
- /*! Z Start coordinate of the point. */
- double z1;
-
- /*! X End coordinate of the point. */
- double x2;
- /*! Y End coordinate of the point. */
- double y2;
- /*! Z End coordinate of the point. */
- double z2;
-};
-
-
-
-/**
- * Arc Data.
- *
- * @author Andrew Mustun
- */
-struct DL_ArcData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_ArcData( double acx, double acy, double acz,
- double aRadius,
- double aAngle1, double aAngle2 )
- {
-
- cx = acx;
- cy = acy;
- cz = acz;
- radius = aRadius;
- angle1 = aAngle1;
- angle2 = aAngle2;
- }
-
- /*! X Coordinate of center point. */
- double cx;
- /*! Y Coordinate of center point. */
- double cy;
- /*! Z Coordinate of center point. */
- double cz;
-
- /*! Radius of arc. */
- double radius;
- /*! Startangle of arc in degrees. */
- double angle1;
- /*! Endangle of arc in degrees. */
- double angle2;
-};
-
-
-
-/**
- * Circle Data.
- *
- * @author Andrew Mustun
- */
-struct DL_CircleData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_CircleData( double acx, double acy, double acz,
- double aRadius )
- {
-
- cx = acx;
- cy = acy;
- cz = acz;
- radius = aRadius;
- }
-
- /*! X Coordinate of center point. */
- double cx;
- /*! Y Coordinate of center point. */
- double cy;
- /*! Z Coordinate of center point. */
- double cz;
-
- /*! Radius of arc. */
- double radius;
-};
-
-
-
-/**
- * Polyline Data.
- *
- * @author Andrew Mustun
- */
-struct DL_PolylineData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_PolylineData( int pNumber, int pMVerteces, int pNVerteces, int pFlags )
- {
- number = pNumber;
- m = pMVerteces;
- n = pNVerteces;
- flags = pFlags;
- }
-
- /*! Number of vertices in this polyline. */
- unsigned int number;
-
- /*! Number of vertices in m direction if polyline is a polygon mesh. */
- unsigned int m;
-
- /*! Number of vertices in n direction if polyline is a polygon mesh. */
- unsigned int n;
-
- /*! Flags */
- int flags;
-};
-
-
-
-/**
- * Vertex Data.
- *
- * @author Andrew Mustun
- */
-struct DL_VertexData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_VertexData( double px = 0.0, double py = 0.0, double pz = 0.0,
- double pBulge = 0.0 )
- {
- x = px;
- y = py;
- z = pz;
- bulge = pBulge;
- }
-
- /*! X Coordinate of the vertex. */
- double x;
- /*! Y Coordinate of the vertex. */
- double y;
- /*! Z Coordinate of the vertex. */
- double z;
- /*! Bulge of vertex.
- * (The tangent of 1/4 of the arc angle or 0 for lines) */
- double bulge;
-};
-
-
-/**
- * Trace Data.
- *
- * @author AHM
- */
-struct DL_TraceData
-{
- double x[4];
- double y[4];
- double z[4];
-};
-
-
-/**
- * Solid Data.
- *
- * @author AHM
- */
-typedef DL_TraceData DL_SolidData;
-
-
-/**
- * Spline Data.
- *
- * @author Andrew Mustun
- */
-struct DL_SplineData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_SplineData( int pDegree, int pNKnots, int pNControl, int pFlags )
- {
- degree = pDegree;
- nKnots = pNKnots;
- nControl = pNControl;
- flags = pFlags;
- }
-
- /*! Degree of the spline curve. */
- unsigned int degree;
-
- /*! Number of knots. */
- unsigned int nKnots;
-
- /*! Number of control points. */
- unsigned int nControl;
-
- /*! Flags */
- int flags;
-};
-
-
-
-/**
- * Spline knot data.
- *
- * @author Andrew Mustun
- */
-struct DL_KnotData
-{
- DL_KnotData() {}
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_KnotData( double pk )
- {
- k = pk;
- }
-
- /*! Knot value. */
- double k;
-};
-
-
-
-/**
- * Spline control point data.
- *
- * @author Andrew Mustun
- */
-struct DL_ControlPointData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_ControlPointData( double px, double py, double pz )
- {
- x = px;
- y = py;
- z = pz;
- }
-
- /*! X coordinate of the control point. */
- double x;
- /*! Y coordinate of the control point. */
- double y;
- /*! Z coordinate of the control point. */
- double z;
-};
-
-
-/**
- * Ellipse Data.
- *
- * @author Andrew Mustun
- */
-struct DL_EllipseData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_EllipseData( double ecx, double ecy, double ecz,
- double emx, double emy, double emz,
- double eRatio,
- double eAngle1, double eAngle2 )
- {
-
- cx = ecx;
- cy = ecy;
- cz = ecz;
- mx = emx;
- my = emy;
- mz = emz;
- ratio = eRatio;
- angle1 = eAngle1;
- angle2 = eAngle2;
- }
-
- /*! X Coordinate of center point. */
- double cx;
- /*! Y Coordinate of center point. */
- double cy;
- /*! Z Coordinate of center point. */
- double cz;
-
- /*! X coordinate of the endpoint of the major axis. */
- double mx;
- /*! Y coordinate of the endpoint of the major axis. */
- double my;
- /*! Z coordinate of the endpoint of the major axis. */
- double mz;
-
- /*! Ratio of minor axis to major axis.. */
- double ratio;
- /*! Startangle of ellipse in rad. */
- double angle1;
- /*! Endangle of ellipse in rad. */
- double angle2;
-};
-
-
-
-/**
- * Insert Data.
- *
- * @author Andrew Mustun
- */
-struct DL_InsertData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_InsertData( const string& iName,
- double iipx, double iipy, double iipz,
- double isx, double isy, double isz,
- double iAngle,
- int iCols, int iRows,
- double iColSp, double iRowSp )
- {
- name = iName;
- ipx = iipx;
- ipy = iipy;
- ipz = iipz;
- sx = isx;
- sy = isy;
- sz = isz;
- angle = iAngle;
- cols = iCols;
- rows = iRows;
- colSp = iColSp;
- rowSp = iRowSp;
- }
-
- /*! Name of the referred block. */
- string name;
- /*! X Coordinate of insertion point. */
- double ipx;
- /*! Y Coordinate of insertion point. */
- double ipy;
- /*! Z Coordinate of insertion point. */
- double ipz;
- /*! X Scale factor. */
- double sx;
- /*! Y Scale factor. */
- double sy;
- /*! Z Scale factor. */
- double sz;
- /*! Rotation angle in rad. */
- double angle;
- /*! Number of colums if we insert an array of the block or 1. */
- int cols;
- /*! Number of rows if we insert an array of the block or 1. */
- int rows;
- /*! Values for the spacing between cols. */
- double colSp;
- /*! Values for the spacing between rows. */
- double rowSp;
-};
-
-
-
-/**
- * MText Data.
- *
- * @author Andrew Mustun
- */
-struct DL_MTextData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_MTextData( double tipx, double tipy, double tipz,
- double tHeight, double tWidth,
- int tAttachmentPoint,
- int tDrawingDirection,
- int tLineSpacingStyle,
- double tLineSpacingFactor,
- const string& tText,
- const string& tStyle,
- double tAngle )
- {
- ipx = tipx;
- ipy = tipy;
- ipz = tipz;
-
- height = tHeight;
- width = tWidth;
- attachmentPoint = tAttachmentPoint;
- drawingDirection = tDrawingDirection;
- lineSpacingStyle = tLineSpacingStyle;
- lineSpacingFactor = tLineSpacingFactor;
- text = tText;
- style = tStyle;
- angle = tAngle;
- }
-
- /*! X Coordinate of insertion point. */
- double ipx;
- /*! Y Coordinate of insertion point. */
- double ipy;
- /*! Z Coordinate of insertion point. */
- double ipz;
- /*! Text height */
- double height;
- /*! Width of the text box. */
- double width;
- /**
- * Attachment point.
- *
- * 1 = Top left, 2 = Top center, 3 = Top right,
- * 4 = Middle left, 5 = Middle center, 6 = Middle right,
- * 7 = Bottom left, 8 = Bottom center, 9 = Bottom right
- */
- int attachmentPoint;
- /**
- * Drawing direction.
- *
- * 1 = left to right, 3 = top to bottom, 5 = by style
- */
- int drawingDirection;
- /**
- * Line spacing style.
- *
- * 1 = at least, 2 = exact
- */
- int lineSpacingStyle;
- /**
- * Line spacing factor. 0.25 .. 4.0
- */
- double lineSpacingFactor;
- /*! Text string. */
- string text;
- /*! Style string. */
- string style;
- /*! Rotation angle. */
- double angle;
-};
-
-
-
-/**
- * Text Data.
- *
- * @author Andrew Mustun
- */
-struct DL_TextData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_TextData( double tipx, double tipy, double tipz,
- double tapx, double tapy, double tapz,
- double tHeight, double tXScaleFactor,
- int tTextGenerationFlags,
- int tHJustification,
- int tVJustification,
- const string& tText,
- const string& tStyle,
- double tAngle )
- {
- ipx = tipx;
- ipy = tipy;
- ipz = tipz;
-
- apx = tapx;
- apy = tapy;
- apz = tapz;
-
- height = tHeight;
- xScaleFactor = tXScaleFactor;
- textGenerationFlags = tTextGenerationFlags;
- hJustification = tHJustification;
- vJustification = tVJustification;
- text = tText;
- style = tStyle;
- angle = tAngle;
- }
-
- /*! X Coordinate of insertion point. */
- double ipx;
- /*! Y Coordinate of insertion point. */
- double ipy;
- /*! Z Coordinate of insertion point. */
- double ipz;
-
- /*! X Coordinate of alignment point. */
- double apx;
- /*! Y Coordinate of alignment point. */
- double apy;
- /*! Z Coordinate of alignment point. */
- double apz;
-
- /*! Text height */
- double height;
- /*! Relative X scale factor. */
- double xScaleFactor;
- /*! 0 = default, 2 = Backwards, 4 = Upside down */
- int textGenerationFlags;
- /**
- * Horizontal justification.
- *
- * 0 = Left (default), 1 = Center, 2 = Right,
- * 3 = Aligned, 4 = Middle, 5 = Fit
- * For 3, 4, 5 the vertical alignment has to be 0.
- */
- int hJustification;
- /**
- * Vertical justification.
- *
- * 0 = Baseline (default), 1 = Bottom, 2 = Middle, 3= Top
- */
- int vJustification;
- /*! Text string. */
- string text;
- /*! Style (font). */
- string style;
- /*! Rotation angle of dimension text away from default orientation. */
- double angle;
-};
-
-
-
-/**
- * Generic Dimension Data.
- *
- * @author Andrew Mustun
- */
-struct DL_DimensionData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_DimensionData( double ddpx, double ddpy, double ddpz,
- double dmpx, double dmpy, double dmpz,
- int dType,
- int dAttachmentPoint,
- int dLineSpacingStyle,
- double dLineSpacingFactor,
- const string& dText,
- const string& dStyle,
- double dAngle )
- {
-
- dpx = ddpx;
- dpy = ddpy;
- dpz = ddpz;
-
- mpx = dmpx;
- mpy = dmpy;
- mpz = dmpz;
-
- type = dType;
-
- attachmentPoint = dAttachmentPoint;
- lineSpacingStyle = dLineSpacingStyle;
- lineSpacingFactor = dLineSpacingFactor;
- text = dText;
- style = dStyle;
- angle = dAngle;
- }
-
- /*! X Coordinate of definition point. */
- double dpx;
- /*! Y Coordinate of definition point. */
- double dpy;
- /*! Z Coordinate of definition point. */
- double dpz;
- /*! X Coordinate of middle point of the text. */
- double mpx;
- /*! Y Coordinate of middle point of the text. */
- double mpy;
- /*! Z Coordinate of middle point of the text. */
- double mpz;
- /**
- * Dimension type.
- *
- * 0 Rotated, horizontal, or vertical
- * 1 Aligned
- * 2 Angular
- * 3 Diametric
- * 4 Radius
- * 5 Angular 3-point
- * 6 Ordinate
- * 64 Ordinate type. This is a bit value (bit 7)
- * used only with integer value 6. If set,
- * ordinate is X-type; if not set, ordinate is
- * Y-type
- * 128 This is a bit value (bit 8) added to the
- * other group 70 values if the dimension text
- * has been positioned at a user-defined
- * location rather than at the default location
- */
- int type;
- /**
- * Attachment point.
- *
- * 1 = Top left, 2 = Top center, 3 = Top right,
- * 4 = Middle left, 5 = Middle center, 6 = Middle right,
- * 7 = Bottom left, 8 = Bottom center, 9 = Bottom right,
- */
- int attachmentPoint;
- /**
- * Line spacing style.
- *
- * 1 = at least, 2 = exact
- */
- int lineSpacingStyle;
- /**
- * Line spacing factor. 0.25 .. 4.0
- */
- double lineSpacingFactor;
- /**
- * Text string.
- *
- * Text string entered explicitly by user or null
- * or "<>" for the actual measurement or " " (one blank space).
- * for supressing the text.
- */
- string text;
- /*! Dimension style (font name). */
- string style;
- /**
- * Rotation angle of dimension text away from
- * default orientation.
- */
- double angle;
-};
-
-
-
-/**
- * Aligned Dimension Data.
- *
- * @author Andrew Mustun
- */
-struct DL_DimAlignedData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_DimAlignedData( double depx1, double depy1, double depz1,
- double depx2, double depy2, double depz2 )
- {
-
- epx1 = depx1;
- epy1 = depy1;
- epz1 = depz1;
-
- epx2 = depx2;
- epy2 = depy2;
- epz2 = depz2;
- }
-
- /*! X Coordinate of Extension point 1. */
- double epx1;
- /*! Y Coordinate of Extension point 1. */
- double epy1;
- /*! Z Coordinate of Extension point 1. */
- double epz1;
-
- /*! X Coordinate of Extension point 2. */
- double epx2;
- /*! Y Coordinate of Extension point 2. */
- double epy2;
- /*! Z Coordinate of Extension point 2. */
- double epz2;
-};
-
-
-
-/**
- * Linear Dimension Data.
- *
- * @author Andrew Mustun
- */
-struct DL_DimLinearData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_DimLinearData( double ddpx1, double ddpy1, double ddpz1,
- double ddpx2, double ddpy2, double ddpz2,
- double dAngle, double dOblique )
- {
-
- dpx1 = ddpx1;
- dpy1 = ddpy1;
- dpz1 = ddpz1;
-
- dpx2 = ddpx2;
- dpy2 = ddpy2;
- dpz2 = ddpz2;
-
- angle = dAngle;
- oblique = dOblique;
- }
-
- /*! X Coordinate of Extension point 1. */
- double dpx1;
- /*! Y Coordinate of Extension point 1. */
- double dpy1;
- /*! Z Coordinate of Extension point 1. */
- double dpz1;
-
- /*! X Coordinate of Extension point 2. */
- double dpx2;
- /*! Y Coordinate of Extension point 2. */
- double dpy2;
- /*! Z Coordinate of Extension point 2. */
- double dpz2;
-
- /*! Rotation angle (angle of dimension line) in degrees. */
- double angle;
- /*! Oblique angle in degrees. */
- double oblique;
-};
-
-
-
-/**
- * Radial Dimension Data.
- *
- * @author Andrew Mustun
- */
-struct DL_DimRadialData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_DimRadialData( double ddpx, double ddpy, double ddpz, double dleader )
- {
- dpx = ddpx;
- dpy = ddpy;
- dpz = ddpz;
-
- leader = dleader;
- }
-
- /*! X Coordinate of definition point. */
- double dpx;
- /*! Y Coordinate of definition point. */
- double dpy;
- /*! Z Coordinate of definition point. */
- double dpz;
-
- /*! Leader length */
- double leader;
-};
-
-
-
-/**
- * Diametric Dimension Data.
- *
- * @author Andrew Mustun
- */
-struct DL_DimDiametricData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_DimDiametricData( double ddpx, double ddpy, double ddpz, double dleader )
- {
- dpx = ddpx;
- dpy = ddpy;
- dpz = ddpz;
-
- leader = dleader;
- }
-
- /*! X Coordinate of definition point. */
- double dpx;
- /*! Y Coordinate of definition point. */
- double dpy;
- /*! Z Coordinate of definition point. */
- double dpz;
-
- /*! Leader length */
- double leader;
-};
-
-
-
-/**
- * Angular Dimension Data.
- *
- * @author Andrew Mustun
- */
-struct DL_DimAngularData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_DimAngularData( double ddpx1, double ddpy1, double ddpz1,
- double ddpx2, double ddpy2, double ddpz2,
- double ddpx3, double ddpy3, double ddpz3,
- double ddpx4, double ddpy4, double ddpz4 )
- {
-
- dpx1 = ddpx1;
- dpy1 = ddpy1;
- dpz1 = ddpz1;
-
- dpx2 = ddpx2;
- dpy2 = ddpy2;
- dpz2 = ddpz2;
-
- dpx3 = ddpx3;
- dpy3 = ddpy3;
- dpz3 = ddpz3;
-
- dpx4 = ddpx4;
- dpy4 = ddpy4;
- dpz4 = ddpz4;
- }
-
- /*! X Coordinate of definition point 1. */
- double dpx1;
- /*! Y Coordinate of definition point 1. */
- double dpy1;
- /*! Z Coordinate of definition point 1. */
- double dpz1;
-
- /*! X Coordinate of definition point 2. */
- double dpx2;
- /*! Y Coordinate of definition point 2. */
- double dpy2;
- /*! Z Coordinate of definition point 2. */
- double dpz2;
-
- /*! X Coordinate of definition point 3. */
- double dpx3;
- /*! Y Coordinate of definition point 3. */
- double dpy3;
- /*! Z Coordinate of definition point 3. */
- double dpz3;
-
- /*! X Coordinate of definition point 4. */
- double dpx4;
- /*! Y Coordinate of definition point 4. */
- double dpy4;
- /*! Z Coordinate of definition point 4. */
- double dpz4;
-};
-
-
-/**
- * Angular Dimension Data (3 points version).
- *
- * @author Andrew Mustun
- */
-struct DL_DimAngular3PData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_DimAngular3PData( double ddpx1, double ddpy1, double ddpz1,
- double ddpx2, double ddpy2, double ddpz2,
- double ddpx3, double ddpy3, double ddpz3 )
- {
-
- dpx1 = ddpx1;
- dpy1 = ddpy1;
- dpz1 = ddpz1;
-
- dpx2 = ddpx2;
- dpy2 = ddpy2;
- dpz2 = ddpz2;
-
- dpx3 = ddpx3;
- dpy3 = ddpy3;
- dpz3 = ddpz3;
- }
-
- /*! X Coordinate of definition point 1. */
- double dpx1;
- /*! Y Coordinate of definition point 1. */
- double dpy1;
- /*! Z Coordinate of definition point 1. */
- double dpz1;
-
- /*! X Coordinate of definition point 2. */
- double dpx2;
- /*! Y Coordinate of definition point 2. */
- double dpy2;
- /*! Z Coordinate of definition point 2. */
- double dpz2;
-
- /*! X Coordinate of definition point 3. */
- double dpx3;
- /*! Y Coordinate of definition point 3. */
- double dpy3;
- /*! Z Coordinate of definition point 3. */
- double dpz3;
-};
-
-
-
-/**
- * Leader (arrow).
- *
- * @author Andrew Mustun
- */
-struct DL_LeaderData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_LeaderData( int lArrowHeadFlag,
- int lLeaderPathType,
- int lLeaderCreationFlag,
- int lHooklineDirectionFlag,
- int lHooklineFlag,
- double lTextAnnotationHeight,
- double lTextAnnotationWidth,
- int lNumber )
- {
-
- arrowHeadFlag = lArrowHeadFlag;
- leaderPathType = lLeaderPathType;
- leaderCreationFlag = lLeaderCreationFlag;
- hooklineDirectionFlag = lHooklineDirectionFlag;
- hooklineFlag = lHooklineFlag;
- textAnnotationHeight = lTextAnnotationHeight;
- textAnnotationWidth = lTextAnnotationWidth;
- number = lNumber;
- }
-
- /*! Arrow head flag (71). */
- int arrowHeadFlag;
- /*! Leader path type (72). */
- int leaderPathType;
- /*! Leader creation flag (73). */
- int leaderCreationFlag;
- /*! Hookline direction flag (74). */
- int hooklineDirectionFlag;
- /*! Hookline flag (75) */
- int hooklineFlag;
- /*! Text annotation height (40). */
- double textAnnotationHeight;
- /*! Text annotation width (41) */
- double textAnnotationWidth;
- /*! Number of vertices in leader (76). */
- int number;
-};
-
-
-
-/**
- * Leader Vertex Data.
- *
- * @author Andrew Mustun
- */
-struct DL_LeaderVertexData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_LeaderVertexData( double px = 0.0, double py = 0.0, double pz = 0.0 )
- {
- x = px;
- y = py;
- z = pz;
- }
-
- /*! X Coordinate of the vertex. */
- double x;
- /*! Y Coordinate of the vertex. */
- double y;
- /*! Z Coordinate of the vertex. */
- double z;
-};
-
-
-
-/**
- * Hatch data.
- */
-struct DL_HatchData
-{
- /**
- * Default constructor.
- */
- DL_HatchData() {}
-
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_HatchData( int hNumLoops,
- bool hSolid,
- double hScale,
- double hAngle,
- const string& hPattern )
- {
- numLoops = hNumLoops;
- solid = hSolid;
- scale = hScale;
- angle = hAngle;
- pattern = hPattern;
- }
-
- /*! Number of boundary paths (loops). */
- int numLoops;
- /*! Solid fill flag (true=solid, false=pattern). */
- bool solid;
- /*! Pattern scale or spacing */
- double scale;
- /*! Pattern angle */
- double angle;
- /*! Pattern name. */
- string pattern;
-};
-
-
-
-/**
- * Hatch boundary path (loop) data.
- */
-struct DL_HatchLoopData
-{
- /**
- * Default constructor.
- */
- DL_HatchLoopData() : numEdges( 0 ) {}
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_HatchLoopData( int hNumEdges )
- {
- numEdges = hNumEdges;
- }
-
- /*! Number of edges in this loop. */
- int numEdges;
-};
-
-
-
-/**
- * Hatch edge data.
- */
-struct DL_HatchEdgeData
-{
- /**
- * Default constructor.
- */
- DL_HatchEdgeData()
- : type( 1 )
- , defined( false )
- , x1( 0. ), y1( 0. )
- , x2( 0. ), y2( 0. )
- , cx( 0. ), cy( 0. )
- , radius( 0. )
- , angle1( 0. )
- , angle2( 0. )
- , ccw( false )
- {
- }
-
- /**
- * Constructor for a line edge.
- * Parameters: see member variables.
- */
- DL_HatchEdgeData( double lx1, double ly1,
- double lx2, double ly2 )
- : type( 1 )
- , defined( true )
- , x1( lx1 ), y1( ly1 )
- , x2( lx2 ), y2( ly2 )
- , cx( 0. ), cy( 0. )
- , radius( 0. )
- , angle1( 0. )
- , angle2( 0. )
- , ccw( false )
- {
- }
-
- /**
- * Constructor for an arc edge.
- * Parameters: see member variables.
- */
- DL_HatchEdgeData( double acx, double acy,
- double aRadius,
- double aAngle1, double aAngle2,
- bool aCcw )
- : type( 2 )
- , defined( true )
- , x1( 0. ), y1( 0. )
- , x2( 0. ), y2( 0. )
- , cx( acx ), cy( acy )
- , radius( aRadius )
- , angle1( aAngle1 )
- , angle2( aAngle2 )
- , ccw( aCcw )
- {
- }
-
- /**
- * Edge type. 1=line, 2=arc.
- */
- int type;
-
- /**
- * Set to true if this edge is fully defined.
- */
- bool defined;
-
- /*! Start point (X). */
- double x1;
- /*! Start point (Y). */
- double y1;
- /*! End point (X). */
- double x2;
- /*! End point (Y). */
- double y2;
- /*! Center point of arc (X). */
- double cx;
- /*! Center point of arc (Y). */
- double cy;
- /*! Arc radius. */
- double radius;
- /*! Start angle. */
- double angle1;
- /*! End angle. */
- double angle2;
- /*! Counterclockwise flag. */
- bool ccw;
-};
-
-
-
-/**
- * Image Data.
- *
- * @author Andrew Mustun
- */
-struct DL_ImageData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_ImageData( const string& iref,
- double iipx, double iipy, double iipz,
- double iux, double iuy, double iuz,
- double ivx, double ivy, double ivz,
- int iwidth, int iheight,
- int ibrightness, int icontrast, int ifade )
- {
- ref = iref;
- ipx = iipx;
- ipy = iipy;
- ipz = iipz;
- ux = iux;
- uy = iuy;
- uz = iuz;
- vx = ivx;
- vy = ivy;
- vz = ivz;
- width = iwidth;
- height = iheight;
- brightness = ibrightness;
- contrast = icontrast;
- fade = ifade;
- }
-
- /*! Reference to the image file
- (unique, used to refer to the image def object). */
- string ref;
- /*! X Coordinate of insertion point. */
- double ipx;
- /*! Y Coordinate of insertion point. */
- double ipy;
- /*! Z Coordinate of insertion point. */
- double ipz;
- /*! X Coordinate of u vector along bottom of image. */
- double ux;
- /*! Y Coordinate of u vector along bottom of image. */
- double uy;
- /*! Z Coordinate of u vector along bottom of image. */
- double uz;
- /*! X Coordinate of v vector along left side of image. */
- double vx;
- /*! Y Coordinate of v vector along left side of image. */
- double vy;
- /*! Z Coordinate of v vector along left side of image. */
- double vz;
- /*! Width of image in pixel. */
- int width;
- /*! Height of image in pixel. */
- int height;
- /*! Brightness (0..100, default = 50). */
- int brightness;
- /*! Contrast (0..100, default = 50). */
- int contrast;
- /*! Fade (0..100, default = 0). */
- int fade;
-};
-
-
-
-/**
- * Image Definition Data.
- *
- * @author Andrew Mustun
- */
-struct DL_ImageDefData
-{
- /**
- * Constructor.
- * Parameters: see member variables.
- */
- DL_ImageDefData( const string& iref,
- const string& ifile )
- {
- ref = iref;
- file = ifile;
- }
-
- /*! Reference to the image file
- (unique, used to refer to the image def object). */
- string ref;
-
- /*! Image file */
- string file;
-};
-
-#endif
-
-// EOF
-
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_exception.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_exception.h
deleted file mode 100644
index b372937..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_exception.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-** $Id: dl_exception.h 163 2003-07-01 15:51:48Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-** Copyright (C) 2001 Robert J. Campbell Jr.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_EXCEPTION_H
-#define DL_EXCEPTION_H
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-/**
- * Used for exception handling.
- */
-class DL_Exception {}
-;
-
-/**
- * Used for exception handling.
- */
-class DL_NullStrExc : public DL_Exception {}
-;
-
-/**
- * Used for exception handling.
- */
-class DL_GroupCodeExc : public DL_Exception
-{
- DL_GroupCodeExc() {}
-};
-#endif
-
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h
deleted file mode 100644
index 289e1c3..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-** $Id: dl_extrusion.h 273 2005-02-28 18:14:39Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_EXTRUSION_H
-#define DL_EXTRUSION_H
-
-#include <math.h>
-
-
-/**
- * Storing and passing around attributes. Attributes
- * are the layer name, color, width and line type.
- *
- * @author Andrew Mustun
- */
-class DL_Extrusion
-{
-
- public:
-
- /**
- * Default constructor.
- */
- DL_Extrusion()
- {
- direction = new double[3];
- setDirection( 0.0, 0.0, 1.0 );
- setElevation( 0.0 );
- }
-
-
- /**
- * Destructor.
- */
- ~DL_Extrusion()
- {
- delete direction;
- }
-
-
- /**
- * Constructor for DXF extrusion.
- *
- * @param direction Vector of axis along which the entity shall be extruded
- * this is also the Z axis of the Entity coordinate system
- * @param elevation Distance of the entities XY plane from the origin of the
- * world coordinate system
- */
- DL_Extrusion( double dx, double dy, double dz, double elevation )
- {
- direction = new double[3];
- setDirection( dx, dy, dz );
- setElevation( elevation );
- }
-
-
-
- /**
- * Sets the direction vector.
- */
- void setDirection( double dx, double dy, double dz )
- {
- direction[0] = dx;
- direction[1] = dy;
- direction[2] = dz;
- }
-
-
-
- /**
- * @return direction vector.
- */
- double* getDirection() const
- {
- return direction;
- }
-
-
-
- /**
- * @return direction vector.
- */
- void getDirection( double dir[] ) const
- {
- dir[0] = direction[0];
- dir[1] = direction[1];
- dir[2] = direction[2];
- }
-
-
-
- /**
- * Sets the elevation.
- */
- void setElevation( double elevation )
- {
- this->elevation = elevation;
- }
-
-
-
- /**
- * @return Elevation.
- */
- double getElevation() const
- {
- return elevation;
- }
-
-
-
- /**
- * Copies extrusion (deep copies) from another extrusion object.
- */
- DL_Extrusion &operator= ( const DL_Extrusion& extru )
- {
- setDirection( extru.direction[0], extru.direction[1], extru.direction[2] );
- setElevation( extru.elevation );
-
- return *this;
- }
-
-
-
- private:
- double *direction;
- double elevation;
-
- DL_Extrusion(const DL_Extrusion &);
-};
-
-#endif
-
-// EOF
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_writer.h
deleted file mode 100644
index c22d751..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer.h
+++ /dev/null
@@ -1,685 +0,0 @@
-/****************************************************************************
-** $Id: dl_writer.h 2398 2005-06-06 18:12:14Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-** Copyright (C) 2001 Robert J. Campbell Jr.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_WRITER_H
-#define DL_WRITER_H
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#if defined(__OS2__)||defined(__EMX__)||defined(_WIN32)
-#define strcasecmp(s,t) stricmp(s,t)
-#endif
-
-#include "dl_attributes.h"
-#include "dl_codes.h"
-
-
-
-/**
- * Defines interface for writing low level DXF constructs to
- * a file. Implementation is defined in derived classes that write
- * to binary or ASCII files.
- *
- * Implements functions that write higher level constructs in terms of
- * the low level ones.
- *
- * @todo Add error checking for string/entry length.
- */
-class DL_Writer
-{
- public:
- /**
- * @para version DXF version. Defaults to VER_2002.
- */
- DL_Writer( DL_Codes::version version ) : m_handle( 0x30 )
- {
- this->version = version;
- modelSpaceHandle = 0;
- paperSpaceHandle = 0;
- paperSpace0Handle = 0;
- }
-
- virtual ~DL_Writer() {}
- ;
-
- /** Generic section for section 'name'.
- *
- * <pre>
- * 0
- * SECTION
- * 2
- * name
- * </pre>
- */
- void section( const char* name ) const
- {
- dxfString( 0, "SECTION" );
- dxfString( 2, name );
- }
-
- /**
- * Section HEADER
- *
- * <pre>
- * 0
- * SECTION
- * 2
- * HEADER
- * </pre>
- */
- void sectionHeader() const
- {
- section( "HEADER" );
- }
-
- /**
- * Section TABLES
- *
- * <pre>
- * 0
- * SECTION
- * 2
- * TABLES
- * </pre>
- */
- void sectionTables() const
- {
- section( "TABLES" );
- }
-
- /**
- * Section BLOCKS
- *
- * <pre>
- * 0
- * SECTION
- * 2
- * BLOCKS
- * </pre>
- */
- void sectionBlocks() const
- {
- section( "BLOCKS" );
- }
-
- /**
- * Section ENTITIES
- *
- * <pre>
- * 0
- * SECTION
- * 2
- * ENTITIES
- * </pre>
- */
- void sectionEntities() const
- {
- section( "ENTITIES" );
- }
-
- /**
- * Section CLASSES
- *
- * <pre>
- * 0
- * SECTION
- * 2
- * CLASSES
- * </pre>
- */
- void sectionClasses() const
- {
- section( "CLASSES" );
- }
-
- /**
- * Section OBJECTS
- *
- * <pre>
- * 0
- * SECTION
- * 2
- * OBJECTS
- * </pre>
- */
- void sectionObjects() const
- {
- section( "OBJECTS" );
- }
-
- /**
- * End of a section.
- *
- * <pre>
- * 0
- * ENDSEC
- * </pre>
- */
- void sectionEnd() const
- {
- dxfString( 0, "ENDSEC" );
- }
-
- /**
- * Generic table for table 'name' with 'num' entries:
- *
- * <pre>
- * 0
- * TABLE
- * 2
- * name
- * 70
- * num
- * </pre>
- */
- void table( const char* name, int num, int handle ) const
- {
- dxfString( 0, "TABLE" );
- dxfString( 2, name );
- if ( version >= VER_2000 )
- {
- dxfHex( 5, handle );
- dxfString( 100, "AcDbSymbolTable" );
- }
- dxfInt( 70, num );
- }
-
- /** Table for layers.
- *
- * @param num Number of layers in total.
- *
- * <pre>
- * 0
- * TABLE
- * 2
- * LAYER
- * 70
- * num
- * </pre>
- */
- void tableLayers( int num ) const
- {
- table( "LAYER", num, 2 );
- }
-
- /** Table for line types.
- *
- * @param num Number of line types in total.
- *
- * <pre>
- * 0
- * TABLE
- * 2
- * LTYPE
- * 70
- * num
- * </pre>
- */
- void tableLineTypes( int num ) const
- {
- //lineTypeHandle = 5;
- table( "LTYPE", num, 5 );
- }
-
- /** Table for application id.
- *
- * @param num Number of registered applications in total.
- *
- * <pre>
- * 0
- * TABLE
- * 2
- * APPID
- * 70
- * num
- * </pre>
- */
- void tableAppid( int num ) const
- {
- table( "APPID", num, 9 );
- }
-
- /**
- * End of a table.
- *
- * <pre>
- * 0
- * ENDTAB
- * </pre>
- */
- void tableEnd() const
- {
- dxfString( 0, "ENDTAB" );
- }
-
- /**
- * End of the DXF file.
- *
- * <pre>
- * 0
- * EOF
- * </pre>
- */
- void dxfEOF() const
- {
- dxfString( 0, "EOF" );
- }
-
- /**
- * Comment.
- *
- * <pre>
- * 999
- * text
- * </pre>
- */
- void comment( const char* text ) const
- {
- dxfString( 999, text );
- }
-
- /**
- * Entity.
- *
- * <pre>
- * 0
- * entTypeName
- * </pre>
- *
- * @return Unique handle or 0.
- */
- void entity( const char* entTypeName ) const
- {
- dxfString( 0, entTypeName );
- if ( version >= VER_2000 )
- {
- handle();
- }
- }
-
- /**
- * Attributes of an entity.
- *
- * <pre>
- * 8
- * layer
- * 62
- * color
- * 39
- * width
- * 6
- * linetype
- * </pre>
- */
- void entityAttributes( const DL_Attributes& attrib ) const
- {
-
- // layer name:
- dxfString( 8, attrib.getLayer() );
-
- // R12 doesn't accept BYLAYER values. The value has to be missing
- // in that case.
- if ( version >= VER_2000 ||
- attrib.getColor() != 256 )
- {
- dxfInt( 62, attrib.getColor() );
- }
- if ( version >= VER_2000 )
- {
- dxfInt( 370, attrib.getWidth() );
- }
- if ( version >= VER_2000 ||
- strcasecmp( attrib.getLineType().c_str(), "BYLAYER" ) )
- {
- dxfString( 6, attrib.getLineType() );
- }
- }
-
- /**
- * Subclass.
- */
- void subClass( const char* sub ) const
- {
- dxfString( 100, sub );
- }
-
- /**
- * Layer (must be in the TABLES section LAYER).
- *
- * <pre>
- * 0
- * LAYER
- * </pre>
- */
- void tableLayerEntry( unsigned long int h = 0 ) const
- {
- dxfString( 0, "LAYER" );
- if ( version >= VER_2000 )
- {
- if ( h == 0 )
- {
- handle();
- }
- else
- {
- dxfHex( 5, h );
- }
- dxfString( 100, "AcDbSymbolTableRecord" );
- dxfString( 100, "AcDbLayerTableRecord" );
- }
- }
-
- /**
- * Line type (must be in the TABLES section LTYPE).
- *
- * <pre>
- * 0
- * LTYPE
- * </pre>
- */
- void tableLineTypeEntry( unsigned long int h = 0 ) const
- {
- dxfString( 0, "LTYPE" );
- if ( version >= VER_2000 )
- {
- if ( h == 0 )
- {
- handle();
- }
- else
- {
- dxfHex( 5, h );
- }
- //dxfHex(330, 0x5);
- dxfString( 100, "AcDbSymbolTableRecord" );
- dxfString( 100, "AcDbLinetypeTableRecord" );
- }
- }
-
- /**
- * Appid (must be in the TABLES section APPID).
- *
- * <pre>
- * 0
- * APPID
- * </pre>
- */
- void tableAppidEntry( unsigned long int h = 0 ) const
- {
- dxfString( 0, "APPID" );
- if ( version >= VER_2000 )
- {
- if ( h == 0 )
- {
- handle();
- }
- else
- {
- dxfHex( 5, h );
- }
- //dxfHex(330, 0x9);
- dxfString( 100, "AcDbSymbolTableRecord" );
- dxfString( 100, "AcDbRegAppTableRecord" );
- }
- }
-
- /**
- * Block (must be in the section BLOCKS).
- *
- * <pre>
- * 0
- * BLOCK
- * </pre>
- */
- void sectionBlockEntry( unsigned long int h = 0 ) const
- {
- dxfString( 0, "BLOCK" );
- if ( version >= VER_2000 )
- {
- if ( h == 0 )
- {
- handle();
- }
- else
- {
- dxfHex( 5, h );
- }
- //dxfHex(330, blockHandle);
- dxfString( 100, "AcDbEntity" );
- if ( h == 0x1C )
- {
- dxfInt( 67, 1 );
- }
- dxfString( 8, "0" ); // TODO: Layer for block
- dxfString( 100, "AcDbBlockBegin" );
- }
- }
-
- /**
- * End of Block (must be in the section BLOCKS).
- *
- * <pre>
- * 0
- * ENDBLK
- * </pre>
- */
- void sectionBlockEntryEnd( unsigned long int h = 0 ) const
- {
- dxfString( 0, "ENDBLK" );
- if ( version >= VER_2000 )
- {
- if ( h == 0 )
- {
- handle();
- }
- else
- {
- dxfHex( 5, h );
- }
- //dxfHex(330, blockHandle);
- dxfString( 100, "AcDbEntity" );
- if ( h == 0x1D )
- {
- dxfInt( 67, 1 );
- }
- dxfString( 8, "0" ); // TODO: Layer for block
- dxfString( 100, "AcDbBlockEnd" );
- }
- }
-
- void color( int col = 256 ) const
- {
- dxfInt( 62, col );
- }
- void lineType( const char *lt ) const
- {
- dxfString( 6, lt );
- }
- void lineTypeScale( double scale ) const
- {
- dxfReal( 48, scale );
- }
- void lineWeight( int lw ) const
- {
- dxfInt( 370, lw );
- }
-
- void coord( int gc, double x, double y, double z = 0 ) const
- {
- dxfReal( gc, x );
- dxfReal( gc + 10, y );
- dxfReal( gc + 20, z );
- }
-
- void coordTriplet( int gc, const double* value ) const
- {
- if ( value )
- {
- dxfReal( gc, *value++ );
- dxfReal( gc + 10, *value++ );
- dxfReal( gc + 20, *value++ );
- }
- }
-
- void resetHandle() const
- {
- m_handle = 1;
- }
-
- /**
- * Writes a unique handle and returns it.
- */
- unsigned long handle( int gc = 5 ) const
- {
- // handle has to be hex
- dxfHex( gc, m_handle );
- return m_handle++;
- }
-
- /**
- * @return Next handle that will be written.
- */
- unsigned long getNextHandle() const
- {
- return m_handle;
- }
-
- /**
- * Increases handle, so that the handle returned remains available.
- */
- unsigned long incHandle() const
- {
- return m_handle++;
- }
-
- /**
- * Sets the handle of the model space. Entities refer to
- * this handle.
- */
- void setModelSpaceHandle( unsigned long h )
- {
- modelSpaceHandle = h;
- }
-
- unsigned long getModelSpaceHandle()
- {
- return modelSpaceHandle;
- }
-
- /**
- * Sets the handle of the paper space. Some special blocks refer to
- * this handle.
- */
- void setPaperSpaceHandle( unsigned long h )
- {
- paperSpaceHandle = h;
- }
-
- unsigned long getPaperSpaceHandle()
- {
- return paperSpaceHandle;
- }
-
- /**
- * Sets the handle of the paper space 0. Some special blocks refer to
- * this handle.
- */
- void setPaperSpace0Handle( unsigned long h )
- {
- paperSpace0Handle = h;
- }
-
- unsigned long getPaperSpace0Handle()
- {
- return paperSpace0Handle;
- }
-
- /**
- * Must be overwritten by the implementing class to write a
- * real value to the file.
- *
- * @param gc Group code.
- * @param value The real value.
- */
- virtual void dxfReal( int gc, double value ) const = 0;
-
- /**
- * Must be overwritten by the implementing class to write an
- * int value to the file.
- *
- * @param gc Group code.
- * @param value The int value.
- */
- virtual void dxfInt( int gc, int value ) const = 0;
-
- /**
- * Must be overwritten by the implementing class to write an
- * int value (hex) to the file.
- *
- * @param gc Group code.
- * @param value The int value.
- */
- virtual void dxfHex( int gc, int value ) const = 0;
-
- /**
- * Must be overwritten by the implementing class to write a
- * string to the file.
- *
- * @param gc Group code.
- * @param value The string.
- */
- virtual void dxfString( int gc, const char* value ) const = 0;
-
- /**
- * Must be overwritten by the implementing class to write a
- * string to the file.
- *
- * @param gc Group code.
- * @param value The string.
- */
- virtual void dxfString( int gc, const string& value ) const = 0;
-
- protected:
- mutable unsigned long m_handle;
- mutable unsigned long modelSpaceHandle;
- mutable unsigned long paperSpaceHandle;
- mutable unsigned long paperSpace0Handle;
-
- /**
- * DXF version to be created.
- */
- DL_Codes::version version;
- private:
-};
-
-#endif
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.cpp b/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.cpp
deleted file mode 100644
index 5963322..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-** $Id: dl_writer_ascii.cpp 242 2004-04-12 22:39:43Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-** Copyright (C) 2001 Robert J. Campbell Jr.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#include <cstdio>
-#include <cstring>
-
-#include "dl_writer_ascii.h"
-#include "dl_exception.h"
-
-
-/**
- * Closes the output file.
- */
-void DL_WriterA::close() const
-{
- m_ofile.close();
-}
-
-
-/**
- * @retval true Opening file has failed.
- * @retval false Otherwise.
- */
-bool DL_WriterA::openFailed() const
-{
- return m_ofile.fail();
-}
-
-
-
-/**
- * Writes a real (double) variable to the DXF file.
- *
- * @param gc Group code.
- * @param value Double value
- */
-void DL_WriterA::dxfReal( int gc, double value ) const
-{
- char str[256];
- sprintf( str, "%.16f", value );
-
- // fix for german locale:
- strReplace( str, ',', '.' );
-
- // Cut away those zeros at the end:
- bool dot = false;
- int end = -1;
- for ( unsigned int i = 0; i < strlen( str ); ++i )
- {
- if ( str[i] == '.' )
- {
- dot = true;
- end = i + 2;
- continue;
- }
- else if ( dot && str[i] != '0' )
- {
- end = i + 1;
- }
- }
- if ( end > 0 && end < ( int )strlen( str ) )
- {
- str[end] = '\0';
- }
-
- dxfString( gc, str );
- m_ofile.flush();
-}
-
-
-
-/**
- * Writes an int variable to the DXF file.
- *
- * @param gc Group code.
- * @param value Int value
- */
-void DL_WriterA::dxfInt( int gc, int value ) const
-{
- m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n"
- << value << "\n";
-}
-
-
-
-/**
- * Writes a hex int variable to the DXF file.
- *
- * @param gc Group code.
- * @param value Int value
- */
-void DL_WriterA::dxfHex( int gc, int value ) const
-{
- char str[12];
- sprintf( str, "%0X", value );
- dxfString( gc, str );
-}
-
-
-
-/**
- * Writes a string variable to the DXF file.
- *
- * @param gc Group code.
- * @param value String
- */
-void DL_WriterA::dxfString( int gc, const char* value ) const
-{
- if ( value == NULL )
- {
-#ifndef __GCC2x__
- throw DL_NullStrExc();
-#endif
- }
- m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n"
- << value << "\n";
-}
-
-
-
-void DL_WriterA::dxfString( int gc, const string& value ) const
-{
- m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n"
- << value << "\n";
-}
-
-
-/**
- * Replaces every occurence of src with dest in the null terminated str.
- */
-void DL_WriterA::strReplace( char* str, char src, char dest )
-{
- size_t i;
- for ( i = 0; i < strlen( str ); i++ )
- {
- if ( str[i] == src )
- {
- str[i] = dest;
- }
- }
-}
-
diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.h
deleted file mode 100644
index 20e4dc2..0000000
--- a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-** $Id: dl_writer_ascii.h 2719 2005-09-24 20:41:23Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-** Copyright (C) 2001 Robert J. Campbell Jr.
-**
-** This file is part of the dxflib project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 2 of the License
-**
-** Licensees holding valid dxflib Professional Edition licenses may use
-** this file in accordance with the dxflib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info at ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
-#ifndef DL_WRITER_ASCII_H
-#define DL_WRITER_ASCII_H
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#include "dl_writer.h"
-#include <fstream>
-#include <string>
-using std::string;
-
-/**
- * Implements functions defined in DL_Writer for writing low
- * level DXF constructs to an ASCII format DXF file.
- *
- * @para fname File name of the file to be created.
- * @para version DXF version. Defaults to VER_2002.
- *
- * @todo What if \c fname is NULL? Or \c fname can't be opened for
- * another reason?
- */
-class DL_WriterA : public DL_Writer
-{
- public:
- DL_WriterA( const char* fname, DL_Codes::version version = VER_2000 )
- : DL_Writer( version ), m_ofile( fname ) {}
- virtual ~DL_WriterA() {}
-
- bool openFailed() const;
- void close() const;
- void dxfReal( int gc, double value ) const override;
- void dxfInt( int gc, int value ) const override;
- void dxfHex( int gc, int value ) const override;
- void dxfString( int gc, const char* value ) const override;
- void dxfString( int gc, const string& value ) const override;
-
- static void strReplace( char* str, char src, char dest );
-
- private:
- /**
- * DXF file to be created.
- */
- mutable std::ofstream m_ofile;
-
-};
-
-#endif
-
diff --git a/src/plugins/dxf2shp_converter/getInsertions.cpp b/src/plugins/dxf2shp_converter/getInsertions.cpp
deleted file mode 100644
index d90e911..0000000
--- a/src/plugins/dxf2shp_converter/getInsertions.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/***************************************************************************
- getInsertions.cpp
- ---------------------
- copyright : (C) by Christopher Michaelis
- ***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-// LICENSE:
-//
-// This code is released under the GPL (GNU Public License) version 2.0.
-// For full details, see the file GPL.txt included with this source code.
-//
-// What this means:
-//
-// This means, in simple terms, that you are free to use this code for any open-source or
-// public domain project. You may NOT use this source code as part of a commercial application.
-// It may be included, in binary form and bearing a GPL notice, along with commercial
-// applications, but the code shall not be compiled directly into a closed-source,
-// commercial application.
-//
-// This code is based on two other products:
-// DXFLIB (http://www.ribbonsoft.com/dxflib.html)
-// This is a library for reading DXF files, also GPL.
-// MAPWINGIS (http://www.mapwindow.org)
-// This is a library for many general-purpose GIS and mapping applications. It's
-// used for the Shapefile functionality. This software is also open source, this one MPL.
-//
-// Questions/Comments/Thoughts?
-// http://www.happysquirrel.com/index.php?feature=hs_questions
-//
-// Thank you!
-//
-
-// getInsertions.cpp: The class which retrieves the block insertions from the DXF file
-
-
-#include "getInsertions.h"
-
-InsertRetrClass::InsertRetrClass()
-{
- Names = new string[MaxInserts];
- XVals = new double[MaxInserts];
- YVals = new double[MaxInserts];
-
- countInserts = 0;
-}
-
-InsertRetrClass::~InsertRetrClass()
-{
- if ( Names != NULL )
- {
- delete [] Names;
- Names = NULL;
- }
- if ( XVals != NULL )
- {
- delete [] XVals;
- XVals = NULL;
- }
- if ( YVals != NULL )
- {
- delete [] YVals;
- YVals = NULL;
- }
-}
-
-void InsertRetrClass::addInsert( const DL_InsertData &data )
-{
- if ( countInserts < MaxInserts )
- {
- Names[countInserts] = data.name;
- XVals[countInserts] = data.ipx;
- YVals[countInserts] = data.ipy;
- }
- countInserts++;
-}
diff --git a/src/plugins/dxf2shp_converter/getInsertions.h b/src/plugins/dxf2shp_converter/getInsertions.h
deleted file mode 100644
index ddf62f3..0000000
--- a/src/plugins/dxf2shp_converter/getInsertions.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/***************************************************************************
- getInsertions.h
- ---------------------
- copyright : (C) by Christopher Michaelis
- ***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; version 2 of the License *
- * *
- ***************************************************************************/
-/* This source has been formatted by an unregistered SourceFormatX */
-/* If you want to remove this info, please register this shareware */
-/* Please visit http://www.textrush.com to get more information */
-
-// What this means:
-//
-// This means, in simple terms, that you are free to use this code for any open-source or
-// public domain project. You may NOT use this source code as part of a commercial application.
-// It may be included, in binary form and bearing a GPL notice, along with commercial
-// applications, but the code shall not be compiled directly into a closed-source,
-// commercial application.
-//
-// This code is based on two other products:
-// DXFLIB (http://www.ribbonsoft.com/dxflib.html)
-// This is a library for reading DXF files, also GPL.
-// MAPWINGIS (http://www.mapwindow.org)
-// This is a library for many general-purpose GIS and mapping applications. It's
-// used for the Shapefile functionality. This software is also open source, this one MPL.
-//
-// Questions/Comments/Thoughts?
-// http://www.happysquirrel.com/index.php?feature=hs_questions
-//
-// Thank you!
-// Christopher Michaelis
-
-// getInsertions.h: The class which retrieves the block insertions from the DXF file
-
-#ifndef INSERTIONCLASS_H
-#define INSERTIONCLASS_H
-
-#include "dxflib/src/dl_creationadapter.h"
-
-class InsertRetrClass: public DL_CreationAdapter
-{
- public:
- InsertRetrClass();
- ~InsertRetrClass();
-
- virtual void addInsert( const DL_InsertData &data ) override;
-
- string *Names;
- double *XVals;
- double *YVals;
-
- int countInserts;
- const static int MaxInserts = 1000000;
-};
-
-#endif
diff --git a/src/plugins/dxf2shp_converter/shapelib-1.2.10/LICENSE.LGPL b/src/plugins/dxf2shp_converter/shapelib-1.2.10/LICENSE.LGPL
deleted file mode 100644
index 0b643ac..0000000
--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/LICENSE.LGPL
+++ /dev/null
@@ -1,483 +0,0 @@
-
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
-
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-
- GNU LIBRARY GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- c) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- d) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
diff --git a/src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c b/src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c
deleted file mode 100644
index c63e751..0000000
--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c
+++ /dev/null
@@ -1,1502 +0,0 @@
-/******************************************************************************
- * $Id: dbfopen.c,v 1.48 2003/03/10 14:51:27 warmerda Exp $
- *
- * Project: Shapelib
- * Purpose: Implementation of .dbf access API documented in dbf_api.html.
- * Author: Frank Warmerdam, warmerdam at pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Frank Warmerdam
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log: dbfopen.c,v $
- * Revision 1.48 2003/03/10 14:51:27 warmerda
- * DBFWrite* calls now return FALSE if they have to truncate
- *
- * Revision 1.47 2002/11/20 03:32:22 warmerda
- * Ensure field name in DBFGetFieldIndex() is properly terminated.
- *
- * Revision 1.46 2002/10/09 13:10:21 warmerda
- * Added check that width is positive.
- *
- * Revision 1.45 2002/09/29 00:00:08 warmerda
- * added FTLogical and logical attribute read/write calls
- *
- * Revision 1.44 2002/05/07 13:46:11 warmerda
- * Added DBFWriteAttributeDirectly().
- *
- * Revision 1.43 2002/02/13 19:39:21 warmerda
- * Fix casting issues in DBFCloneEmpty().
- *
- * Revision 1.42 2002/01/15 14:36:07 warmerda
- * updated email address
- *
- * Revision 1.41 2002/01/15 14:31:49 warmerda
- * compute rather than copying nHeaderLength in DBFCloneEmpty()
- *
- * Revision 1.40 2002/01/09 04:32:35 warmerda
- * fixed to read correct amount of header
- *
- * Revision 1.39 2001/12/11 22:41:03 warmerda
- * improve io related error checking when reading header
- *
- * Revision 1.38 2001/11/28 16:07:31 warmerda
- * Cleanup to avoid compiler warnings as suggested by Richard Hash.
- *
- * Revision 1.37 2001/07/04 05:18:09 warmerda
- * do last fix properly
- *
- * Revision 1.36 2001/07/04 05:16:09 warmerda
- * fixed fieldname comparison in DBFGetFieldIndex
- *
- * Revision 1.35 2001/06/22 02:10:06 warmerda
- * fixed NULL shape support with help from Jim Matthews
- *
- * Revision 1.33 2001/05/31 19:20:13 warmerda
- * added DBFGetFieldIndex()
- *
- * Revision 1.32 2001/05/31 18:15:40 warmerda
- * Added support for NULL fields in DBF files
- *
- * Revision 1.31 2001/05/23 13:36:52 warmerda
- * added use of SHPAPI_CALL
- *
- * Revision 1.30 2000/12/05 14:43:38 warmerda
- * DBReadAttribute() white space trimming bug fix
- *
- * Revision 1.29 2000/10/05 14:36:44 warmerda
- * fix bug with writing very wide numeric fields
- *
- * Revision 1.28 2000/09/25 14:18:07 warmerda
- * Added some casts of strlen() return result to fix warnings on some
- * systems, as submitted by Daniel.
- *
- * Revision 1.27 2000/09/25 14:15:51 warmerda
- * added DBFGetNativeFieldType()
- *
- * Revision 1.26 2000/07/07 13:39:45 warmerda
- * removed unused variables, and added system include files
- *
- * Revision 1.25 2000/05/29 18:19:13 warmerda
- * avoid use of uchar, and adding casting fix
- *
- * Revision 1.24 2000/05/23 13:38:27 warmerda
- * Added error checks on return results of fread() and fseek().
- *
- * Revision 1.23 2000/05/23 13:25:49 warmerda
- * Avoid crashing if field or record are out of range in dbfread*attribute().
- *
- * Revision 1.22 1999/12/15 13:47:24 warmerda
- * Added stdlib.h to ensure that atof() is prototyped.
- *
- * Revision 1.21 1999/12/13 17:25:46 warmerda
- * Added support for upper case .DBF extension.
- *
- * Revision 1.20 1999/11/30 16:32:11 warmerda
- * Use atof() instead of sscanf().
- *
- * Revision 1.19 1999/11/05 14:12:04 warmerda
- * updated license terms
- *
- * Revision 1.18 1999/07/27 00:53:28 warmerda
- * ensure that whole old field value clear on write of string
- *
- * Revision 1.1 1999/07/05 18:58:07 warmerda
- * New
- *
- * Revision 1.17 1999/06/11 19:14:12 warmerda
- * Fixed some memory leaks.
- *
- * Revision 1.16 1999/06/11 19:04:11 warmerda
- * Remoted some unused variables.
- *
- * Revision 1.15 1999/05/11 03:19:28 warmerda
- * added new Tuple api, and improved extension handling - add from candrsn
- *
- * Revision 1.14 1999/05/04 15:01:48 warmerda
- * Added 'F' support.
- *
- * Revision 1.13 1999/03/23 17:38:59 warmerda
- * DBFAddField() now actually does return the new field number, or -1 if
- * it fails.
- *
- * Revision 1.12 1999/03/06 02:54:46 warmerda
- * Added logic to convert shapefile name to dbf filename in DBFOpen()
- * for convenience.
- *
- * Revision 1.11 1998/12/31 15:30:34 warmerda
- * Improved the interchangability of numeric and string attributes. Add
- * white space trimming option for attributes.
- *
- * Revision 1.10 1998/12/03 16:36:44 warmerda
- * Use r+b instead of rb+ for binary access.
- *
- * Revision 1.9 1998/12/03 15:34:23 warmerda
- * Updated copyright message.
- *
- * Revision 1.8 1997/12/04 15:40:15 warmerda
- * Added newline character after field definitions.
- *
- * Revision 1.7 1997/03/06 14:02:10 warmerda
- * Ensure bUpdated is initialized.
- *
- * Revision 1.6 1996/02/12 04:54:41 warmerda
- * Ensure that DBFWriteAttribute() returns TRUE if it succeeds.
- *
- * Revision 1.5 1995/10/21 03:15:12 warmerda
- * Changed to use binary file access, and ensure that the
- * field name field is zero filled, and limited to 10 chars.
- *
- * Revision 1.4 1995/08/24 18:10:42 warmerda
- * Added use of SfRealloc() to avoid pre-ANSI realloc() functions such
- * as on the Sun.
- *
- * Revision 1.3 1995/08/04 03:15:16 warmerda
- * Fixed up header.
- *
- * Revision 1.2 1995/08/04 03:14:43 warmerda
- * Added header.
- */
-
-static char rcsid[] =
- "$Id: dbfopen.c,v 1.48 2003/03/10 14:51:27 warmerda Exp $";
-
-#include "shapefil.h"
-
-#include <math.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-
-#ifndef FALSE
-# define FALSE 0
-# define TRUE 1
-#endif
-
-static int nStringFieldLen = 0;
-static char * pszStringField = NULL;
-
-/************************************************************************/
-/* SfRealloc() */
-/* */
-/* A realloc cover function that will access a NULL pointer as */
-/* a valid input. */
-/************************************************************************/
-
-static void * SfRealloc( void * pMem, int nNewSize )
-
-{
- if ( pMem == NULL )
- return(( void * ) malloc( nNewSize ) );
- else
- return(( void * ) realloc( pMem, nNewSize ) );
-}
-
-/************************************************************************/
-/* DBFWriteHeader() */
-/* */
-/* This is called to write out the file header, and field */
-/* descriptions before writing any actual data records. This */
-/* also computes all the DBFDataSet field offset/size/decimals */
-/* and so forth values. */
-/************************************************************************/
-
-static void DBFWriteHeader( DBFHandle psDBF )
-
-{
- unsigned char abyHeader[XBASE_FLDHDR_SZ];
- int i;
-
- if ( !psDBF->bNoHeader )
- return;
-
- psDBF->bNoHeader = FALSE;
-
- /* -------------------------------------------------------------------- */
- /* Initialize the file header information. */
- /* -------------------------------------------------------------------- */
- for ( i = 0; i < XBASE_FLDHDR_SZ; i++ )
- abyHeader[i] = 0;
-
- abyHeader[0] = 0x03; /* memo field? - just copying */
-
- /* date updated on close, record count preset at zero */
-
- abyHeader[8] = psDBF->nHeaderLength % 256;
- abyHeader[9] = psDBF->nHeaderLength / 256;
-
- abyHeader[10] = psDBF->nRecordLength % 256;
- abyHeader[11] = psDBF->nRecordLength / 256;
-
- /* -------------------------------------------------------------------- */
- /* Write the initial 32 byte file header, and all the field */
- /* descriptions. */
- /* -------------------------------------------------------------------- */
- fseek( psDBF->fp, 0, 0 );
- fwrite( abyHeader, XBASE_FLDHDR_SZ, 1, psDBF->fp );
- fwrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, psDBF->fp );
-
- /* -------------------------------------------------------------------- */
- /* Write out the newline character if there is room for it. */
- /* -------------------------------------------------------------------- */
- if ( psDBF->nHeaderLength > 32*psDBF->nFields + 32 )
- {
- char cNewline;
-
- cNewline = 0x0d;
- fwrite( &cNewline, 1, 1, psDBF->fp );
- }
-}
-
-/************************************************************************/
-/* DBFFlushRecord() */
-/* */
-/* Write out the current record if there is one. */
-/************************************************************************/
-
-static void DBFFlushRecord( DBFHandle psDBF )
-
-{
- int nRecordOffset;
-
- if ( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 )
- {
- psDBF->bCurrentRecordModified = FALSE;
-
- nRecordOffset = psDBF->nRecordLength * psDBF->nCurrentRecord
- + psDBF->nHeaderLength;
-
- fseek( psDBF->fp, nRecordOffset, 0 );
- fwrite( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
- }
-}
-
-/************************************************************************/
-/* DBFOpen() */
-/* */
-/* Open a .dbf file. */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFOpen( const char * pszFilename, const char * pszAccess )
-
-{
- DBFHandle psDBF;
- unsigned char *pabyBuf;
- int nFields, nHeadLen, nRecLen, iField, i;
- char *pszBasename, *pszFullname;
-
- /* -------------------------------------------------------------------- */
- /* We only allow the access strings "rb" and "r+". */
- /* -------------------------------------------------------------------- */
- if ( strcmp( pszAccess, "r" ) != 0 && strcmp( pszAccess, "r+" ) != 0
- && strcmp( pszAccess, "rb" ) != 0 && strcmp( pszAccess, "rb+" ) != 0
- && strcmp( pszAccess, "r+b" ) != 0 )
- return( NULL );
-
- if ( strcmp( pszAccess, "r" ) == 0 )
- pszAccess = "rb";
-
- if ( strcmp( pszAccess, "r+" ) == 0 )
- pszAccess = "rb+";
-
- /* -------------------------------------------------------------------- */
- /* Compute the base (layer) name. If there is any extension */
- /* on the passed in filename we will strip it off. */
- /* -------------------------------------------------------------------- */
- pszBasename = ( char * ) malloc( strlen( pszFilename ) + 5 );
- strcpy( pszBasename, pszFilename );
- for ( i = strlen( pszBasename ) - 1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if ( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
- pszFullname = ( char * ) malloc( strlen( pszBasename ) + 5 );
- sprintf( pszFullname, "%s.dbf", pszBasename );
-
- psDBF = ( DBFHandle ) calloc( 1, sizeof( DBFInfo ) );
- psDBF->fp = fopen( pszFullname, pszAccess );
-
- if ( psDBF->fp == NULL )
- {
- sprintf( pszFullname, "%s.DBF", pszBasename );
- psDBF->fp = fopen( pszFullname, pszAccess );
- }
-
- free( pszBasename );
- free( pszFullname );
-
- if ( psDBF->fp == NULL )
- {
- free( psDBF );
- return( NULL );
- }
-
- psDBF->bNoHeader = FALSE;
- psDBF->nCurrentRecord = -1;
- psDBF->bCurrentRecordModified = FALSE;
-
- /* -------------------------------------------------------------------- */
- /* Read Table Header info */
- /* -------------------------------------------------------------------- */
- pabyBuf = ( unsigned char * ) malloc( 500 );
- if ( fread( pabyBuf, 32, 1, psDBF->fp ) != 1 )
- {
- fclose( psDBF->fp );
- free( pabyBuf );
- free( psDBF );
- return NULL;
- }
-
- psDBF->nRecords =
- pabyBuf[4] + pabyBuf[5] * 256 + pabyBuf[6] * 256 * 256 + pabyBuf[7] * 256 * 256 * 256;
-
- psDBF->nHeaderLength = nHeadLen = pabyBuf[8] + pabyBuf[9] * 256;
- psDBF->nRecordLength = nRecLen = pabyBuf[10] + pabyBuf[11] * 256;
-
- psDBF->nFields = nFields = ( nHeadLen - 32 ) / 32;
-
- psDBF->pszCurrentRecord = ( char * ) malloc( nRecLen );
-
- /* -------------------------------------------------------------------- */
- /* Read in Field Definitions */
- /* -------------------------------------------------------------------- */
-
- pabyBuf = psDBF->pszHeader = ( unsigned char * ) SfRealloc( pabyBuf, nHeadLen );
-
- fseek( psDBF->fp, 32, 0 );
- if ( fread( pabyBuf, nHeadLen - 32, 1, psDBF->fp ) != 1 )
- {
- fclose( psDBF->fp );
- free( pabyBuf );
- free( psDBF );
- return NULL;
- }
-
- psDBF->panFieldOffset = ( int * ) malloc( sizeof( int ) * nFields );
- psDBF->panFieldSize = ( int * ) malloc( sizeof( int ) * nFields );
- psDBF->panFieldDecimals = ( int * ) malloc( sizeof( int ) * nFields );
- psDBF->pachFieldType = ( char * ) malloc( sizeof( char ) * nFields );
-
- for ( iField = 0; iField < nFields; iField++ )
- {
- unsigned char *pabyFInfo;
-
- pabyFInfo = pabyBuf + iField * 32;
-
- if ( pabyFInfo[11] == 'N' || pabyFInfo[11] == 'F' )
- {
- psDBF->panFieldSize[iField] = pabyFInfo[16];
- psDBF->panFieldDecimals[iField] = pabyFInfo[17];
- }
- else
- {
- psDBF->panFieldSize[iField] = pabyFInfo[16] + pabyFInfo[17] * 256;
- psDBF->panFieldDecimals[iField] = 0;
- }
-
- psDBF->pachFieldType[iField] = ( char ) pabyFInfo[11];
- if ( iField == 0 )
- psDBF->panFieldOffset[iField] = 1;
- else
- psDBF->panFieldOffset[iField] =
- psDBF->panFieldOffset[iField-1] + psDBF->panFieldSize[iField-1];
- }
-
- return( psDBF );
-}
-
-/************************************************************************/
-/* DBFClose() */
-/************************************************************************/
-
-void SHPAPI_CALL
-DBFClose( DBFHandle psDBF )
-{
- /* -------------------------------------------------------------------- */
- /* Write out header if not already written. */
- /* -------------------------------------------------------------------- */
- if ( psDBF->bNoHeader )
- DBFWriteHeader( psDBF );
-
- DBFFlushRecord( psDBF );
-
- /* -------------------------------------------------------------------- */
- /* Update last access date, and number of records if we have */
- /* write access. */
- /* -------------------------------------------------------------------- */
- if ( psDBF->bUpdated )
- {
- unsigned char abyFileHeader[32];
-
- fseek( psDBF->fp, 0, 0 );
- fread( abyFileHeader, 32, 1, psDBF->fp );
-
- abyFileHeader[1] = 95; /* YY */
- abyFileHeader[2] = 7; /* MM */
- abyFileHeader[3] = 26; /* DD */
-
- abyFileHeader[4] = psDBF->nRecords % 256;
- abyFileHeader[5] = ( psDBF->nRecords / 256 ) % 256;
- abyFileHeader[6] = ( psDBF->nRecords / ( 256 * 256 ) ) % 256;
- abyFileHeader[7] = ( psDBF->nRecords / ( 256 * 256 * 256 ) ) % 256;
-
- fseek( psDBF->fp, 0, 0 );
- fwrite( abyFileHeader, 32, 1, psDBF->fp );
- }
-
- /* -------------------------------------------------------------------- */
- /* Close, and free resources. */
- /* -------------------------------------------------------------------- */
- fclose( psDBF->fp );
-
- if ( psDBF->panFieldOffset != NULL )
- {
- free( psDBF->panFieldOffset );
- free( psDBF->panFieldSize );
- free( psDBF->panFieldDecimals );
- free( psDBF->pachFieldType );
- }
-
- free( psDBF->pszHeader );
- free( psDBF->pszCurrentRecord );
-
- free( psDBF );
-
- if ( pszStringField != NULL )
- {
- free( pszStringField );
- pszStringField = NULL;
- nStringFieldLen = 0;
- }
-}
-
-/************************************************************************/
-/* DBFCreate() */
-/* */
-/* Create a new .dbf file. */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFCreate( const char *pszFilename )
-
-{
- DBFHandle psDBF;
- FILE *fp;
- char *pszFullname, *pszBasename;
- int i;
-
- /* -------------------------------------------------------------------- */
- /* Compute the base (layer) name. If there is any extension */
- /* on the passed in filename we will strip it off. */
- /* -------------------------------------------------------------------- */
- pszBasename = ( char * ) malloc( strlen( pszFilename ) + 5 );
- strcpy( pszBasename, pszFilename );
- for ( i = strlen( pszBasename ) - 1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if ( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
- pszFullname = ( char * ) malloc( strlen( pszBasename ) + 5 );
- sprintf( pszFullname, "%s.dbf", pszBasename );
- free( pszBasename );
-
- /* -------------------------------------------------------------------- */
- /* Create the file. */
- /* -------------------------------------------------------------------- */
- fp = fopen( pszFullname, "wb" );
- if ( fp == NULL )
- {
- free( pszFullname );
- return( NULL );
- }
-
- fputc( 0, fp );
- fclose( fp );
-
- fp = fopen( pszFullname, "rb+" );
- if ( fp == NULL )
- {
- free( pszFullname );
- return( NULL );
- }
-
- free( pszFullname );
-
- /* -------------------------------------------------------------------- */
- /* Create the info structure. */
- /* -------------------------------------------------------------------- */
- psDBF = ( DBFHandle ) malloc( sizeof( DBFInfo ) );
-
- psDBF->fp = fp;
- psDBF->nRecords = 0;
- psDBF->nFields = 0;
- psDBF->nRecordLength = 1;
- psDBF->nHeaderLength = 33;
-
- psDBF->panFieldOffset = NULL;
- psDBF->panFieldSize = NULL;
- psDBF->panFieldDecimals = NULL;
- psDBF->pachFieldType = NULL;
- psDBF->pszHeader = NULL;
-
- psDBF->nCurrentRecord = -1;
- psDBF->bCurrentRecordModified = FALSE;
- psDBF->pszCurrentRecord = NULL;
-
- psDBF->bNoHeader = TRUE;
-
- return( psDBF );
-}
-
-/************************************************************************/
-/* DBFAddField() */
-/* */
-/* Add a field to a newly created .dbf file before any records */
-/* are written. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFAddField( DBFHandle psDBF, const char * pszFieldName,
- DBFFieldType eType, int nWidth, int nDecimals )
-
-{
- char *pszFInfo;
- int i;
-
- /* -------------------------------------------------------------------- */
- /* Do some checking to ensure we can add records to this file. */
- /* -------------------------------------------------------------------- */
- if ( psDBF->nRecords > 0 )
- return( -1 );
-
- if ( !psDBF->bNoHeader )
- return( -1 );
-
- if ( eType != FTDouble && nDecimals != 0 )
- return( -1 );
-
- if ( nWidth < 1 )
- return -1;
-
- /* -------------------------------------------------------------------- */
- /* SfRealloc all the arrays larger to hold the additional field */
- /* information. */
- /* -------------------------------------------------------------------- */
- psDBF->nFields++;
-
- psDBF->panFieldOffset = ( int * )
- SfRealloc( psDBF->panFieldOffset, sizeof( int ) * psDBF->nFields );
-
- psDBF->panFieldSize = ( int * )
- SfRealloc( psDBF->panFieldSize, sizeof( int ) * psDBF->nFields );
-
- psDBF->panFieldDecimals = ( int * )
- SfRealloc( psDBF->panFieldDecimals, sizeof( int ) * psDBF->nFields );
-
- psDBF->pachFieldType = ( char * )
- SfRealloc( psDBF->pachFieldType, sizeof( char ) * psDBF->nFields );
-
- /* -------------------------------------------------------------------- */
- /* Assign the new field information fields. */
- /* -------------------------------------------------------------------- */
- psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength;
- psDBF->nRecordLength += nWidth;
- psDBF->panFieldSize[psDBF->nFields-1] = nWidth;
- psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals;
-
- if ( eType == FTLogical )
- psDBF->pachFieldType[psDBF->nFields-1] = 'L';
- else if ( eType == FTString )
- psDBF->pachFieldType[psDBF->nFields-1] = 'C';
- else
- psDBF->pachFieldType[psDBF->nFields-1] = 'N';
-
- /* -------------------------------------------------------------------- */
- /* Extend the required header information. */
- /* -------------------------------------------------------------------- */
- psDBF->nHeaderLength += 32;
- psDBF->bUpdated = FALSE;
-
- psDBF->pszHeader = ( char * ) SfRealloc( psDBF->pszHeader, psDBF->nFields * 32 );
-
- pszFInfo = psDBF->pszHeader + 32 * ( psDBF->nFields - 1 );
-
- for ( i = 0; i < 32; i++ )
- pszFInfo[i] = '\0';
-
- if (( int ) strlen( pszFieldName ) < 10 )
- strncpy( pszFInfo, pszFieldName, strlen( pszFieldName ) );
- else
- strncpy( pszFInfo, pszFieldName, 10 );
-
- pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1];
-
- if ( eType == FTString )
- {
- pszFInfo[16] = nWidth % 256;
- pszFInfo[17] = nWidth / 256;
- }
- else
- {
- pszFInfo[16] = nWidth;
- pszFInfo[17] = nDecimals;
- }
-
- /* -------------------------------------------------------------------- */
- /* Make the current record buffer appropriately larger. */
- /* -------------------------------------------------------------------- */
- psDBF->pszCurrentRecord = ( char * ) SfRealloc( psDBF->pszCurrentRecord,
- psDBF->nRecordLength );
-
- return( psDBF->nFields - 1 );
-}
-
-/************************************************************************/
-/* DBFReadAttribute() */
-/* */
-/* Read one of the attribute fields of a record. */
-/************************************************************************/
-
-static void *DBFReadAttribute( DBFHandle psDBF, int hEntity, int iField,
- char chReqType )
-
-{
- int nRecordOffset;
- unsigned char *pabyRec;
- void *pReturnField = NULL;
-
- static double dDoubleField;
-
- /* -------------------------------------------------------------------- */
- /* Verify selection. */
- /* -------------------------------------------------------------------- */
- if ( hEntity < 0 || hEntity >= psDBF->nRecords )
- return( NULL );
-
- if ( iField < 0 || iField >= psDBF->nFields )
- return( NULL );
-
- /* -------------------------------------------------------------------- */
- /* Have we read the record? */
- /* -------------------------------------------------------------------- */
- if ( psDBF->nCurrentRecord != hEntity )
- {
- DBFFlushRecord( psDBF );
-
- nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
- if ( fseek( psDBF->fp, nRecordOffset, 0 ) != 0 )
- {
- fprintf( stderr, "fseek(%d) failed on DBF file.\n",
- nRecordOffset );
- return NULL;
- }
-
- if ( fread( psDBF->pszCurrentRecord, psDBF->nRecordLength,
- 1, psDBF->fp ) != 1 )
- {
- fprintf( stderr, "fread(%d) failed on DBF file.\n",
- psDBF->nRecordLength );
- return NULL;
- }
-
- psDBF->nCurrentRecord = hEntity;
- }
-
- pabyRec = ( unsigned char * ) psDBF->pszCurrentRecord;
-
- /* -------------------------------------------------------------------- */
- /* Ensure our field buffer is large enough to hold this buffer. */
- /* -------------------------------------------------------------------- */
- if ( psDBF->panFieldSize[iField] + 1 > nStringFieldLen )
- {
- nStringFieldLen = psDBF->panFieldSize[iField] * 2 + 10;
- pszStringField = ( char * ) SfRealloc( pszStringField, nStringFieldLen );
- }
-
- /* -------------------------------------------------------------------- */
- /* Extract the requested field. */
- /* -------------------------------------------------------------------- */
- strncpy( pszStringField,
- (( const char * ) pabyRec ) + psDBF->panFieldOffset[iField],
- psDBF->panFieldSize[iField] );
- pszStringField[psDBF->panFieldSize[iField]] = '\0';
-
- pReturnField = pszStringField;
-
- /* -------------------------------------------------------------------- */
- /* Decode the field. */
- /* -------------------------------------------------------------------- */
- if ( chReqType == 'N' )
- {
- dDoubleField = atof( pszStringField );
-
- pReturnField = &dDoubleField;
- }
-
- /* -------------------------------------------------------------------- */
- /* Should we trim white space off the string attribute value? */
- /* -------------------------------------------------------------------- */
-#ifdef TRIM_DBF_WHITESPACE
- else
- {
- char *pchSrc, *pchDst;
-
- pchDst = pchSrc = pszStringField;
- while ( *pchSrc == ' ' )
- pchSrc++;
-
- while ( *pchSrc != '\0' )
- *( pchDst++ ) = *( pchSrc++ );
- *pchDst = '\0';
-
- while ( pchDst != pszStringField && *( --pchDst ) == ' ' )
- *pchDst = '\0';
- }
-#endif
-
- return( pReturnField );
-}
-
-/************************************************************************/
-/* DBFReadIntAttribute() */
-/* */
-/* Read an integer attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFReadIntegerAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- double *pdValue;
-
- pdValue = ( double * ) DBFReadAttribute( psDBF, iRecord, iField, 'N' );
-
- if ( pdValue == NULL )
- return 0;
- else
- return(( int ) *pdValue );
-}
-
-/************************************************************************/
-/* DBFReadDoubleAttribute() */
-/* */
-/* Read a double attribute. */
-/************************************************************************/
-
-double SHPAPI_CALL
-DBFReadDoubleAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- double *pdValue;
-
- pdValue = ( double * ) DBFReadAttribute( psDBF, iRecord, iField, 'N' );
-
- if ( pdValue == NULL )
- return 0.0;
- else
- return( *pdValue );
-}
-
-/************************************************************************/
-/* DBFReadStringAttribute() */
-/* */
-/* Read a string attribute. */
-/************************************************************************/
-
-const char SHPAPI_CALL1( * )
-DBFReadStringAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- return(( const char * ) DBFReadAttribute( psDBF, iRecord, iField, 'C' ) );
-}
-
-/************************************************************************/
-/* DBFReadLogicalAttribute() */
-/* */
-/* Read a logical attribute. */
-/************************************************************************/
-
-const char SHPAPI_CALL1( * )
-DBFReadLogicalAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- return(( const char * ) DBFReadAttribute( psDBF, iRecord, iField, 'L' ) );
-}
-
-/************************************************************************/
-/* DBFIsAttributeNULL() */
-/* */
-/* Return TRUE if value for field is NULL. */
-/* */
-/* Contributed by Jim Matthews. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFIsAttributeNULL( DBFHandle psDBF, int iRecord, int iField )
-
-{
- const char *pszValue;
-
- pszValue = DBFReadStringAttribute( psDBF, iRecord, iField );
-
- switch ( psDBF->pachFieldType[iField] )
- {
- case 'N':
- case 'F':
- /* NULL numeric fields have value "****************" */
- return pszValue[0] == '*';
-
- case 'D':
- /* NULL date fields have value "00000000" */
- return strncmp( pszValue, "00000000", 8 ) == 0;
-
- case 'L':
- /* NULL boolean fields have value "?" */
- return pszValue[0] == '?';
-
- default:
- /* empty string fields are considered NULL */
- return strlen( pszValue ) == 0;
- }
-}
-
-/************************************************************************/
-/* DBFGetFieldCount() */
-/* */
-/* Return the number of fields in this table. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFGetFieldCount( DBFHandle psDBF )
-
-{
- return( psDBF->nFields );
-}
-
-/************************************************************************/
-/* DBFGetRecordCount() */
-/* */
-/* Return the number of records in this table. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFGetRecordCount( DBFHandle psDBF )
-
-{
- return( psDBF->nRecords );
-}
-
-/************************************************************************/
-/* DBFGetFieldInfo() */
-/* */
-/* Return any requested information about the field. */
-/************************************************************************/
-
-DBFFieldType SHPAPI_CALL
-DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName,
- int * pnWidth, int * pnDecimals )
-
-{
- if ( iField < 0 || iField >= psDBF->nFields )
- return( FTInvalid );
-
- if ( pnWidth != NULL )
- *pnWidth = psDBF->panFieldSize[iField];
-
- if ( pnDecimals != NULL )
- *pnDecimals = psDBF->panFieldDecimals[iField];
-
- if ( pszFieldName != NULL )
- {
- int i;
-
- strncpy( pszFieldName, ( char * ) psDBF->pszHeader + iField*32, 11 );
- pszFieldName[11] = '\0';
- for ( i = 10; i > 0 && pszFieldName[i] == ' '; i-- )
- pszFieldName[i] = '\0';
- }
-
- if ( psDBF->pachFieldType[iField] == 'L' )
- return( FTLogical );
-
- else if ( psDBF->pachFieldType[iField] == 'N'
- || psDBF->pachFieldType[iField] == 'F'
- || psDBF->pachFieldType[iField] == 'D' )
- {
- if ( psDBF->panFieldDecimals[iField] > 0 )
- return( FTDouble );
- else
- return( FTInteger );
- }
- else
- {
- return( FTString );
- }
-}
-
-/************************************************************************/
-/* DBFWriteAttribute() */
-/* */
-/* Write an attribute record to the file. */
-/************************************************************************/
-
-static int DBFWriteAttribute( DBFHandle psDBF, int hEntity, int iField,
- void * pValue )
-
-{
- int nRecordOffset, i, j, nRetResult = TRUE;
- unsigned char *pabyRec;
- char szSField[400], szFormat[20];
-
- /* -------------------------------------------------------------------- */
- /* Is this a valid record? */
- /* -------------------------------------------------------------------- */
- if ( hEntity < 0 || hEntity > psDBF->nRecords )
- return( FALSE );
-
- if ( psDBF->bNoHeader )
- DBFWriteHeader( psDBF );
-
- /* -------------------------------------------------------------------- */
- /* Is this a brand new record? */
- /* -------------------------------------------------------------------- */
- if ( hEntity == psDBF->nRecords )
- {
- DBFFlushRecord( psDBF );
-
- psDBF->nRecords++;
- for ( i = 0; i < psDBF->nRecordLength; i++ )
- psDBF->pszCurrentRecord[i] = ' ';
-
- psDBF->nCurrentRecord = hEntity;
- }
-
- /* -------------------------------------------------------------------- */
- /* Is this an existing record, but different than the last one */
- /* we accessed? */
- /* -------------------------------------------------------------------- */
- if ( psDBF->nCurrentRecord != hEntity )
- {
- DBFFlushRecord( psDBF );
-
- nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
- fseek( psDBF->fp, nRecordOffset, 0 );
- fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
- psDBF->nCurrentRecord = hEntity;
- }
-
- pabyRec = ( unsigned char * ) psDBF->pszCurrentRecord;
-
- psDBF->bCurrentRecordModified = TRUE;
- psDBF->bUpdated = TRUE;
-
- /* -------------------------------------------------------------------- */
- /* Translate NULL value to valid DBF file representation. */
- /* */
- /* Contributed by Jim Matthews. */
- /* -------------------------------------------------------------------- */
- if ( pValue == NULL )
- {
- switch ( psDBF->pachFieldType[iField] )
- {
- case 'N':
- case 'F':
- /* NULL numeric fields have value "****************" */
- memset(( char * )( pabyRec + psDBF->panFieldOffset[iField] ), '*',
- psDBF->panFieldSize[iField] );
- break;
-
- case 'D':
- /* NULL date fields have value "00000000" */
- memset(( char * )( pabyRec + psDBF->panFieldOffset[iField] ), '0',
- psDBF->panFieldSize[iField] );
- break;
-
- case 'L':
- /* NULL boolean fields have value "?" */
- memset(( char * )( pabyRec + psDBF->panFieldOffset[iField] ), '?',
- psDBF->panFieldSize[iField] );
- break;
-
- default:
- /* empty string fields are considered NULL */
- memset(( char * )( pabyRec + psDBF->panFieldOffset[iField] ), '\0',
- psDBF->panFieldSize[iField] );
- break;
- }
- return TRUE;
- }
-
- /* -------------------------------------------------------------------- */
- /* Assign all the record fields. */
- /* -------------------------------------------------------------------- */
- switch ( psDBF->pachFieldType[iField] )
- {
- case 'D':
- case 'N':
- case 'F':
- if ( psDBF->panFieldDecimals[iField] == 0 )
- {
- int nWidth = psDBF->panFieldSize[iField];
-
- if ( sizeof( szSField ) - 2 < nWidth )
- nWidth = sizeof( szSField ) - 2;
-
- sprintf( szFormat, "%%%dd", nWidth );
- sprintf( szSField, szFormat, ( int ) *(( double * ) pValue ) );
- if (( int )strlen( szSField ) > psDBF->panFieldSize[iField] )
- {
- szSField[psDBF->panFieldSize[iField]] = '\0';
- nRetResult = FALSE;
- }
-
- strncpy(( char * )( pabyRec + psDBF->panFieldOffset[iField] ),
- szSField, strlen( szSField ) );
- }
- else
- {
- int nWidth = psDBF->panFieldSize[iField];
-
- if ( sizeof( szSField ) - 2 < nWidth )
- nWidth = sizeof( szSField ) - 2;
-
- sprintf( szFormat, "%%%d.%df",
- nWidth, psDBF->panFieldDecimals[iField] );
- sprintf( szSField, szFormat, *(( double * ) pValue ) );
- if (( int ) strlen( szSField ) > psDBF->panFieldSize[iField] )
- {
- szSField[psDBF->panFieldSize[iField]] = '\0';
- nRetResult = FALSE;
- }
- strncpy(( char * )( pabyRec + psDBF->panFieldOffset[iField] ),
- szSField, strlen( szSField ) );
- }
- break;
-
- case 'L':
- if ( psDBF->panFieldSize[iField] >= 1 &&
- ( *( char* )pValue == 'F' || *( char* )pValue == 'T' ) )
- *( pabyRec + psDBF->panFieldOffset[iField] ) = *( char* )pValue;
- break;
-
- default:
- if (( int ) strlen(( char * ) pValue ) > psDBF->panFieldSize[iField] )
- {
- j = psDBF->panFieldSize[iField];
- nRetResult = FALSE;
- }
- else
- {
- memset( pabyRec + psDBF->panFieldOffset[iField], ' ',
- psDBF->panFieldSize[iField] );
- j = strlen(( char * ) pValue );
- }
-
- strncpy(( char * )( pabyRec + psDBF->panFieldOffset[iField] ),
- ( char * ) pValue, j );
- break;
- }
-
- return( nRetResult );
-}
-
-/************************************************************************/
-/* DBFWriteAttributeDirectly() */
-/* */
-/* Write an attribute record to the file, but without any */
-/* reformatting based on type. The provided buffer is written */
-/* as is to the field position in the record. */
-/************************************************************************/
-
-int DBFWriteAttributeDirectly( DBFHandle psDBF, int hEntity, int iField,
- void * pValue )
-
-{
- int nRecordOffset, i, j;
- unsigned char *pabyRec;
-
- /* -------------------------------------------------------------------- */
- /* Is this a valid record? */
- /* -------------------------------------------------------------------- */
- if ( hEntity < 0 || hEntity > psDBF->nRecords )
- return( FALSE );
-
- if ( psDBF->bNoHeader )
- DBFWriteHeader( psDBF );
-
- /* -------------------------------------------------------------------- */
- /* Is this a brand new record? */
- /* -------------------------------------------------------------------- */
- if ( hEntity == psDBF->nRecords )
- {
- DBFFlushRecord( psDBF );
-
- psDBF->nRecords++;
- for ( i = 0; i < psDBF->nRecordLength; i++ )
- psDBF->pszCurrentRecord[i] = ' ';
-
- psDBF->nCurrentRecord = hEntity;
- }
-
- /* -------------------------------------------------------------------- */
- /* Is this an existing record, but different than the last one */
- /* we accessed? */
- /* -------------------------------------------------------------------- */
- if ( psDBF->nCurrentRecord != hEntity )
- {
- DBFFlushRecord( psDBF );
-
- nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
- fseek( psDBF->fp, nRecordOffset, 0 );
- fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
- psDBF->nCurrentRecord = hEntity;
- }
-
- pabyRec = ( unsigned char * ) psDBF->pszCurrentRecord;
-
- /* -------------------------------------------------------------------- */
- /* Assign all the record fields. */
- /* -------------------------------------------------------------------- */
- if (( int )strlen(( char * ) pValue ) > psDBF->panFieldSize[iField] )
- j = psDBF->panFieldSize[iField];
- else
- {
- memset( pabyRec + psDBF->panFieldOffset[iField], ' ',
- psDBF->panFieldSize[iField] );
- j = strlen(( char * ) pValue );
- }
-
- strncpy(( char * )( pabyRec + psDBF->panFieldOffset[iField] ),
- ( char * ) pValue, j );
-
- psDBF->bCurrentRecordModified = TRUE;
- psDBF->bUpdated = TRUE;
-
- return( TRUE );
-}
-
-/************************************************************************/
-/* DBFWriteDoubleAttribute() */
-/* */
-/* Write a double attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteDoubleAttribute( DBFHandle psDBF, int iRecord, int iField,
- double dValue )
-
-{
- return( DBFWriteAttribute( psDBF, iRecord, iField, ( void * ) &dValue ) );
-}
-
-/************************************************************************/
-/* DBFWriteIntegerAttribute() */
-/* */
-/* Write a integer attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteIntegerAttribute( DBFHandle psDBF, int iRecord, int iField,
- int nValue )
-
-{
- double dValue = nValue;
-
- return( DBFWriteAttribute( psDBF, iRecord, iField, ( void * ) &dValue ) );
-}
-
-/************************************************************************/
-/* DBFWriteStringAttribute() */
-/* */
-/* Write a string attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteStringAttribute( DBFHandle psDBF, int iRecord, int iField,
- const char * pszValue )
-
-{
- return( DBFWriteAttribute( psDBF, iRecord, iField, ( void * ) pszValue ) );
-}
-
-/************************************************************************/
-/* DBFWriteNULLAttribute() */
-/* */
-/* Write a string attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteNULLAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- return( DBFWriteAttribute( psDBF, iRecord, iField, NULL ) );
-}
-
-/************************************************************************/
-/* DBFWriteLogicalAttribute() */
-/* */
-/* Write a logical attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteLogicalAttribute( DBFHandle psDBF, int iRecord, int iField,
- const char lValue )
-
-{
- return( DBFWriteAttribute( psDBF, iRecord, iField, ( void * )( &lValue ) ) );
-}
-
-/************************************************************************/
-/* DBFWriteTuple() */
-/* */
-/* Write an attribute record to the file. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteTuple( DBFHandle psDBF, int hEntity, void * pRawTuple )
-
-{
- int nRecordOffset, i;
- unsigned char *pabyRec;
-
- /* -------------------------------------------------------------------- */
- /* Is this a valid record? */
- /* -------------------------------------------------------------------- */
- if ( hEntity < 0 || hEntity > psDBF->nRecords )
- return( FALSE );
-
- if ( psDBF->bNoHeader )
- DBFWriteHeader( psDBF );
-
- /* -------------------------------------------------------------------- */
- /* Is this a brand new record? */
- /* -------------------------------------------------------------------- */
- if ( hEntity == psDBF->nRecords )
- {
- DBFFlushRecord( psDBF );
-
- psDBF->nRecords++;
- for ( i = 0; i < psDBF->nRecordLength; i++ )
- psDBF->pszCurrentRecord[i] = ' ';
-
- psDBF->nCurrentRecord = hEntity;
- }
-
- /* -------------------------------------------------------------------- */
- /* Is this an existing record, but different than the last one */
- /* we accessed? */
- /* -------------------------------------------------------------------- */
- if ( psDBF->nCurrentRecord != hEntity )
- {
- DBFFlushRecord( psDBF );
-
- nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
- fseek( psDBF->fp, nRecordOffset, 0 );
- fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
- psDBF->nCurrentRecord = hEntity;
- }
-
- pabyRec = ( unsigned char * ) psDBF->pszCurrentRecord;
-
- memcpy( pabyRec, pRawTuple, psDBF->nRecordLength );
-
- psDBF->bCurrentRecordModified = TRUE;
- psDBF->bUpdated = TRUE;
-
- return( TRUE );
-}
-
-/************************************************************************/
-/* DBFReadTuple() */
-/* */
-/* Read one of the attribute fields of a record. */
-/************************************************************************/
-
-const char SHPAPI_CALL1( * )
-DBFReadTuple( DBFHandle psDBF, int hEntity )
-
-{
- int nRecordOffset;
- unsigned char *pabyRec;
- static char *pReturnTuple = NULL;
-
- static int nTupleLen = 0;
-
- /* -------------------------------------------------------------------- */
- /* Have we read the record? */
- /* -------------------------------------------------------------------- */
- if ( hEntity < 0 || hEntity >= psDBF->nRecords )
- return( NULL );
-
- if ( psDBF->nCurrentRecord != hEntity )
- {
- DBFFlushRecord( psDBF );
-
- nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
-
- fseek( psDBF->fp, nRecordOffset, 0 );
- fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
- psDBF->nCurrentRecord = hEntity;
- }
-
- pabyRec = ( unsigned char * ) psDBF->pszCurrentRecord;
-
- if ( nTupleLen < psDBF->nRecordLength )
- {
- nTupleLen = psDBF->nRecordLength;
- pReturnTuple = ( char * ) SfRealloc( pReturnTuple, psDBF->nRecordLength );
- }
-
- memcpy( pReturnTuple, pabyRec, psDBF->nRecordLength );
-
- return( pReturnTuple );
-}
-
-/************************************************************************/
-/* DBFCloneEmpty() */
-/* */
-/* Read one of the attribute fields of a record. */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFCloneEmpty( DBFHandle psDBF, const char * pszFilename )
-{
- DBFHandle newDBF;
-
- newDBF = DBFCreate( pszFilename );
- if ( newDBF == NULL )
- return ( NULL );
-
- newDBF->pszHeader = ( char * ) malloc( 32 * psDBF->nFields );
- memcpy( newDBF->pszHeader, psDBF->pszHeader, 32 * psDBF->nFields );
-
- newDBF->nFields = psDBF->nFields;
- newDBF->nRecordLength = psDBF->nRecordLength;
- newDBF->nHeaderLength = 32 * ( psDBF->nFields + 1 );
-
- newDBF->panFieldOffset = ( int * ) malloc( sizeof( int ) * psDBF->nFields );
- memcpy( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof( int ) * psDBF->nFields );
- newDBF->panFieldSize = ( int * ) malloc( sizeof( int ) * psDBF->nFields );
- memcpy( newDBF->panFieldSize, psDBF->panFieldSize, sizeof( int ) * psDBF->nFields );
- newDBF->panFieldDecimals = ( int * ) malloc( sizeof( int ) * psDBF->nFields );
- memcpy( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof( int ) * psDBF->nFields );
- newDBF->pachFieldType = ( char * ) malloc( sizeof( int ) * psDBF->nFields );
- memcpy( newDBF->pachFieldType, psDBF->pachFieldType, sizeof( int ) * psDBF->nFields );
-
- newDBF->bNoHeader = TRUE;
- newDBF->bUpdated = TRUE;
-
- DBFWriteHeader( newDBF );
- DBFClose( newDBF );
-
- newDBF = DBFOpen( pszFilename, "rb+" );
-
- return ( newDBF );
-}
-
-/************************************************************************/
-/* DBFGetNativeFieldType() */
-/* */
-/* Return the DBase field type for the specified field. */
-/* */
-/* Value can be one of: 'C' (String), 'D' (Date), 'F' (Float), */
-/* 'N' (Numeric, with or without decimal), */
-/* 'L' (Logical), */
-/* 'M' (Memo: 10 digits .DBT block ptr) */
-/************************************************************************/
-
-char SHPAPI_CALL
-DBFGetNativeFieldType( DBFHandle psDBF, int iField )
-
-{
- if ( iField >= 0 && iField < psDBF->nFields )
- return psDBF->pachFieldType[iField];
-
- return ' ';
-}
-
-/************************************************************************/
-/* str_to_upper() */
-/************************************************************************/
-
-static void str_to_upper( char *string )
-{
- int len;
- short i = -1;
-
- len = strlen( string );
-
- while ( ++i < len )
- if ( isalpha( string[i] ) && islower( string[i] ) )
- string[i] = toupper(( int )string[i] );
-}
-
-/************************************************************************/
-/* DBFGetFieldIndex() */
-/* */
-/* Get the index number for a field in a .dbf file. */
-/* */
-/* Contributed by Jim Matthews. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFGetFieldIndex( DBFHandle psDBF, const char *pszFieldName )
-
-{
- char name[12], name1[12], name2[12];
- int i;
-
- strncpy( name1, pszFieldName, 11 );
- name1[11] = '\0';
- str_to_upper( name1 );
-
- for ( i = 0; i < DBFGetFieldCount( psDBF ); i++ )
- {
- DBFGetFieldInfo( psDBF, i, name, NULL, NULL );
- strncpy( name2, name, 11 );
- str_to_upper( name2 );
-
- if ( !strncmp( name1, name2, 10 ) )
- return( i );
- }
- return( -1 );
-}
diff --git a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shapefil.h b/src/plugins/dxf2shp_converter/shapelib-1.2.10/shapefil.h
deleted file mode 100644
index bf07768..0000000
--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shapefil.h
+++ /dev/null
@@ -1,486 +0,0 @@
-#ifndef _SHAPEFILE_H_INCLUDED
-#define _SHAPEFILE_H_INCLUDED
-
-/******************************************************************************
- * $Id: shapefil.h,v 1.26 2002/09/29 00:00:08 warmerda Exp $
- *
- * Project: Shapelib
- * Purpose: Primary include file for Shapelib.
- * Author: Frank Warmerdam, warmerdam at pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Frank Warmerdam
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log: shapefil.h,v $
- * Revision 1.26 2002/09/29 00:00:08 warmerda
- * added FTLogical and logical attribute read/write calls
- *
- * Revision 1.25 2002/05/07 13:46:30 warmerda
- * added DBFWriteAttributeDirectly().
- *
- * Revision 1.24 2002/04/10 16:59:54 warmerda
- * added SHPRewindObject
- *
- * Revision 1.23 2002/01/15 14:36:07 warmerda
- * updated email address
- *
- * Revision 1.22 2002/01/15 14:32:00 warmerda
- * try to improve SHPAPI_CALL docs
- *
- * Revision 1.21 2001/11/01 16:29:55 warmerda
- * move pabyRec into SHPInfo for thread safety
- *
- * Revision 1.20 2001/07/20 13:06:02 warmerda
- * fixed SHPAPI attribute for SHPTreeFindLikelyShapes
- *
- * Revision 1.19 2001/05/31 19:20:13 warmerda
- * added DBFGetFieldIndex()
- *
- * Revision 1.18 2001/05/31 18:15:40 warmerda
- * Added support for NULL fields in DBF files
- *
- * Revision 1.17 2001/05/23 13:36:52 warmerda
- * added use of SHPAPI_CALL
- *
- * Revision 1.16 2000/09/25 14:15:59 warmerda
- * added DBFGetNativeFieldType()
- *
- * Revision 1.15 2000/02/16 16:03:51 warmerda
- * added null shape support
- *
- * Revision 1.14 1999/11/05 14:12:05 warmerda
- * updated license terms
- *
- * Revision 1.13 1999/06/02 18:24:21 warmerda
- * added trimming code
- *
- * Revision 1.12 1999/06/02 17:56:12 warmerda
- * added quad'' subnode support for trees
- *
- * Revision 1.11 1999/05/18 19:11:11 warmerda
- * Added example searching capability
- *
- * Revision 1.10 1999/05/18 17:49:38 warmerda
- * added initial quadtree support
- *
- * Revision 1.9 1999/05/11 03:19:28 warmerda
- * added new Tuple api, and improved extension handling - add from candrsn
- *
- * Revision 1.8 1999/03/23 17:22:27 warmerda
- * Added extern "C" protection for C++ users of shapefil.h.
- *
- * Revision 1.7 1998/12/31 15:31:07 warmerda
- * Added the TRIM_DBF_WHITESPACE and DISABLE_MULTIPATCH_MEASURE options.
- *
- * Revision 1.6 1998/12/03 15:48:15 warmerda
- * Added SHPCalculateExtents().
- *
- * Revision 1.5 1998/11/09 20:57:16 warmerda
- * Altered SHPGetInfo() call.
- *
- * Revision 1.4 1998/11/09 20:19:33 warmerda
- * Added 3D support, and use of SHPObject.
- *
- * Revision 1.3 1995/08/23 02:24:05 warmerda
- * Added support for reading bounds.
- *
- * Revision 1.2 1995/08/04 03:17:39 warmerda
- * Added header.
- *
- */
-
-#include <stdio.h>
-
-#ifdef USE_DBMALLOC
-#include <dbmalloc.h>
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /************************************************************************/
- /* Configuration options. */
- /************************************************************************/
-
- /* -------------------------------------------------------------------- */
- /* Should the DBFReadStringAttribute() strip leading and */
- /* trailing white space? */
- /* -------------------------------------------------------------------- */
-#define TRIM_DBF_WHITESPACE
-
- /* -------------------------------------------------------------------- */
- /* Should we write measure values to the Multipatch object? */
- /* Reportedly ArcView crashes if we do write it, so for now it */
- /* is disabled. */
- /* -------------------------------------------------------------------- */
-#define DISABLE_MULTIPATCH_MEASURE
-
- /* -------------------------------------------------------------------- */
- /* SHPAPI_CALL */
- /* */
- /* The following two macros are present to allow forcing */
- /* various calling conventions on the Shapelib API. */
- /* */
- /* To force __stdcall conventions (needed to call Shapelib */
- /* from Visual Basic and/or Dephi I believe) the makefile could */
- /* be modified to define: */
- /* */
- /* /DSHPAPI_CALL=__stdcall */
- /* */
- /* If it is desired to force export of the Shapelib API without */
- /* using the shapelib.def file, use the following definition. */
- /* */
- /* /DSHAPELIB_DLLEXPORT */
- /* */
- /* To get both at once it will be necessary to hack this */
- /* include file to define: */
- /* */
- /* #define SHPAPI_CALL __declspec(dllexport) __stdcall */
- /* #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall */
- /* */
- /* The complexity of the situtation is partly caused by the */
- /* peculiar requirement of Visual C++ that __stdcall appear */
- /* after any "*"'s in the return value of a function while the */
- /* __declspec(dllexport) must appear before them. */
- /* -------------------------------------------------------------------- */
-
-#ifdef SHAPELIB_DLLEXPORT
-# define SHPAPI_CALL __declspec(dllexport)
-# define SHPAPI_CALL1(x) __declspec(dllexport) x
-#endif
-
-#ifndef SHPAPI_CALL
-# define SHPAPI_CALL
-#endif
-
-#ifndef SHPAPI_CALL1
-# define SHPAPI_CALL1(x) x SHPAPI_CALL
-#endif
-
- /************************************************************************/
- /* SHP Support. */
- /************************************************************************/
- typedef struct
- {
- FILE *fpSHP;
- FILE *fpSHX;
-
- int nShapeType; /* SHPT_* */
-
- int nFileSize; /* SHP file */
-
- int nRecords;
- int nMaxRecords;
- int *panRecOffset;
- int *panRecSize;
-
- double adBoundsMin[4];
- double adBoundsMax[4];
-
- int bUpdated;
-
- unsigned char *pabyRec;
- int nBufSize;
- } SHPInfo;
-
- typedef SHPInfo * SHPHandle;
-
- /* -------------------------------------------------------------------- */
- /* Shape types (nSHPType) */
- /* -------------------------------------------------------------------- */
-#define SHPT_NULL 0
-#define SHPT_POINT 1
-#define SHPT_ARC 3
-#define SHPT_POLYGON 5
-#define SHPT_MULTIPOINT 8
-#define SHPT_POINTZ 11
-#define SHPT_ARCZ 13
-#define SHPT_POLYGONZ 15
-#define SHPT_MULTIPOINTZ 18
-#define SHPT_POINTM 21
-#define SHPT_ARCM 23
-#define SHPT_POLYGONM 25
-#define SHPT_MULTIPOINTM 28
-#define SHPT_MULTIPATCH 31
-
-
- /* -------------------------------------------------------------------- */
- /* Part types - everything but SHPT_MULTIPATCH just uses */
- /* SHPP_RING. */
- /* -------------------------------------------------------------------- */
-
-#define SHPP_TRISTRIP 0
-#define SHPP_TRIFAN 1
-#define SHPP_OUTERRING 2
-#define SHPP_INNERRING 3
-#define SHPP_FIRSTRING 4
-#define SHPP_RING 5
-
- /* -------------------------------------------------------------------- */
- /* SHPObject - represents on shape (without attributes) read */
- /* from the .shp file. */
- /* -------------------------------------------------------------------- */
- typedef struct
- {
- int nSHPType;
-
- int nShapeId; /* -1 is unknown/unassigned */
-
- int nParts;
- int *panPartStart;
- int *panPartType;
-
- int nVertices;
- double *padfX;
- double *padfY;
- double *padfZ;
- double *padfM;
-
- double dfXMin;
- double dfYMin;
- double dfZMin;
- double dfMMin;
-
- double dfXMax;
- double dfYMax;
- double dfZMax;
- double dfMMax;
- } SHPObject;
-
- /* -------------------------------------------------------------------- */
- /* SHP API Prototypes */
- /* -------------------------------------------------------------------- */
- SHPHandle SHPAPI_CALL
- SHPOpen( const char * pszShapeFile, const char * pszAccess );
- SHPHandle SHPAPI_CALL
- SHPCreate( const char * pszShapeFile, int nShapeType );
- void SHPAPI_CALL
- SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
- double * padfMinBound, double * padfMaxBound );
-
- SHPObject SHPAPI_CALL1( * )
- SHPReadObject( SHPHandle hSHP, int iShape );
- int SHPAPI_CALL
- SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
-
- void SHPAPI_CALL
- SHPDestroyObject( SHPObject * psObject );
- void SHPAPI_CALL
- SHPComputeExtents( SHPObject * psObject );
- SHPObject SHPAPI_CALL1( * )
- SHPCreateObject( int nSHPType, int nShapeId,
- int nParts, int * panPartStart, int * panPartType,
- int nVertices, double * padfX, double * padfY,
- double * padfZ, double * padfM );
- SHPObject SHPAPI_CALL1( * )
- SHPCreateSimpleObject( int nSHPType, int nVertices,
- double * padfX, double * padfY, double * padfZ );
-
- int SHPAPI_CALL
- SHPRewindObject( SHPHandle hSHP, SHPObject * psObject );
-
- void SHPAPI_CALL
- SHPClose( SHPHandle hSHP );
-
- const char SHPAPI_CALL1( * )
- SHPTypeName( int nSHPType );
- const char SHPAPI_CALL1( * )
- SHPPartTypeName( int nPartType );
-
- /* -------------------------------------------------------------------- */
- /* Shape quadtree indexing API. */
- /* -------------------------------------------------------------------- */
-
- /* this can be two or four for binary or quad tree */
-#define MAX_SUBNODE 4
-
- typedef struct shape_tree_node
- {
- /* region covered by this node */
- double adfBoundsMin[4];
- double adfBoundsMax[4];
-
- /* list of shapes stored at this node. The papsShapeObj pointers
- or the whole list can be NULL */
- int nShapeCount;
- int *panShapeIds;
- SHPObject **papsShapeObj;
-
- int nSubNodes;
- struct shape_tree_node *apsSubNode[MAX_SUBNODE];
-
- } SHPTreeNode;
-
- typedef struct
- {
- SHPHandle hSHP;
-
- int nMaxDepth;
- int nDimension;
-
- SHPTreeNode *psRoot;
- } SHPTree;
-
- SHPTree SHPAPI_CALL1( * )
- SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
- double *padfBoundsMin, double *padfBoundsMax );
- void SHPAPI_CALL
- SHPDestroyTree( SHPTree * hTree );
-
- int SHPAPI_CALL
- SHPWriteTree( SHPTree *hTree, const char * pszFileName );
- SHPTree SHPAPI_CALL
- SHPReadTree( const char * pszFileName );
-
- int SHPAPI_CALL
- SHPTreeAddObject( SHPTree * hTree, SHPObject * psObject );
- int SHPAPI_CALL
- SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject );
- int SHPAPI_CALL
- SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId );
-
- void SHPAPI_CALL
- SHPTreeTrimExtraNodes( SHPTree * hTree );
-
- int SHPAPI_CALL1( * )
- SHPTreeFindLikelyShapes( SHPTree * hTree,
- double * padfBoundsMin,
- double * padfBoundsMax,
- int * );
- int SHPAPI_CALL
- SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
-
- /************************************************************************/
- /* DBF Support. */
- /************************************************************************/
- typedef struct
- {
- FILE *fp;
-
- int nRecords;
-
- int nRecordLength;
- int nHeaderLength;
- int nFields;
- int *panFieldOffset;
- int *panFieldSize;
- int *panFieldDecimals;
- char *pachFieldType;
-
- char *pszHeader;
-
- int nCurrentRecord;
- int bCurrentRecordModified;
- char *pszCurrentRecord;
-
- int bNoHeader;
- int bUpdated;
- } DBFInfo;
-
- typedef DBFInfo * DBFHandle;
-
- typedef enum
- {
- FTString,
- FTInteger,
- FTDouble,
- FTLogical,
- FTInvalid
- } DBFFieldType;
-
-#define XBASE_FLDHDR_SZ 32
-
- DBFHandle SHPAPI_CALL
- DBFOpen( const char * pszDBFFile, const char * pszAccess );
- DBFHandle SHPAPI_CALL
- DBFCreate( const char * pszDBFFile );
-
- int SHPAPI_CALL
- DBFGetFieldCount( DBFHandle psDBF );
- int SHPAPI_CALL
- DBFGetRecordCount( DBFHandle psDBF );
- int SHPAPI_CALL
- DBFAddField( DBFHandle hDBF, const char * pszFieldName,
- DBFFieldType eType, int nWidth, int nDecimals );
-
- DBFFieldType SHPAPI_CALL
- DBFGetFieldInfo( DBFHandle psDBF, int iField,
- char * pszFieldName, int * pnWidth, int * pnDecimals );
-
- int SHPAPI_CALL
- DBFGetFieldIndex( DBFHandle psDBF, const char *pszFieldName );
-
- int SHPAPI_CALL
- DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
- double SHPAPI_CALL
- DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
- const char SHPAPI_CALL1( * )
- DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
- const char SHPAPI_CALL1( * )
- DBFReadLogicalAttribute( DBFHandle hDBF, int iShape, int iField );
- int SHPAPI_CALL
- DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
-
- int SHPAPI_CALL
- DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField,
- int nFieldValue );
- int SHPAPI_CALL
- DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
- double dFieldValue );
- int SHPAPI_CALL
- DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
- const char * pszFieldValue );
- int SHPAPI_CALL
- DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField );
-
- int SHPAPI_CALL
- DBFWriteLogicalAttribute( DBFHandle hDBF, int iShape, int iField,
- const char lFieldValue );
- int SHPAPI_CALL
- DBFWriteAttributeDirectly( DBFHandle psDBF, int hEntity, int iField,
- void * pValue );
- const char SHPAPI_CALL1( * )
- DBFReadTuple( DBFHandle psDBF, int hEntity );
- int SHPAPI_CALL
- DBFWriteTuple( DBFHandle psDBF, int hEntity, void * pRawTuple );
-
- DBFHandle SHPAPI_CALL
- DBFCloneEmpty( DBFHandle psDBF, const char * pszFileName );
-
- void SHPAPI_CALL
- DBFClose( DBFHandle hDBF );
- char SHPAPI_CALL
- DBFGetNativeFieldType( DBFHandle hDBF, int iField );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ndef _SHAPEFILE_H_INCLUDED */
diff --git a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shapelib.def b/src/plugins/dxf2shp_converter/shapelib-1.2.10/shapelib.def
deleted file mode 100644
index 016fece..0000000
--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shapelib.def
+++ /dev/null
@@ -1,42 +0,0 @@
-LIBRARY shapelib
-EXPORTS SHPOpen
- SHPCreate
- SHPGetInfo
- SHPReadObject
- SHPWriteObject
- SHPDestroyObject
- SHPComputeExtents
- SHPCreateObject
- SHPCreateSimpleObject
- SHPClose
- SHPTypeName
- SHPPartTypeName
- SHPCreateTree
- SHPDestroyTree
- SHPTreeAddShapeId
- SHPTreeTrimExtraNodes
- SHPTreeFindLikelyShapes
- SHPCheckBoundsOverlap
- DBFOpen
- DBFCreate
- DBFGetFieldCount
- DBFGetRecordCount
- DBFAddField
- DBFGetFieldInfo
- DBFReadIntegerAttribute
- DBFReadDoubleAttribute
- DBFReadStringAttribute
- DBFWriteIntegerAttribute
- DBFWriteDoubleAttribute
- DBFWriteStringAttribute
- DBFReadTuple
- DBFWriteTuple
- DBFCloneEmpty
- DBFClose
- DBFWriteNULLAttribute
- DBFGetFieldIndex
- DBFIsAttributeNULL
- DBFWriteLogicalAttribute
- DBFReadLogicalAttribute
-
-
diff --git a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c b/src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c
deleted file mode 100644
index 0b1be79..0000000
--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c
+++ /dev/null
@@ -1,1878 +0,0 @@
-/******************************************************************************
- * $Id: shpopen.c,v 1.39 2002/08/26 06:46:56 warmerda Exp $
- *
- * Project: Shapelib
- * Purpose: Implementation of core Shapefile read/write functions.
- * Author: Frank Warmerdam, warmerdam at pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, 2001, Frank Warmerdam
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log: shpopen.c,v $
- * Revision 1.39 2002/08/26 06:46:56 warmerda
- * avoid c++ comments
- *
- * Revision 1.38 2002/05/07 16:43:39 warmerda
- * Removed debugging printf.
- *
- * Revision 1.37 2002/04/10 17:35:22 warmerda
- * fixed bug in ring reversal code
- *
- * Revision 1.36 2002/04/10 16:59:54 warmerda
- * added SHPRewindObject
- *
- * Revision 1.35 2001/12/07 15:10:44 warmerda
- * fix if .shx fails to open
- *
- * Revision 1.34 2001/11/01 16:29:55 warmerda
- * move pabyRec into SHPInfo for thread safety
- *
- * Revision 1.33 2001/07/03 12:18:15 warmerda
- * Improved cleanup if SHX not found, provied by Riccardo Cohen.
- *
- * Revision 1.32 2001/06/22 01:58:07 warmerda
- * be more careful about establishing initial bounds in face of NULL shapes
- *
- * Revision 1.31 2001/05/31 19:35:29 warmerda
- * added support for writing null shapes
- *
- * Revision 1.30 2001/05/28 12:46:29 warmerda
- * Add some checking on reasonableness of record count when opening.
- *
- * Revision 1.29 2001/05/23 13:36:52 warmerda
- * added use of SHPAPI_CALL
- *
- * Revision 1.28 2001/02/06 22:25:06 warmerda
- * fixed memory leaks when SHPOpen() fails
- *
- * Revision 1.27 2000/07/18 15:21:33 warmerda
- * added better enforcement of -1 for append in SHPWriteObject
- *
- * Revision 1.26 2000/02/16 16:03:51 warmerda
- * added null shape support
- *
- * Revision 1.25 1999/12/15 13:47:07 warmerda
- * Fixed record size settings in .shp file (was 4 words too long)
- * Added stdlib.h.
- *
- * Revision 1.24 1999/11/05 14:12:04 warmerda
- * updated license terms
- *
- * Revision 1.23 1999/07/27 00:53:46 warmerda
- * added support for rewriting shapes
- *
- * Revision 1.22 1999/06/11 19:19:11 warmerda
- * Cleanup pabyRec static buffer on SHPClose().
- *
- * Revision 1.21 1999/06/02 14:57:56 kshih
- * Remove unused variables
- *
- * Revision 1.20 1999/04/19 21:04:17 warmerda
- * Fixed syntax error.
- *
- * Revision 1.19 1999/04/19 21:01:57 warmerda
- * Force access string to binary in SHPOpen().
- *
- * Revision 1.18 1999/04/01 18:48:07 warmerda
- * Try upper case extensions if lower case doesn't work.
- *
- * Revision 1.17 1998/12/31 15:29:39 warmerda
- * Disable writing measure values to multipatch objects if
- * DISABLE_MULTIPATCH_MEASURE is defined.
- *
- * Revision 1.16 1998/12/16 05:14:33 warmerda
- * Added support to write MULTIPATCH. Fixed reading Z coordinate of
- * MULTIPATCH. Fixed record size written for all feature types.
- *
- * Revision 1.15 1998/12/03 16:35:29 warmerda
- * r+b is proper binary access string, not rb+.
- *
- * Revision 1.14 1998/12/03 15:47:56 warmerda
- * Fixed setting of nVertices in SHPCreateObject().
- *
- * Revision 1.13 1998/12/03 15:33:54 warmerda
- * Made SHPCalculateExtents() separately callable.
- *
- * Revision 1.12 1998/11/11 20:01:50 warmerda
- * Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines.
- *
- * Revision 1.11 1998/11/09 20:56:44 warmerda
- * Fixed up handling of file wide bounds.
- *
- * Revision 1.10 1998/11/09 20:18:51 warmerda
- * Converted to support 3D shapefiles, and use of SHPObject.
- *
- * Revision 1.9 1998/02/24 15:09:05 warmerda
- * Fixed memory leak.
- *
- * Revision 1.8 1997/12/04 15:40:29 warmerda
- * Fixed byte swapping of record number, and record length fields in the
- * .shp file.
- *
- * Revision 1.7 1995/10/21 03:15:58 warmerda
- * Added support for binary file access, the magic cookie 9997
- * and tried to improve the int32 selection logic for 16bit systems.
- *
- * Revision 1.6 1995/09/04 04:19:41 warmerda
- * Added fix for file bounds.
- *
- * Revision 1.5 1995/08/25 15:16:44 warmerda
- * Fixed a couple of problems with big endian systems ... one with bounds
- * and the other with multipart polygons.
- *
- * Revision 1.4 1995/08/24 18:10:17 warmerda
- * Switch to use SfRealloc() to avoid problems with pre-ANSI realloc()
- * functions (such as on the Sun).
- *
- * Revision 1.3 1995/08/23 02:23:15 warmerda
- * Added support for reading bounds, and fixed up problems in setting the
- * file wide bounds.
- *
- * Revision 1.2 1995/08/04 03:16:57 warmerda
- * Added header.
- *
- */
-
-static char rcsid[] =
- "$Id: shpopen.c,v 1.39 2002/08/26 06:46:56 warmerda Exp $";
-
-#include "shapefil.h"
-
-#include <math.h>
-#include <limits.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-typedef unsigned char uchar;
-
-#if UINT_MAX == 65535
-typedef long int32;
-#else
-typedef int int32;
-#endif
-
-#ifndef FALSE
-# define FALSE 0
-# define TRUE 1
-#endif
-
-#define ByteCopy( a, b, c ) memcpy( b, a, c )
-#ifndef MAX
-# define MIN(a,b) ((a<b) ? a : b)
-# define MAX(a,b) ((a>b) ? a : b)
-#endif
-
-static int bBigEndian;
-
-
-/************************************************************************/
-/* SwapWord() */
-/* */
-/* Swap a 2, 4 or 8 byte word. */
-/************************************************************************/
-
-static void SwapWord( int length, void * wordP )
-
-{
- int i;
- uchar temp;
-
- for ( i = 0; i < length / 2; i++ )
- {
- temp = (( uchar * ) wordP )[i];
- (( uchar * )wordP )[i] = (( uchar * ) wordP )[length-i-1];
- (( uchar * ) wordP )[length-i-1] = temp;
- }
-}
-
-/************************************************************************/
-/* SfRealloc() */
-/* */
-/* A realloc cover function that will access a NULL pointer as */
-/* a valid input. */
-/************************************************************************/
-
-static void * SfRealloc( void * pMem, int nNewSize )
-
-{
- if ( pMem == NULL )
- return(( void * ) malloc( nNewSize ) );
- else
- return(( void * ) realloc( pMem, nNewSize ) );
-}
-
-/************************************************************************/
-/* SHPWriteHeader() */
-/* */
-/* Write out a header for the .shp and .shx files as well as the */
-/* contents of the index (.shx) file. */
-/************************************************************************/
-
-static void SHPWriteHeader( SHPHandle psSHP )
-
-{
- uchar abyHeader[100];
- int i;
- int32 i32;
- double dValue;
- int32 *panSHX;
-
- /* -------------------------------------------------------------------- */
- /* Prepare header block for .shp file. */
- /* -------------------------------------------------------------------- */
- for ( i = 0; i < 100; i++ )
- abyHeader[i] = 0;
-
- abyHeader[2] = 0x27; /* magic cookie */
- abyHeader[3] = 0x0a;
-
- i32 = psSHP->nFileSize / 2; /* file size */
- ByteCopy( &i32, abyHeader + 24, 4 );
- if ( !bBigEndian ) SwapWord( 4, abyHeader + 24 );
-
- i32 = 1000; /* version */
- ByteCopy( &i32, abyHeader + 28, 4 );
- if ( bBigEndian ) SwapWord( 4, abyHeader + 28 );
-
- i32 = psSHP->nShapeType; /* shape type */
- ByteCopy( &i32, abyHeader + 32, 4 );
- if ( bBigEndian ) SwapWord( 4, abyHeader + 32 );
-
- dValue = psSHP->adBoundsMin[0]; /* set bounds */
- ByteCopy( &dValue, abyHeader + 36, 8 );
- if ( bBigEndian ) SwapWord( 8, abyHeader + 36 );
-
- dValue = psSHP->adBoundsMin[1];
- ByteCopy( &dValue, abyHeader + 44, 8 );
- if ( bBigEndian ) SwapWord( 8, abyHeader + 44 );
-
- dValue = psSHP->adBoundsMax[0];
- ByteCopy( &dValue, abyHeader + 52, 8 );
- if ( bBigEndian ) SwapWord( 8, abyHeader + 52 );
-
- dValue = psSHP->adBoundsMax[1];
- ByteCopy( &dValue, abyHeader + 60, 8 );
- if ( bBigEndian ) SwapWord( 8, abyHeader + 60 );
-
- dValue = psSHP->adBoundsMin[2]; /* z */
- ByteCopy( &dValue, abyHeader + 68, 8 );
- if ( bBigEndian ) SwapWord( 8, abyHeader + 68 );
-
- dValue = psSHP->adBoundsMax[2];
- ByteCopy( &dValue, abyHeader + 76, 8 );
- if ( bBigEndian ) SwapWord( 8, abyHeader + 76 );
-
- dValue = psSHP->adBoundsMin[3]; /* m */
- ByteCopy( &dValue, abyHeader + 84, 8 );
- if ( bBigEndian ) SwapWord( 8, abyHeader + 84 );
-
- dValue = psSHP->adBoundsMax[3];
- ByteCopy( &dValue, abyHeader + 92, 8 );
- if ( bBigEndian ) SwapWord( 8, abyHeader + 92 );
-
- /* -------------------------------------------------------------------- */
- /* Write .shp file header. */
- /* -------------------------------------------------------------------- */
- fseek( psSHP->fpSHP, 0, 0 );
- fwrite( abyHeader, 100, 1, psSHP->fpSHP );
-
- /* -------------------------------------------------------------------- */
- /* Prepare, and write .shx file header. */
- /* -------------------------------------------------------------------- */
- i32 = ( psSHP->nRecords * 2 * sizeof( int32 ) + 100 ) / 2; /* file size */
- ByteCopy( &i32, abyHeader + 24, 4 );
- if ( !bBigEndian ) SwapWord( 4, abyHeader + 24 );
-
- fseek( psSHP->fpSHX, 0, 0 );
- fwrite( abyHeader, 100, 1, psSHP->fpSHX );
-
- /* -------------------------------------------------------------------- */
- /* Write out the .shx contents. */
- /* -------------------------------------------------------------------- */
- panSHX = ( int32 * ) malloc( sizeof( int32 ) * 2 * psSHP->nRecords );
-
- for ( i = 0; i < psSHP->nRecords; i++ )
- {
- panSHX[i*2 ] = psSHP->panRecOffset[i] / 2;
- panSHX[i*2+1] = psSHP->panRecSize[i] / 2;
- if ( !bBigEndian ) SwapWord( 4, panSHX + i*2 );
- if ( !bBigEndian ) SwapWord( 4, panSHX + i*2 + 1 );
- }
-
- fwrite( panSHX, sizeof( int32 ) * 2, psSHP->nRecords, psSHP->fpSHX );
-
- free( panSHX );
-}
-
-/************************************************************************/
-/* SHPOpen() */
-/* */
-/* Open the .shp and .shx files based on the basename of the */
-/* files or either file name. */
-/************************************************************************/
-
-SHPHandle SHPAPI_CALL
-SHPOpen( const char * pszLayer, const char * pszAccess )
-
-{
- char *pszFullname, *pszBasename;
- SHPHandle psSHP;
-
- uchar *pabyBuf;
- int i;
- double dValue;
-
- /* -------------------------------------------------------------------- */
- /* Ensure the access string is one of the legal ones. We */
- /* ensure the result string indicates binary to avoid common */
- /* problems on Windows. */
- /* -------------------------------------------------------------------- */
- if ( strcmp( pszAccess, "rb+" ) == 0 || strcmp( pszAccess, "r+b" ) == 0
- || strcmp( pszAccess, "r+" ) == 0 )
- pszAccess = "r+b";
- else
- pszAccess = "rb";
-
- /* -------------------------------------------------------------------- */
- /* Establish the byte order on this machine. */
- /* -------------------------------------------------------------------- */
- i = 1;
- if ( *(( uchar * ) &i ) == 1 )
- bBigEndian = FALSE;
- else
- bBigEndian = TRUE;
-
- /* -------------------------------------------------------------------- */
- /* Initialize the info structure. */
- /* -------------------------------------------------------------------- */
- psSHP = ( SHPHandle ) calloc( sizeof( SHPInfo ), 1 );
-
- psSHP->bUpdated = FALSE;
-
- /* -------------------------------------------------------------------- */
- /* Compute the base (layer) name. If there is any extension */
- /* on the passed in filename we will strip it off. */
- /* -------------------------------------------------------------------- */
- pszBasename = ( char * ) malloc( strlen( pszLayer ) + 5 );
- strcpy( pszBasename, pszLayer );
- for ( i = strlen( pszBasename ) - 1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if ( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
- /* -------------------------------------------------------------------- */
- /* Open the .shp and .shx files. Note that files pulled from */
- /* a PC to Unix with upper case filenames won't work! */
- /* -------------------------------------------------------------------- */
- pszFullname = ( char * ) malloc( strlen( pszBasename ) + 5 );
- sprintf( pszFullname, "%s.shp", pszBasename );
- psSHP->fpSHP = fopen( pszFullname, pszAccess );
- if ( psSHP->fpSHP == NULL )
- {
- sprintf( pszFullname, "%s.SHP", pszBasename );
- psSHP->fpSHP = fopen( pszFullname, pszAccess );
- }
-
- if ( psSHP->fpSHP == NULL )
- {
- free( psSHP );
- free( pszBasename );
- free( pszFullname );
- return( NULL );
- }
-
- sprintf( pszFullname, "%s.shx", pszBasename );
- psSHP->fpSHX = fopen( pszFullname, pszAccess );
- if ( psSHP->fpSHX == NULL )
- {
- sprintf( pszFullname, "%s.SHX", pszBasename );
- psSHP->fpSHX = fopen( pszFullname, pszAccess );
- }
-
- if ( psSHP->fpSHX == NULL )
- {
- fclose( psSHP->fpSHP );
- free( psSHP );
- free( pszBasename );
- free( pszFullname );
- return( NULL );
- }
-
- free( pszFullname );
- free( pszBasename );
-
- /* -------------------------------------------------------------------- */
- /* Read the file size from the SHP file. */
- /* -------------------------------------------------------------------- */
- pabyBuf = ( uchar * ) malloc( 100 );
- fread( pabyBuf, 100, 1, psSHP->fpSHP );
-
- psSHP->nFileSize = ( pabyBuf[24] * 256 * 256 * 256
- + pabyBuf[25] * 256 * 256
- + pabyBuf[26] * 256
- + pabyBuf[27] ) * 2;
-
- /* -------------------------------------------------------------------- */
- /* Read SHX file Header info */
- /* -------------------------------------------------------------------- */
- fread( pabyBuf, 100, 1, psSHP->fpSHX );
-
- if ( pabyBuf[0] != 0
- || pabyBuf[1] != 0
- || pabyBuf[2] != 0x27
- || ( pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d ) )
- {
- fclose( psSHP->fpSHP );
- fclose( psSHP->fpSHX );
- free( psSHP );
- free( pabyBuf );
-
- return( NULL );
- }
-
- psSHP->nRecords = pabyBuf[27] + pabyBuf[26] * 256
- + pabyBuf[25] * 256 * 256 + pabyBuf[24] * 256 * 256 * 256;
- psSHP->nRecords = ( psSHP->nRecords * 2 - 100 ) / 8;
-
- psSHP->nShapeType = pabyBuf[32];
-
- if ( psSHP->nRecords < 0 || psSHP->nRecords > 256000000 )
- {
- /* this header appears to be corrupt. Give up. */
- fclose( psSHP->fpSHP );
- fclose( psSHP->fpSHX );
- free( psSHP );
-
- free( pabyBuf );
-
- return( NULL );
- }
-
- /* -------------------------------------------------------------------- */
- /* Read the bounds. */
- /* -------------------------------------------------------------------- */
- if ( bBigEndian ) SwapWord( 8, pabyBuf + 36 );
- memcpy( &dValue, pabyBuf + 36, 8 );
- psSHP->adBoundsMin[0] = dValue;
-
- if ( bBigEndian ) SwapWord( 8, pabyBuf + 44 );
- memcpy( &dValue, pabyBuf + 44, 8 );
- psSHP->adBoundsMin[1] = dValue;
-
- if ( bBigEndian ) SwapWord( 8, pabyBuf + 52 );
- memcpy( &dValue, pabyBuf + 52, 8 );
- psSHP->adBoundsMax[0] = dValue;
-
- if ( bBigEndian ) SwapWord( 8, pabyBuf + 60 );
- memcpy( &dValue, pabyBuf + 60, 8 );
- psSHP->adBoundsMax[1] = dValue;
-
- if ( bBigEndian ) SwapWord( 8, pabyBuf + 68 ); /* z */
- memcpy( &dValue, pabyBuf + 68, 8 );
- psSHP->adBoundsMin[2] = dValue;
-
- if ( bBigEndian ) SwapWord( 8, pabyBuf + 76 );
- memcpy( &dValue, pabyBuf + 76, 8 );
- psSHP->adBoundsMax[2] = dValue;
-
- if ( bBigEndian ) SwapWord( 8, pabyBuf + 84 ); /* z */
- memcpy( &dValue, pabyBuf + 84, 8 );
- psSHP->adBoundsMin[3] = dValue;
-
- if ( bBigEndian ) SwapWord( 8, pabyBuf + 92 );
- memcpy( &dValue, pabyBuf + 92, 8 );
- psSHP->adBoundsMax[3] = dValue;
-
- free( pabyBuf );
-
- /* -------------------------------------------------------------------- */
- /* Read the .shx file to get the offsets to each record in */
- /* the .shp file. */
- /* -------------------------------------------------------------------- */
- psSHP->nMaxRecords = psSHP->nRecords;
-
- psSHP->panRecOffset =
- ( int * ) malloc( sizeof( int ) * MAX( 1, psSHP->nMaxRecords ) );
- psSHP->panRecSize =
- ( int * ) malloc( sizeof( int ) * MAX( 1, psSHP->nMaxRecords ) );
-
- pabyBuf = ( uchar * ) malloc( 8 * MAX( 1, psSHP->nRecords ) );
- fread( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX );
-
- for ( i = 0; i < psSHP->nRecords; i++ )
- {
- int32 nOffset, nLength;
-
- memcpy( &nOffset, pabyBuf + i * 8, 4 );
- if ( !bBigEndian ) SwapWord( 4, &nOffset );
-
- memcpy( &nLength, pabyBuf + i * 8 + 4, 4 );
- if ( !bBigEndian ) SwapWord( 4, &nLength );
-
- psSHP->panRecOffset[i] = nOffset * 2;
- psSHP->panRecSize[i] = nLength * 2;
- }
- free( pabyBuf );
-
- return( psSHP );
-}
-
-/************************************************************************/
-/* SHPClose() */
-/* */
-/* Close the .shp and .shx files. */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPClose( SHPHandle psSHP )
-
-{
- /* -------------------------------------------------------------------- */
- /* Update the header if we have modified anything. */
- /* -------------------------------------------------------------------- */
- if ( psSHP->bUpdated )
- {
- SHPWriteHeader( psSHP );
- }
-
- /* -------------------------------------------------------------------- */
- /* Free all resources, and close files. */
- /* -------------------------------------------------------------------- */
- free( psSHP->panRecOffset );
- free( psSHP->panRecSize );
-
- fclose( psSHP->fpSHX );
- fclose( psSHP->fpSHP );
-
- if ( psSHP->pabyRec != NULL )
- {
- free( psSHP->pabyRec );
- }
-
- free( psSHP );
-}
-
-/************************************************************************/
-/* SHPGetInfo() */
-/* */
-/* Fetch general information about the shape file. */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPGetInfo( SHPHandle psSHP, int * pnEntities, int * pnShapeType,
- double * padfMinBound, double * padfMaxBound )
-
-{
- int i;
-
- if ( pnEntities != NULL )
- *pnEntities = psSHP->nRecords;
-
- if ( pnShapeType != NULL )
- *pnShapeType = psSHP->nShapeType;
-
- for ( i = 0; i < 4; i++ )
- {
- if ( padfMinBound != NULL )
- padfMinBound[i] = psSHP->adBoundsMin[i];
- if ( padfMaxBound != NULL )
- padfMaxBound[i] = psSHP->adBoundsMax[i];
- }
-}
-
-/************************************************************************/
-/* SHPCreate() */
-/* */
-/* Create a new shape file and return a handle to the open */
-/* shape file with read/write access. */
-/************************************************************************/
-
-SHPHandle SHPAPI_CALL
-SHPCreate( const char * pszLayer, int nShapeType )
-
-{
- char *pszBasename, *pszFullname;
- int i;
- FILE *fpSHP, *fpSHX;
- uchar abyHeader[100];
- int32 i32;
- double dValue;
-
- /* -------------------------------------------------------------------- */
- /* Establish the byte order on this system. */
- /* -------------------------------------------------------------------- */
- i = 1;
- if ( *(( uchar * ) &i ) == 1 )
- bBigEndian = FALSE;
- else
- bBigEndian = TRUE;
-
- /* -------------------------------------------------------------------- */
- /* Compute the base (layer) name. If there is any extension */
- /* on the passed in filename we will strip it off. */
- /* -------------------------------------------------------------------- */
- pszBasename = ( char * ) malloc( strlen( pszLayer ) + 5 );
- strcpy( pszBasename, pszLayer );
- for ( i = strlen( pszBasename ) - 1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if ( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
- /* -------------------------------------------------------------------- */
- /* Open the two files so we can write their headers. */
- /* -------------------------------------------------------------------- */
- pszFullname = ( char * ) malloc( strlen( pszBasename ) + 5 );
- sprintf( pszFullname, "%s.shp", pszBasename );
- fpSHP = fopen( pszFullname, "wb" );
- if ( fpSHP == NULL )
- {
- free( pszBasename );
- free( pszFullname );
- return NULL;
- }
-
- sprintf( pszFullname, "%s.shx", pszBasename );
- fpSHX = fopen( pszFullname, "wb" );
- if ( fpSHX == NULL )
- {
- free( pszBasename );
- free( pszFullname );
- fclose( fpSHP );
- return( NULL );
- }
-
- free( pszFullname );
- free( pszBasename );
-
- /* -------------------------------------------------------------------- */
- /* Prepare header block for .shp file. */
- /* -------------------------------------------------------------------- */
- for ( i = 0; i < 100; i++ )
- abyHeader[i] = 0;
-
- abyHeader[2] = 0x27; /* magic cookie */
- abyHeader[3] = 0x0a;
-
- i32 = 50; /* file size */
- ByteCopy( &i32, abyHeader + 24, 4 );
- if ( !bBigEndian ) SwapWord( 4, abyHeader + 24 );
-
- i32 = 1000; /* version */
- ByteCopy( &i32, abyHeader + 28, 4 );
- if ( bBigEndian ) SwapWord( 4, abyHeader + 28 );
-
- i32 = nShapeType; /* shape type */
- ByteCopy( &i32, abyHeader + 32, 4 );
- if ( bBigEndian ) SwapWord( 4, abyHeader + 32 );
-
- dValue = 0.0; /* set bounds */
- ByteCopy( &dValue, abyHeader + 36, 8 );
- ByteCopy( &dValue, abyHeader + 44, 8 );
- ByteCopy( &dValue, abyHeader + 52, 8 );
- ByteCopy( &dValue, abyHeader + 60, 8 );
-
- /* -------------------------------------------------------------------- */
- /* Write .shp file header. */
- /* -------------------------------------------------------------------- */
- fwrite( abyHeader, 100, 1, fpSHP );
-
- /* -------------------------------------------------------------------- */
- /* Prepare, and write .shx file header. */
- /* -------------------------------------------------------------------- */
- i32 = 50; /* file size */
- ByteCopy( &i32, abyHeader + 24, 4 );
- if ( !bBigEndian ) SwapWord( 4, abyHeader + 24 );
-
- fwrite( abyHeader, 100, 1, fpSHX );
-
- /* -------------------------------------------------------------------- */
- /* Close the files, and then open them as regular existing files. */
- /* -------------------------------------------------------------------- */
- fclose( fpSHP );
- fclose( fpSHX );
-
- return( SHPOpen( pszLayer, "r+b" ) );
-}
-
-/************************************************************************/
-/* _SHPSetBounds() */
-/* */
-/* Compute a bounds rectangle for a shape, and set it into the */
-/* indicated location in the record. */
-/************************************************************************/
-
-static void _SHPSetBounds( uchar * pabyRec, SHPObject * psShape )
-
-{
- ByteCopy( &( psShape->dfXMin ), pabyRec + 0, 8 );
- ByteCopy( &( psShape->dfYMin ), pabyRec + 8, 8 );
- ByteCopy( &( psShape->dfXMax ), pabyRec + 16, 8 );
- ByteCopy( &( psShape->dfYMax ), pabyRec + 24, 8 );
-
- if ( bBigEndian )
- {
- SwapWord( 8, pabyRec + 0 );
- SwapWord( 8, pabyRec + 8 );
- SwapWord( 8, pabyRec + 16 );
- SwapWord( 8, pabyRec + 24 );
- }
-}
-
-/************************************************************************/
-/* SHPComputeExtents() */
-/* */
-/* Recompute the extents of a shape. Automatically done by */
-/* SHPCreateObject(). */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPComputeExtents( SHPObject * psObject )
-
-{
- int i;
-
- /* -------------------------------------------------------------------- */
- /* Build extents for this object. */
- /* -------------------------------------------------------------------- */
- if ( psObject->nVertices > 0 )
- {
- psObject->dfXMin = psObject->dfXMax = psObject->padfX[0];
- psObject->dfYMin = psObject->dfYMax = psObject->padfY[0];
- psObject->dfZMin = psObject->dfZMax = psObject->padfZ[0];
- psObject->dfMMin = psObject->dfMMax = psObject->padfM[0];
- }
-
- for ( i = 0; i < psObject->nVertices; i++ )
- {
- psObject->dfXMin = MIN( psObject->dfXMin, psObject->padfX[i] );
- psObject->dfYMin = MIN( psObject->dfYMin, psObject->padfY[i] );
- psObject->dfZMin = MIN( psObject->dfZMin, psObject->padfZ[i] );
- psObject->dfMMin = MIN( psObject->dfMMin, psObject->padfM[i] );
-
- psObject->dfXMax = MAX( psObject->dfXMax, psObject->padfX[i] );
- psObject->dfYMax = MAX( psObject->dfYMax, psObject->padfY[i] );
- psObject->dfZMax = MAX( psObject->dfZMax, psObject->padfZ[i] );
- psObject->dfMMax = MAX( psObject->dfMMax, psObject->padfM[i] );
- }
-}
-
-/************************************************************************/
-/* SHPCreateObject() */
-/* */
-/* Create a shape object. It should be freed with */
-/* SHPDestroyObject(). */
-/************************************************************************/
-
-SHPObject SHPAPI_CALL1( * )
-SHPCreateObject( int nSHPType, int nShapeId, int nParts,
- int * panPartStart, int * panPartType,
- int nVertices, double * padfX, double * padfY,
- double * padfZ, double * padfM )
-
-{
- SHPObject *psObject;
- int i, bHasM, bHasZ;
-
- psObject = ( SHPObject * ) calloc( 1, sizeof( SHPObject ) );
- psObject->nSHPType = nSHPType;
- psObject->nShapeId = nShapeId;
-
- /* -------------------------------------------------------------------- */
- /* Establish whether this shape type has M, and Z values. */
- /* -------------------------------------------------------------------- */
- if ( nSHPType == SHPT_ARCM
- || nSHPType == SHPT_POINTM
- || nSHPType == SHPT_POLYGONM
- || nSHPType == SHPT_MULTIPOINTM )
- {
- bHasM = TRUE;
- bHasZ = FALSE;
- }
- else if ( nSHPType == SHPT_ARCZ
- || nSHPType == SHPT_POINTZ
- || nSHPType == SHPT_POLYGONZ
- || nSHPType == SHPT_MULTIPOINTZ
- || nSHPType == SHPT_MULTIPATCH )
- {
- bHasM = TRUE;
- bHasZ = TRUE;
- }
- else
- {
- bHasM = FALSE;
- bHasZ = FALSE;
- }
-
- /* -------------------------------------------------------------------- */
- /* Capture parts. Note that part type is optional, and */
- /* defaults to ring. */
- /* -------------------------------------------------------------------- */
- if ( nSHPType == SHPT_ARC || nSHPType == SHPT_POLYGON
- || nSHPType == SHPT_ARCM || nSHPType == SHPT_POLYGONM
- || nSHPType == SHPT_ARCZ || nSHPType == SHPT_POLYGONZ
- || nSHPType == SHPT_MULTIPATCH )
- {
- psObject->nParts = MAX( 1, nParts );
-
- psObject->panPartStart = ( int * )
- malloc( sizeof( int ) * psObject->nParts );
- psObject->panPartType = ( int * )
- malloc( sizeof( int ) * psObject->nParts );
-
- psObject->panPartStart[0] = 0;
- psObject->panPartType[0] = SHPP_RING;
-
- for ( i = 0; i < nParts; i++ )
- {
- psObject->panPartStart[i] = panPartStart[i];
- if ( panPartType != NULL )
- psObject->panPartType[i] = panPartType[i];
- else
- psObject->panPartType[i] = SHPP_RING;
- }
- }
-
- /* -------------------------------------------------------------------- */
- /* Capture vertices. Note that Z and M are optional, but X and */
- /* Y are not. */
- /* -------------------------------------------------------------------- */
- if ( nVertices > 0 )
- {
- psObject->padfX = ( double * ) calloc( sizeof( double ), nVertices );
- psObject->padfY = ( double * ) calloc( sizeof( double ), nVertices );
- psObject->padfZ = ( double * ) calloc( sizeof( double ), nVertices );
- psObject->padfM = ( double * ) calloc( sizeof( double ), nVertices );
-
- assert( padfX != NULL );
- assert( padfY != NULL );
-
- for ( i = 0; i < nVertices; i++ )
- {
- psObject->padfX[i] = padfX[i];
- psObject->padfY[i] = padfY[i];
- if ( padfZ != NULL && bHasZ )
- psObject->padfZ[i] = padfZ[i];
- if ( padfM != NULL && bHasM )
- psObject->padfM[i] = padfM[i];
- }
- }
-
- /* -------------------------------------------------------------------- */
- /* Compute the extents. */
- /* -------------------------------------------------------------------- */
- psObject->nVertices = nVertices;
- SHPComputeExtents( psObject );
-
- return( psObject );
-}
-
-/************************************************************************/
-/* SHPCreateSimpleObject() */
-/* */
-/* Create a simple (common) shape object. Destroy with */
-/* SHPDestroyObject(). */
-/************************************************************************/
-
-SHPObject SHPAPI_CALL1( * )
-SHPCreateSimpleObject( int nSHPType, int nVertices,
- double * padfX, double * padfY,
- double * padfZ )
-
-{
- return( SHPCreateObject( nSHPType, -1, 0, NULL, NULL,
- nVertices, padfX, padfY, padfZ, NULL ) );
-}
-
-/************************************************************************/
-/* SHPWriteObject() */
-/* */
-/* Write out the vertices of a new structure. Note that it is */
-/* only possible to write vertices at the end of the file. */
-/************************************************************************/
-
-int SHPAPI_CALL
-SHPWriteObject( SHPHandle psSHP, int nShapeId, SHPObject * psObject )
-
-{
- int nRecordOffset, i, nRecordSize;
- uchar *pabyRec;
- int32 i32;
-
- psSHP->bUpdated = TRUE;
-
- /* -------------------------------------------------------------------- */
- /* Ensure that shape object matches the type of the file it is */
- /* being written to. */
- /* -------------------------------------------------------------------- */
- assert( psObject->nSHPType == psSHP->nShapeType
- || psObject->nSHPType == SHPT_NULL );
-
- /* -------------------------------------------------------------------- */
- /* Ensure that -1 is used for appends. Either blow an */
- /* assertion, or if they are disabled, set the shapeid to -1 */
- /* for appends. */
- /* -------------------------------------------------------------------- */
- assert( nShapeId == -1
- || ( nShapeId >= 0 && nShapeId < psSHP->nRecords ) );
-
- if ( nShapeId != -1 && nShapeId >= psSHP->nRecords )
- nShapeId = -1;
-
- /* -------------------------------------------------------------------- */
- /* Add the new entity to the in memory index. */
- /* -------------------------------------------------------------------- */
- if ( nShapeId == -1 && psSHP->nRecords + 1 > psSHP->nMaxRecords )
- {
- psSHP->nMaxRecords = ( int )( psSHP->nMaxRecords * 1.3 + 100 );
-
- psSHP->panRecOffset = ( int * )
- SfRealloc( psSHP->panRecOffset, sizeof( int ) * psSHP->nMaxRecords );
- psSHP->panRecSize = ( int * )
- SfRealloc( psSHP->panRecSize, sizeof( int ) * psSHP->nMaxRecords );
- }
-
- /* -------------------------------------------------------------------- */
- /* Initialize record. */
- /* -------------------------------------------------------------------- */
- pabyRec = ( uchar * ) malloc( psObject->nVertices * 4 * sizeof( double )
- + psObject->nParts * 8 + 128 );
-
- /* -------------------------------------------------------------------- */
- /* Extract vertices for a Polygon or Arc. */
- /* -------------------------------------------------------------------- */
- if ( psObject->nSHPType == SHPT_POLYGON
- || psObject->nSHPType == SHPT_POLYGONZ
- || psObject->nSHPType == SHPT_POLYGONM
- || psObject->nSHPType == SHPT_ARC
- || psObject->nSHPType == SHPT_ARCZ
- || psObject->nSHPType == SHPT_ARCM
- || psObject->nSHPType == SHPT_MULTIPATCH )
- {
- int32 nPoints, nParts;
- int i;
-
- nPoints = psObject->nVertices;
- nParts = psObject->nParts;
-
- _SHPSetBounds( pabyRec + 12, psObject );
-
- if ( bBigEndian ) SwapWord( 4, &nPoints );
- if ( bBigEndian ) SwapWord( 4, &nParts );
-
- ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
- ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
-
- nRecordSize = 52;
-
- /*
- * Write part start positions.
- */
- ByteCopy( psObject->panPartStart, pabyRec + 44 + 8,
- 4 * psObject->nParts );
- for ( i = 0; i < psObject->nParts; i++ )
- {
- if ( bBigEndian ) SwapWord( 4, pabyRec + 44 + 8 + 4*i );
- nRecordSize += 4;
- }
-
- /*
- * Write multipatch part types if needed.
- */
- if ( psObject->nSHPType == SHPT_MULTIPATCH )
- {
- memcpy( pabyRec + nRecordSize, psObject->panPartType,
- 4*psObject->nParts );
- for ( i = 0; i < psObject->nParts; i++ )
- {
- if ( bBigEndian ) SwapWord( 4, pabyRec + nRecordSize );
- nRecordSize += 4;
- }
- }
-
- /*
- * Write the (x,y) vertex values.
- */
- for ( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfX + i, pabyRec + nRecordSize, 8 );
- ByteCopy( psObject->padfY + i, pabyRec + nRecordSize + 8, 8 );
-
- if ( bBigEndian )
- SwapWord( 8, pabyRec + nRecordSize );
-
- if ( bBigEndian )
- SwapWord( 8, pabyRec + nRecordSize + 8 );
-
- nRecordSize += 2 * 8;
- }
-
- /*
- * Write the Z coordinates (if any).
- */
- if ( psObject->nSHPType == SHPT_POLYGONZ
- || psObject->nSHPType == SHPT_ARCZ
- || psObject->nSHPType == SHPT_MULTIPATCH )
- {
- ByteCopy( &( psObject->dfZMin ), pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- ByteCopy( &( psObject->dfZMax ), pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- for ( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
-
- /*
- * Write the M values, if any.
- */
- if ( psObject->nSHPType == SHPT_POLYGONM
- || psObject->nSHPType == SHPT_ARCM
-#ifndef DISABLE_MULTIPATCH_MEASURE
- || psObject->nSHPType == SHPT_MULTIPATCH
-#endif
- || psObject->nSHPType == SHPT_POLYGONZ
- || psObject->nSHPType == SHPT_ARCZ )
- {
- ByteCopy( &( psObject->dfMMin ), pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- ByteCopy( &( psObject->dfMMax ), pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- for ( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
- }
-
- /* -------------------------------------------------------------------- */
- /* Extract vertices for a MultiPoint. */
- /* -------------------------------------------------------------------- */
- else if ( psObject->nSHPType == SHPT_MULTIPOINT
- || psObject->nSHPType == SHPT_MULTIPOINTZ
- || psObject->nSHPType == SHPT_MULTIPOINTM )
- {
- int32 nPoints;
- int i;
-
- nPoints = psObject->nVertices;
-
- _SHPSetBounds( pabyRec + 12, psObject );
-
- if ( bBigEndian ) SwapWord( 4, &nPoints );
- ByteCopy( &nPoints, pabyRec + 44, 4 );
-
- for ( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfX + i, pabyRec + 48 + i*16, 8 );
- ByteCopy( psObject->padfY + i, pabyRec + 48 + i*16 + 8, 8 );
-
- if ( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 + 8 );
- }
-
- nRecordSize = 48 + 16 * psObject->nVertices;
-
- if ( psObject->nSHPType == SHPT_MULTIPOINTZ )
- {
- ByteCopy( &( psObject->dfZMin ), pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- ByteCopy( &( psObject->dfZMax ), pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- for ( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
-
- if ( psObject->nSHPType == SHPT_MULTIPOINTZ
- || psObject->nSHPType == SHPT_MULTIPOINTM )
- {
- ByteCopy( &( psObject->dfMMin ), pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- ByteCopy( &( psObject->dfMMax ), pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- for ( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
- }
-
- /* -------------------------------------------------------------------- */
- /* Write point. */
- /* -------------------------------------------------------------------- */
- else if ( psObject->nSHPType == SHPT_POINT
- || psObject->nSHPType == SHPT_POINTZ
- || psObject->nSHPType == SHPT_POINTM )
- {
- ByteCopy( psObject->padfX, pabyRec + 12, 8 );
- ByteCopy( psObject->padfY, pabyRec + 20, 8 );
-
- if ( bBigEndian ) SwapWord( 8, pabyRec + 12 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + 20 );
-
- nRecordSize = 28;
-
- if ( psObject->nSHPType == SHPT_POINTZ )
- {
- ByteCopy( psObject->padfZ, pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
-
- if ( psObject->nSHPType == SHPT_POINTZ
- || psObject->nSHPType == SHPT_POINTM )
- {
- ByteCopy( psObject->padfM, pabyRec + nRecordSize, 8 );
- if ( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
-
- /* -------------------------------------------------------------------- */
- /* Not much to do for null geometries. */
- /* -------------------------------------------------------------------- */
- else if ( psObject->nSHPType == SHPT_NULL )
- {
- nRecordSize = 12;
- }
-
- else
- {
- /* unknown type */
- assert( FALSE );
- }
-
- /* -------------------------------------------------------------------- */
- /* Establish where we are going to put this record. If we are */
- /* rewriting and existing record, and it will fit, then put it */
- /* back where the original came from. Otherwise write at the end. */
- /* -------------------------------------------------------------------- */
- if ( nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize - 8 )
- {
- if ( nShapeId == -1 )
- nShapeId = psSHP->nRecords++;
-
- psSHP->panRecOffset[nShapeId] = nRecordOffset = psSHP->nFileSize;
- psSHP->panRecSize[nShapeId] = nRecordSize - 8;
- psSHP->nFileSize += nRecordSize;
- }
- else
- {
- nRecordOffset = psSHP->panRecOffset[nShapeId];
- }
-
- /* -------------------------------------------------------------------- */
- /* Set the shape type, record number, and record size. */
- /* -------------------------------------------------------------------- */
- i32 = nShapeId + 1; /* record # */
- if ( !bBigEndian ) SwapWord( 4, &i32 );
- ByteCopy( &i32, pabyRec, 4 );
-
- i32 = ( nRecordSize - 8 ) / 2; /* record size */
- if ( !bBigEndian ) SwapWord( 4, &i32 );
- ByteCopy( &i32, pabyRec + 4, 4 );
-
- i32 = psObject->nSHPType; /* shape type */
- if ( bBigEndian ) SwapWord( 4, &i32 );
- ByteCopy( &i32, pabyRec + 8, 4 );
-
- /* -------------------------------------------------------------------- */
- /* Write out record. */
- /* -------------------------------------------------------------------- */
- if ( fseek( psSHP->fpSHP, nRecordOffset, 0 ) != 0
- || fwrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 )
- {
- printf( "Error in fseek() or fwrite().\n" );
- free( pabyRec );
- return -1;
- }
-
- free( pabyRec );
-
- /* -------------------------------------------------------------------- */
- /* Expand file wide bounds based on this shape. */
- /* -------------------------------------------------------------------- */
- if ( psSHP->adBoundsMin[0] == 0.0
- && psSHP->adBoundsMax[0] == 0.0
- && psSHP->adBoundsMin[1] == 0.0
- && psSHP->adBoundsMax[1] == 0.0
- && psObject->nSHPType != SHPT_NULL )
- {
- psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0];
- psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0];
- psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0];
- psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM[0];
- }
-
- for ( i = 0; i < psObject->nVertices; i++ )
- {
- psSHP->adBoundsMin[0] = MIN( psSHP->adBoundsMin[0], psObject->padfX[i] );
- psSHP->adBoundsMin[1] = MIN( psSHP->adBoundsMin[1], psObject->padfY[i] );
- psSHP->adBoundsMin[2] = MIN( psSHP->adBoundsMin[2], psObject->padfZ[i] );
- psSHP->adBoundsMin[3] = MIN( psSHP->adBoundsMin[3], psObject->padfM[i] );
- psSHP->adBoundsMax[0] = MAX( psSHP->adBoundsMax[0], psObject->padfX[i] );
- psSHP->adBoundsMax[1] = MAX( psSHP->adBoundsMax[1], psObject->padfY[i] );
- psSHP->adBoundsMax[2] = MAX( psSHP->adBoundsMax[2], psObject->padfZ[i] );
- psSHP->adBoundsMax[3] = MAX( psSHP->adBoundsMax[3], psObject->padfM[i] );
- }
-
- return( nShapeId );
-}
-
-/************************************************************************/
-/* SHPReadObject() */
-/* */
-/* Read the vertices, parts, and other non-attribute information */
-/* for one shape. */
-/************************************************************************/
-
-SHPObject SHPAPI_CALL1( * )
-SHPReadObject( SHPHandle psSHP, int hEntity )
-
-{
- SHPObject *psShape;
-
- /* -------------------------------------------------------------------- */
- /* Validate the record/entity number. */
- /* -------------------------------------------------------------------- */
- if ( hEntity < 0 || hEntity >= psSHP->nRecords )
- return( NULL );
-
- /* -------------------------------------------------------------------- */
- /* Ensure our record buffer is large enough. */
- /* -------------------------------------------------------------------- */
- if ( psSHP->panRecSize[hEntity] + 8 > psSHP->nBufSize )
- {
- psSHP->nBufSize = psSHP->panRecSize[hEntity] + 8;
- psSHP->pabyRec = ( uchar * ) SfRealloc( psSHP->pabyRec, psSHP->nBufSize );
- }
-
- /* -------------------------------------------------------------------- */
- /* Read the record. */
- /* -------------------------------------------------------------------- */
- fseek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 );
- fread( psSHP->pabyRec, psSHP->panRecSize[hEntity] + 8, 1, psSHP->fpSHP );
-
- /* -------------------------------------------------------------------- */
- /* Allocate and minimally initialize the object. */
- /* -------------------------------------------------------------------- */
- psShape = ( SHPObject * ) calloc( 1, sizeof( SHPObject ) );
- psShape->nShapeId = hEntity;
-
- memcpy( &psShape->nSHPType, psSHP->pabyRec + 8, 4 );
- if ( bBigEndian ) SwapWord( 4, &( psShape->nSHPType ) );
-
- /* ==================================================================== */
- /* Extract vertices for a Polygon or Arc. */
- /* ==================================================================== */
- if ( psShape->nSHPType == SHPT_POLYGON || psShape->nSHPType == SHPT_ARC
- || psShape->nSHPType == SHPT_POLYGONZ
- || psShape->nSHPType == SHPT_POLYGONM
- || psShape->nSHPType == SHPT_ARCZ
- || psShape->nSHPType == SHPT_ARCM
- || psShape->nSHPType == SHPT_MULTIPATCH )
- {
- int32 nPoints, nParts;
- int i, nOffset;
-
- /* -------------------------------------------------------------------- */
- /* Get the X/Y bounds. */
- /* -------------------------------------------------------------------- */
- memcpy( &( psShape->dfXMin ), psSHP->pabyRec + 8 + 4, 8 );
- memcpy( &( psShape->dfYMin ), psSHP->pabyRec + 8 + 12, 8 );
- memcpy( &( psShape->dfXMax ), psSHP->pabyRec + 8 + 20, 8 );
- memcpy( &( psShape->dfYMax ), psSHP->pabyRec + 8 + 28, 8 );
-
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfXMin ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfYMin ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfXMax ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfYMax ) );
-
- /* -------------------------------------------------------------------- */
- /* Extract part/point count, and build vertex and part arrays */
- /* to proper size. */
- /* -------------------------------------------------------------------- */
- memcpy( &nPoints, psSHP->pabyRec + 40 + 8, 4 );
- memcpy( &nParts, psSHP->pabyRec + 36 + 8, 4 );
-
- if ( bBigEndian ) SwapWord( 4, &nPoints );
- if ( bBigEndian ) SwapWord( 4, &nParts );
-
- psShape->nVertices = nPoints;
- psShape->padfX = ( double * ) calloc( nPoints, sizeof( double ) );
- psShape->padfY = ( double * ) calloc( nPoints, sizeof( double ) );
- psShape->padfZ = ( double * ) calloc( nPoints, sizeof( double ) );
- psShape->padfM = ( double * ) calloc( nPoints, sizeof( double ) );
-
- psShape->nParts = nParts;
- psShape->panPartStart = ( int * ) calloc( nParts, sizeof( int ) );
- psShape->panPartType = ( int * ) calloc( nParts, sizeof( int ) );
-
- for ( i = 0; i < nParts; i++ )
- psShape->panPartType[i] = SHPP_RING;
-
- /* -------------------------------------------------------------------- */
- /* Copy out the part array from the record. */
- /* -------------------------------------------------------------------- */
- memcpy( psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts );
- for ( i = 0; i < nParts; i++ )
- {
- if ( bBigEndian ) SwapWord( 4, psShape->panPartStart + i );
- }
-
- nOffset = 44 + 8 + 4 * nParts;
-
- /* -------------------------------------------------------------------- */
- /* If this is a multipatch, we will also have parts types. */
- /* -------------------------------------------------------------------- */
- if ( psShape->nSHPType == SHPT_MULTIPATCH )
- {
- memcpy( psShape->panPartType, psSHP->pabyRec + nOffset, 4*nParts );
- for ( i = 0; i < nParts; i++ )
- {
- if ( bBigEndian ) SwapWord( 4, psShape->panPartType + i );
- }
-
- nOffset += 4 * nParts;
- }
-
- /* -------------------------------------------------------------------- */
- /* Copy out the vertices from the record. */
- /* -------------------------------------------------------------------- */
- for ( i = 0; i < nPoints; i++ )
- {
- memcpy( psShape->padfX + i,
- psSHP->pabyRec + nOffset + i * 16,
- 8 );
-
- memcpy( psShape->padfY + i,
- psSHP->pabyRec + nOffset + i * 16 + 8,
- 8 );
-
- if ( bBigEndian ) SwapWord( 8, psShape->padfX + i );
- if ( bBigEndian ) SwapWord( 8, psShape->padfY + i );
- }
-
- nOffset += 16 * nPoints;
-
- /* -------------------------------------------------------------------- */
- /* If we have a Z coordinate, collect that now. */
- /* -------------------------------------------------------------------- */
- if ( psShape->nSHPType == SHPT_POLYGONZ
- || psShape->nSHPType == SHPT_ARCZ
- || psShape->nSHPType == SHPT_MULTIPATCH )
- {
- memcpy( &( psShape->dfZMin ), psSHP->pabyRec + nOffset, 8 );
- memcpy( &( psShape->dfZMax ), psSHP->pabyRec + nOffset + 8, 8 );
-
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfZMin ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfZMax ) );
-
- for ( i = 0; i < nPoints; i++ )
- {
- memcpy( psShape->padfZ + i,
- psSHP->pabyRec + nOffset + 16 + i*8, 8 );
- if ( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
- }
-
- nOffset += 16 + 8 * nPoints;
- }
-
- /* -------------------------------------------------------------------- */
- /* If we have a M measure value, then read it now. We assume */
- /* that the measure can be present for any shape if the size is */
- /* big enough, but really it will only occur for the Z shapes */
- /* (options), and the M shapes. */
- /* -------------------------------------------------------------------- */
- if ( psSHP->panRecSize[hEntity] + 8 >= nOffset + 16 + 8*nPoints )
- {
- memcpy( &( psShape->dfMMin ), psSHP->pabyRec + nOffset, 8 );
- memcpy( &( psShape->dfMMax ), psSHP->pabyRec + nOffset + 8, 8 );
-
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfMMin ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfMMax ) );
-
- for ( i = 0; i < nPoints; i++ )
- {
- memcpy( psShape->padfM + i,
- psSHP->pabyRec + nOffset + 16 + i*8, 8 );
- if ( bBigEndian ) SwapWord( 8, psShape->padfM + i );
- }
- }
-
- }
-
- /* ==================================================================== */
- /* Extract vertices for a MultiPoint. */
- /* ==================================================================== */
- else if ( psShape->nSHPType == SHPT_MULTIPOINT
- || psShape->nSHPType == SHPT_MULTIPOINTM
- || psShape->nSHPType == SHPT_MULTIPOINTZ )
- {
- int32 nPoints;
- int i, nOffset;
-
- memcpy( &nPoints, psSHP->pabyRec + 44, 4 );
- if ( bBigEndian ) SwapWord( 4, &nPoints );
-
- psShape->nVertices = nPoints;
- psShape->padfX = ( double * ) calloc( nPoints, sizeof( double ) );
- psShape->padfY = ( double * ) calloc( nPoints, sizeof( double ) );
- psShape->padfZ = ( double * ) calloc( nPoints, sizeof( double ) );
- psShape->padfM = ( double * ) calloc( nPoints, sizeof( double ) );
-
- for ( i = 0; i < nPoints; i++ )
- {
- memcpy( psShape->padfX + i, psSHP->pabyRec + 48 + 16 * i, 8 );
- memcpy( psShape->padfY + i, psSHP->pabyRec + 48 + 16 * i + 8, 8 );
-
- if ( bBigEndian ) SwapWord( 8, psShape->padfX + i );
- if ( bBigEndian ) SwapWord( 8, psShape->padfY + i );
- }
-
- nOffset = 48 + 16 * nPoints;
-
- /* -------------------------------------------------------------------- */
- /* Get the X/Y bounds. */
- /* -------------------------------------------------------------------- */
- memcpy( &( psShape->dfXMin ), psSHP->pabyRec + 8 + 4, 8 );
- memcpy( &( psShape->dfYMin ), psSHP->pabyRec + 8 + 12, 8 );
- memcpy( &( psShape->dfXMax ), psSHP->pabyRec + 8 + 20, 8 );
- memcpy( &( psShape->dfYMax ), psSHP->pabyRec + 8 + 28, 8 );
-
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfXMin ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfYMin ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfXMax ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfYMax ) );
-
- /* -------------------------------------------------------------------- */
- /* If we have a Z coordinate, collect that now. */
- /* -------------------------------------------------------------------- */
- if ( psShape->nSHPType == SHPT_MULTIPOINTZ )
- {
- memcpy( &( psShape->dfZMin ), psSHP->pabyRec + nOffset, 8 );
- memcpy( &( psShape->dfZMax ), psSHP->pabyRec + nOffset + 8, 8 );
-
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfZMin ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfZMax ) );
-
- for ( i = 0; i < nPoints; i++ )
- {
- memcpy( psShape->padfZ + i,
- psSHP->pabyRec + nOffset + 16 + i*8, 8 );
- if ( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
- }
-
- nOffset += 16 + 8 * nPoints;
- }
-
- /* -------------------------------------------------------------------- */
- /* If we have a M measure value, then read it now. We assume */
- /* that the measure can be present for any shape if the size is */
- /* big enough, but really it will only occur for the Z shapes */
- /* (options), and the M shapes. */
- /* -------------------------------------------------------------------- */
- if ( psSHP->panRecSize[hEntity] + 8 >= nOffset + 16 + 8*nPoints )
- {
- memcpy( &( psShape->dfMMin ), psSHP->pabyRec + nOffset, 8 );
- memcpy( &( psShape->dfMMax ), psSHP->pabyRec + nOffset + 8, 8 );
-
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfMMin ) );
- if ( bBigEndian ) SwapWord( 8, &( psShape->dfMMax ) );
-
- for ( i = 0; i < nPoints; i++ )
- {
- memcpy( psShape->padfM + i,
- psSHP->pabyRec + nOffset + 16 + i*8, 8 );
- if ( bBigEndian ) SwapWord( 8, psShape->padfM + i );
- }
- }
- }
-
- /* ==================================================================== */
- /* Extract vertices for a point. */
- /* ==================================================================== */
- else if ( psShape->nSHPType == SHPT_POINT
- || psShape->nSHPType == SHPT_POINTM
- || psShape->nSHPType == SHPT_POINTZ )
- {
- int nOffset;
-
- psShape->nVertices = 1;
- psShape->padfX = ( double * ) calloc( 1, sizeof( double ) );
- psShape->padfY = ( double * ) calloc( 1, sizeof( double ) );
- psShape->padfZ = ( double * ) calloc( 1, sizeof( double ) );
- psShape->padfM = ( double * ) calloc( 1, sizeof( double ) );
-
- memcpy( psShape->padfX, psSHP->pabyRec + 12, 8 );
- memcpy( psShape->padfY, psSHP->pabyRec + 20, 8 );
-
- if ( bBigEndian ) SwapWord( 8, psShape->padfX );
- if ( bBigEndian ) SwapWord( 8, psShape->padfY );
-
- nOffset = 20 + 8;
-
- /* -------------------------------------------------------------------- */
- /* If we have a Z coordinate, collect that now. */
- /* -------------------------------------------------------------------- */
- if ( psShape->nSHPType == SHPT_POINTZ )
- {
- memcpy( psShape->padfZ, psSHP->pabyRec + nOffset, 8 );
-
- if ( bBigEndian ) SwapWord( 8, psShape->padfZ );
-
- nOffset += 8;
- }
-
- /* -------------------------------------------------------------------- */
- /* If we have a M measure value, then read it now. We assume */
- /* that the measure can be present for any shape if the size is */
- /* big enough, but really it will only occur for the Z shapes */
- /* (options), and the M shapes. */
- /* -------------------------------------------------------------------- */
- if ( psSHP->panRecSize[hEntity] + 8 >= nOffset + 8 )
- {
- memcpy( psShape->padfM, psSHP->pabyRec + nOffset, 8 );
-
- if ( bBigEndian ) SwapWord( 8, psShape->padfM );
- }
-
- /* -------------------------------------------------------------------- */
- /* Since no extents are supplied in the record, we will apply */
- /* them from the single vertex. */
- /* -------------------------------------------------------------------- */
- psShape->dfXMin = psShape->dfXMax = psShape->padfX[0];
- psShape->dfYMin = psShape->dfYMax = psShape->padfY[0];
- psShape->dfZMin = psShape->dfZMax = psShape->padfZ[0];
- psShape->dfMMin = psShape->dfMMax = psShape->padfM[0];
- }
-
- return( psShape );
-}
-
-/************************************************************************/
-/* SHPTypeName() */
-/************************************************************************/
-
-const char SHPAPI_CALL1( * )
-SHPTypeName( int nSHPType )
-
-{
- switch ( nSHPType )
- {
- case SHPT_NULL:
- return "NullShape";
-
- case SHPT_POINT:
- return "Point";
-
- case SHPT_ARC:
- return "Arc";
-
- case SHPT_POLYGON:
- return "Polygon";
-
- case SHPT_MULTIPOINT:
- return "MultiPoint";
-
- case SHPT_POINTZ:
- return "PointZ";
-
- case SHPT_ARCZ:
- return "ArcZ";
-
- case SHPT_POLYGONZ:
- return "PolygonZ";
-
- case SHPT_MULTIPOINTZ:
- return "MultiPointZ";
-
- case SHPT_POINTM:
- return "PointM";
-
- case SHPT_ARCM:
- return "ArcM";
-
- case SHPT_POLYGONM:
- return "PolygonM";
-
- case SHPT_MULTIPOINTM:
- return "MultiPointM";
-
- case SHPT_MULTIPATCH:
- return "MultiPatch";
-
- default:
- return "UnknownShapeType";
- }
-}
-
-/************************************************************************/
-/* SHPPartTypeName() */
-/************************************************************************/
-
-const char SHPAPI_CALL1( * )
-SHPPartTypeName( int nPartType )
-
-{
- switch ( nPartType )
- {
- case SHPP_TRISTRIP:
- return "TriangleStrip";
-
- case SHPP_TRIFAN:
- return "TriangleFan";
-
- case SHPP_OUTERRING:
- return "OuterRing";
-
- case SHPP_INNERRING:
- return "InnerRing";
-
- case SHPP_FIRSTRING:
- return "FirstRing";
-
- case SHPP_RING:
- return "Ring";
-
- default:
- return "UnknownPartType";
- }
-}
-
-/************************************************************************/
-/* SHPDestroyObject() */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPDestroyObject( SHPObject * psShape )
-
-{
- if ( psShape == NULL )
- return;
-
- if ( psShape->padfX != NULL )
- free( psShape->padfX );
- if ( psShape->padfY != NULL )
- free( psShape->padfY );
- if ( psShape->padfZ != NULL )
- free( psShape->padfZ );
- if ( psShape->padfM != NULL )
- free( psShape->padfM );
-
- if ( psShape->panPartStart != NULL )
- free( psShape->panPartStart );
- if ( psShape->panPartType != NULL )
- free( psShape->panPartType );
-
- free( psShape );
-}
-
-/************************************************************************/
-/* SHPRewindObject() */
-/* */
-/* Reset the winding of polygon objects to adhere to the */
-/* specification. */
-/************************************************************************/
-
-int SHPAPI_CALL
-SHPRewindObject( SHPHandle hSHP, SHPObject * psObject )
-
-{
- int iOpRing, bAltered = 0;
-
- /* -------------------------------------------------------------------- */
- /* Do nothing if this is not a polygon object. */
- /* -------------------------------------------------------------------- */
- if ( psObject->nSHPType != SHPT_POLYGON
- && psObject->nSHPType != SHPT_POLYGONZ
- && psObject->nSHPType != SHPT_POLYGONM )
- return 0;
-
- /* -------------------------------------------------------------------- */
- /* Process each of the rings. */
- /* -------------------------------------------------------------------- */
- for ( iOpRing = 0; iOpRing < psObject->nParts; iOpRing++ )
- {
- int bInner, iVert, nVertCount, nVertStart, iCheckRing;
- double dfSum, dfTestX, dfTestY;
-
- /* -------------------------------------------------------------------- */
- /* Determine if this ring is an inner ring or an outer ring */
- /* relative to all the other rings. For now we assume the */
- /* first ring is outer and all others are inner, but eventually */
- /* we need to fix this to handle multiple island polygons and */
- /* unordered sets of rings. */
- /* -------------------------------------------------------------------- */
- dfTestX = psObject->padfX[psObject->panPartStart[iOpRing]];
- dfTestY = psObject->padfY[psObject->panPartStart[iOpRing]];
-
- bInner = FALSE;
- for ( iCheckRing = 0; iCheckRing < psObject->nParts; iCheckRing++ )
- {
- int iEdge;
-
- if ( iCheckRing == iOpRing )
- continue;
-
- nVertStart = psObject->panPartStart[iCheckRing];
-
- if ( iCheckRing == psObject->nParts - 1 )
- nVertCount = psObject->nVertices
- - psObject->panPartStart[iCheckRing];
- else
- nVertCount = psObject->panPartStart[iCheckRing+1]
- - psObject->panPartStart[iCheckRing];
-
- for ( iEdge = 0; iEdge < nVertCount; iEdge++ )
- {
- int iNext;
-
- if ( iEdge < nVertCount - 1 )
- iNext = iEdge + 1;
- else
- iNext = 0;
-
- if (( psObject->padfY[iEdge+nVertStart] < dfTestY
- && psObject->padfY[iNext+nVertStart] >= dfTestY )
- || ( psObject->padfY[iNext+nVertStart] < dfTestY
- && psObject->padfY[iEdge+nVertStart] >= dfTestY ) )
- {
- if ( psObject->padfX[iEdge+nVertStart]
- + ( dfTestY - psObject->padfY[iEdge+nVertStart] )
- / ( psObject->padfY[iNext+nVertStart]
- - psObject->padfY[iEdge+nVertStart] )
- *( psObject->padfX[iNext+nVertStart]
- - psObject->padfX[iEdge+nVertStart] ) < dfTestX )
- bInner = !bInner;
- }
- }
- }
-
- /* -------------------------------------------------------------------- */
- /* Determine the current order of this ring so we will know if */
- /* it has to be reversed. */
- /* -------------------------------------------------------------------- */
- nVertStart = psObject->panPartStart[iOpRing];
-
- if ( iOpRing == psObject->nParts - 1 )
- nVertCount = psObject->nVertices - psObject->panPartStart[iOpRing];
- else
- nVertCount = psObject->panPartStart[iOpRing+1]
- - psObject->panPartStart[iOpRing];
-
- dfSum = 0.0;
- for ( iVert = nVertStart; iVert < nVertStart + nVertCount - 1; iVert++ )
- {
- dfSum += psObject->padfX[iVert] * psObject->padfY[iVert+1]
- - psObject->padfY[iVert] * psObject->padfX[iVert+1];
- }
-
- dfSum += psObject->padfX[iVert] * psObject->padfY[nVertStart]
- - psObject->padfY[iVert] * psObject->padfX[nVertStart];
-
- /* -------------------------------------------------------------------- */
- /* Reverse if necessary. */
- /* -------------------------------------------------------------------- */
- if (( dfSum < 0.0 && bInner ) || ( dfSum > 0.0 && !bInner ) )
- {
- int i;
-
- bAltered++;
- for ( i = 0; i < nVertCount / 2; i++ )
- {
- double dfSaved;
-
- /* Swap X */
- dfSaved = psObject->padfX[nVertStart+i];
- psObject->padfX[nVertStart+i] =
- psObject->padfX[nVertStart+nVertCount-i-1];
- psObject->padfX[nVertStart+nVertCount-i-1] = dfSaved;
-
- /* Swap Y */
- dfSaved = psObject->padfY[nVertStart+i];
- psObject->padfY[nVertStart+i] =
- psObject->padfY[nVertStart+nVertCount-i-1];
- psObject->padfY[nVertStart+nVertCount-i-1] = dfSaved;
-
- /* Swap Z */
- if ( psObject->padfZ )
- {
- dfSaved = psObject->padfZ[nVertStart+i];
- psObject->padfZ[nVertStart+i] =
- psObject->padfZ[nVertStart+nVertCount-i-1];
- psObject->padfZ[nVertStart+nVertCount-i-1] = dfSaved;
- }
-
- /* Swap M */
- if ( psObject->padfM )
- {
- dfSaved = psObject->padfM[nVertStart+i];
- psObject->padfM[nVertStart+i] =
- psObject->padfM[nVertStart+nVertCount-i-1];
- psObject->padfM[nVertStart+nVertCount-i-1] = dfSaved;
- }
- }
- }
- }
-
- return bAltered;
-}
diff --git a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shprewind.c b/src/plugins/dxf2shp_converter/shapelib-1.2.10/shprewind.c
deleted file mode 100644
index b034972..0000000
--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shprewind.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/******************************************************************************
- * $Id: shprewind.c,v 1.2 2002/04/10 17:23:11 warmerda Exp $
- *
- * Project: Shapelib
- * Purpose: Utility to validate and reset the winding order of rings in
- * polygon geometries to match the ordering required by spec.
- * Author: Frank Warmerdam, warmerdam at pobox.com
- *
- ******************************************************************************
- * Copyright (c) 2002, Frank Warmerdam
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log: shprewind.c,v $
- * Revision 1.2 2002/04/10 17:23:11 warmerda
- * copy from source to destination now
- *
- * Revision 1.1 2002/04/10 16:56:36 warmerda
- * New
- *
- */
-
-#include "shapefil.h"
-
-int main( int argc, char ** argv )
-
-{
- SHPHandle hSHP, hSHPOut;
- int nShapeType, nEntities, i, nInvalidCount = 0;
- double adfMinBound[4], adfMaxBound[4];
-
- /* -------------------------------------------------------------------- */
- /* Display a usage message. */
- /* -------------------------------------------------------------------- */
- if ( argc != 3 )
- {
- printf( "shprewind in_shp_file out_shp_file\n" );
- exit( 1 );
- }
-
- /* -------------------------------------------------------------------- */
- /* Open the passed shapefile. */
- /* -------------------------------------------------------------------- */
- hSHP = SHPOpen( argv[1], "rb" );
-
- if ( hSHP == NULL )
- {
- printf( "Unable to open:%s\n", argv[1] );
- exit( 1 );
- }
-
- SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound );
-
- /* -------------------------------------------------------------------- */
- /* Create output shapefile. */
- /* -------------------------------------------------------------------- */
- hSHPOut = SHPCreate( argv[2], nShapeType );
-
- if ( hSHPOut == NULL )
- {
- printf( "Unable to create:%s\n", argv[2] );
- exit( 1 );
- }
-
- /* -------------------------------------------------------------------- */
- /* Skim over the list of shapes, printing all the vertices. */
- /* -------------------------------------------------------------------- */
- for ( i = 0; i < nEntities; i++ )
- {
- SHPObject *psShape;
-
- psShape = SHPReadObject( hSHP, i );
- if ( SHPRewindObject( hSHP, psShape ) )
- nInvalidCount++;
- SHPWriteObject( hSHPOut, -1, psShape );
- SHPDestroyObject( psShape );
- }
-
- SHPClose( hSHP );
- SHPClose( hSHPOut );
-
- printf( "%d objects rewound.\n", nInvalidCount );
-
- exit( 0 );
-}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/qgis.git
More information about the Pkg-grass-devel
mailing list