diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd80fd5c94..296008fff7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -360,6 +360,7 @@ add_subdirectory( cvpcb )
add_subdirectory( eeschema )
add_subdirectory( gerbview )
add_subdirectory( kicad )
+add_subdirectory( lib_dxf )
add_subdirectory( pcbnew )
add_subdirectory( polygon )
add_subdirectory( pagelayout_editor )
diff --git a/lib_dxf/CMakeLists.txt b/lib_dxf/CMakeLists.txt
new file mode 100644
index 0000000000..1a729823e2
--- /dev/null
+++ b/lib_dxf/CMakeLists.txt
@@ -0,0 +1,12 @@
+include_directories(intern)
+
+set(LIBDXF_SRCS
+ libdxfrw.cpp
+ intern/dxfwriter.cpp
+ intern/drw_textcodec.cpp
+ intern/dxfreader.cpp
+ drw_objects.cpp
+ drw_entities.cpp
+ )
+
+add_library(lib_dxf STATIC ${LIBDXF_SRCS})
diff --git a/lib_dxf/CREDITS.txt b/lib_dxf/CREDITS.txt
new file mode 100644
index 0000000000..04a1e7e217
--- /dev/null
+++ b/lib_dxf/CREDITS.txt
@@ -0,0 +1,4 @@
+This library comes from the LibreCAD project, a 2D CAD program.
+see http://sourceforge.net/projects/libdxfrw/
+the latest sources are on:
+https://github.com/LibreCAD/LibreCAD/tree/master/libraries/libdxfrw/src
diff --git a/lib_dxf/drw_base.h b/lib_dxf/drw_base.h
new file mode 100644
index 0000000000..0be3367524
--- /dev/null
+++ b/lib_dxf/drw_base.h
@@ -0,0 +1,473 @@
+/******************************************************************************
+** libDXFrw - Library to read/write DXF files (ascii & binary) **
+** **
+** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
+** **
+** This library is free software, licensed 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. **
+** You should have received a copy of the GNU General Public License **
+** along with this program. If not, see . **
+******************************************************************************/
+
+#ifndef DRW_BASE_H
+#define DRW_BASE_H
+
+#define DRW_VERSION "0.5.10"
+
+#include
+#include
+
+using std::string;
+
+#define UTF8STRING std::string
+#define DRW_UNUSED( x ) (void) x
+
+#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
+# define DRW_WIN
+#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
+# define DRW_WIN
+#elif defined(__MWERKS__) && defined(__INTEL__)
+# define DRW_WIN
+#else
+# define DRW_POSIX
+#endif
+
+#ifndef M_PI
+ #define M_PI 3.141592653589793238462643
+#endif
+#ifndef M_PI_2
+ #define M_PI_2 1.57079632679489661923
+#endif
+#define M_PIx2 6.283185307179586 // 2*PI
+#define ARAD 57.29577951308232
+
+namespace DRW {
+// ! Version numbers for the DXF Format.
+enum Version {
+ UNKNOWNV, /*!< UNKNOWN VERSION. */
+ AC1006, /*!< R10. */
+ AC1009, /*!< R11 & R12. */
+ AC1012, /*!< R13. */
+ AC1014, /*!< R14. */
+ AC1015, /*!< ACAD 2000. */
+ AC1018, /*!< ACAD 2004. */
+ AC1021, /*!< ACAD 2007. */
+ AC1024 /*!< ACAD 2010. */
+};
+
+enum error {
+ BAD_NONE, /*!< No error. */
+ BAD_UNKNOWN, /*!< UNKNOWN. */
+ BAD_OPEN, /*!< error opening file. */
+ BAD_VERSION, /*!< unsupported version. */
+ BAD_READ_FILE_HEADER, /*!< error in file header read process. */
+ BAD_READ_HEADER, /*!< error in header vars read process. */
+ BAD_READ_OFFSETS, /*!< error in object map read process. */
+ BAD_READ_CLASSES, /*!< error in classes read process. */
+ BAD_READ_TABLES, /*!< error in tables read process. */
+ BAD_READ_ENTITIES /*!< error in entities read process. */
+};
+}
+
+// ! Class to handle 3D coordinate point
+/*!
+ * Class to handle 3D coordinate point
+ * @author Rallaz
+ */
+class DRW_Coord
+{
+public:
+ DRW_Coord() { x = 0; y = 0; z = 0; }
+ DRW_Coord( double ix, double iy, double iz )
+ {
+ x = ix; y = iy; z = iz;
+ }
+
+ DRW_Coord operator =( const DRW_Coord& data )
+ {
+ x = data.x; y = data.y; z = data.z;
+ return *this;
+ }
+
+/*!< convert to unitary vector */
+ void unitize()
+ {
+ double dist;
+
+ dist = sqrt( x * x + y * y + z * z );
+
+ if( dist > 0.0 )
+ {
+ x = x / dist;
+ y = y / dist;
+ z = z / dist;
+ }
+ }
+
+public:
+ double x;
+ double y;
+ double z;
+};
+
+
+// ! Class to handle vertex
+/*!
+ * Class to handle vertex for lwpolyline entity
+ * @author Rallaz
+ */
+class DRW_Vertex2D
+{
+public:
+ DRW_Vertex2D()
+ {
+// eType = DRW::LWPOLYLINE;
+ stawidth = endwidth = bulge = 0;
+ }
+
+ DRW_Vertex2D( double sx, double sy, double b )
+ {
+ stawidth = endwidth = 0;
+ x = sx;
+ y = sy;
+ bulge = b;
+ }
+
+public:
+ double x; /*!< x coordinate, code 10 */
+ double y; /*!< y coordinate, code 20 */
+ double stawidth; /*!< Start width, code 40 */
+ double endwidth; /*!< End width, code 41 */
+ double bulge; /*!< bulge, code 42 */
+};
+
+
+// ! Class to handle header vars
+/*!
+ * Class to handle header vars
+ * @author Rallaz
+ */
+class DRW_Variant
+{
+public:
+ enum TYPE {
+ STRING,
+ INTEGER,
+ DOUBLE,
+ COORD,
+ INVALID
+ };
+
+ DRW_Variant()
+ {
+ type = INVALID;
+ }
+
+ ~DRW_Variant()
+ {
+ if( type == COORD )
+ delete content.v;
+ }
+
+ enum TYPE type;
+
+ void addString( UTF8STRING s ) { setType( STRING ); data = s; content.s = &data; }
+ void addInt( int i ) { setType( INTEGER ); content.i = i; }
+ void addDouble( double d ) { setType( DOUBLE ); content.d = d; }
+ void addCoord( DRW_Coord* v ) { setType( COORD ); content.v = v; }
+ void setType( enum TYPE t )
+ {
+ if( type == COORD )
+ delete content.v;
+
+ type = t;
+ }
+
+ void setCoordX( double d ) { if( type == COORD ) content.v->x = d; }
+ void setCoordY( double d ) { if( type == COORD ) content.v->y = d; }
+ void setCoordZ( double d ) { if( type == COORD ) content.v->z = d; }
+private:
+ typedef union
+ {
+ UTF8STRING* s;
+ int i;
+ double d;
+ DRW_Coord* v;
+ } DRW_VarContent;
+public:
+ DRW_VarContent content;
+public:
+ int code;
+// string version;
+// string codepage;
+private:
+// DRW_VarContent content;
+ string data;
+};
+
+
+// ! Class to convert between line width and integer
+/*!
+ * Class to convert between line width and integer
+ * verifing valid values, if value is not valid
+ * returns widthDefault.
+ * @author Rallaz
+ */
+class DRW_LW_Conv
+{
+public:
+ enum lineWidth {
+ width00 = 0, /*!< 0.00mm (dxf 0)*/
+ width01 = 1, /*!< 0.05mm (dxf 5)*/
+ width02 = 2, /*!< 0.09mm (dxf 9)*/
+ width03 = 3, /*!< 0.13mm (dxf 13)*/
+ width04 = 4, /*!< 0.15mm (dxf 15)*/
+ width05 = 5, /*!< 0.18mm (dxf 18)*/
+ width06 = 6, /*!< 0.20mm (dxf 20)*/
+ width07 = 7, /*!< 0.25mm (dxf 25)*/
+ width08 = 8, /*!< 0.30mm (dxf 30)*/
+ width09 = 9, /*!< 0.35mm (dxf 35)*/
+ width10 = 10, /*!< 0.40mm (dxf 40)*/
+ width11 = 11, /*!< 0.50mm (dxf 50)*/
+ width12 = 12, /*!< 0.53mm (dxf 53)*/
+ width13 = 13, /*!< 0.60mm (dxf 60)*/
+ width14 = 14, /*!< 0.70mm (dxf 70)*/
+ width15 = 15, /*!< 0.80mm (dxf 80)*/
+ width16 = 16, /*!< 0.90mm (dxf 90)*/
+ width17 = 17, /*!< 1.00mm (dxf 100)*/
+ width18 = 18, /*!< 1.06mm (dxf 106)*/
+ width19 = 19, /*!< 1.20mm (dxf 120)*/
+ width20 = 20, /*!< 1.40mm (dxf 140)*/
+ width21 = 21, /*!< 1.58mm (dxf 158)*/
+ width22 = 22, /*!< 2.00mm (dxf 200)*/
+ width23 = 23, /*!< 2.11mm (dxf 211)*/
+ widthByLayer = 29, /*!< by layer (dxf -1) */
+ widthByBlock = 30, /*!< by block (dxf -2) */
+ widthDefault = 31 /*!< by default (dxf -3) */
+ };
+
+ static int lineWidth2dxfInt( enum lineWidth lw )
+ {
+ switch( lw )
+ {
+ case widthByLayer:
+ return -1;
+
+ case widthByBlock:
+ return -2;
+
+ case widthDefault:
+ return -3;
+
+ case width00:
+ return 0;
+
+ case width01:
+ return 5;
+
+ case width02:
+ return 9;
+
+ case width03:
+ return 13;
+
+ case width04:
+ return 15;
+
+ case width05:
+ return 18;
+
+ case width06:
+ return 20;
+
+ case width07:
+ return 25;
+
+ case width08:
+ return 30;
+
+ case width09:
+ return 35;
+
+ case width10:
+ return 40;
+
+ case width11:
+ return 50;
+
+ case width12:
+ return 53;
+
+ case width13:
+ return 60;
+
+ case width14:
+ return 70;
+
+ case width15:
+ return 80;
+
+ case width16:
+ return 90;
+
+ case width17:
+ return 100;
+
+ case width18:
+ return 106;
+
+ case width19:
+ return 120;
+
+ case width20:
+ return 140;
+
+ case width21:
+ return 158;
+
+ case width22:
+ return 200;
+
+ case width23:
+ return 211;
+
+ default:
+ return -3;
+ }
+
+ return static_cast (lw);
+ }
+
+ static int lineWidth2dwgInt( enum lineWidth lw )
+ {
+ return static_cast (lw);
+ }
+
+ static enum lineWidth dxfInt2lineWidth( int i )
+ {
+ if( i<0 )
+ {
+ if( i==-1 )
+ return widthByLayer;
+ else if( i==-2 )
+ return widthByBlock;
+ else if( i==-3 )
+ return widthDefault;
+ }
+ else if( i<3 )
+ {
+ return width00;
+ }
+ else if( i<7 )
+ {
+ return width01;
+ }
+ else if( i<11 )
+ {
+ return width02;
+ }
+ else if( i<14 )
+ {
+ return width03;
+ }
+ else if( i<16 )
+ {
+ return width04;
+ }
+ else if( i<19 )
+ {
+ return width05;
+ }
+ else if( i<22 )
+ {
+ return width06;
+ }
+ else if( i<27 )
+ {
+ return width07;
+ }
+ else if( i<32 )
+ {
+ return width08;
+ }
+ else if( i<37 )
+ {
+ return width09;
+ }
+ else if( i<45 )
+ {
+ return width10;
+ }
+ else if( i<52 )
+ {
+ return width11;
+ }
+ else if( i<57 )
+ {
+ return width12;
+ }
+ else if( i<65 )
+ {
+ return width13;
+ }
+ else if( i<75 )
+ {
+ return width14;
+ }
+ else if( i<85 )
+ {
+ return width15;
+ }
+ else if( i<95 )
+ {
+ return width16;
+ }
+ else if( i<103 )
+ {
+ return width17;
+ }
+ else if( i<112 )
+ {
+ return width18;
+ }
+ else if( i<130 )
+ {
+ return width19;
+ }
+ else if( i<149 )
+ {
+ return width20;
+ }
+ else if( i<180 )
+ {
+ return width21;
+ }
+ else if( i<205 )
+ {
+ return width22;
+ }
+ else
+ {
+ return width23;
+ }
+
+ // default by default
+ return widthDefault;
+ }
+
+ static enum lineWidth dwgInt2lineWidth( int i )
+ {
+ if( (i>-1 && i<24) || (i>28 && i<32) )
+ {
+ return static_cast (i);
+ }
+
+ // default by default
+ return widthDefault;
+ }
+};
+
+#endif
+
+// EOF
diff --git a/lib_dxf/drw_entities.cpp b/lib_dxf/drw_entities.cpp
new file mode 100644
index 0000000000..93107e9ba7
--- /dev/null
+++ b/lib_dxf/drw_entities.cpp
@@ -0,0 +1,1429 @@
+/******************************************************************************
+** libDXFrw - Library to read/write DXF files (ascii & binary) **
+** **
+** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
+** **
+** This library is free software, licensed 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. **
+** You should have received a copy of the GNU General Public License **
+** along with this program. If not, see . **
+******************************************************************************/
+
+#include
+#include "drw_entities.h"
+#include "intern/dxfreader.h"
+
+
+// ! Calculate arbitary axis
+/*!
+ * Calculate arbitary axis for apply extrusions
+ * @author Rallaz
+ */
+void DRW_Entity::calculateAxis( DRW_Coord extPoint )
+{
+ if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 )
+ {
+ extAxisX.x = extPoint.z;
+ extAxisX.y = 0;
+ extAxisX.z = -extPoint.x;
+ }
+ else
+ {
+ extAxisX.x = -extPoint.y;
+ extAxisX.y = extPoint.x;
+ extAxisX.z = 0;
+ }
+
+ extAxisX.unitize();
+ extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
+ extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
+ extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);
+ extAxisY.unitize();
+}
+
+
+// ! Extrude a point using arbitary axis
+/*!
+ * apply extrusion in a point using arbitary axis (previous calculated)
+ * @author Rallaz
+ */
+void DRW_Entity::extrudePoint( DRW_Coord extPoint, DRW_Coord* point )
+{
+ double px, py, pz;
+
+ px = (extAxisX.x * point->x) + (extAxisY.x * point->y) + (extPoint.x * point->z);
+ py = (extAxisX.y * point->x) + (extAxisY.y * point->y) + (extPoint.y * point->z);
+ pz = (extAxisX.z * point->x) + (extAxisY.z * point->y) + (extPoint.z * point->z);
+
+ point->x = px;
+ point->y = py;
+ point->z = pz;
+}
+
+
+void DRW_Entity::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 5:
+ handle = reader->getHandleString();
+ break;
+
+ case 330:
+ handleBlock = reader->getHandleString();
+ break;
+
+ case 8:
+ layer = reader->getUtf8String();
+ break;
+
+ case 6:
+ lineType = reader->getUtf8String();
+ break;
+
+ case 62:
+ color = reader->getInt32();
+ break;
+
+ case 370:
+ lWeight = DRW_LW_Conv::dxfInt2lineWidth( reader->getInt32() );
+ break;
+
+ case 48:
+ ltypeScale = reader->getDouble();
+ break;
+
+ case 60:
+ visible = reader->getBool();
+ break;
+
+ case 420:
+ color24 = reader->getInt32();
+ break;
+
+ case 430:
+ colorName = reader->getString();
+ break;
+
+ case 67:
+ space = reader->getInt32();
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void DRW_Point::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 10:
+ basePoint.x = reader->getDouble();
+ break;
+
+ case 20:
+ basePoint.y = reader->getDouble();
+ break;
+
+ case 30:
+ basePoint.z = reader->getDouble();
+ break;
+
+ case 39:
+ thickness = reader->getDouble();
+ break;
+
+ case 210:
+ haveExtrusion = true;
+ extPoint.x = reader->getDouble();
+ break;
+
+ case 220:
+ extPoint.y = reader->getDouble();
+ break;
+
+ case 230:
+ extPoint.z = reader->getDouble();
+ break;
+
+ default:
+ DRW_Entity::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Line::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 11:
+ secPoint.x = reader->getDouble();
+ break;
+
+ case 21:
+ secPoint.y = reader->getDouble();
+ break;
+
+ case 31:
+ secPoint.z = reader->getDouble();
+ break;
+
+ default:
+ DRW_Point::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Circle::applyExtrusion()
+{
+ if( haveExtrusion )
+ {
+ calculateAxis( extPoint );
+ extrudePoint( extPoint, &basePoint );
+ }
+}
+
+
+void DRW_Circle::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 40:
+ radious = reader->getDouble();
+ break;
+
+ default:
+ DRW_Point::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Arc::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 50:
+ staangle = reader->getDouble() / ARAD;
+ break;
+
+ case 51:
+ endangle = reader->getDouble() / ARAD;
+ break;
+
+ default:
+ DRW_Circle::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Ellipse::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 40:
+ ratio = reader->getDouble();
+ break;
+
+ case 41:
+ staparam = reader->getDouble();
+ break;
+
+ case 42:
+ endparam = reader->getDouble();
+ break;
+
+ default:
+ DRW_Line::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Ellipse::applyExtrusion()
+{
+ if( haveExtrusion )
+ {
+ calculateAxis( extPoint );
+ extrudePoint( extPoint, &secPoint );
+ double intialparam = staparam;
+
+ if( extPoint.z < 0. )
+ {
+ staparam = M_PIx2 - endparam;
+ endparam = M_PIx2 - intialparam;
+ }
+ }
+}
+
+
+// if ratio > 1 minor axis are greather than major axis, correct it
+void DRW_Ellipse::correctAxis()
+{
+ bool complete = false;
+
+ if( staparam == endparam )
+ {
+ staparam = 0.0;
+ endparam = M_PIx2; // 2*M_PI;
+ complete = true;
+ }
+
+ if( ratio > 1 )
+ {
+ if( fabs( endparam - staparam - M_PIx2 ) < 1.0e-10 )
+ complete = true;
+
+ double incX = secPoint.x;
+ secPoint.x = -(secPoint.y * ratio);
+ secPoint.y = incX * ratio;
+ ratio = 1 / ratio;
+
+ if( !complete )
+ {
+ if( staparam < M_PI_2 )
+ staparam += M_PI * 2;
+
+ if( endparam < M_PI_2 )
+ endparam += M_PI * 2;
+
+ endparam -= M_PI_2;
+ staparam -= M_PI_2;
+ }
+ }
+}
+
+
+// parts are the number of vertex to split polyline, default 128
+void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts )
+{
+ double radMajor, radMinor, cosRot, sinRot, incAngle, curAngle;
+ double cosCurr, sinCurr;
+
+ radMajor = sqrt( secPoint.x * secPoint.x + secPoint.y * secPoint.y );
+ radMinor = radMajor * ratio;
+ // calculate sin & cos of included angle
+ incAngle = atan2( secPoint.y, secPoint.x );
+ cosRot = cos( incAngle );
+ sinRot = sin( incAngle );
+ incAngle = M_PIx2 / parts;
+ curAngle = staparam;
+ int i = curAngle / incAngle;
+
+ do {
+ if( curAngle > endparam )
+ {
+ curAngle = endparam;
+ i = parts + 2;
+ }
+
+ cosCurr = cos( curAngle );
+ sinCurr = sin( curAngle );
+ double x = basePoint.x + (cosCurr * cosRot * radMajor) - (sinCurr * sinRot * radMinor);
+ double y = basePoint.y + (cosCurr * sinRot * radMajor) + (sinCurr * cosRot * radMinor);
+ pol->addVertex( DRW_Vertex( x, y, 0.0, 0.0 ) );
+ curAngle = (++i) * incAngle;
+ } while( iflags = 1;
+ }
+
+ pol->layer = this->layer;
+ pol->lineType = this->lineType;
+ pol->color = this->color;
+ pol->lWeight = this->lWeight;
+ pol->extPoint = this->extPoint;
+}
+
+
+void DRW_Trace::applyExtrusion()
+{
+ if( haveExtrusion )
+ {
+ calculateAxis( extPoint );
+ extrudePoint( extPoint, &basePoint );
+ extrudePoint( extPoint, &secPoint );
+ extrudePoint( extPoint, &thirdPoint );
+ extrudePoint( extPoint, &fourPoint );
+ }
+}
+
+
+void DRW_Trace::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 12:
+ thirdPoint.x = reader->getDouble();
+ break;
+
+ case 22:
+ thirdPoint.y = reader->getDouble();
+ break;
+
+ case 32:
+ thirdPoint.z = reader->getDouble();
+ break;
+
+ case 13:
+ fourPoint.x = reader->getDouble();
+ break;
+
+ case 23:
+ fourPoint.y = reader->getDouble();
+ break;
+
+ case 33:
+ fourPoint.z = reader->getDouble();
+ break;
+
+ default:
+ DRW_Line::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Solid::parseCode( int code, dxfReader* reader )
+{
+ DRW_Trace::parseCode( code, reader );
+}
+
+
+void DRW_3Dface::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 70:
+ invisibleflag = reader->getInt32();
+ break;
+
+ default:
+ DRW_Trace::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Block::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 2:
+ name = reader->getUtf8String();
+ break;
+
+ case 70:
+ flags = reader->getInt32();
+ break;
+
+ default:
+ DRW_Point::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Insert::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 2:
+ name = reader->getUtf8String();
+ break;
+
+ case 41:
+ xscale = reader->getDouble();
+ break;
+
+ case 42:
+ yscale = reader->getDouble();
+ break;
+
+ case 43:
+ zscale = reader->getDouble();
+ break;
+
+ case 50:
+ angle = reader->getDouble();
+ break;
+
+ case 70:
+ colcount = reader->getInt32();
+ break;
+
+ case 71:
+ rowcount = reader->getInt32();
+ break;
+
+ case 44:
+ colspace = reader->getDouble();
+ break;
+
+ case 45:
+ rowspace = reader->getDouble();
+ break;
+
+ default:
+ DRW_Point::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_LWPolyline::applyExtrusion()
+{
+ if( haveExtrusion )
+ {
+ calculateAxis( extPoint );
+
+ for( unsigned int i = 0; ix, vert->y, elevation );
+ extrudePoint( extPoint, &v );
+ vert->x = v.x;
+ vert->y = v.y;
+ }
+ }
+}
+
+
+void DRW_LWPolyline::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 10:
+ {
+ vertex = new DRW_Vertex2D();
+ vertlist.push_back( vertex );
+ vertex->x = reader->getDouble();
+ break;
+ }
+
+ case 20:
+
+ if( vertex != NULL )
+ vertex->y = reader->getDouble();
+
+ break;
+
+ case 40:
+
+ if( vertex != NULL )
+ vertex->stawidth = reader->getDouble();
+
+ break;
+
+ case 41:
+
+ if( vertex != NULL )
+ vertex->endwidth = reader->getDouble();
+
+ break;
+
+ case 42:
+
+ if( vertex != NULL )
+ vertex->bulge = reader->getDouble();
+
+ break;
+
+ case 38:
+ elevation = reader->getDouble();
+ break;
+
+ case 39:
+ thickness = reader->getDouble();
+ break;
+
+ case 43:
+ width = reader->getDouble();
+ break;
+
+ case 70:
+ flags = reader->getInt32();
+ break;
+
+ case 90:
+ vertexnum = reader->getInt32();
+ vertlist.reserve( vertexnum );
+ break;
+
+ case 210:
+ haveExtrusion = true;
+ extPoint.x = reader->getDouble();
+ break;
+
+ case 220:
+ extPoint.y = reader->getDouble();
+ break;
+
+ case 230:
+ extPoint.z = reader->getDouble();
+ break;
+
+ default:
+ DRW_Entity::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Text::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 40:
+ height = reader->getDouble();
+ break;
+
+ case 41:
+ widthscale = reader->getDouble();
+ break;
+
+ case 50:
+ angle = reader->getDouble();
+ break;
+
+ case 51:
+ oblique = reader->getDouble();
+ break;
+
+ case 71:
+ textgen = reader->getInt32();
+ break;
+
+ case 72:
+ alignH = (HAlign) reader->getInt32();
+ break;
+
+ case 73:
+ alignV = (VAlign) reader->getInt32();
+ break;
+
+ case 1:
+ text = reader->getUtf8String();
+ break;
+
+ case 7:
+ style = reader->getUtf8String();
+ break;
+
+ default:
+ DRW_Line::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_MText::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 1:
+ text += reader->getString();
+ text = reader->toUtf8String( text );
+ break;
+
+ case 11:
+ haveXAxis = true;
+ DRW_Text::parseCode( code, reader );
+ break;
+
+ case 3:
+ text += reader->getString();
+ break;
+
+ case 44:
+ interlin = reader->getDouble();
+ break;
+
+ default:
+ DRW_Text::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_MText::updateAngle()
+{
+ if( haveXAxis )
+ {
+ angle = atan2( secPoint.y, secPoint.x ) * 180 / M_PI;
+ }
+}
+
+
+void DRW_Polyline::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 70:
+ flags = reader->getInt32();
+ break;
+
+ case 40:
+ defstawidth = reader->getDouble();
+ break;
+
+ case 41:
+ defendwidth = reader->getDouble();
+ break;
+
+ case 71:
+ vertexcount = reader->getInt32();
+ break;
+
+ case 72:
+ facecount = reader->getInt32();
+ break;
+
+ case 73:
+ smoothM = reader->getInt32();
+ break;
+
+ case 74:
+ smoothN = reader->getInt32();
+ break;
+
+ case 75:
+ curvetype = reader->getInt32();
+ break;
+
+ default:
+ DRW_Point::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Vertex::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 70:
+ flags = reader->getInt32();
+ break;
+
+ case 40:
+ stawidth = reader->getDouble();
+ break;
+
+ case 41:
+ endwidth = reader->getDouble();
+ break;
+
+ case 42:
+ bulge = reader->getDouble();
+ break;
+
+ case 50:
+ tgdir = reader->getDouble();
+ break;
+
+ case 71:
+ vindex1 = reader->getInt32();
+ break;
+
+ case 72:
+ vindex2 = reader->getInt32();
+ break;
+
+ case 73:
+ vindex3 = reader->getInt32();
+ break;
+
+ case 74:
+ vindex4 = reader->getInt32();
+ break;
+
+ case 91:
+ identifier = reader->getInt32();
+ break;
+
+ default:
+ DRW_Point::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Hatch::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 2:
+ name = reader->getUtf8String();
+ break;
+
+ case 70:
+ solid = reader->getInt32();
+ break;
+
+ case 71:
+ associative = reader->getInt32();
+ break;
+
+ case 72: /*edge type*/
+
+ if( ispol ) // if is polyline is a as_bulge flag
+ {
+ break;
+ }
+ else if( reader->getInt32() == 1 ) // line
+ {
+ addLine();
+ }
+ else if( reader->getInt32() == 2 ) // arc
+ {
+ addArc();
+ }
+ else if( reader->getInt32() == 3 ) // elliptic arc
+ {
+ addEllipse();
+ }
+ else if( reader->getInt32() == 4 ) // spline
+ {
+ addSpline();
+ }
+
+ break;
+
+ case 10:
+
+ if( pt )
+ pt->basePoint.x = reader->getDouble();
+ else if( pline )
+ {
+ plvert = pline->addVertex();
+ plvert->x = reader->getDouble();
+ }
+
+ break;
+
+ case 20:
+
+ if( pt )
+ pt->basePoint.y = reader->getDouble();
+ else if( plvert )
+ plvert->y = reader->getDouble();
+
+ break;
+
+ case 11:
+
+ if( line )
+ line->secPoint.x = reader->getDouble();
+ else if( ellipse )
+ ellipse->secPoint.x = reader->getDouble();
+
+ break;
+
+ case 21:
+
+ if( line )
+ line->secPoint.y = reader->getDouble();
+ else if( ellipse )
+ ellipse->secPoint.y = reader->getDouble();
+
+ break;
+
+ case 40:
+
+ if( arc )
+ arc->radious = reader->getDouble();
+ else if( ellipse )
+ ellipse->ratio = reader->getDouble();
+
+ break;
+
+ case 41:
+ scale = reader->getDouble();
+ break;
+
+ case 42:
+
+ if( plvert )
+ plvert->bulge = reader->getDouble();
+
+ break;
+
+ case 50:
+
+ if( arc )
+ arc->staangle = reader->getDouble() / ARAD;
+ else if( ellipse )
+ ellipse->staparam = reader->getDouble() / ARAD;
+
+ break;
+
+ case 51:
+
+ if( arc )
+ arc->endangle = reader->getDouble() / ARAD;
+ else if( ellipse )
+ ellipse->endparam = reader->getDouble() / ARAD;
+
+ break;
+
+ case 52:
+ angle = reader->getDouble();
+ break;
+
+ case 73:
+
+ if( arc )
+ arc->isccw = reader->getInt32();
+ else if( pline )
+ pline->flags = reader->getInt32();
+
+ break;
+
+ case 75:
+ hstyle = reader->getInt32();
+ break;
+
+ case 76:
+ hpattern = reader->getInt32();
+ break;
+
+ case 77:
+ doubleflag = reader->getInt32();
+ break;
+
+ case 78:
+ deflines = reader->getInt32();
+ break;
+
+ case 91:
+ loopsnum = reader->getInt32();
+ looplist.reserve( loopsnum );
+ break;
+
+ case 92:
+ loop = new DRW_HatchLoop( reader->getInt32() );
+ looplist.push_back( loop );
+
+ if( reader->getInt32() & 2 )
+ {
+ ispol = true;
+ clearEntities();
+ pline = new DRW_LWPolyline;
+ loop->objlist.push_back( pline );
+ }
+ else
+ ispol = false;
+
+ break;
+
+ case 93:
+
+ if( pline )
+ pline->vertexnum = reader->getInt32();
+ else
+ loop->numedges = reader->getInt32(); // aqui reserve
+
+ break;
+
+ case 98: // seed points ??
+ clearEntities();
+ break;
+
+ default:
+ DRW_Point::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Spline::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 210:
+ ex = reader->getDouble();
+ break;
+
+ case 220:
+ ey = reader->getDouble();
+ break;
+
+ case 230:
+ ez = reader->getDouble();
+ break;
+
+ case 12:
+ tgsx = reader->getDouble();
+ break;
+
+ case 22:
+ tgsy = reader->getDouble();
+ break;
+
+ case 32:
+ tgsz = reader->getDouble();
+ break;
+
+ case 13:
+ tgex = reader->getDouble();
+ break;
+
+ case 23:
+ tgey = reader->getDouble();
+ break;
+
+ case 33:
+ tgez = reader->getDouble();
+ break;
+
+ case 70:
+ flags = reader->getInt32();
+ break;
+
+ case 71:
+ degree = reader->getInt32();
+ break;
+
+ case 72:
+ nknots = reader->getInt32();
+ break;
+
+ case 73:
+ ncontrol = reader->getInt32();
+ break;
+
+ case 74:
+ nfit = reader->getInt32();
+ break;
+
+ case 42:
+ tolknot = reader->getDouble();
+ break;
+
+ case 43:
+ tolcontrol = reader->getDouble();
+ break;
+
+ case 44:
+ tolfit = reader->getDouble();
+ break;
+
+ case 10:
+ {
+ controlpoint = new DRW_Coord();
+ controllist.push_back( controlpoint );
+ controlpoint->x = reader->getDouble();
+ break;
+ }
+
+ case 20:
+
+ if( controlpoint != NULL )
+ controlpoint->y = reader->getDouble();
+
+ break;
+
+ case 30:
+
+ if( controlpoint != NULL )
+ controlpoint->z = reader->getDouble();
+
+ break;
+
+ case 11:
+ {
+ fitpoint = new DRW_Coord();
+ fitlist.push_back( fitpoint );
+ fitpoint->x = reader->getDouble();
+ break;
+ }
+
+ case 21:
+
+ if( fitpoint != NULL )
+ fitpoint->y = reader->getDouble();
+
+ break;
+
+ case 31:
+
+ if( fitpoint != NULL )
+ fitpoint->z = reader->getDouble();
+
+ break;
+
+ case 40:
+ knotslist.push_back( reader->getDouble() );
+ break;
+
+// case 41:
+// break;
+ default:
+ DRW_Entity::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Image::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 12:
+ vx = reader->getDouble();
+ break;
+
+ case 22:
+ vy = reader->getDouble();
+ break;
+
+ case 32:
+ vz = reader->getDouble();
+ break;
+
+ case 13:
+ sizeu = reader->getDouble();
+ break;
+
+ case 23:
+ sizev = reader->getDouble();
+ break;
+
+ case 340:
+ ref = reader->getString();
+ break;
+
+ case 280:
+ clip = reader->getInt32();
+ break;
+
+ case 281:
+ brightness = reader->getInt32();
+ break;
+
+ case 282:
+ contrast = reader->getInt32();
+ break;
+
+ case 283:
+ fade = reader->getInt32();
+ break;
+
+ default:
+ DRW_Line::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Dimension::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 1:
+ text = reader->getUtf8String();
+ break;
+
+ case 2:
+ name = reader->getString();
+ break;
+
+ case 3:
+ style = reader->getUtf8String();
+ break;
+
+ case 70:
+ type = reader->getInt32();
+ break;
+
+ case 71:
+ align = reader->getInt32();
+ break;
+
+ case 72:
+ linesty = reader->getInt32();
+ break;
+
+ case 10:
+ defPoint.x = reader->getDouble();
+ break;
+
+ case 20:
+ defPoint.y = reader->getDouble();
+ break;
+
+ case 30:
+ defPoint.z = reader->getDouble();
+ break;
+
+ case 11:
+ textPoint.x = reader->getDouble();
+ break;
+
+ case 21:
+ textPoint.y = reader->getDouble();
+ break;
+
+ case 31:
+ textPoint.z = reader->getDouble();
+ break;
+
+ case 12:
+ clonePoint.x = reader->getDouble();
+ break;
+
+ case 22:
+ clonePoint.y = reader->getDouble();
+ break;
+
+ case 32:
+ clonePoint.z = reader->getDouble();
+ break;
+
+ case 13:
+ def1.x = reader->getDouble();
+ break;
+
+ case 23:
+ def1.y = reader->getDouble();
+ break;
+
+ case 33:
+ def1.z = reader->getDouble();
+ break;
+
+ case 14:
+ def2.x = reader->getDouble();
+ break;
+
+ case 24:
+ def2.y = reader->getDouble();
+ break;
+
+ case 34:
+ def2.z = reader->getDouble();
+ break;
+
+ case 15:
+ circlePoint.x = reader->getDouble();
+ break;
+
+ case 25:
+ circlePoint.y = reader->getDouble();
+ break;
+
+ case 35:
+ circlePoint.z = reader->getDouble();
+ break;
+
+ case 16:
+ arcPoint.x = reader->getDouble();
+ break;
+
+ case 26:
+ arcPoint.y = reader->getDouble();
+ break;
+
+ case 36:
+ arcPoint.z = reader->getDouble();
+ break;
+
+ case 41:
+ linefactor = reader->getDouble();
+ break;
+
+ case 53:
+ rot = reader->getDouble();
+ break;
+
+ case 50:
+ angle = reader->getDouble();
+ break;
+
+ case 52:
+ oblique = reader->getDouble();
+ break;
+
+ case 40:
+ length = reader->getDouble();
+ break;
+
+/* case 51:
+ * hdir = reader->getDouble();
+ * break;*/
+ default:
+ DRW_Entity::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Leader::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 3:
+ style = reader->getUtf8String();
+ break;
+
+ case 71:
+ arrow = reader->getInt32();
+ break;
+
+ case 72:
+ leadertype = reader->getInt32();
+ break;
+
+ case 73:
+ flag = reader->getInt32();
+ break;
+
+ case 74:
+ hookline = reader->getInt32();
+ break;
+
+ case 75:
+ hookflag = reader->getInt32();
+ break;
+
+ case 76:
+ vertnum = reader->getInt32();
+ break;
+
+ case 77:
+ coloruse = reader->getInt32();
+ break;
+
+ case 40:
+ textheight = reader->getDouble();
+ break;
+
+ case 41:
+ textwidth = reader->getDouble();
+ break;
+
+ case 10:
+ {
+ vertexpoint = new DRW_Coord();
+ vertexlist.push_back( vertexpoint );
+ vertexpoint->x = reader->getDouble();
+ break;
+ }
+
+ case 20:
+
+ if( vertexpoint != NULL )
+ vertexpoint->y = reader->getDouble();
+
+ break;
+
+ case 30:
+
+ if( vertexpoint != NULL )
+ vertexpoint->z = reader->getDouble();
+
+ break;
+
+ case 340:
+ handle = reader->getString();
+ break;
+
+ case 210:
+ extrusionPoint.x = reader->getDouble();
+ break;
+
+ case 220:
+ extrusionPoint.y = reader->getDouble();
+ break;
+
+ case 230:
+ extrusionPoint.z = reader->getDouble();
+ break;
+
+ case 211:
+ horizdir.x = reader->getDouble();
+ break;
+
+ case 221:
+ horizdir.y = reader->getDouble();
+ break;
+
+ case 231:
+ horizdir.z = reader->getDouble();
+ break;
+
+ case 212:
+ offsetblock.x = reader->getDouble();
+ break;
+
+ case 222:
+ offsetblock.y = reader->getDouble();
+ break;
+
+ case 232:
+ offsetblock.z = reader->getDouble();
+ break;
+
+ case 213:
+ offsettext.x = reader->getDouble();
+ break;
+
+ case 223:
+ offsettext.y = reader->getDouble();
+ break;
+
+ case 233:
+ offsettext.z = reader->getDouble();
+ break;
+
+ default:
+ DRW_Entity::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_Viewport::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 40:
+ pswidth = reader->getDouble();
+ break;
+
+ case 41:
+ psheight = reader->getDouble();
+ break;
+
+ case 68:
+ vpstatus = reader->getInt32();
+ break;
+
+ case 69:
+ vpID = reader->getInt32();
+ break;
+
+ case 12:
+ {
+ centerPX = reader->getDouble();
+ break;
+ }
+
+ case 22:
+ centerPY = reader->getDouble();
+ break;
+
+ default:
+ DRW_Point::parseCode( code, reader );
+ break;
+ }
+}
diff --git a/lib_dxf/drw_entities.h b/lib_dxf/drw_entities.h
new file mode 100644
index 0000000000..7aaf18e7e7
--- /dev/null
+++ b/lib_dxf/drw_entities.h
@@ -0,0 +1,1300 @@
+/******************************************************************************
+** libDXFrw - Library to read/write DXF files (ascii & binary) **
+** **
+** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
+** **
+** This library is free software, licensed 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. **
+** You should have received a copy of the GNU General Public License **
+** along with this program. If not, see . **
+******************************************************************************/
+
+#ifndef DRW_ENTITIES_H
+#define DRW_ENTITIES_H
+
+
+#include
+#include
+#include "drw_base.h"
+
+class dxfReader;
+class DRW_Polyline;
+
+using std::string;
+
+namespace DRW {
+// ! Entity's type.
+enum ETYPE {
+ POINT,
+ LINE,
+ CIRCLE,
+ ARC,
+ ELLIPSE,
+ TRACE,
+ SOLID,
+ BLOCK,
+ INSERT,
+ LWPOLYLINE,
+ POLYLINE,
+ VERTEX,
+ SPLINE,
+ HATCH,
+ TEXT,
+ MTEXT,
+ E3DFACE,
+ IMAGE,
+ LEADER,
+ DIMENSION,
+ DIMALIGNED,
+ DIMLINEAR,
+ DIMRADIAL,
+ DIMDIAMETRIC,
+ DIMANGULAR,
+ DIMANGULAR3P,
+ DIMORDINATE,
+
+// OVERLAYBOX,
+// CONSTRUCTIONLINE,
+ RAY,
+ XLINE,
+ VIEWPORT,
+ UNKNOWN
+};
+}
+
+// ! Base class for entities
+/*!
+ * Base class for entities
+ * @author Rallaz
+ */
+class DRW_Entity
+{
+public:
+ // initializes default values
+ DRW_Entity()
+ {
+ eType = DRW::UNKNOWN;
+ lineType = "BYLAYER";
+ color = 256; // default BYLAYER (256)
+ ltypeScale = 1.0;
+ visible = true;
+ layer = "0";
+ lWeight = DRW_LW_Conv::widthByLayer; // default BYLAYER (dxf -1, dwg 29)
+ handleBlock = space = 0; // default ModelSpace (0) & handleBlock = no handle (0)
+ haveExtrusion = false;
+ color24 = -1; // default -1 not set
+ }
+
+ virtual ~DRW_Entity() {}
+
+ DRW_Entity( const DRW_Entity& d )
+ {
+ eType = d.eType;
+ handle = d.handle;
+ handleBlock = d.handleBlock;
+ layer = d.layer;
+ lineType = d.lineType;
+ color = d.color;
+ color24 = d.color24;
+ colorName = d.colorName;
+ ltypeScale = d.ltypeScale;
+ visible = d.visible;
+ lWeight = d.lWeight;
+ space = d.space;
+ haveExtrusion = d.haveExtrusion;
+ }
+
+ virtual void applyExtrusion() = 0;
+
+protected:
+ void parseCode( int code, dxfReader* reader );
+ void calculateAxis( DRW_Coord extPoint );
+ void extrudePoint( DRW_Coord extPoint, DRW_Coord* point );
+
+public:
+ enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */
+ int handle; /*!< entity identifier, code 5 */
+ int handleBlock; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */
+ UTF8STRING layer; /*!< layer name, code 8 */
+ UTF8STRING lineType; /*!< line type, code 6 */
+ int color; /*!< entity color, code 62 */
+ enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */
+ double ltypeScale; /*!< linetype scale, code 48 */
+ bool visible; /*!< entity visibility, code 60 */
+ int color24; /*!< 24-bit color, code 420 */
+ string colorName; /*!< color name, code 430 */
+ int space; /*!< space indicator 0 = model, 1 paper, code 67*/
+ bool haveExtrusion; /*!< set to true if the entity have extrusion*/
+private:
+ DRW_Coord extAxisX;
+ DRW_Coord extAxisY;
+};
+
+
+// ! Class to handle point entity
+/*!
+ * Class to handle point entity
+ * @author Rallaz
+ */
+class DRW_Point : public DRW_Entity
+{
+public:
+ DRW_Point()
+ {
+ eType = DRW::POINT;
+ basePoint.z = extPoint.x = extPoint.y = 0;
+ extPoint.z = 1;
+ thickness = 0;
+ }
+
+ virtual void applyExtrusion() {}
+
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */
+ double thickness; /*!< thickness, code 39 */
+ DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
+};
+
+// ! Class to handle line entity
+/*!
+ * Class to handle line entity
+ * @author Rallaz
+ */
+class DRW_Line : public DRW_Point
+{
+public:
+ DRW_Line()
+ {
+ eType = DRW::LINE;
+ secPoint.z = 0;
+ }
+
+ virtual void applyExtrusion() {}
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ DRW_Coord secPoint; /*!< second point, code 11, 21 & 31 */
+};
+
+// ! Class to handle ray entity
+/*!
+ * Class to handle ray entity
+ * @author Rallaz
+ */
+class DRW_Ray : public DRW_Line
+{
+public:
+ DRW_Ray()
+ {
+ eType = DRW::RAY;
+ }
+};
+
+// ! Class to handle xline entity
+/*!
+ * Class to handle xline entity
+ * @author Rallaz
+ */
+class DRW_Xline : public DRW_Line
+{
+public:
+ DRW_Xline()
+ {
+ eType = DRW::XLINE;
+ }
+};
+
+// ! Class to handle circle entity
+/*!
+ * Class to handle circle entity
+ * @author Rallaz
+ */
+class DRW_Circle : public DRW_Point
+{
+public:
+ DRW_Circle()
+ {
+ eType = DRW::CIRCLE;
+ }
+
+ virtual void applyExtrusion();
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ double radious; /*!< radius, code 40 */
+};
+
+// ! Class to handle arc entity
+/*!
+ * Class to handle arc entity
+ * @author Rallaz
+ */
+class DRW_Arc : public DRW_Circle
+{
+public:
+ DRW_Arc()
+ {
+ eType = DRW::ARC;
+ isccw = 1;
+ }
+
+ virtual void applyExtrusion() { DRW_Circle::applyExtrusion(); }
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ double staangle; /*!< start angle, code 50 in radians*/
+ double endangle; /*!< end angle, code 51 in radians */
+ int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */
+};
+
+// ! Class to handle ellipse entity
+/*!
+ * Class to handle ellipse and elliptic arc entity
+ * Note: start/end parameter are in radians for ellipse entity but
+ * for hatch boundary are in degrees
+ * @author Rallaz
+ */
+class DRW_Ellipse : public DRW_Line
+{
+public:
+ DRW_Ellipse()
+ {
+ eType = DRW::ELLIPSE;
+ isccw = 1;
+ }
+
+ void parseCode( int code, dxfReader* reader );
+ void toPolyline( DRW_Polyline* pol, int parts = 128 );
+ virtual void applyExtrusion();
+ void correctAxis();
+
+public:
+ double ratio; /*!< ratio, code 40 */
+ double staparam; /*!< start parameter, code 41, 0.0 for full ellipse*/
+ double endparam; /*!< end parameter, code 42, 2*PI for full ellipse */
+ int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */
+};
+
+// ! Class to handle trace entity
+/*!
+ * Class to handle trace entity
+ * @author Rallaz
+ */
+class DRW_Trace : public DRW_Line
+{
+public:
+ DRW_Trace()
+ {
+ eType = DRW::TRACE;
+ thirdPoint.z = 0;
+ fourPoint.z = 0;
+ }
+
+ virtual void applyExtrusion();
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ DRW_Coord thirdPoint; /*!< third point, code 12, 22 & 32 */
+ DRW_Coord fourPoint; /*!< four point, code 13, 23 & 33 */
+};
+
+// ! Class to handle solid entity
+/*!
+ * Class to handle solid entity
+ * @author Rallaz
+ */
+class DRW_Solid : public DRW_Trace
+{
+public:
+ DRW_Solid()
+ {
+ eType = DRW::SOLID;
+ }
+
+ void parseCode( int code, dxfReader* reader );
+};
+
+// ! Class to handle 3dface entity
+/*!
+ * Class to handle 3dface entity
+ * @author Rallaz
+ */
+class DRW_3Dface : public DRW_Trace
+{
+public:
+ DRW_3Dface()
+ {
+ eType = DRW::E3DFACE;
+ invisibleflag = 0;
+ }
+
+ virtual void applyExtrusion() {}
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ int invisibleflag; /*!< invisible edge flag, code 70 */
+};
+
+// ! Class to handle block entries
+/*!
+ * Class to handle block entries
+ * @author Rallaz
+ */
+class DRW_Block : public DRW_Point
+{
+public:
+ DRW_Block()
+ {
+ eType = DRW::BLOCK;
+ layer = "0";
+ flags = 0;
+ name = "*U0";
+ }
+
+ virtual void applyExtrusion() {}
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ UTF8STRING name; /*!< block name, code 2 */
+ int flags; /*!< block type, code 70 */
+};
+
+
+// ! Class to handle insert entries
+/*!
+ * Class to handle insert entries
+ * @author Rallaz
+ */
+class DRW_Insert : public DRW_Point
+{
+public:
+ DRW_Insert()
+ {
+ eType = DRW::INSERT;
+ xscale = 1;
+ yscale = 1;
+ zscale = 1;
+ angle = 0;
+ colcount = 1;
+ rowcount = 1;
+ colspace = 0;
+ rowspace = 0;
+ }
+
+ virtual void applyExtrusion() { DRW_Point::applyExtrusion(); }
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ UTF8STRING name; /*!< block name, code 2 */
+ double xscale; /*!< x scale factor, code 41 */
+ double yscale; /*!< y scale factor, code 42 */
+ double zscale; /*!< z scale factor, code 43 */
+ double angle; /*!< rotation angle, code 50 */
+ int colcount; /*!< column count, code 70 */
+ int rowcount; /*!< row count, code 71 */
+ double colspace; /*!< column space, code 44 */
+ double rowspace; /*!< row space, code 45 */
+};
+
+// ! Class to handle lwpolyline entity
+/*!
+ * Class to handle lwpolyline entity
+ * @author Rallaz
+ */
+class DRW_LWPolyline : public DRW_Entity
+{
+public:
+ DRW_LWPolyline()
+ {
+ eType = DRW::LWPOLYLINE;
+ elevation = thickness = width = 0.0;
+ flags = 0;
+ extPoint.x = extPoint.y = 0;
+ extPoint.z = 1;
+ vertex = NULL;
+ }
+
+ ~DRW_LWPolyline()
+ {
+ while( !vertlist.empty() )
+ {
+ vertlist.pop_back();
+ }
+ }
+
+ virtual void applyExtrusion();
+
+ void addVertex( DRW_Vertex2D v )
+ {
+ DRW_Vertex2D* vert = new DRW_Vertex2D();
+
+ vert->x = v.x;
+ vert->y = v.y;
+ vert->stawidth = v.stawidth;
+ vert->endwidth = v.endwidth;
+ vert->bulge = v.bulge;
+ vertlist.push_back( vert );
+ }
+
+ DRW_Vertex2D* addVertex()
+ {
+ DRW_Vertex2D* vert = new DRW_Vertex2D();
+
+ vert->stawidth = 0;
+ vert->endwidth = 0;
+ vert->bulge = 0;
+ vertlist.push_back( vert );
+ return vert;
+ }
+
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ int vertexnum; /*!< number of vertex, code 90 */
+ int flags; /*!< polyline flag, code 70, default 0 */
+ double width; /*!< constant width, code 43 */
+ double elevation; /*!< elevation, code 38 */
+ double thickness; /*!< thickness, code 39 */
+ DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
+ DRW_Vertex2D* vertex; /*!< current vertex to add data */
+ std::vector vertlist; /*!< vertex list */
+};
+
+// ! Class to handle insert entries
+/*!
+ * Class to handle insert entries
+ * @author Rallaz
+ */
+class DRW_Text : public DRW_Line
+{
+public:
+ // ! Vertical alignments.
+ enum VAlign {
+ VBaseLine = 0, /*!< Top = 0 */
+ VBottom, /*!< Bottom = 1 */
+ VMiddle, /*!< Middle = 2 */
+ VTop /*!< Top = 3 */
+ };
+
+ // ! Horizontal alignments.
+ enum HAlign {
+ HLeft = 0, /*!< Left = 0 */
+ HCenter, /*!< Centered = 1 */
+ HRight, /*!< Right = 2 */
+ HAligned, /*!< Aligned = 3 (if VAlign==0) */
+ HMiddle, /*!< middle = 4 (if VAlign==0) */
+ HFit /*!< fit into point = 5 (if VAlign==0) */
+ };
+
+ DRW_Text()
+ {
+ eType = DRW::TEXT;
+ angle = 0;
+ widthscale = 1;
+ oblique = 0;
+ style = "STANDARD";
+ textgen = 0;
+ alignH = HLeft;
+ alignV = VBaseLine;
+ }
+
+ virtual void applyExtrusion() {} // RLZ TODO
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ double height; /*!< height text, code 40 */
+ UTF8STRING text; /*!< text string, code 1 */
+ double angle; /*!< rotation angle in degrees (360), code 50 */
+ double widthscale; /*!< width factor, code 41 */
+ double oblique; /*!< oblique angle, code 51 */
+ UTF8STRING style; /*!< style name, code 7 */
+ int textgen; /*!< text generation, code 71 */
+ enum HAlign alignH; /*!< horizontal align, code 72 */
+ enum VAlign alignV; /*!< vertical align, code 73 */
+};
+
+// ! Class to handle insert entries
+/*!
+ * Class to handle insert entries
+ * @author Rallaz
+ */
+class DRW_MText : public DRW_Text
+{
+public:
+ // ! Attachments.
+ enum Attach {
+ TopLeft = 1,
+ TopCenter,
+ TopRight,
+ MiddleLeft,
+ MiddleCenter,
+ MiddleRight,
+ BottomLeft,
+ BottomCenter,
+ BottomRight
+ };
+
+ DRW_MText()
+ {
+ eType = DRW::MTEXT;
+ interlin = 1;
+ alignV = (VAlign) TopLeft;
+ textgen = 1;
+ haveXAxis = false; // if true needed to recalculate angle
+ }
+
+ void parseCode( int code, dxfReader* reader );
+ void updateAngle(); // recalculate angle if 'haveXAxis' is true
+
+public:
+ double interlin; /*!< width factor, code 44 */
+private:
+ bool haveXAxis;
+};
+
+// ! Class to handle vertex
+/*!
+ * Class to handle vertex for polyline entity
+ * @author Rallaz
+ */
+class DRW_Vertex : public DRW_Point
+{
+public:
+ DRW_Vertex()
+ {
+ eType = DRW::VERTEX;
+ stawidth = endwidth = bulge = 0;
+ vindex1 = vindex2 = vindex3 = vindex4 = 0;
+ flags = identifier = 0;
+ }
+
+ DRW_Vertex( double sx, double sy, double sz, double b )
+ {
+ stawidth = endwidth = 0;
+ vindex1 = vindex2 = vindex3 = vindex4 = 0;
+ flags = identifier = 0;
+ basePoint.x = sx;
+ basePoint.y = sy;
+ basePoint.z = sz;
+ bulge = b;
+ }
+
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ double stawidth; /*!< Start width, code 40 */
+ double endwidth; /*!< End width, code 41 */
+ double bulge; /*!< bulge, code 42 */
+
+ int flags; /*!< vertex flag, code 70, default 0 */
+ double tgdir; /*!< curve fit tangent direction, code 50 */
+ int vindex1; /*!< polyface mesh vertex index, code 71, default 0 */
+ int vindex2; /*!< polyface mesh vertex index, code 72, default 0 */
+ int vindex3; /*!< polyface mesh vertex index, code 73, default 0 */
+ int vindex4; /*!< polyface mesh vertex index, code 74, default 0 */
+ int identifier; /*!< vertex identifier, code 91, default 0 */
+};
+
+// ! Class to handle polyline entity
+/*!
+ * Class to handle polyline entity
+ * @author Rallaz
+ */
+class DRW_Polyline : public DRW_Point
+{
+public:
+ DRW_Polyline()
+ {
+ eType = DRW::POLYLINE;
+ defstawidth = defendwidth = 0.0;
+ basePoint.x = basePoint.y = 0.0;
+ flags = vertexcount = facecount = 0;
+ smoothM = smoothN = curvetype = 0;
+ }
+
+ ~DRW_Polyline()
+ {
+ while( !vertlist.empty() )
+ {
+ vertlist.pop_back();
+ }
+ }
+
+ void addVertex( DRW_Vertex v )
+ {
+ DRW_Vertex* vert = new DRW_Vertex();
+
+ vert->basePoint.x = v.basePoint.x;
+ vert->basePoint.y = v.basePoint.y;
+ vert->basePoint.z = v.basePoint.z;
+ vert->stawidth = v.stawidth;
+ vert->endwidth = v.endwidth;
+ vert->bulge = v.bulge;
+ vertlist.push_back( vert );
+ }
+
+ void appendVertex( DRW_Vertex* v )
+ {
+ vertlist.push_back( v );
+ }
+
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ int flags; /*!< polyline flag, code 70, default 0 */
+ double defstawidth; /*!< Start width, code 40, default 0 */
+ double defendwidth; /*!< End width, code 41, default 0 */
+ int vertexcount; /*!< polygon mesh M vertex or polyface vertex num, code 71, default 0 */
+ int facecount; /*!< polygon mesh N vertex or polyface face num, code 72, default 0 */
+ int smoothM; /*!< smooth surface M density, code 73, default 0 */
+ int smoothN; /*!< smooth surface M density, code 74, default 0 */
+ int curvetype; /*!< curves & smooth surface type, code 75, default 0 */
+
+ std::vector vertlist; /*!< vertex list */
+};
+
+
+// ! Class to handle spline entity
+/*!
+ * Class to handle spline entity
+ * @author Rallaz
+ */
+class DRW_Spline : public DRW_Entity
+{
+public:
+ DRW_Spline()
+ {
+ eType = DRW::SPLINE;
+ flags = nknots = ncontrol = nfit = 0;
+ ex = ey = 0.0;
+ ez = 1.0;
+ tolknot = tolcontrol = tolfit = 0.0000001;
+ }
+
+ ~DRW_Spline()
+ {
+ while( !controllist.empty() )
+ {
+ controllist.pop_back();
+ }
+
+ while( !fitlist.empty() )
+ {
+ fitlist.pop_back();
+ }
+ }
+
+ virtual void applyExtrusion() {}
+
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ double ex; /*!< normal vector x coordinate, code 210 */
+ double ey; /*!< normal vector y coordinate, code 220 */
+ double ez; /*!< normal vector z coordinate, code 230 */
+ double tgsx; /*!< start tangent x coordinate, code 12 */
+ double tgsy; /*!< start tangent y coordinate, code 22 */
+ double tgsz; /*!< start tangent z coordinate, code 32 */
+ double tgex; /*!< end tangent x coordinate, code 13 */
+ double tgey; /*!< end tangent y coordinate, code 23 */
+ double tgez; /*!< end tangent z coordinate, code 33 */
+ int flags; /*!< spline flag, code 70 */
+ int degree; /*!< degree of the spline, code 71 */
+ int nknots; /*!< number of knots, code 72, default 0 */
+ int ncontrol; /*!< number of control points, code 73, default 0 */
+ int nfit; /*!< number of fit points, code 74, default 0 */
+ double tolknot; /*!< knot tolerance, code 42, default 0.0000001 */
+ double tolcontrol; /*!< control point tolerance, code 43, default 0.0000001 */
+ double tolfit; /*!< fit point tolerance, code 44, default 0.0000001 */
+
+ std::vector knotslist; /*!< knots list, code 40 */
+ std::vector controllist; /*!< control points list, code 10, 20 & 30 */
+ std::vector fitlist; /*!< fit points list, code 11, 21 & 31 */
+private:
+ DRW_Coord* controlpoint; /*!< current control point to add data */
+ DRW_Coord* fitpoint; /*!< current fit point to add data */
+};
+
+// ! Class to handle hatch loop
+/*!
+ * Class to handle hatch loop
+ * @author Rallaz
+ */
+class DRW_HatchLoop
+{
+public:
+ DRW_HatchLoop( int t )
+ {
+ type = t;
+ numedges = 0;
+ }
+
+ ~DRW_HatchLoop()
+ {
+/* while (!pollist.empty()) {
+ * pollist.pop_back();
+ * }*/
+ while( !objlist.empty() )
+ {
+ objlist.pop_back();
+ }
+ }
+
+ void update()
+ {
+ numedges = objlist.size();
+ }
+
+public:
+ int type; /*!< boundary path type, code 92, polyline=2, default=0 */
+ int numedges; /*!< number of edges (if not a polyline), code 93 */
+// TODO: store lwpolylines as entities
+// std::vector pollist; /*!< polyline list */
+ std::vector objlist; /*!< entities list */
+};
+
+// ! Class to handle hatch entity
+/*!
+ * Class to handle hatch entity
+ * @author Rallaz
+ */
+// TODO: handle lwpolylines, splines and ellipses
+class DRW_Hatch : public DRW_Point
+{
+public:
+ DRW_Hatch()
+ {
+ eType = DRW::HATCH;
+ angle = scale = 0.0;
+ basePoint.x = basePoint.y = basePoint.z = 0.0;
+ loopsnum = hstyle = associative = 0;
+ solid = hpattern = 1;
+ deflines = doubleflag = 0;
+ loop = NULL;
+ clearEntities();
+ }
+
+ ~DRW_Hatch()
+ {
+ while( !looplist.empty() )
+ {
+ looplist.pop_back();
+ }
+ }
+
+ void appendLoop( DRW_HatchLoop* v )
+ {
+ looplist.push_back( v );
+ }
+
+ virtual void applyExtrusion() {}
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ UTF8STRING name; /*!< hatch pattern name, code 2 */
+ int solid; /*!< solid fill flag, code 70, solid=1, pattern=0 */
+ int associative; /*!< associativity, code 71, associatve=1, non-assoc.=0 */
+ int hstyle; /*!< hatch style, code 75 */
+ int hpattern; /*!< hatch pattern type, code 76 */
+ int doubleflag; /*!< hatch pattern double flag, code 77, double=1, single=0 */
+ int loopsnum; /*!< namber of boundary paths (loops), code 91 */
+ double angle; /*!< hatch pattern angle, code 52 */
+ double scale; /*!< hatch pattern scale, code 41 */
+ int deflines; /*!< number of pattern definition lines, code 78 */
+
+ std::vector looplist; /*!< polyline list */
+private:
+ void clearEntities()
+ {
+ pt = line = NULL;
+ pline = NULL;
+ arc = NULL;
+ ellipse = NULL;
+ spline = NULL;
+ plvert = NULL;
+ }
+
+ void addLine()
+ {
+ clearEntities();
+
+ if( loop )
+ {
+ pt = line = new DRW_Line;
+ loop->objlist.push_back( line );
+ }
+ }
+
+ void addArc()
+ {
+ clearEntities();
+
+ if( loop )
+ {
+ pt = arc = new DRW_Arc;
+ loop->objlist.push_back( arc );
+ }
+ }
+
+ void addEllipse()
+ {
+ clearEntities();
+
+ if( loop )
+ {
+ pt = ellipse = new DRW_Ellipse;
+ loop->objlist.push_back( ellipse );
+ }
+ }
+
+ void addSpline()
+ {
+ clearEntities();
+
+ if( loop )
+ {
+ pt = NULL;
+ spline = new DRW_Spline;
+ loop->objlist.push_back( spline );
+ }
+ }
+
+ DRW_HatchLoop* loop; /*!< current loop to add data */
+ DRW_Line* line;
+ DRW_Arc* arc;
+ DRW_Ellipse* ellipse;
+ DRW_Spline* spline;
+ DRW_LWPolyline* pline;
+ DRW_Point* pt;
+ DRW_Vertex2D* plvert;
+ bool ispol;
+};
+
+// ! Class to handle image entity
+/*!
+ * Class to handle image entity
+ * @author Rallaz
+ */
+class DRW_Image : public DRW_Line
+{
+public:
+ DRW_Image()
+ {
+ eType = DRW::IMAGE;
+ vz = fade = clip = 0;
+ brightness = contrast = 50;
+ }
+
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ string ref; /*!< Hard reference to imagedef object, code 340 */
+ double vx; /*!< V-vector of single pixel, x coordinate, code 12 */
+ double vy; /*!< V-vector of single pixel, y coordinate, code 22 */
+ double vz; /*!< V-vector of single pixel, z coordinate, code 32 */
+ double sizeu; /*!< image size in pixels, U value, code 13 */
+ double sizev; /*!< image size in pixels, V value, code 23 */
+ double dz; /*!< z coordinate, code 33 */
+ int clip; /*!< Clipping state, code 280, 0=off 1=on */
+ int brightness; /*!< Brightness value, code 281, (0-100) default 50 */
+ int contrast; /*!< Brightness value, code 282, (0-100) default 50 */
+ int fade; /*!< Brightness value, code 283, (0-100) default 0 */
+};
+
+
+// ! Base class for dimension entity
+/*!
+ * Base class for dimension entity
+ * @author Rallaz
+ */
+class DRW_Dimension : public DRW_Entity
+{
+public:
+ DRW_Dimension()
+ {
+ eType = DRW::DIMENSION;
+ linesty = 1;
+ linefactor = extPoint.z = 1.0;
+ angle = oblique = rot = 0.0;
+ align = 5;
+ style = "STANDARD";
+ defPoint.z = extPoint.x = extPoint.y = 0;
+ textPoint.z = rot = 0;
+ clonePoint.x = clonePoint.y = clonePoint.z = 0;
+ }
+
+ DRW_Dimension( const DRW_Dimension& d ) : DRW_Entity( d )
+ {
+ eType = DRW::DIMENSION;
+ type = d.type;
+ name = d.name;
+ defPoint = d.defPoint;
+ textPoint = d.textPoint;
+ text = d.text;
+ style = d.style;
+ align = d.align;
+ linesty = d.linesty;
+ linefactor = d.linefactor;
+ rot = d.rot;
+ extPoint = d.extPoint;
+ clonePoint = d.clonePoint;
+ def1 = d.def1;
+ def2 = d.def2;
+ angle = d.angle;
+ oblique = d.oblique;
+ arcPoint = d.arcPoint;
+ circlePoint = d.circlePoint;
+ length = d.length;
+ }
+
+ virtual ~DRW_Dimension() {}
+
+ void parseCode( int code, dxfReader* reader );
+
+ virtual void applyExtrusion() {}
+
+ DRW_Coord getDefPoint() const { return defPoint; } /*!< Definition point, code 10, 20 & 30 */
+ void setDefPoint( const DRW_Coord p ) { defPoint = p; }
+ DRW_Coord getTextPoint() const { return textPoint; } /*!< Middle point of text, code 11, 21 & 31 */
+ void setTextPoint( const DRW_Coord p ) { textPoint = p; }
+ string getStyle() const { return style; } /*!< Dimension style, code 3 */
+ void setStyle( const string s ) { style = s; }
+ int getAlign() const { return align; } /*!< attachment point, code 71 */
+ void setAlign( const int a ) { align = a; }
+ int getTextLineStyle() const { return linesty; } /*!< Dimension text line spacing style, code 72, default 1 */
+ void setTextLineStyle( const int l ) { linesty = l; }
+ string getText() const { return text; } /*!< Dimension text explicitly entered by the user, code 1 */
+ void setText( const string t ) { text = t; }
+ double getTextLineFactor() const { return linefactor; } /*!< Dimension text line spacing factor, code 41, default 1? */
+ void setTextLineFactor( const double l ) { linefactor = l; }
+ double getDir() const { return rot; } /*!< rotation angle of the dimension text, code 53 (optional) default 0 */
+ void setDir( const double d ) { rot = d; }
+
+ DRW_Coord getExtrusion() { return extPoint; } /*!< extrusion, code 210, 220 & 230 */
+ void setExtrusion( const DRW_Coord p ) { extPoint = p; }
+ string getName() { return name; } /*!< Name of the block that contains the entities, code 2 */
+ void setName( const string s ) { name = s; }
+// int getType(){ return type;} /*!< Dimension type, code 70 */
+protected:
+ DRW_Coord getPt2() const { return clonePoint; }
+ void setPt2( const DRW_Coord p ) { clonePoint = p; }
+ DRW_Coord getPt3() const { return def1; }
+ void setPt3( const DRW_Coord p ) { def1 = p; }
+ DRW_Coord getPt4() const { return def2; }
+ void setPt4( const DRW_Coord p ) { def2 = p; }
+ DRW_Coord getPt5() const { return circlePoint; }
+ void setPt5( const DRW_Coord p ) { circlePoint = p; }
+ DRW_Coord getPt6() const { return arcPoint; }
+ void setPt6( const DRW_Coord p ) { arcPoint = p; }
+ double getAn50() const { return angle; } /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
+ void setAn50( const double d ) { angle = d; }
+ double getOb52() const { return oblique; } /*!< oblique angle, code 52 */
+ void setOb52( const double d ) { oblique = d; }
+ double getRa40() const { return length; } /*!< Leader length, code 40 */
+ void setRa40( const double d ) { length = d; }
+public:
+ int type; /*!< Dimension type, code 70 */
+private:
+ string name; /*!< Name of the block that contains the entities, code 2 */
+ DRW_Coord defPoint; /*!< definition point, code 10, 20 & 30 (WCS) */
+ DRW_Coord textPoint; /*!< Middle point of text, code 11, 21 & 31 (OCS) */
+ UTF8STRING text; /*!< Dimension text explicitly entered by the user, code 1 */
+ UTF8STRING style; /*!< Dimension style, code 3 */
+ int align; /*!< attachment point, code 71 */
+ int linesty; /*!< Dimension text line spacing style, code 72, default 1 */
+ double linefactor; /*!< Dimension text line spacing factor, code 41, default 1? (value range 0.25 to 4.00*/
+ double rot; /*!< rotation angle of the dimension text, code 53 */
+ DRW_Coord extPoint; /*!< extrusion normal vector, code 210, 220 & 230 */
+
+ // double hdir; /*!< horizontal direction for the dimension, code 51, default ? */
+ DRW_Coord clonePoint; /*!< Insertion point for clones (Baseline & Continue), code 12, 22 & 32 (OCS) */
+ DRW_Coord def1; /*!< Definition point 1for linear & angular, code 13, 23 & 33 (WCS) */
+ DRW_Coord def2; /*!< Definition point 2, code 14, 24 & 34 (WCS) */
+ double angle; /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
+ double oblique; /*!< oblique angle, code 52 */
+
+ DRW_Coord circlePoint; /*!< Definition point for diameter, radius & angular dims code 15, 25 & 35 (WCS) */
+ DRW_Coord arcPoint; /*!< Point defining dimension arc, x coordinate, code 16, 26 & 36 (OCS) */
+ double length; /*!< Leader length, code 40 */
+};
+
+
+// ! Class to handle aligned dimension entity
+/*!
+ * Class to handle aligned dimension entity
+ * @author Rallaz
+ */
+class DRW_DimAligned : public DRW_Dimension
+{
+public:
+ DRW_DimAligned()
+ {
+ eType = DRW::DIMALIGNED;
+ }
+
+ DRW_DimAligned( const DRW_Dimension& d ) : DRW_Dimension( d )
+ {
+ eType = DRW::DIMALIGNED;
+ }
+
+ DRW_Coord getClonepoint() const { return getPt2(); } /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */
+ void setClonePoint( DRW_Coord c ) { setPt2( c ); }
+
+ DRW_Coord getDimPoint() const { return getDefPoint(); } /*!< dim line location point, code 10, 20 & 30 */
+ void setDimPoint( const DRW_Coord p ) { setDefPoint( p ); }
+ DRW_Coord getDef1Point() const { return getPt3(); } /*!< Definition point 1, code 13, 23 & 33 */
+ void setDef1Point( const DRW_Coord p ) { setPt3( p ); }
+ DRW_Coord getDef2Point() const { return getPt4(); } /*!< Definition point 2, code 14, 24 & 34 */
+ void setDef2Point( const DRW_Coord p ) { setPt4( p ); }
+};
+
+// ! Class to handle linear or rotated dimension entity
+/*!
+ * Class to handle linear or rotated dimension entity
+ * @author Rallaz
+ */
+class DRW_DimLinear : public DRW_DimAligned
+{
+public:
+ DRW_DimLinear()
+ {
+ eType = DRW::DIMLINEAR;
+ }
+
+ DRW_DimLinear( const DRW_Dimension& d ) : DRW_DimAligned( d )
+ {
+ eType = DRW::DIMLINEAR;
+ }
+
+ double getAngle() const { return getAn50(); } /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
+ void setAngle( const double d ) { setAn50( d ); }
+ double getOblique() const { return getOb52(); } /*!< oblique angle, code 52 */
+ void setOblique( const double d ) { setOb52( d ); }
+};
+
+// ! Class to handle radial dimension entity
+/*!
+ * Class to handle aligned, linear or rotated dimension entity
+ * @author Rallaz
+ */
+class DRW_DimRadial : public DRW_Dimension
+{
+public:
+ DRW_DimRadial()
+ {
+ eType = DRW::DIMRADIAL;
+ }
+
+ DRW_DimRadial( const DRW_Dimension& d ) : DRW_Dimension( d )
+ {
+ eType = DRW::DIMRADIAL;
+ }
+
+ DRW_Coord getCenterPoint() const { return getDefPoint(); } /*!< center point, code 10, 20 & 30 */
+ void setCenterPoint( const DRW_Coord p ) { setDefPoint( p ); }
+ DRW_Coord getDiameterPoint() const { return getPt5(); } /*!< Definition point for radius, code 15, 25 & 35 */
+ void setDiameterPoint( const DRW_Coord p ) { setPt5( p ); }
+ double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */
+ void setLeaderLength( const double d ) { setRa40( d ); }
+};
+
+// ! Class to handle radial dimension entity
+/*!
+ * Class to handle aligned, linear or rotated dimension entity
+ * @author Rallaz
+ */
+class DRW_DimDiametric : public DRW_Dimension
+{
+public:
+ DRW_DimDiametric()
+ {
+ eType = DRW::DIMDIAMETRIC;
+ }
+
+ DRW_DimDiametric( const DRW_Dimension& d ) : DRW_Dimension( d )
+ {
+ eType = DRW::DIMDIAMETRIC;
+ }
+
+ DRW_Coord getDiameter1Point() const { return getPt5(); } /*!< First definition point for diameter, code 15, 25 & 35 */
+ void setDiameter1Point( const DRW_Coord p ) { setPt5( p ); }
+ DRW_Coord getDiameter2Point() const { return getDefPoint(); } /*!< Oposite point for diameter, code 10, 20 & 30 */
+ void setDiameter2Point( const DRW_Coord p ) { setDefPoint( p ); }
+ double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */
+ void setLeaderLength( const double d ) { setRa40( d ); }
+};
+
+// ! Class to handle angular dimension entity
+/*!
+ * Class to handle angular dimension entity
+ * @author Rallaz
+ */
+class DRW_DimAngular : public DRW_Dimension
+{
+public:
+ DRW_DimAngular()
+ {
+ eType = DRW::DIMANGULAR;
+ }
+
+ DRW_DimAngular( const DRW_Dimension& d ) : DRW_Dimension( d )
+ {
+ eType = DRW::DIMANGULAR;
+ }
+
+ DRW_Coord getFirstLine1() const { return getPt3(); } /*!< Definition point line 1-1, code 13, 23 & 33 */
+ void setFirstLine1( const DRW_Coord p ) { setPt3( p ); }
+ DRW_Coord getFirstLine2() const { return getPt4(); } /*!< Definition point line 1-2, code 14, 24 & 34 */
+ void setFirstLine2( const DRW_Coord p ) { setPt4( p ); }
+ DRW_Coord getSecondLine1() const { return getPt5(); } /*!< Definition point line 2-1, code 15, 25 & 35 */
+ void setSecondLine1( const DRW_Coord p ) { setPt5( p ); }
+ DRW_Coord getSecondLine2() const { return getDefPoint(); } /*!< Definition point line 2-2, code 10, 20 & 30 */
+ void setSecondLine2( const DRW_Coord p ) { setDefPoint( p ); }
+ DRW_Coord getDimPoint() const { return getPt6(); } /*!< Dimension definition point, code 16, 26 & 36 */
+ void setDimPoint( const DRW_Coord p ) { setPt6( p ); }
+};
+
+
+// ! Class to handle angular 3p dimension entity
+/*!
+ * Class to handle angular 3p dimension entity
+ * @author Rallaz
+ */
+class DRW_DimAngular3p : public DRW_Dimension
+{
+public:
+ DRW_DimAngular3p()
+ {
+ eType = DRW::DIMANGULAR3P;
+ }
+
+ DRW_DimAngular3p( const DRW_Dimension& d ) : DRW_Dimension( d )
+ {
+ eType = DRW::DIMANGULAR3P;
+ }
+
+ DRW_Coord getFirstLine() const { return getPt3(); } /*!< Definition point line 1, code 13, 23 & 33 */
+ void setFirstLine( const DRW_Coord p ) { setPt3( p ); }
+ DRW_Coord getSecondLine() const { return getPt4(); } /*!< Definition point line 2, code 14, 24 & 34 */
+ void setSecondLine( const DRW_Coord p ) { setPt4( p ); }
+ DRW_Coord getVertexPoint() const { return getPt5(); } /*!< Vertex point, code 15, 25 & 35 */
+ void SetVertexPoint( const DRW_Coord p ) { setPt5( p ); }
+ DRW_Coord getDimPoint() const { return getDefPoint(); } /*!< Dimension definition point, code 10, 20 & 30 */
+ void setDimPoint( const DRW_Coord p ) { setDefPoint( p ); }
+};
+
+// ! Class to handle ordinate dimension entity
+/*!
+ * Class to handle ordinate dimension entity
+ * @author Rallaz
+ */
+class DRW_DimOrdinate : public DRW_Dimension
+{
+public:
+ DRW_DimOrdinate()
+ {
+ eType = DRW::DIMORDINATE;
+ }
+
+ DRW_DimOrdinate( const DRW_Dimension& d ) : DRW_Dimension( d )
+ {
+ eType = DRW::DIMORDINATE;
+ }
+
+ DRW_Coord getOriginPoint() const { return getDefPoint(); } /*!< Origin definition point, code 10, 20 & 30 */
+ void setOriginPoint( const DRW_Coord p ) { setDefPoint( p ); }
+ DRW_Coord getFirstLine() const { return getPt3(); } /*!< Feature location point, code 13, 23 & 33 */
+ void setFirstLine( const DRW_Coord p ) { setPt3( p ); }
+ DRW_Coord getSecondLine() const { return getPt4(); } /*!< Leader end point, code 14, 24 & 34 */
+ void setSecondLine( const DRW_Coord p ) { setPt4( p ); }
+};
+
+
+// ! Class to handle leader entity
+/*!
+ * Class to handle leader entity
+ * @author Rallaz
+ */
+class DRW_Leader : public DRW_Entity
+{
+public:
+ DRW_Leader()
+ {
+ eType = DRW::LEADER;
+ flag = 3;
+ hookflag = vertnum = leadertype = 0;
+ extrusionPoint.x = extrusionPoint.y = 0.0;
+ arrow = 1;
+ extrusionPoint.z = 1.0;
+ }
+
+ ~DRW_Leader()
+ {
+ while( !vertexlist.empty() )
+ {
+ vertexlist.pop_back();
+ }
+ }
+
+ virtual void applyExtrusion() {}
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ UTF8STRING style; /*!< Dimension style name, code 3 */
+ int arrow; /*!< Arrowhead flag, code 71, 0=Disabled; 1=Enabled */
+ int leadertype; /*!< Leader path type, code 72, 0=Straight line segments; 1=Spline */
+ int flag; /*!< Leader creation flag, code 73, default 3 */
+ int hookline; /*!< Hook line direction flag, code 74, default 1 */
+ int hookflag; /*!< Hook line flag, code 75 */
+ double textheight; /*!< Text annotation height, code 40 */
+ double textwidth; /*!< Text annotation width, code 41 */
+ int vertnum; /*!< Number of vertices, code 76 */
+ int coloruse; /*!< Color to use if leader's DIMCLRD = BYBLOCK, code 77 */
+ string handle; /*!< Hard reference to associated annotation, code 340 */
+ DRW_Coord extrusionPoint; /*!< Normal vector, code 210, 220 & 230 */
+ DRW_Coord horizdir; /*!< "Horizontal" direction for leader, code 211, 221 & 231 */
+ DRW_Coord offsetblock; /*!< Offset of last leader vertex from block, code 212, 222 & 232 */
+ DRW_Coord offsettext; /*!< Offset of last leader vertex from annotation, code 213, 223 & 233 */
+
+ std::vector vertexlist; /*!< vertex points list, code 10, 20 & 30 */
+private:
+ DRW_Coord* vertexpoint; /*!< current control point to add data */
+};
+
+// ! Class to handle viewport entity
+/*!
+ * Class to handle viewport entity
+ * @author Rallaz
+ */
+class DRW_Viewport : public DRW_Point
+{
+public:
+ DRW_Viewport()
+ {
+ eType = DRW::VIEWPORT;
+ vpstatus = 0;
+ pswidth = 205;
+ psheight = 156;
+ centerPX = 128.5;
+ centerPY = 97.5;
+ }
+
+ virtual void applyExtrusion() {}
+ void parseCode( int code, dxfReader* reader );
+
+public:
+ double pswidth; /*!< Width in paper space units, code 40 */
+ double psheight; /*!< Height in paper space units, code 41 */
+ int vpstatus; /*!< Viewport status, code 68 */
+ int vpID; /*!< Viewport ID, code 69 */
+ double centerPX; /*!< view center piont X, code 12 */
+ double centerPY; /*!< view center piont Y, code 22 */
+};
+
+
+#endif
+
+// EOF
diff --git a/lib_dxf/drw_interface.h b/lib_dxf/drw_interface.h
new file mode 100644
index 0000000000..52fbe84f16
--- /dev/null
+++ b/lib_dxf/drw_interface.h
@@ -0,0 +1,223 @@
+/******************************************************************************
+** libDXFrw - Library to read/write DXF files (ascii & binary) **
+** **
+** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
+** **
+** This library is free software, licensed 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. **
+** You should have received a copy of the GNU General Public License **
+** along with this program. If not, see . **
+******************************************************************************/
+
+#ifndef DRW_INTERFACE_H
+#define DRW_INTERFACE_H
+
+#include
+
+#include "drw_entities.h"
+#include "drw_objects.h"
+// #include "dl_extrusion.h"
+
+/**
+ * Abstract class (interface) for comunicate dxfReader with the application.
+ * Inherit your class which takes care of the entities in the
+ * processed DXF file from this interface.
+ *
+ * @author Rallaz
+ */
+class DRW_Interface
+{
+public:
+ DRW_Interface()
+ {
+// extrusion = new DL_Extrusion;
+ }
+
+ virtual ~DRW_Interface()
+ {
+// delete extrusion;
+ }
+
+ /** Called when header is parsed. */
+ virtual void addHeader( const DRW_Header* data ) = 0;
+
+ /** Called for every line Type. */
+ virtual void addLType( const DRW_LType& data ) = 0;
+
+ /** Called for every layer. */
+ virtual void addLayer( const DRW_Layer& data ) = 0;
+
+ /** Called for every dim style. */
+ virtual void addDimStyle( const DRW_Dimstyle& data ) = 0;
+
+ /** Called for every VPORT table. */
+ virtual void addVport( const DRW_Vport& data ) = 0;
+
+ /** Called for every text style. */
+ virtual void addTextStyle( const DRW_Textstyle& 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 DRW_Block& data ) = 0;
+
+ /**
+ * In DWG called when the following entities corresponding to a
+ * block different from the current. Note: all entities added after this
+ * command go into this block until setBlock() is called already.
+ *
+ * int handle are the value of DRW_Block::handleBlock added with addBlock()
+ */
+ virtual void setBlock( const int handle ) = 0;
+
+ /** Called to end the current block */
+ virtual void endBlock() = 0;
+
+ /** Called for every point */
+ virtual void addPoint( const DRW_Point& data ) = 0;
+
+ /** Called for every line */
+ virtual void addLine( const DRW_Line& data ) = 0;
+
+ /** Called for every ray */
+ virtual void addRay( const DRW_Ray& data ) = 0;
+
+ /** Called for every xline */
+ virtual void addXline( const DRW_Xline& data ) = 0;
+
+ /** Called for every arc */
+ virtual void addArc( const DRW_Arc& data ) = 0;
+
+ /** Called for every circle */
+ virtual void addCircle( const DRW_Circle& data ) = 0;
+
+ /** Called for every ellipse */
+ virtual void addEllipse( const DRW_Ellipse& data ) = 0;
+
+ /** Called for every lwpolyline */
+ virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0;
+
+ /** Called for every polyline start */
+ virtual void addPolyline( const DRW_Polyline& data ) = 0;
+
+ /** Called for every spline */
+ virtual void addSpline( const DRW_Spline* data ) = 0;
+
+ /** Called for every spline knot value */
+ virtual void addKnot( const DRW_Entity& data ) = 0;
+
+ /** Called for every insert. */
+ virtual void addInsert( const DRW_Insert& data ) = 0;
+
+ /** Called for every trace start */
+ virtual void addTrace( const DRW_Trace& data ) = 0;
+
+ /** Called for every 3dface start */
+ virtual void add3dFace( const DRW_3Dface& data ) = 0;
+
+ /** Called for every solid start */
+ virtual void addSolid( const DRW_Solid& data ) = 0;
+
+
+ /** Called for every Multi Text entity. */
+ virtual void addMText( const DRW_MText& data ) = 0;
+
+ /** Called for every Text entity. */
+ virtual void addText( const DRW_Text& data ) = 0;
+
+ /**
+ * Called for every aligned dimension entity.
+ */
+ virtual void addDimAlign( const DRW_DimAligned* data ) = 0;
+
+ /**
+ * Called for every linear or rotated dimension entity.
+ */
+ virtual void addDimLinear( const DRW_DimLinear* data ) = 0;
+
+ /**
+ * Called for every radial dimension entity.
+ */
+ virtual void addDimRadial( const DRW_DimRadial* data ) = 0;
+
+ /**
+ * Called for every diametric dimension entity.
+ */
+ virtual void addDimDiametric( const DRW_DimDiametric* data ) = 0;
+
+ /**
+ * Called for every angular dimension (2 lines version) entity.
+ */
+ virtual void addDimAngular( const DRW_DimAngular* data ) = 0;
+
+ /**
+ * Called for every angular dimension (3 points version) entity.
+ */
+ virtual void addDimAngular3P( const DRW_DimAngular3p* data ) = 0;
+
+ /**
+ * Called for every ordinate dimension entity.
+ */
+ virtual void addDimOrdinate( const DRW_DimOrdinate* data ) = 0;
+
+ /**
+ * Called for every leader start.
+ */
+ virtual void addLeader( const DRW_Leader* data ) = 0;
+
+ /**
+ * Called for every hatch entity.
+ */
+ virtual void addHatch( const DRW_Hatch* data ) = 0;
+
+ /**
+ * Called for every viewport entity.
+ */
+ virtual void addViewport( const DRW_Viewport& data ) = 0;
+
+ /**
+ * Called for every image entity.
+ */
+ virtual void addImage( const DRW_Image* data ) = 0;
+
+ /**
+ * Called for every image definition.
+ */
+ virtual void linkImage( const DRW_ImageDef* data ) = 0;
+
+ /**
+ * Called for every comment in the DXF file (code 999).
+ */
+ virtual void addComment( const char* comment ) = 0;
+
+ /** 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;
+// }
+
+ virtual void writeHeader( DRW_Header& data ) = 0;
+ virtual void writeBlocks() = 0;
+ virtual void writeBlockRecords() = 0;
+ virtual void writeEntities() = 0;
+ virtual void writeLTypes() = 0;
+ virtual void writeLayers() = 0;
+ virtual void writeTextstyles() = 0;
+ virtual void writeVports() = 0;
+ virtual void writeDimstyles() = 0;
+
+protected:
+// DL_Attributes attributes;
+// DL_Extrusion *extrusion;
+};
+
+#endif
diff --git a/lib_dxf/drw_objects.cpp b/lib_dxf/drw_objects.cpp
new file mode 100644
index 0000000000..03f644c686
--- /dev/null
+++ b/lib_dxf/drw_objects.cpp
@@ -0,0 +1,1315 @@
+/******************************************************************************
+** libDXFrw - Library to read/write DXF files (ascii & binary) **
+** **
+** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
+** **
+** This library is free software, licensed 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. **
+** You should have received a copy of the GNU General Public License **
+** along with this program. If not, see . **
+******************************************************************************/
+
+#include
+#include
+#include "drw_objects.h"
+#include "intern/dxfreader.h"
+#include "intern/dxfwriter.h"
+
+// ! Base class for tables entries
+/*!
+ * Base class for tables entries
+ * @author Rallaz
+ */
+void DRW_TableEntry::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 5:
+ handle = reader->getHandleString();
+ break;
+
+ case 330:
+ handleBlock = reader->getHandleString();
+ break;
+
+ case 2:
+ name = reader->getUtf8String();
+ break;
+
+ case 70:
+ flags = reader->getInt32();
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+// ! Class to handle dimstyle entries
+/*!
+ * Class to handle ldim style symbol table entries
+ * @author Rallaz
+ */
+void DRW_Dimstyle::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 105:
+ handle = reader->getHandleString();
+ break;
+
+ case 3:
+ dimpost = reader->getUtf8String();
+ break;
+
+ case 4:
+ dimapost = reader->getUtf8String();
+ break;
+
+ case 5:
+ dimblk = reader->getUtf8String();
+ break;
+
+ case 6:
+ dimblk1 = reader->getUtf8String();
+ break;
+
+ case 7:
+ dimblk2 = reader->getUtf8String();
+ break;
+
+ case 40:
+ dimscale = reader->getDouble();
+ break;
+
+ case 41:
+ dimasz = reader->getDouble();
+ break;
+
+ case 42:
+ dimexo = reader->getDouble();
+ break;
+
+ case 43:
+ dimdli = reader->getDouble();
+ break;
+
+ case 44:
+ dimexe = reader->getDouble();
+ break;
+
+ case 45:
+ dimrnd = reader->getDouble();
+ break;
+
+ case 46:
+ dimdle = reader->getDouble();
+ break;
+
+ case 47:
+ dimtp = reader->getDouble();
+ break;
+
+ case 48:
+ dimtm = reader->getDouble();
+ break;
+
+ case 140:
+ dimtxt = reader->getDouble();
+ break;
+
+ case 141:
+ dimcen = reader->getDouble();
+ break;
+
+ case 142:
+ dimtsz = reader->getDouble();
+ break;
+
+ case 143:
+ dimaltf = reader->getDouble();
+ break;
+
+ case 144:
+ dimlfac = reader->getDouble();
+ break;
+
+ case 145:
+ dimtvp = reader->getDouble();
+ break;
+
+ case 146:
+ dimtfac = reader->getDouble();
+ break;
+
+ case 147:
+ dimgap = reader->getDouble();
+ break;
+
+ case 148:
+ dimaltrnd = reader->getDouble();
+ break;
+
+ case 71:
+ dimtol = reader->getInt32();
+ break;
+
+ case 72:
+ dimlim = reader->getInt32();
+ break;
+
+ case 73:
+ dimtih = reader->getInt32();
+ break;
+
+ case 74:
+ dimtoh = reader->getInt32();
+ break;
+
+ case 75:
+ dimse1 = reader->getInt32();
+ break;
+
+ case 76:
+ dimse2 = reader->getInt32();
+ break;
+
+ case 77:
+ dimtad = reader->getInt32();
+ break;
+
+ case 78:
+ dimzin = reader->getInt32();
+ break;
+
+ case 79:
+ dimazin = reader->getInt32();
+ break;
+
+ case 170:
+ dimalt = reader->getInt32();
+ break;
+
+ case 171:
+ dimaltd = reader->getInt32();
+ break;
+
+ case 172:
+ dimtofl = reader->getInt32();
+ break;
+
+ case 173:
+ dimsah = reader->getInt32();
+ break;
+
+ case 174:
+ dimtix = reader->getInt32();
+ break;
+
+ case 175:
+ dimsoxd = reader->getInt32();
+ break;
+
+ case 176:
+ dimclrd = reader->getInt32();
+ break;
+
+ case 177:
+ dimclre = reader->getInt32();
+ break;
+
+ case 178:
+ dimclrt = reader->getInt32();
+ break;
+
+ case 179:
+ dimadec = reader->getInt32();
+ break;
+
+ case 270:
+ dimunit = reader->getInt32();
+ break;
+
+ case 271:
+ dimdec = reader->getInt32();
+ break;
+
+ case 272:
+ dimtdec = reader->getInt32();
+ break;
+
+ case 273:
+ dimaltu = reader->getInt32();
+ break;
+
+ case 274:
+ dimalttd = reader->getInt32();
+ break;
+
+ case 275:
+ dimaunit = reader->getInt32();
+ break;
+
+ case 276:
+ dimfrac = reader->getInt32();
+ break;
+
+ case 277:
+ dimlunit = reader->getInt32();
+ break;
+
+ case 278:
+ dimdsep = reader->getInt32();
+ break;
+
+ case 279:
+ dimtmove = reader->getInt32();
+ break;
+
+ case 280:
+ dimjust = reader->getInt32();
+ break;
+
+ case 281:
+ dimsd1 = reader->getInt32();
+ break;
+
+ case 282:
+ dimsd2 = reader->getInt32();
+ break;
+
+ case 283:
+ dimtolj = reader->getInt32();
+ break;
+
+ case 284:
+ dimtzin = reader->getInt32();
+ break;
+
+ case 285:
+ dimaltz = reader->getInt32();
+ break;
+
+ case 286:
+ dimaltttz = reader->getInt32();
+ break;
+
+ case 287:
+ dimfit = reader->getInt32();
+ break;
+
+ case 288:
+ dimupt = reader->getInt32();
+ break;
+
+ case 289:
+ dimatfit = reader->getInt32();
+ break;
+
+ case 340:
+ dimtxsty = reader->getUtf8String();
+ break;
+
+ case 341:
+ dimldrblk = reader->getUtf8String();
+ break;
+
+ case 342:
+ dimblk = reader->getUtf8String();
+ break;
+
+ case 343:
+ dimblk1 = reader->getUtf8String();
+ break;
+
+ case 344:
+ dimblk2 = reader->getUtf8String();
+ break;
+
+ default:
+ DRW_TableEntry::parseCode( code, reader );
+ break;
+ }
+}
+
+
+// ! Class to handle line type entries
+/*!
+ * Class to handle line type symbol table entries
+ * @author Rallaz
+ */
+void DRW_LType::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 3:
+ desc = reader->getUtf8String();
+ break;
+
+ case 73:
+ size = reader->getInt32();
+ path.reserve( size );
+ break;
+
+ case 40:
+ length = reader->getDouble();
+ break;
+
+ case 49:
+ path.push_back( reader->getDouble() );
+ pathIdx++;
+ break;
+
+/* case 74:
+ * haveShape = reader->getInt32();
+ * break;*/
+ default:
+ DRW_TableEntry::parseCode( code, reader );
+ break;
+ }
+}
+
+
+// ! Update line type
+/*!
+ * Update the size and length of line type acording to the path
+ * @author Rallaz
+ */
+/*TODO: control max length permited */
+void DRW_LType::update()
+{
+ double d = 0;
+
+ size = path.size();
+
+ for( int i = 0; i< size; i++ )
+ {
+ d += fabs( path.at( i ) );
+ }
+
+ length = d;
+}
+
+
+// ! Class to handle layer entries
+/*!
+ * Class to handle layer symbol table entries
+ * @author Rallaz
+ */
+void DRW_Layer::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 6:
+ lineType = reader->getUtf8String();
+ break;
+
+ case 62:
+ color = reader->getInt32();
+ break;
+
+ case 290:
+ plotF = reader->getBool();
+ break;
+
+ case 370:
+ lWeight = DRW_LW_Conv::dxfInt2lineWidth( reader->getInt32() );
+ break;
+
+ case 390:
+ handlePlotS = reader->getString();
+ break;
+
+ case 347:
+ handlePlotM = reader->getString();
+ break;
+
+ case 420:
+ color24 = reader->getInt32();
+ break;
+
+ default:
+ DRW_TableEntry::parseCode( code, reader );
+ break;
+ }
+}
+
+
+// ! Class to handle text style entries
+/*!
+ * Class to handle text style symbol table entries
+ * @author Rallaz
+ */
+void DRW_Textstyle::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 3:
+ font = reader->getUtf8String();
+ break;
+
+ case 4:
+ bigFont = reader->getUtf8String();
+ break;
+
+ case 40:
+ height = reader->getDouble();
+ break;
+
+ case 41:
+ width = reader->getDouble();
+ break;
+
+ case 50:
+ oblique = reader->getDouble();
+ break;
+
+ case 42:
+ lastHeight = reader->getDouble();
+ break;
+
+ case 71:
+ genFlag = reader->getInt32();
+ break;
+
+ case 1071:
+ fontFamily = reader->getInt32();
+ break;
+
+ default:
+ DRW_TableEntry::parseCode( code, reader );
+ break;
+ }
+}
+
+
+// ! Class to handle vport entries
+/*!
+ * Class to handle vport symbol table entries
+ * @author Rallaz
+ */
+void DRW_Vport::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 10:
+ lowerLeft.x = reader->getDouble();
+ break;
+
+ case 20:
+ lowerLeft.y = reader->getDouble();
+ break;
+
+ case 11:
+ UpperRight.x = reader->getDouble();
+ break;
+
+ case 21:
+ UpperRight.y = reader->getDouble();
+ break;
+
+ case 12:
+ center.x = reader->getDouble();
+ break;
+
+ case 22:
+ center.y = reader->getDouble();
+ break;
+
+ case 13:
+ snapBase.x = reader->getDouble();
+ break;
+
+ case 23:
+ snapBase.y = reader->getDouble();
+ break;
+
+ case 14:
+ snapSpacing.x = reader->getDouble();
+ break;
+
+ case 24:
+ snapSpacing.y = reader->getDouble();
+ break;
+
+ case 15:
+ gridSpacing.x = reader->getDouble();
+ break;
+
+ case 25:
+ gridSpacing.y = reader->getDouble();
+ break;
+
+ case 16:
+ viewDir.x = reader->getDouble();
+ break;
+
+ case 26:
+ viewDir.y = reader->getDouble();
+ break;
+
+ case 36:
+ viewDir.z = reader->getDouble();
+ break;
+
+ case 17:
+ viewTarget.x = reader->getDouble();
+ break;
+
+ case 27:
+ viewTarget.y = reader->getDouble();
+ break;
+
+ case 37:
+ viewTarget.z = reader->getDouble();
+ break;
+
+ case 40:
+ height = reader->getDouble();
+ break;
+
+ case 41:
+ ratio = reader->getDouble();
+ break;
+
+ case 42:
+ lensHeight = reader->getDouble();
+ break;
+
+ case 43:
+ frontClip = reader->getDouble();
+ break;
+
+ case 44:
+ backClip = reader->getDouble();
+ break;
+
+ case 50:
+ snapAngle = reader->getDouble();
+ break;
+
+ case 51:
+ twistAngle = reader->getDouble();
+ break;
+
+ case 71:
+ viewMode = reader->getInt32();
+ break;
+
+ case 72:
+ circleZoom = reader->getInt32();
+ break;
+
+ case 73:
+ fastZoom = reader->getInt32();
+ break;
+
+ case 74:
+ ucsIcon = reader->getInt32();
+ break;
+
+ case 75:
+ snap = reader->getInt32();
+ break;
+
+ case 76:
+ grid = reader->getInt32();
+ break;
+
+ case 77:
+ snapStyle = reader->getInt32();
+ break;
+
+ case 78:
+ snapIsopair = reader->getInt32();
+ break;
+
+ default:
+ DRW_TableEntry::parseCode( code, reader );
+ break;
+ }
+}
+
+
+void DRW_ImageDef::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 1:
+ name = reader->getUtf8String();
+ break;
+
+ case 5:
+ handle = reader->getString();
+ break;
+
+ case 10:
+ u = reader->getDouble();
+ break;
+
+ case 20:
+ v = reader->getDouble();
+ break;
+
+ case 11:
+ up = reader->getDouble();
+ break;
+
+ case 12:
+ vp = reader->getDouble();
+ break;
+
+ case 21:
+ vp = reader->getDouble();
+ break;
+
+ case 280:
+ loaded = reader->getInt32();
+ break;
+
+ case 281:
+ resolution = reader->getInt32();
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void DRW_Header::addComment( string c )
+{
+ if( !comments.empty() )
+ comments += '\n';
+
+ comments += c;
+}
+
+
+void DRW_Header::parseCode( int code, dxfReader* reader )
+{
+ switch( code )
+ {
+ case 9:
+ curr = new DRW_Variant();
+ name = reader->getString();
+
+ if( version < DRW::AC1015 && name == "$DIMUNIT" )
+ name = "$DIMLUNIT";
+
+ vars[name] = curr;
+ break;
+
+ case 1:
+ curr->addString( reader->getUtf8String() );
+
+ if( name =="$ACADVER" )
+ {
+ reader->setVersion( curr->content.s );
+ version = reader->getVersion();
+ }
+
+ curr->code = code;
+ break;
+
+ case 2:
+ curr->addString( reader->getUtf8String() );
+ curr->code = code;
+ break;
+
+ case 3:
+ curr->addString( reader->getUtf8String() );
+
+ if( name =="$DWGCODEPAGE" )
+ {
+ reader->setCodePage( curr->content.s );
+ curr->addString( reader->getCodePage() );
+ }
+
+ curr->code = code;
+ break;
+
+ case 6:
+ curr->addString( reader->getUtf8String() );
+ curr->code = code;
+ break;
+
+ case 7:
+ curr->addString( reader->getUtf8String() );
+ curr->code = code;
+ break;
+
+ case 8:
+ curr->addString( reader->getUtf8String() );
+ curr->code = code;
+ break;
+
+ case 10:
+ curr->addCoord( new DRW_Coord() );
+ curr->setCoordX( reader->getDouble() );
+ curr->code = code;
+ break;
+
+ case 20:
+ curr->setCoordY( reader->getDouble() );
+ break;
+
+ case 30:
+ curr->setCoordZ( reader->getDouble() );
+ curr->code = code;
+ break;
+
+ case 40:
+ curr->addDouble( reader->getDouble() );
+ curr->code = code;
+ break;
+
+ case 50:
+ curr->addDouble( reader->getDouble() );
+ curr->code = code;
+ break;
+
+ case 62:
+ curr->addInt( reader->getInt32() );
+ curr->code = code;
+ break;
+
+ case 70:
+ curr->addInt( reader->getInt32() );
+ curr->code = code;
+ break;
+
+ case 280:
+ curr->addInt( reader->getInt32() );
+ curr->code = code;
+ break;
+
+ case 290:
+ curr->addInt( reader->getInt32() );
+ curr->code = code;
+ break;
+
+ case 370:
+ curr->addInt( reader->getInt32() );
+ curr->code = code;
+ break;
+
+ case 380:
+ curr->addInt( reader->getInt32() );
+ curr->code = code;
+ break;
+
+ case 390:
+ curr->addString( reader->getUtf8String() );
+ curr->code = code;
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
+{
+/*RLZ: TODO complete all vars to AC1024*/
+ double varDouble;
+ int varInt;
+ std::string varStr;
+ DRW_Coord varCoord;
+
+ writer->writeString( 2, "HEADER" );
+ writer->writeString( 9, "$ACADVER" );
+
+ switch( ver )
+ {
+ case DRW::AC1006: // unsupported version acad 10
+ case DRW::AC1009: // acad 11 & 12
+ varStr = "AC1009";
+ break;
+
+ case DRW::AC1012: // unsupported version acad 13
+ case DRW::AC1014: // acad 14
+ varStr = "AC1014";
+ break;
+
+ case DRW::AC1015: // acad 2000
+ varStr = "AC1015";
+ break;
+
+ case DRW::AC1018: // acad 2004
+ varStr = "AC1018";
+ break;
+
+/* case DRW::AC1021: //acad 2007
+ * varStr = "AC1021";
+ * break;*/
+ case DRW::AC1024: // acad 2010
+ varStr = "AC1024";
+ break;
+
+ default: // acad 2007 default version
+ varStr = "AC1021";
+ break;
+ }
+
+ writer->writeString( 1, varStr );
+ writer->setVersion( &varStr );
+
+ if( ver > DRW::AC1012 )
+ {
+ writer->writeString( 9, "$HANDSEED" );
+// RLZ dxfHex(5, 0xFFFF);
+ writer->writeString( 5, "20000" );
+ }
+
+ if( !getStr( "$DWGCODEPAGE", &varStr ) )
+ {
+ varStr = "ANSI_1252";
+ }
+
+ writer->writeString( 9, "$DWGCODEPAGE" );
+ writer->setCodePage( &varStr );
+ writer->writeString( 3, writer->getCodePage() );
+ writer->writeString( 9, "$INSBASE" );
+
+ if( getCoord( "$INSBASE", &varCoord ) )
+ {
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ writer->writeDouble( 30, varCoord.z );
+ }
+ else
+ {
+ writer->writeDouble( 10, 0.0 );
+ writer->writeDouble( 20, 0.0 );
+ writer->writeDouble( 30, 0.0 );
+ }
+
+ writer->writeString( 9, "$EXTMIN" );
+
+ if( getCoord( "$EXTMIN", &varCoord ) )
+ {
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ writer->writeDouble( 30, varCoord.z );
+ }
+ else
+ {
+ writer->writeDouble( 10, 1.0000000000000000E+020 );
+ writer->writeDouble( 20, 1.0000000000000000E+020 );
+ writer->writeDouble( 30, 1.0000000000000000E+020 );
+ }
+
+ writer->writeString( 9, "$EXTMAX" );
+
+ if( getCoord( "$EXTMAX", &varCoord ) )
+ {
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ writer->writeDouble( 30, varCoord.z );
+ }
+ else
+ {
+ writer->writeDouble( 10, -1.0000000000000000E+020 );
+ writer->writeDouble( 20, -1.0000000000000000E+020 );
+ writer->writeDouble( 30, -1.0000000000000000E+020 );
+ }
+
+ writer->writeString( 9, "$LIMMIN" );
+
+ if( getCoord( "$LIMMIN", &varCoord ) )
+ {
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ }
+ else
+ {
+ writer->writeDouble( 10, 0.0 );
+ writer->writeDouble( 20, 0.0 );
+ }
+
+ writer->writeString( 9, "$LIMMAX" );
+
+ if( getCoord( "$LIMMAX", &varCoord ) )
+ {
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ }
+ else
+ {
+ writer->writeDouble( 10, 420.0 );
+ writer->writeDouble( 20, 297.0 );
+ }
+
+ writer->writeString( 9, "$ORTHOMODE" );
+
+ if( getInt( "$ORTHOMODE", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 0 );
+
+ writer->writeString( 9, "$LTSCALE" );
+
+ if( getDouble( "$LTSCALE", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 1.0 );
+
+ writer->writeString( 9, "$TEXTSTYLE" );
+
+ if( getStr( "$TEXTSTYLE", &varStr ) )
+ if( ver == DRW::AC1009 )
+ writer->writeUtf8Caps( 7, varStr );
+ else
+ writer->writeUtf8String( 7, varStr );
+
+
+ else
+ writer->writeString( 7, "STANDARD" );
+
+ writer->writeString( 9, "$DIMASZ" );
+
+ if( getDouble( "$DIMASZ", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 2.5 );
+
+ writer->writeString( 9, "$DIMSCALE" );
+
+ if( getDouble( "$DIMSCALE", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 1.0 );
+
+ writer->writeString( 9, "$DIMEXO" );
+
+ if( getDouble( "$DIMEXO", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 0.625 );
+
+ writer->writeString( 9, "$DIMEXE" );
+
+ if( getDouble( "$DIMEXE", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 1.25 );
+
+ writer->writeString( 9, "$DIMTXT" );
+
+ if( getDouble( "$DIMTXT", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 2.5 );
+
+ writer->writeString( 9, "$DIMTSZ" );
+
+ if( getDouble( "$DIMTSZ", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 0.0 );
+
+ if( ver > DRW::AC1009 )
+ {
+ writer->writeString( 9, "$DIMAUNIT" );
+
+ if( getInt( "$DIMAUNIT", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 0 );
+
+ writer->writeString( 9, "$DIMADEC" );
+
+ if( getInt( "$DIMADEC", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 0 );
+ }
+
+ // verify if exist "$DIMLUNIT" or obsolete "$DIMUNIT" (pre v2000)
+ if( !getInt( "$DIMLUNIT", &varInt ) )
+ {
+ if( !getInt( "$DIMUNIT", &varInt ) )
+ varInt = 2;
+ }
+
+ // verify valid values from 1 to 6
+ if( varInt<1 || varInt>6 )
+ varInt = 2;
+
+ if( ver > DRW::AC1014 )
+ {
+ writer->writeString( 9, "$DIMLUNIT" );
+ writer->writeInt16( 70, varInt );
+ }
+ else
+ {
+ writer->writeString( 9, "$DIMUNIT" );
+ writer->writeInt16( 70, varInt );
+ }
+
+ writer->writeString( 9, "$DIMSTYLE" );
+
+ if( getStr( "$DIMSTYLE", &varStr ) )
+ if( ver == DRW::AC1009 )
+ writer->writeUtf8Caps( 2, varStr );
+ else
+ writer->writeUtf8String( 2, varStr );
+
+
+ else
+ writer->writeString( 2, "STANDARD" );
+
+ writer->writeString( 9, "$DIMGAP" );
+
+ if( getDouble( "$DIMGAP", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 0.625 );
+
+ writer->writeString( 9, "$DIMTIH" );
+
+ if( getInt( "$DIMTIH", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 0 );
+
+ writer->writeString( 9, "$LUNITS" );
+
+ if( getInt( "$LUNITS", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 2 );
+
+ writer->writeString( 9, "$LUPREC" );
+
+ if( getInt( "$LUPREC", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 4 );
+
+ writer->writeString( 9, "$AUNITS" );
+
+ if( getInt( "$AUNITS", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 0 );
+
+ writer->writeString( 9, "$AUPREC" );
+
+ if( getInt( "$AUPREC", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 2 );
+
+ if( ver > DRW::AC1009 )
+ {
+ writer->writeString( 9, "$SPLINESEGS" );
+
+ if( getInt( "$SPLINESEGS", &varInt ) )
+ {
+ writer->writeInt16( 70, varInt );
+ }
+ else
+ writer->writeInt16( 70, 8 );
+ }
+
+/* RLZ: moved to active VPORT, but can write in header if present*/
+ if( getInt( "$GRIDMODE", &varInt ) )
+ {
+ writer->writeString( 9, "$GRIDMODE" );
+ writer->writeInt16( 70, varInt );
+ }
+
+ if( getInt( "$SNAPSTYLE", &varInt ) )
+ {
+ writer->writeString( 9, "$SNAPSTYLE" );
+ writer->writeInt16( 70, varInt );
+ }
+
+ if( getCoord( "$GRIDUNIT", &varCoord ) )
+ {
+ writer->writeString( 9, "$GRIDUNIT" );
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ }
+
+ if( getCoord( "$VIEWCTR", &varCoord ) )
+ {
+ writer->writeString( 9, "$VIEWCTR" );
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ }
+
+/* RLZ: moved to active VPORT, but can write in header if present*/
+
+ if( ver > DRW::AC1009 )
+ {
+ writer->writeString( 9, "$PINSBASE" );
+
+ if( getCoord( "$PINSBASE", &varCoord ) )
+ {
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ writer->writeDouble( 30, varCoord.z );
+ }
+ else
+ {
+ writer->writeDouble( 10, 0.0 );
+ writer->writeDouble( 20, 0.0 );
+ writer->writeDouble( 30, 0.0 );
+ }
+ }
+
+ writer->writeString( 9, "$PLIMMIN" );
+
+ if( getCoord( "$PLIMMIN", &varCoord ) )
+ {
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ }
+ else
+ {
+ writer->writeDouble( 10, 0.0 );
+ writer->writeDouble( 20, 0.0 );
+ }
+
+ writer->writeString( 9, "$PLIMMAX" );
+
+ if( getCoord( "$PLIMMAX", &varCoord ) )
+ {
+ writer->writeDouble( 10, varCoord.x );
+ writer->writeDouble( 20, varCoord.y );
+ }
+ else
+ {
+ writer->writeDouble( 10, 297.0 );
+ writer->writeDouble( 20, 210.0 );
+ }
+
+ if( ver > DRW::AC1014 )
+ {
+ writer->writeString( 9, "$INSUNITS" );
+
+ if( getInt( "$INSUNITS", &varInt ) )
+ writer->writeInt16( 70, varInt );
+ else
+ writer->writeInt16( 70, 0 );
+ }
+
+ if( ver > DRW::AC1009 )
+ {
+ writer->writeString( 9, "$PSVPSCALE" );
+
+ if( getDouble( "$PSVPSCALE", &varDouble ) )
+ writer->writeDouble( 40, varDouble );
+ else
+ writer->writeDouble( 40, 0.0 );
+ }
+
+ std::map::const_iterator it;
+
+ for( it = vars.begin(); it != vars.end(); it++ )
+ {
+ std::cerr << (*it).first << std::endl;
+ }
+}
+
+
+bool DRW_Header::getDouble( string key, double* varDouble )
+{
+ bool result = false;
+ std::map::iterator it;
+
+ it = vars.find( key );
+
+ if( it != vars.end() )
+ {
+ DRW_Variant* var = (*it).second;
+
+ if( var->type == DRW_Variant::DOUBLE )
+ {
+ *varDouble = var->content.d;
+ result = true;
+ }
+
+ vars.erase( it );
+ }
+
+ return result;
+}
+
+
+bool DRW_Header::getInt( string key, int* varInt )
+{
+ bool result = false;
+ std::map::iterator it;
+
+ it = vars.find( key );
+
+ if( it != vars.end() )
+ {
+ DRW_Variant* var = (*it).second;
+
+ if( var->type == DRW_Variant::INTEGER )
+ {
+ *varInt = var->content.i;
+ result = true;
+ }
+
+ vars.erase( it );
+ }
+
+ return result;
+}
+
+
+bool DRW_Header::getStr( string key, std::string* varStr )
+{
+ bool result = false;
+ std::map::iterator it;
+
+ it = vars.find( key );
+
+ if( it != vars.end() )
+ {
+ DRW_Variant* var = (*it).second;
+
+ if( var->type == DRW_Variant::STRING )
+ {
+ *varStr = *var->content.s;
+ result = true;
+ }
+
+ vars.erase( it );
+ }
+
+ return result;
+}
+
+
+bool DRW_Header::getCoord( string key, DRW_Coord* varCoord )
+{
+ bool result = false;
+ std::map::iterator it;
+
+ it = vars.find( key );
+
+ if( it != vars.end() )
+ {
+ DRW_Variant* var = (*it).second;
+
+ if( var->type == DRW_Variant::COORD )
+ {
+ *varCoord = *var->content.v;
+ result = true;
+ }
+
+ vars.erase( it );
+ }
+
+ return result;
+}
diff --git a/lib_dxf/drw_objects.h b/lib_dxf/drw_objects.h
new file mode 100644
index 0000000000..502a507245
--- /dev/null
+++ b/lib_dxf/drw_objects.h
@@ -0,0 +1,680 @@
+/******************************************************************************
+** libDXFrw - Library to read/write DXF files (ascii & binary) **
+** **
+** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
+** **
+** This library is free software, licensed 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. **
+** You should have received a copy of the GNU General Public License **
+** along with this program. If not, see . **
+******************************************************************************/
+
+#ifndef DRW_OBJECTS_H
+#define DRW_OBJECTS_H
+
+
+#include
+#include
+#include