diff --git a/lib_dxf/drw_base.h b/lib_dxf/drw_base.h index db700be133..56c4931301 100644 --- a/lib_dxf/drw_base.h +++ b/lib_dxf/drw_base.h @@ -13,7 +13,7 @@ #ifndef DRW_BASE_H #define DRW_BASE_H -#define DRW_VERSION "0.5.11" +#define DRW_VERSION "0.5.13" #include #include @@ -42,7 +42,8 @@ namespace DRW { // ! Version numbers for the DXF Format. -enum Version { +enum Version +{ UNKNOWNV, /*!< UNKNOWN VERSION. */ AC1006, /*!< R10. */ AC1009, /*!< R11 & R12. */ @@ -54,7 +55,8 @@ enum Version { AC1024 /*!< ACAD 2010. */ }; -enum error { +enum error +{ BAD_NONE, /*!< No error. */ BAD_UNKNOWN, /*!< UNKNOWN. */ BAD_OPEN, /*!< error opening file. */ @@ -76,7 +78,7 @@ enum error { class DRW_Coord { public: - DRW_Coord() { x = 0; y = 0; z = 0; } + DRW_Coord(): x(0), y(0), z(0) {} DRW_Coord( double ix, double iy, double iz ) { x = ix; y = iy; z = iz; @@ -121,15 +123,15 @@ public: DRW_Vertex2D() { // eType = DRW::LWPOLYLINE; - stawidth = endwidth = bulge = 0; + x = y = stawidth = endwidth = bulge = 0.0; } DRW_Vertex2D( double sx, double sy, double b ) { stawidth = endwidth = 0; - x = sx; - y = sy; - bulge = b; + x = sx; + y = sy; + bulge = b; } public: @@ -149,7 +151,8 @@ public: class DRW_Variant { public: - enum TYPE { + enum TYPE + { STRING, INTEGER, DOUBLE, @@ -162,46 +165,63 @@ public: type = INVALID; } + DRW_Variant( const DRW_Variant& d ) + { + code = d.code; + type = d.type; + + if( d.type == COORD ) vdata = d.vdata; + + if( d.type == STRING ) sdata = d.sdata; + + content = d.content; + } + + DRW_Variant( int c, UTF8STRING s ) { addString( s ); code = c; } + DRW_Variant( int c, int i ) { addInt( i ); code = c; } + DRW_Variant( int c, double d ) { addDouble( d ); code = c; } + DRW_Variant( int c, double x, double y, double z ) + { + setType( COORD ); vdata.x = x; vdata.y = y; + vdata.z = z; content.v = &vdata; code = c; + } + ~DRW_Variant() { - if( type == COORD ) - delete content.v; } - enum TYPE type; - - void addString( UTF8STRING s ) { setType( STRING ); data = s; content.s = &data; } + void addString( UTF8STRING s ) { setType( STRING ); sdata = s; content.s = &sdata; } 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 ) + void addCoord() { - if( type == COORD ) - delete content.v; - - type = t; + setType( COORD ); vdata.x = 0.0; vdata.y = 0.0; vdata.z = 0.0; content.v = + &vdata; } - 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; } + void addCoord( DRW_Coord v ) { setType( COORD ); vdata = v; content.v = &vdata; } + void setType( enum TYPE t ) { type = t; } + void setCoordX( double d ) { if( type == COORD ) vdata.x = d; } + void setCoordY( double d ) { if( type == COORD ) vdata.y = d; } + void setCoordZ( double d ) { if( type == COORD ) vdata.z = d; } + private: typedef union { UTF8STRING* s; - int i; - double d; - DRW_Coord* v; + int i; + double d; + DRW_Coord* v; } DRW_VarContent; + public: - DRW_VarContent content; -public: - int code; -// string version; -// string codepage; + DRW_VarContent content; + enum TYPE type; + int code; /*!< dxf code of this value*/ + private: -// DRW_VarContent content; - std::string data; + std::string sdata; + DRW_Coord vdata; }; @@ -215,7 +235,8 @@ private: class DRW_LW_Conv { public: - enum lineWidth { + enum lineWidth + { width00 = 0, /*!< 0.00mm (dxf 0)*/ width01 = 1, /*!< 0.05mm (dxf 5)*/ width02 = 2, /*!< 0.09mm (dxf 9)*/ diff --git a/lib_dxf/drw_entities.cpp b/lib_dxf/drw_entities.cpp index 93107e9ba7..c970e6134f 100644 --- a/lib_dxf/drw_entities.cpp +++ b/lib_dxf/drw_entities.cpp @@ -22,23 +22,33 @@ */ void DRW_Entity::calculateAxis( DRW_Coord extPoint ) { + // Follow the arbitrary DXF definitions for extrusion axes. if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 ) { + // If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec. + // The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x + // Factoring in the fixed values for Wy gives N.z,0,-N.x extAxisX.x = extPoint.z; extAxisX.y = 0; extAxisX.z = -extPoint.x; } else { + // Otherwise, implement Ax = Wz x N where Wz is [0,0,1] per the DXF spec. + // The cross product works out to Wz.y*N.z-Wz.z*N.y, Wz.z*N.x-Wz.x*N.z, Wz.x*N.y-Wz.y*N.x + // Factoring in the fixed values for Wz gives -N.y,N.x,0. extAxisX.x = -extPoint.y; extAxisX.y = extPoint.x; extAxisX.z = 0; } extAxisX.unitize(); + + // Ay = N x Ax 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(); } @@ -110,6 +120,58 @@ void DRW_Entity::parseCode( int code, dxfReader* reader ) space = reader->getInt32(); break; + case 1000: + case 1001: + case 1002: + case 1003: + case 1004: + case 1005: + extData.push_back( new DRW_Variant( code, reader->getString() ) ); + break; + + case 1010: + case 1011: + case 1012: + case 1013: + curr = new DRW_Variant(); + curr->addCoord(); + curr->setCoordX( reader->getDouble() ); + curr->code = code; + extData.push_back( curr ); + break; + + case 1020: + case 1021: + case 1022: + case 1023: + + if( curr ) + curr->setCoordY( reader->getDouble() ); + + break; + + case 1030: + case 1031: + case 1032: + case 1033: + + if( curr ) + curr->setCoordZ( reader->getDouble() ); + + curr = NULL; + break; + + case 1040: + case 1041: + case 1042: + extData.push_back( new DRW_Variant( code, reader->getDouble() ) ); + break; + + case 1070: + case 1071: + extData.push_back( new DRW_Variant( code, reader->getInt32() ) ); + break; + default: break; } @@ -137,8 +199,8 @@ void DRW_Point::parseCode( int code, dxfReader* reader ) break; case 210: - haveExtrusion = true; - extPoint.x = reader->getDouble(); + haveExtrusion = true; + extPoint.x = reader->getDouble(); break; case 220: @@ -183,6 +245,8 @@ void DRW_Circle::applyExtrusion() { if( haveExtrusion ) { + // NOTE: Commenting these out causes the the arcs being tested to be located + // on the other side of the y axis (all x dimensions are negated). calculateAxis( extPoint ); extrudePoint( extPoint, &basePoint ); } @@ -204,6 +268,30 @@ void DRW_Circle::parseCode( int code, dxfReader* reader ) } +void DRW_Arc::applyExtrusion() +{ + DRW_Circle::applyExtrusion(); + + if( haveExtrusion ) + { + // If the extrusion vector has a z value less than 0, the angles for the arc + // have to be mirrored since DXF files use the right hand rule. + // Note that the following code only handles the special case where there is a 2D + // drawing with the z axis heading into the paper (or rather screen). An arbitrary + // extrusion axis (with x and y values greater than 1/64) may still have issues. + if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 && extPoint.z < 0.0 ) + { + staangle = M_PI - staangle; + endangle = M_PI - endangle; + + double temp = staangle; + staangle = endangle; + endangle = temp; + } + } +} + + void DRW_Arc::parseCode( int code, dxfReader* reader ) { switch( code ) @@ -309,9 +397,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts ) 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 = atan2( secPoint.y, secPoint.x ); + cosRot = cos( incAngle ); + sinRot = sin( incAngle ); incAngle = M_PIx2 / parts; curAngle = staparam; int i = curAngle / incAngle; @@ -336,9 +424,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts ) pol->flags = 1; } - pol->layer = this->layer; - pol->lineType = this->lineType; - pol->color = this->color; + pol->layer = this->layer; + pol->lineType = this->lineType; + pol->color = this->color; pol->lWeight = this->lWeight; pol->extPoint = this->extPoint; } @@ -487,8 +575,8 @@ void DRW_LWPolyline::applyExtrusion() for( unsigned int i = 0; ix, vert->y, elevation ); + DRW_Vertex2D* vert = vertlist.at( i ); + DRW_Coord v( vert->x, vert->y, elevation ); extrudePoint( extPoint, &v ); vert->x = v.x; vert->y = v.y; @@ -502,12 +590,12 @@ 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; - } + { + vertex = new DRW_Vertex2D(); + vertlist.push_back( vertex ); + vertex->x = reader->getDouble(); + break; + } case 20: @@ -559,8 +647,8 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader ) break; case 210: - haveExtrusion = true; - extPoint.x = reader->getDouble(); + haveExtrusion = true; + extPoint.x = reader->getDouble(); break; case 220: @@ -779,19 +867,19 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader ) { break; } - else if( reader->getInt32() == 1 ) // line + else if( reader->getInt32() == 1 ) // line { addLine(); } - else if( reader->getInt32() == 2 ) // arc + else if( reader->getInt32() == 2 ) // arc { addArc(); } - else if( reader->getInt32() == 3 ) // elliptic arc + else if( reader->getInt32() == 3 ) // elliptic arc { addEllipse(); } - else if( reader->getInt32() == 4 ) // spline + else if( reader->getInt32() == 4 ) // spline { addSpline(); } @@ -804,8 +892,8 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader ) pt->basePoint.x = reader->getDouble(); else if( pline ) { - plvert = pline->addVertex(); - plvert->x = reader->getDouble(); + plvert = pline->addVertex(); + plvert->x = reader->getDouble(); } break; @@ -1018,12 +1106,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader ) break; case 10: - { - controlpoint = new DRW_Coord(); - controllist.push_back( controlpoint ); - controlpoint->x = reader->getDouble(); - break; - } + { + controlpoint = new DRW_Coord(); + controllist.push_back( controlpoint ); + controlpoint->x = reader->getDouble(); + break; + } case 20: @@ -1040,12 +1128,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader ) break; case 11: - { - fitpoint = new DRW_Coord(); - fitlist.push_back( fitpoint ); - fitpoint->x = reader->getDouble(); - break; - } + { + fitpoint = new DRW_Coord(); + fitlist.push_back( fitpoint ); + fitpoint->x = reader->getDouble(); + break; + } case 21: @@ -1312,12 +1400,12 @@ void DRW_Leader::parseCode( int code, dxfReader* reader ) break; case 10: - { - vertexpoint = new DRW_Coord(); - vertexlist.push_back( vertexpoint ); - vertexpoint->x = reader->getDouble(); - break; - } + { + vertexpoint = new DRW_Coord(); + vertexlist.push_back( vertexpoint ); + vertexpoint->x = reader->getDouble(); + break; + } case 20: @@ -1413,10 +1501,10 @@ void DRW_Viewport::parseCode( int code, dxfReader* reader ) break; case 12: - { - centerPX = reader->getDouble(); - break; - } + { + centerPX = reader->getDouble(); + break; + } case 22: centerPY = reader->getDouble(); diff --git a/lib_dxf/drw_entities.h b/lib_dxf/drw_entities.h index 911937c921..7f7b0855f4 100644 --- a/lib_dxf/drw_entities.h +++ b/lib_dxf/drw_entities.h @@ -23,7 +23,8 @@ class DRW_Polyline; namespace DRW { // ! Entity's type. -enum ETYPE { +enum ETYPE +{ POINT, LINE, CIRCLE, @@ -72,61 +73,73 @@ 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 + 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 + handle = 0; + curr = NULL; } - virtual ~DRW_Entity() {} + virtual ~DRW_Entity() + { + for( std::vector::iterator it = extData.begin(); it!=extData.end(); ++it ) + delete *it; + + extData.clear(); + } 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; + 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; + curr = NULL; } - virtual void applyExtrusion() = 0; + virtual void applyExtrusion() = 0; protected: - void parseCode( int code, dxfReader* reader ); - void calculateAxis( DRW_Coord extPoint ); - void extrudePoint( DRW_Coord extPoint, DRW_Coord* point ); + 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 */ - std::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*/ + 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 */ + std::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*/ + std::vector extData; /*!< FIFO list of extended data, codes 1000 to 1071*/ + private: - DRW_Coord extAxisX; - DRW_Coord extAxisY; + DRW_Coord extAxisX; + DRW_Coord extAxisY; + DRW_Variant* curr; }; @@ -143,7 +156,7 @@ public: eType = DRW::POINT; basePoint.z = extPoint.x = extPoint.y = 0; extPoint.z = 1; - thickness = 0; + thickness = 0; } virtual void applyExtrusion() {} @@ -151,9 +164,9 @@ public: 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 */ + 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 @@ -216,6 +229,7 @@ public: DRW_Circle() { eType = DRW::CIRCLE; + radious = 0.0; } virtual void applyExtrusion(); @@ -237,15 +251,17 @@ public: { eType = DRW::ARC; isccw = 1; + staangle = 0.0; + endangle = 0.0; } - virtual void applyExtrusion() { DRW_Circle::applyExtrusion(); } - void parseCode( int code, dxfReader* reader ); + virtual void 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 */ + int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */ }; // ! Class to handle ellipse entity @@ -262,6 +278,8 @@ public: { eType = DRW::ELLIPSE; isccw = 1; + ratio = 1.0; + staparam = endparam = 0; } void parseCode( int code, dxfReader* reader ); @@ -273,7 +291,7 @@ 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 */ + int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */ }; // ! Class to handle trace entity @@ -356,8 +374,8 @@ public: void parseCode( int code, dxfReader* reader ); public: - UTF8STRING name; /*!< block name, code 2 */ - int flags; /*!< block type, code 70 */ + UTF8STRING name; /*!< block name, code 2 */ + int flags; /*!< block type, code 70 */ }; @@ -371,11 +389,11 @@ class DRW_Insert : public DRW_Point public: DRW_Insert() { - eType = DRW::INSERT; - xscale = 1; - yscale = 1; - zscale = 1; - angle = 0; + eType = DRW::INSERT; + xscale = 1; + yscale = 1; + zscale = 1; + angle = 0; colcount = 1; rowcount = 1; colspace = 0; @@ -386,15 +404,15 @@ public: 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 */ + 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 @@ -407,12 +425,13 @@ class DRW_LWPolyline : public DRW_Entity public: DRW_LWPolyline() { - eType = DRW::LWPOLYLINE; - elevation = thickness = width = 0.0; - flags = 0; + eType = DRW::LWPOLYLINE; + elevation = thickness = width = 0.0; + flags = 0; extPoint.x = extPoint.y = 0; extPoint.z = 1; - vertex = NULL; + vertex = NULL; + vertexnum = 0; } ~DRW_LWPolyline() @@ -433,7 +452,7 @@ public: vert->y = v.y; vert->stawidth = v.stawidth; vert->endwidth = v.endwidth; - vert->bulge = v.bulge; + vert->bulge = v.bulge; vertlist.push_back( vert ); } @@ -443,7 +462,7 @@ public: vert->stawidth = 0; vert->endwidth = 0; - vert->bulge = 0; + vert->bulge = 0; vertlist.push_back( vert ); return vert; } @@ -451,13 +470,13 @@ public: 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 */ + 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 */ }; @@ -470,7 +489,8 @@ class DRW_Text : public DRW_Line { public: // ! Vertical alignments. - enum VAlign { + enum VAlign + { VBaseLine = 0, /*!< Top = 0 */ VBottom, /*!< Bottom = 1 */ VMiddle, /*!< Middle = 2 */ @@ -478,7 +498,8 @@ public: }; // ! Horizontal alignments. - enum HAlign { + enum HAlign + { HLeft = 0, /*!< Left = 0 */ HCenter, /*!< Centered = 1 */ HRight, /*!< Right = 2 */ @@ -491,25 +512,26 @@ public: { eType = DRW::TEXT; angle = 0; - widthscale = 1; - oblique = 0; - style = "STANDARD"; + widthscale = 1; + oblique = 0; + style = "STANDARD"; textgen = 0; alignH = HLeft; alignV = VBaseLine; + height = 0.0; } 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 */ + 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 */ }; @@ -523,7 +545,8 @@ class DRW_MText : public DRW_Text { public: // ! Attachments. - enum Attach { + enum Attach + { TopLeft = 1, TopCenter, TopRight, @@ -537,20 +560,21 @@ public: DRW_MText() { - eType = DRW::MTEXT; - interlin = 1; - alignV = (VAlign) TopLeft; - textgen = 1; - haveXAxis = false; // if true needed to recalculate angle + 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 */ + double interlin; /*!< width factor, code 44 */ + private: - bool haveXAxis; + bool haveXAxis; }; // ! Class to handle vertex @@ -563,21 +587,23 @@ class DRW_Vertex : public DRW_Point public: DRW_Vertex() { - eType = DRW::VERTEX; + eType = DRW::VERTEX; stawidth = endwidth = bulge = 0; vindex1 = vindex2 = vindex3 = vindex4 = 0; - flags = identifier = 0; + flags = identifier = 0; + tgdir = 0.0; } DRW_Vertex( double sx, double sy, double sz, double b ) { stawidth = endwidth = 0; vindex1 = vindex2 = vindex3 = vindex4 = 0; - flags = identifier = 0; + flags = identifier = 0; basePoint.x = sx; basePoint.y = sy; basePoint.z = sz; - bulge = b; + bulge = b; + tgdir = 0.0; } void parseCode( int code, dxfReader* reader ); @@ -587,13 +613,13 @@ public: 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 */ + 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 @@ -609,7 +635,7 @@ public: eType = DRW::POLYLINE; defstawidth = defendwidth = 0.0; basePoint.x = basePoint.y = 0.0; - flags = vertexcount = facecount = 0; + flags = vertexcount = facecount = 0; smoothM = smoothN = curvetype = 0; } @@ -628,8 +654,8 @@ public: 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->stawidth = v.stawidth; + vert->endwidth = v.endwidth; vert->bulge = v.bulge; vertlist.push_back( vert ); } @@ -642,14 +668,14 @@ public: void parseCode( int code, dxfReader* reader ); public: - int flags; /*!< polyline flag, code 70, default 0 */ + 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 */ + 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 */ }; @@ -667,9 +693,13 @@ public: { eType = DRW::SPLINE; flags = nknots = ncontrol = nfit = 0; - ex = ey = 0.0; - ez = 1.0; + ex = ey = 0.0; + ez = 1.0; tolknot = tolcontrol = tolfit = 0.0000001; + tgsx = tgsy = tgsz = tgex = tgey = tgez = 0.0; + degree = 0; + controlpoint = 0; + fitpoint = 0; } ~DRW_Spline() @@ -699,21 +729,22 @@ public: 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 */ + 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 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 */ + DRW_Coord* controlpoint; /*!< current control point to add data */ + DRW_Coord* fitpoint; /*!< current fit point to add data */ }; // ! Class to handle hatch loop @@ -726,8 +757,8 @@ class DRW_HatchLoop public: DRW_HatchLoop( int t ) { - type = t; - numedges = 0; + type = t; + numedges = 0; } ~DRW_HatchLoop() @@ -768,11 +799,12 @@ public: 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; + loopsnum = hstyle = associative = 0; + solid = hpattern = 1; + deflines = doubleflag = 0; + loop = NULL; clearEntities(); + ispol = false; } ~DRW_Hatch() @@ -792,24 +824,25 @@ public: 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 */ + 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; + pt = line = NULL; + pline = NULL; + arc = NULL; ellipse = NULL; spline = NULL; plvert = NULL; @@ -854,21 +887,21 @@ private: if( loop ) { - pt = NULL; - spline = new DRW_Spline; + 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_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; + DRW_Point* pt; + DRW_Vertex2D* plvert; + bool ispol; }; // ! Class to handle image entity @@ -881,25 +914,26 @@ class DRW_Image : public DRW_Line public: DRW_Image() { - eType = DRW::IMAGE; - vz = fade = clip = 0; + eType = DRW::IMAGE; + vz = fade = clip = 0; brightness = contrast = 50; + vx = vy = sizeu = sizev = dz = 0.0; } void parseCode( int code, dxfReader* reader ); public: std::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 */ + 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 */ }; @@ -913,39 +947,41 @@ 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"; + 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; + type = 0; + length = 0.0; } DRW_Dimension( const DRW_Dimension& d ) : DRW_Entity( d ) { - eType = DRW::DIMENSION; - type = d.type; - name = d.name; + 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; + 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; + 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; + length = d.length; } virtual ~DRW_Dimension() {} @@ -955,68 +991,71 @@ public: virtual void applyExtrusion() {} DRW_Coord getDefPoint() const { return defPoint; } /*!< Definition point, code 10, 20 & 30 */ - void setDefPoint( const DRW_Coord p ) { defPoint = p; } + 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; } + void setTextPoint( const DRW_Coord& p ) { textPoint = p; } std::string getStyle() const { return style; } /*!< Dimension style, code 3 */ - void setStyle( const std::string s ) { style = s; } + void setStyle( const std::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; } std::string getText() const { return text; } /*!< Dimension text explicitly entered by the user, code 1 */ - void setText( const std::string t ) { text = t; } + void setText( const std::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; } + void setExtrusion( const DRW_Coord& p ) { extPoint = p; } std::string getName() { return name; } /*!< Name of the block that contains the entities, code 2 */ - void setName( const std::string s ) { name = s; } + void setName( const std::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; } + void setPt2( const DRW_Coord& p ) { clonePoint = p; } DRW_Coord getPt3() const { return def1; } - void setPt3( const DRW_Coord p ) { def1 = p; } + void setPt3( const DRW_Coord& p ) { def1 = p; } DRW_Coord getPt4() const { return def2; } - void setPt4( const DRW_Coord p ) { def2 = p; } + void setPt4( const DRW_Coord& p ) { def2 = p; } DRW_Coord getPt5() const { return circlePoint; } - void setPt5( const DRW_Coord p ) { circlePoint = p; } + void setPt5( const DRW_Coord& p ) { circlePoint = p; } DRW_Coord getPt6() const { return arcPoint; } - void setPt6( const DRW_Coord p ) { arcPoint = p; } + 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 */ + int type; /*!< Dimension type, code 70 */ + private: std::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 */ + 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 */ + 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 */ + double length; /*!< Leader length, code 40 */ }; @@ -1039,14 +1078,14 @@ public: } DRW_Coord getClonepoint() const { return getPt2(); } /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */ - void setClonePoint( DRW_Coord c ) { setPt2( c ); } + 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 ); } + 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 ); } + 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 ); } + void setDef2Point( const DRW_Coord& p ) { setPt4( p ); } }; // ! Class to handle linear or rotated dimension entity @@ -1092,9 +1131,9 @@ public: } DRW_Coord getCenterPoint() const { return getDefPoint(); } /*!< center point, code 10, 20 & 30 */ - void setCenterPoint( const DRW_Coord p ) { setDefPoint( p ); } + 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 ); } + void setDiameterPoint( const DRW_Coord& p ) { setPt5( p ); } double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */ void setLeaderLength( const double d ) { setRa40( d ); } }; @@ -1118,9 +1157,9 @@ public: } DRW_Coord getDiameter1Point() const { return getPt5(); } /*!< First definition point for diameter, code 15, 25 & 35 */ - void setDiameter1Point( const DRW_Coord p ) { setPt5( p ); } + 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 ); } + void setDiameter2Point( const DRW_Coord& p ) { setDefPoint( p ); } double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */ void setLeaderLength( const double d ) { setRa40( d ); } }; @@ -1144,15 +1183,15 @@ public: } DRW_Coord getFirstLine1() const { return getPt3(); } /*!< Definition point line 1-1, code 13, 23 & 33 */ - void setFirstLine1( const DRW_Coord p ) { setPt3( p ); } + 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 ); } + 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 ); } + 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 ); } + 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 ); } + void setDimPoint( const DRW_Coord& p ) { setPt6( p ); } }; @@ -1175,13 +1214,13 @@ public: } DRW_Coord getFirstLine() const { return getPt3(); } /*!< Definition point line 1, code 13, 23 & 33 */ - void setFirstLine( const DRW_Coord p ) { setPt3( p ); } + 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 ); } + 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 ); } + 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 ); } + void setDimPoint( const DRW_Coord& p ) { setDefPoint( p ); } }; // ! Class to handle ordinate dimension entity @@ -1203,11 +1242,11 @@ public: } DRW_Coord getOriginPoint() const { return getDefPoint(); } /*!< Origin definition point, code 10, 20 & 30 */ - void setOriginPoint( const DRW_Coord p ) { setDefPoint( p ); } + 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 ); } + 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 ); } + void setSecondLine( const DRW_Coord& p ) { setPt4( p ); } }; @@ -1221,12 +1260,16 @@ class DRW_Leader : public DRW_Entity public: DRW_Leader() { - eType = DRW::LEADER; - flag = 3; - hookflag = vertnum = leadertype = 0; + eType = DRW::LEADER; + flag = 3; + hookflag = vertnum = leadertype = 0; extrusionPoint.x = extrusionPoint.y = 0.0; arrow = 1; extrusionPoint.z = 1.0; + hookline = 0; + textheight = textwidth = 0.0; + coloruse = 0; + vertexpoint = NULL; } ~DRW_Leader() @@ -1241,25 +1284,26 @@ public: 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 */ - std::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 */ + 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 */ + std::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 */ - std::vector vertexlist; /*!< vertex points list, code 10, 20 & 30 */ private: - DRW_Coord* vertexpoint; /*!< current control point to add data */ + DRW_Coord* vertexpoint; /*!< current control point to add data */ }; // ! Class to handle viewport entity @@ -1272,8 +1316,8 @@ class DRW_Viewport : public DRW_Point public: DRW_Viewport() { - eType = DRW::VIEWPORT; - vpstatus = 0; + eType = DRW::VIEWPORT; + vpID = vpstatus = 0; pswidth = 205; psheight = 156; centerPX = 128.5; @@ -1286,8 +1330,8 @@ public: 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 */ + 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 */ }; diff --git a/lib_dxf/drw_interface.h b/lib_dxf/drw_interface.h index 52fbe84f16..0797b29870 100644 --- a/lib_dxf/drw_interface.h +++ b/lib_dxf/drw_interface.h @@ -40,22 +40,25 @@ public: } /** Called when header is parsed. */ - virtual void addHeader( const DRW_Header* data ) = 0; + virtual void addHeader( const DRW_Header* data ) = 0; /** Called for every line Type. */ - virtual void addLType( const DRW_LType& data ) = 0; + virtual void addLType( const DRW_LType& data ) = 0; /** Called for every layer. */ - virtual void addLayer( const DRW_Layer& data ) = 0; + virtual void addLayer( const DRW_Layer& data ) = 0; /** Called for every dim style. */ - virtual void addDimStyle( const DRW_Dimstyle& data ) = 0; + virtual void addDimStyle( const DRW_Dimstyle& data ) = 0; /** Called for every VPORT table. */ - virtual void addVport( const DRW_Vport& data ) = 0; + virtual void addVport( const DRW_Vport& data ) = 0; /** Called for every text style. */ - virtual void addTextStyle( const DRW_Textstyle& data ) = 0; + virtual void addTextStyle( const DRW_Textstyle& data ) = 0; + + /** Called for every AppId entry. */ + virtual void addAppId( const DRW_AppId& data ) = 0; /** * Called for every block. Note: all entities added after this @@ -63,7 +66,7 @@ public: * * @see endBlock() */ - virtual void addBlock( const DRW_Block& data ) = 0; + virtual void addBlock( const DRW_Block& data ) = 0; /** * In DWG called when the following entities corresponding to a @@ -72,127 +75,127 @@ public: * * int handle are the value of DRW_Block::handleBlock added with addBlock() */ - virtual void setBlock( const int handle ) = 0; + virtual void setBlock( const int handle ) = 0; /** Called to end the current block */ - virtual void endBlock() = 0; + virtual void endBlock() = 0; /** Called for every point */ - virtual void addPoint( const DRW_Point& data ) = 0; + virtual void addPoint( const DRW_Point& data ) = 0; /** Called for every line */ - virtual void addLine( const DRW_Line& data ) = 0; + virtual void addLine( const DRW_Line& data ) = 0; /** Called for every ray */ - virtual void addRay( const DRW_Ray& data ) = 0; + virtual void addRay( const DRW_Ray& data ) = 0; /** Called for every xline */ - virtual void addXline( const DRW_Xline& data ) = 0; + virtual void addXline( const DRW_Xline& data ) = 0; /** Called for every arc */ - virtual void addArc( const DRW_Arc& data ) = 0; + virtual void addArc( const DRW_Arc& data ) = 0; /** Called for every circle */ - virtual void addCircle( const DRW_Circle& data ) = 0; + virtual void addCircle( const DRW_Circle& data ) = 0; /** Called for every ellipse */ - virtual void addEllipse( const DRW_Ellipse& data ) = 0; + virtual void addEllipse( const DRW_Ellipse& data ) = 0; /** Called for every lwpolyline */ - virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0; + virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0; /** Called for every polyline start */ - virtual void addPolyline( const DRW_Polyline& data ) = 0; + virtual void addPolyline( const DRW_Polyline& data ) = 0; /** Called for every spline */ - virtual void addSpline( const DRW_Spline* data ) = 0; + virtual void addSpline( const DRW_Spline* data ) = 0; /** Called for every spline knot value */ - virtual void addKnot( const DRW_Entity& data ) = 0; + virtual void addKnot( const DRW_Entity& data ) = 0; /** Called for every insert. */ - virtual void addInsert( const DRW_Insert& data ) = 0; + virtual void addInsert( const DRW_Insert& data ) = 0; /** Called for every trace start */ - virtual void addTrace( const DRW_Trace& data ) = 0; + virtual void addTrace( const DRW_Trace& data ) = 0; /** Called for every 3dface start */ - virtual void add3dFace( const DRW_3Dface& data ) = 0; + virtual void add3dFace( const DRW_3Dface& data ) = 0; /** Called for every solid start */ - virtual void addSolid( const DRW_Solid& data ) = 0; + virtual void addSolid( const DRW_Solid& data ) = 0; /** Called for every Multi Text entity. */ - virtual void addMText( const DRW_MText& data ) = 0; + virtual void addMText( const DRW_MText& data ) = 0; /** Called for every Text entity. */ - virtual void addText( const DRW_Text& data ) = 0; + virtual void addText( const DRW_Text& data ) = 0; /** * Called for every aligned dimension entity. */ - virtual void addDimAlign( const DRW_DimAligned* data ) = 0; + virtual void addDimAlign( const DRW_DimAligned* data ) = 0; /** * Called for every linear or rotated dimension entity. */ - virtual void addDimLinear( const DRW_DimLinear* data ) = 0; + virtual void addDimLinear( const DRW_DimLinear* data ) = 0; /** * Called for every radial dimension entity. */ - virtual void addDimRadial( const DRW_DimRadial* data ) = 0; + virtual void addDimRadial( const DRW_DimRadial* data ) = 0; /** * Called for every diametric dimension entity. */ - virtual void addDimDiametric( const DRW_DimDiametric* data ) = 0; + 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; + 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; + virtual void addDimAngular3P( const DRW_DimAngular3p* data ) = 0; /** * Called for every ordinate dimension entity. */ - virtual void addDimOrdinate( const DRW_DimOrdinate* data ) = 0; + virtual void addDimOrdinate( const DRW_DimOrdinate* data ) = 0; /** * Called for every leader start. */ - virtual void addLeader( const DRW_Leader* data ) = 0; + virtual void addLeader( const DRW_Leader* data ) = 0; /** * Called for every hatch entity. */ - virtual void addHatch( const DRW_Hatch* data ) = 0; + virtual void addHatch( const DRW_Hatch* data ) = 0; /** * Called for every viewport entity. */ - virtual void addViewport( const DRW_Viewport& data ) = 0; + virtual void addViewport( const DRW_Viewport& data ) = 0; /** * Called for every image entity. */ - virtual void addImage( const DRW_Image* data ) = 0; + virtual void addImage( const DRW_Image* data ) = 0; /** * Called for every image definition. */ - virtual void linkImage( const DRW_ImageDef* data ) = 0; + 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; + virtual void addComment( const char* comment ) = 0; /** Sets the current attributes for entities. */ /* void setExtrusion(double dx, double dy, double dz, double elevation) { @@ -208,12 +211,13 @@ public: 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; + virtual void writeEntities() = 0; + virtual void writeLTypes() = 0; + virtual void writeLayers() = 0; + virtual void writeTextstyles() = 0; + virtual void writeVports() = 0; + virtual void writeDimstyles() = 0; + virtual void writeAppId() = 0; protected: // DL_Attributes attributes; diff --git a/lib_dxf/drw_objects.cpp b/lib_dxf/drw_objects.cpp index 9cccb01731..128ab8d2d7 100644 --- a/lib_dxf/drw_objects.cpp +++ b/lib_dxf/drw_objects.cpp @@ -41,6 +41,58 @@ void DRW_TableEntry::parseCode( int code, dxfReader* reader ) flags = reader->getInt32(); break; + case 1000: + case 1001: + case 1002: + case 1003: + case 1004: + case 1005: + extData.push_back( new DRW_Variant( code, reader->getString() ) ); + break; + + case 1010: + case 1011: + case 1012: + case 1013: + curr = new DRW_Variant(); + curr->addCoord(); + curr->setCoordX( reader->getDouble() ); + curr->code = code; + extData.push_back( curr ); + break; + + case 1020: + case 1021: + case 1022: + case 1023: + + if( curr ) + curr->setCoordY( reader->getDouble() ); + + break; + + case 1030: + case 1031: + case 1032: + case 1033: + + if( curr ) + curr->setCoordZ( reader->getDouble() ); + + curr = NULL; + break; + + case 1040: + case 1041: + case 1042: + extData.push_back( new DRW_Variant( code, reader->getDouble() ) ); + break; + + case 1070: + case 1071: + extData.push_back( new DRW_Variant( code, reader->getInt32() ) ); + break; + default: break; } @@ -747,7 +799,7 @@ void DRW_Header::parseCode( int code, dxfReader* reader ) break; case 10: - curr->addCoord( new DRW_Coord() ); + curr->addCoord(); curr->setCoordX( reader->getDouble() ); curr->code = code; break; @@ -815,8 +867,8 @@ void DRW_Header::parseCode( int code, dxfReader* reader ) void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) { /*RLZ: TODO complete all vars to AC1024*/ - double varDouble; - int varInt; + double varDouble; + int varInt; std::string varStr; DRW_Coord varCoord; @@ -970,6 +1022,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) writer->writeUtf8String( 7, varStr ); + + else writer->writeString( 7, "STANDARD" ); @@ -982,6 +1036,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) writer->writeUtf8String( 8, varStr ); + + else writer->writeString( 8, "0" ); @@ -1082,6 +1138,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) writer->writeUtf8String( 2, varStr ); + + else writer->writeString( 2, "STANDARD" ); @@ -1235,7 +1293,7 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) #ifdef DRW_DBG std::map::const_iterator it; - for( it = vars.begin(); it != vars.end(); it++ ) + for( it = vars.begin(); it != vars.end(); ++it ) { // QString key = QString::fromStdString((*it).first); std::cerr << (*it).first << std::endl; @@ -1245,6 +1303,42 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) } +void DRW_Header::addDouble( std::string key, double value, int code ) +{ + curr = new DRW_Variant(); + curr->addDouble( value ); + curr->code = code; + vars[key] = curr; +} + + +void DRW_Header::addInt( std::string key, int value, int code ) +{ + curr = new DRW_Variant(); + curr->addInt( value ); + curr->code = code; + vars[key] = curr; +} + + +void DRW_Header::addStr( std::string key, std::string value, int code ) +{ + curr = new DRW_Variant(); + curr->addString( value ); + curr->code = code; + vars[key] = curr; +} + + +void DRW_Header::addCoord( std::string key, DRW_Coord value, int code ) +{ + curr = new DRW_Variant(); + curr->addCoord( value ); + curr->code = code; + vars[key] = curr; +} + + bool DRW_Header::getDouble( std::string key, double* varDouble ) { bool result = false; @@ -1258,8 +1352,8 @@ bool DRW_Header::getDouble( std::string key, double* varDouble ) if( var->type == DRW_Variant::DOUBLE ) { - *varDouble = var->content.d; - result = true; + *varDouble = var->content.d; + result = true; } vars.erase( it ); @@ -1330,8 +1424,8 @@ bool DRW_Header::getCoord( std::string key, DRW_Coord* varCoord ) if( var->type == DRW_Variant::COORD ) { - *varCoord = *var->content.v; - result = true; + *varCoord = *var->content.v; + result = true; } vars.erase( it ); diff --git a/lib_dxf/drw_objects.h b/lib_dxf/drw_objects.h index dbdb21435f..46c9a3ca1d 100644 --- a/lib_dxf/drw_objects.h +++ b/lib_dxf/drw_objects.h @@ -24,14 +24,16 @@ class dxfWriter; namespace DRW { // ! Table entries type. -enum TTYPE { +enum TTYPE +{ UNKNOWNT, LTYPE, LAYER, STYLE, DIMSTYLE, VPORT, - BLOCK_RECORD + BLOCK_RECORD, + APPID }; } @@ -48,18 +50,42 @@ public: { tType = DRW::UNKNOWNT; flags = 0; + curr = NULL; + handle = 0; + handleBlock = 0; + } + + virtual ~DRW_TableEntry() + { + for( std::vector::iterator it = extData.begin(); it!=extData.end(); ++it ) + delete *it; + + extData.clear(); } - virtual ~DRW_TableEntry() {} protected: void parseCode( int code, dxfReader* reader ); + void reset() + { + flags = 0; + + for( std::vector::iterator it = extData.begin(); it!=extData.end(); ++it ) + delete *it; + + extData.clear(); + } + public: - enum DRW::TTYPE tType; /*!< 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 name; /*!< entry name, code 2 */ - int flags; /*!< Flags relevant to entry, code 70 */ + enum DRW::TTYPE tType; /*!< 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 name; /*!< entry name, code 2 */ + int flags; /*!< Flags relevant to entry, code 70 */ + std::vector extData; /*!< FIFO list of extended data, codes 1000 to 1071*/ + +private: + DRW_Variant* curr; }; @@ -75,27 +101,28 @@ public: void reset() { - tType = DRW::DIMSTYLE; - dimasz = dimtxt = dimexe = 0.18; - dimexo = 0.0625; - dimgap = dimcen = 0.09; + tType = DRW::DIMSTYLE; + dimasz = dimtxt = dimexe = 0.18; + dimexo = 0.0625; + dimgap = dimcen = 0.09; dimtxsty = "Standard"; dimscale = dimlfac = dimtfac = 1.0; - dimdli = 0.38; - dimrnd = dimdle = dimtp = dimtm = dimtsz = dimtvp = 0.0; - dimaltf = 25.4; - dimtol = dimlim = dimse1 = dimse2 = dimtad = dimzin = 0; - dimtoh = dimtolj = 1; - dimalt = dimtofl = dimsah = dimtix = dimsoxd = 0; - dimaltd = dimunit = dimaltu = dimalttd = dimlunit = 2; - dimclrd = dimclre = dimclrt = dimjust = dimupt = 0; - dimazin = dimaltz = dimaltttz = dimtzin = dimfrac = 0; - dimtih = dimadec = dimaunit = dimsd1 = dimsd2 = dimtmove = 0; - dimaltrnd = 0.0; - dimdec = dimtdec = 4; - dimfit = dimatfit = 3; - dimdsep = '.'; - dimlwd = dimlwe = -2; + dimdli = 0.38; + dimrnd = dimdle = dimtp = dimtm = dimtsz = dimtvp = 0.0; + dimaltf = 25.4; + dimtol = dimlim = dimse1 = dimse2 = dimtad = dimzin = 0; + dimtoh = dimtolj = 1; + dimalt = dimtofl = dimsah = dimtix = dimsoxd = 0; + dimaltd = dimunit = dimaltu = dimalttd = dimlunit = 2; + dimclrd = dimclre = dimclrt = dimjust = dimupt = 0; + dimazin = dimaltz = dimaltttz = dimtzin = dimfrac = 0; + dimtih = dimadec = dimaunit = dimsd1 = dimsd2 = dimtmove = 0; + dimaltrnd = 0.0; + dimdec = dimtdec = 4; + dimfit = dimatfit = 3; + dimdsep = '.'; + dimlwd = dimlwe = -2; + DRW_TableEntry::reset(); } void parseCode( int code, dxfReader* reader ); @@ -108,67 +135,67 @@ public: UTF8STRING dimblk; /*!< code 5, code 342 V2000+ */ UTF8STRING dimblk1; /*!< code 6, code 343 V2000+ */ UTF8STRING dimblk2; /*!< code 7, code 344 V2000+ */ - double dimscale; /*!< code 40 */ - double dimasz; /*!< code 41 */ - double dimexo; /*!< code 42 */ - double dimdli; /*!< code 43 */ - double dimexe; /*!< code 44 */ - double dimrnd; /*!< code 45 */ - double dimdle; /*!< code 46 */ - double dimtp; /*!< code 47 */ - double dimtm; /*!< code 48 */ - double dimtxt; /*!< code 140 */ - double dimcen; /*!< code 141 */ - double dimtsz; /*!< code 142 */ - double dimaltf; /*!< code 143 */ - double dimlfac; /*!< code 144 */ - double dimtvp; /*!< code 145 */ - double dimtfac; /*!< code 146 */ - double dimgap; /*!< code 147 */ - double dimaltrnd; /*!< code 148 V2000+ */ - int dimtol; /*!< code 71 */ - int dimlim; /*!< code 72 */ - int dimtih; /*!< code 73 */ - int dimtoh; /*!< code 74 */ - int dimse1; /*!< code 75 */ - int dimse2; /*!< code 76 */ - int dimtad; /*!< code 77 */ - int dimzin; /*!< code 78 */ - int dimazin; /*!< code 79 V2000+ */ - int dimalt; /*!< code 170 */ - int dimaltd; /*!< code 171 */ - int dimtofl; /*!< code 172 */ - int dimsah; /*!< code 173 */ - int dimtix; /*!< code 174 */ - int dimsoxd; /*!< code 175 */ - int dimclrd; /*!< code 176 */ - int dimclre; /*!< code 177 */ - int dimclrt; /*!< code 178 */ - int dimadec; /*!< code 179 V2000+ */ - int dimunit; /*!< code 270 R13+ (obsolete 2000+, use dimlunit & dimfrac) */ - int dimdec; /*!< code 271 R13+ */ - int dimtdec; /*!< code 272 R13+ */ - int dimaltu; /*!< code 273 R13+ */ - int dimalttd; /*!< code 274 R13+ */ - int dimaunit; /*!< code 275 R13+ */ - int dimfrac; /*!< code 276 V2000+ */ - int dimlunit; /*!< code 277 V2000+ */ - int dimdsep; /*!< code 278 V2000+ */ - int dimtmove; /*!< code 279 V2000+ */ - int dimjust; /*!< code 280 R13+ */ - int dimsd1; /*!< code 281 R13+ */ - int dimsd2; /*!< code 282 R13+ */ - int dimtolj; /*!< code 283 R13+ */ - int dimtzin; /*!< code 284 R13+ */ - int dimaltz; /*!< code 285 R13+ */ - int dimaltttz; /*!< code 286 R13+ */ - int dimfit; /*!< code 287 R13+ (obsolete 2000+, use dimatfit & dimtmove)*/ - int dimupt; /*!< code 288 R13+ */ - int dimatfit; /*!< code 289 V2000+ */ + double dimscale; /*!< code 40 */ + double dimasz; /*!< code 41 */ + double dimexo; /*!< code 42 */ + double dimdli; /*!< code 43 */ + double dimexe; /*!< code 44 */ + double dimrnd; /*!< code 45 */ + double dimdle; /*!< code 46 */ + double dimtp; /*!< code 47 */ + double dimtm; /*!< code 48 */ + double dimtxt; /*!< code 140 */ + double dimcen; /*!< code 141 */ + double dimtsz; /*!< code 142 */ + double dimaltf; /*!< code 143 */ + double dimlfac; /*!< code 144 */ + double dimtvp; /*!< code 145 */ + double dimtfac; /*!< code 146 */ + double dimgap; /*!< code 147 */ + double dimaltrnd; /*!< code 148 V2000+ */ + int dimtol; /*!< code 71 */ + int dimlim; /*!< code 72 */ + int dimtih; /*!< code 73 */ + int dimtoh; /*!< code 74 */ + int dimse1; /*!< code 75 */ + int dimse2; /*!< code 76 */ + int dimtad; /*!< code 77 */ + int dimzin; /*!< code 78 */ + int dimazin; /*!< code 79 V2000+ */ + int dimalt; /*!< code 170 */ + int dimaltd; /*!< code 171 */ + int dimtofl; /*!< code 172 */ + int dimsah; /*!< code 173 */ + int dimtix; /*!< code 174 */ + int dimsoxd; /*!< code 175 */ + int dimclrd; /*!< code 176 */ + int dimclre; /*!< code 177 */ + int dimclrt; /*!< code 178 */ + int dimadec; /*!< code 179 V2000+ */ + int dimunit; /*!< code 270 R13+ (obsolete 2000+, use dimlunit & dimfrac) */ + int dimdec; /*!< code 271 R13+ */ + int dimtdec; /*!< code 272 R13+ */ + int dimaltu; /*!< code 273 R13+ */ + int dimalttd; /*!< code 274 R13+ */ + int dimaunit; /*!< code 275 R13+ */ + int dimfrac; /*!< code 276 V2000+ */ + int dimlunit; /*!< code 277 V2000+ */ + int dimdsep; /*!< code 278 V2000+ */ + int dimtmove; /*!< code 279 V2000+ */ + int dimjust; /*!< code 280 R13+ */ + int dimsd1; /*!< code 281 R13+ */ + int dimsd2; /*!< code 282 R13+ */ + int dimtolj; /*!< code 283 R13+ */ + int dimtzin; /*!< code 284 R13+ */ + int dimaltz; /*!< code 285 R13+ */ + int dimaltttz; /*!< code 286 R13+ */ + int dimfit; /*!< code 287 R13+ (obsolete 2000+, use dimatfit & dimtmove)*/ + int dimupt; /*!< code 288 R13+ */ + int dimatfit; /*!< code 289 V2000+ */ UTF8STRING dimtxsty; /*!< code 340 R13+ */ UTF8STRING dimldrblk; /*!< code 341 V2000+ */ - int dimlwd; /*!< code 371 V2000+ */ - int dimlwe; /*!< code 372 V2000+ */ + int dimlwd; /*!< code 371 V2000+ */ + int dimlwe; /*!< code 372 V2000+ */ }; @@ -190,24 +217,22 @@ public: size = 0; length = 0.0; pathIdx = 0; -/* color = 256; // default BYLAYER (256) - * plotF = true; // default TRUE (plot yes) - * lWeight = -1; // default BYLAYER (-1)*/ -// align = 65; //always 65 + DRW_TableEntry::reset(); } void parseCode( int code, dxfReader* reader ); void update(); public: - UTF8STRING desc; /*!< descriptive string, code 3 */ + UTF8STRING desc; /*!< descriptive string, code 3 */ // int align; /*!< align code, always 65 ('A') code 72 */ - int size; /*!< element number, code 73 */ - double length; /*!< total length of pattern, code 40 */ + int size; /*!< element number, code 73 */ + double length; /*!< total length of pattern, code 40 */ // int haveShape; /*!< complex linetype type, code 74 */ std::vector path; /*!< trace, point or space length sequence, code 49 */ + private: - int pathIdx; + int pathIdx; }; @@ -223,21 +248,22 @@ public: void reset() { - tType = DRW::LAYER; - lineType = "CONTINUOUS"; - color = 7; // default BYLAYER (256) - plotF = true; // default TRUE (plot yes) - lWeight = DRW_LW_Conv::widthDefault; // default BYDEFAULT (dxf -3, dwg 31) - color24 = -1; // default -1 not set + tType = DRW::LAYER; + lineType = "CONTINUOUS"; + color = 7; // default BYLAYER (256) + plotF = true; // default TRUE (plot yes) + lWeight = DRW_LW_Conv::widthDefault; // default BYDEFAULT (dxf -3, dwg 31) + color24 = -1; // default -1 not set + DRW_TableEntry::reset(); } void parseCode( int code, dxfReader* reader ); public: - UTF8STRING lineType; /*!< line type, code 6 */ - int color; /*!< layer color, code 62 */ - int color24; /*!< 24-bit color, code 420 */ - bool plotF; /*!< Plot flag, code 290 */ + UTF8STRING lineType; /*!< line type, code 6 */ + int color; /*!< layer color, code 62 */ + int color24; /*!< 24-bit color, code 420 */ + bool plotF; /*!< Plot flag, code 290 */ enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */ std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */ std::string handlePlotM; /*!< Hard-pointer ID/handle of materialstyle, code 347 */ @@ -255,25 +281,26 @@ public: void reset() { - tType = DRW::STYLE; - height = oblique = 0.0; - width = lastHeight = 1.0; - font = "txt"; - genFlag = 0; // 2= X mirror, 4= Y mirror - fontFamily = 0; + tType = DRW::STYLE; + height = oblique = 0.0; + width = lastHeight = 1.0; + font = "txt"; + genFlag = 0; // 2= X mirror, 4= Y mirror + fontFamily = 0; + DRW_TableEntry::reset(); } void parseCode( int code, dxfReader* reader ); public: - double height; /*!< Fixed text height (0 not set), code 40 */ - double width; /*!< Width factor, code 41 */ - double oblique; /*!< Oblique angle, code 50 */ - int genFlag; /*!< Text generation flags, code 71 */ - double lastHeight; /*!< Last height used, code 42 */ + double height; /*!< Fixed text height (0 not set), code 40 */ + double width; /*!< Width factor, code 41 */ + double oblique; /*!< Oblique angle, code 50 */ + int genFlag; /*!< Text generation flags, code 71 */ + double lastHeight; /*!< Last height used, code 42 */ UTF8STRING font; /*!< primary font file name, code 3 */ UTF8STRING bigFont; /*!< bigfont file name or blank if none, code 4 */ - int fontFamily; /*!< ttf font family, italic and bold flags, code 1071 */ + int fontFamily; /*!< ttf font family, italic and bold flags, code 1071 */ }; // ! Class to handle vport entries @@ -290,19 +317,20 @@ public: { UpperRight.x = UpperRight.y = 1.0; snapSpacing.x = snapSpacing.y = 10.0; - gridSpacing = snapSpacing; - center.x = 0.651828; - center.y = -0.16; - viewDir.z = 1; - height = 5.13732; - ratio = 2.4426877; - lensHeight = 50; - frontClip = backClip = snapAngle = twistAngle = 0.0; - viewMode = snap = grid = snapStyle = snapIsopair = 0; - fastZoom = 1; - circleZoom = 100; - ucsIcon = 3; - gridBehavior = 7; + gridSpacing = snapSpacing; + center.x = 0.651828; + center.y = -0.16; + viewDir.z = 1; + height = 5.13732; + ratio = 2.4426877; + lensHeight = 50; + frontClip = backClip = snapAngle = twistAngle = 0.0; + viewMode = snap = grid = snapStyle = snapIsopair = 0; + fastZoom = 1; + circleZoom = 100; + ucsIcon = 3; + gridBehavior = 7; + DRW_TableEntry::reset(); } void parseCode( int code, dxfReader* reader ); @@ -316,22 +344,22 @@ public: DRW_Coord gridSpacing; /*!< grid Spacing, code 15 & 25 */ DRW_Coord viewDir; /*!< view direction from target point, code 16, 26 & 36 */ DRW_Coord viewTarget; /*!< view target point, code 17, 27 & 37 */ - double height; /*!< view height, code 40 */ - double ratio; /*!< viewport aspect ratio, code 41 */ - double lensHeight; /*!< lens height, code 42 */ - double frontClip; /*!< front clipping plane, code 43 */ - double backClip; /*!< back clipping plane, code 44 */ - double snapAngle; /*!< snap rotation angle, code 50 */ - double twistAngle; /*!< view twist angle, code 51 */ - int viewMode; /*!< view mode, code 71 */ - int circleZoom; /*!< circle zoom percent, code 72 */ - int fastZoom; /*!< fast zoom setting, code 73 */ - int ucsIcon; /*!< UCSICON setting, code 74 */ - int snap; /*!< snap on/off, code 75 */ - int grid; /*!< grid on/off, code 76 */ - int snapStyle; /*!< snap style, code 77 */ - int snapIsopair; /*!< snap isopair, code 78 */ - int gridBehavior; /*!< grid behavior, code 60, undocummented */ + double height; /*!< view height, code 40 */ + double ratio; /*!< viewport aspect ratio, code 41 */ + double lensHeight; /*!< lens height, code 42 */ + double frontClip; /*!< front clipping plane, code 43 */ + double backClip; /*!< back clipping plane, code 44 */ + double snapAngle; /*!< snap rotation angle, code 50 */ + double twistAngle; /*!< view twist angle, code 51 */ + int viewMode; /*!< view mode, code 71 */ + int circleZoom; /*!< circle zoom percent, code 72 */ + int fastZoom; /*!< fast zoom setting, code 73 */ + int ucsIcon; /*!< UCSICON setting, code 74 */ + int snap; /*!< snap on/off, code 75 */ + int grid; /*!< grid on/off, code 76 */ + int snapStyle; /*!< snap style, code 77 */ + int snapIsopair; /*!< snap isopair, code 78 */ + int gridBehavior; /*!< grid behavior, code 60, undocummented */ /** code 60, bit coded possible value are * bit 1 (1) show out of limits * bit 2 (2) adaptive grid @@ -352,6 +380,9 @@ public: DRW_ImageDef() { version = 0; + u = v = up = vp = 0.0; + loaded = 0; + resolution = 0; } void parseCode( int code, dxfReader* reader ); @@ -359,13 +390,13 @@ public: public: std::string handle; /*!< entity identifier, code 5 */ UTF8STRING name; /*!< File name of image, code 1 */ - int version; /*!< class version, code 90, 0=R14 version */ - double u; /*!< image size in pixels U value, code 10 */ - double v; /*!< image size in pixels V value, code 20 */ - double up; /*!< default size of one pixel U value, code 11 */ - double vp; /*!< default size of one pixel V value, code 12 really is 21*/ - int loaded; /*!< image is loaded flag, code 280, 0=unloaded, 1=loaded */ - int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */ + int version; /*!< class version, code 90, 0=R14 version */ + double u; /*!< image size in pixels U value, code 10 */ + double v; /*!< image size in pixels V value, code 20 */ + double up; /*!< default size of one pixel U value, code 11 */ + double vp; /*!< default size of one pixel V value, code 12 really is 21*/ + int loaded; /*!< image is loaded flag, code 280, 0=unloaded, 1=loaded */ + int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */ std::map reactors; }; @@ -373,7 +404,9 @@ public: // ! Class to handle header entries /*! - * Class to handle layer symbol table entries + * Class to handle header vars, to read iterate over "std::map vars" + * to write add a DRW_Variant* into "std::map vars" (do not delete it, are cleared in dtor) + * or use add* helper functions. * @author Rallaz */ class DRW_Header @@ -381,18 +414,29 @@ class DRW_Header public: DRW_Header() { + version = 0; + curr = 0; } ~DRW_Header() { + for( std::map::iterator it = vars.begin(); it!=vars.end(); ++it ) + delete it->second; + vars.clear(); } + void addDouble( std::string key, double value, int code ); + void addInt( std::string key, int value, int code ); + void addStr( std::string key, std::string value, int code ); + void addCoord( std::string key, DRW_Coord value, int code ); + + std::string getComments() const { return comments; } + void parseCode( int code, dxfReader* reader ); void write( dxfWriter* writer, DRW::Version ver ); void addComment( std::string c ); - std::string getComments() const { return comments; } private: bool getDouble( std::string key, double* varDouble ); bool getInt( std::string key, int* varInt ); @@ -401,11 +445,32 @@ private: public: std::map vars; + private: - std::string comments; - std::string name; - DRW_Variant* curr; - int version; // to use on read + std::string comments; + std::string name; + DRW_Variant* curr; + int version; // to use on read +}; + +// ! Class to handle AppId entries +/*! + * Class to handle AppId symbol table entries + * @author Rallaz + */ +class DRW_AppId : public DRW_TableEntry +{ +public: + DRW_AppId() { reset(); } + + void reset() + { + tType = DRW::APPID; + flags = 0; + name = ""; + } + + void parseCode( int code, dxfReader* reader ) { DRW_TableEntry::parseCode( code, reader ); } }; namespace DRW { diff --git a/lib_dxf/intern/drw_textcodec.cpp b/lib_dxf/intern/drw_textcodec.cpp index 70bdced9dd..b640bc95a8 100644 --- a/lib_dxf/intern/drw_textcodec.cpp +++ b/lib_dxf/intern/drw_textcodec.cpp @@ -12,7 +12,7 @@ DRW_TextCodec::DRW_TextCodec() { version = DRW::AC1021; - conv = new DRW_Converter( NULL, 0 ); + conv = new DRW_Converter( NULL, 0 ); } @@ -62,16 +62,16 @@ void DRW_TextCodec::setCodePage( std::string* c ) conv = new DRW_ConvTable( DRW_Table874, CPLENGHTCOMMON ); else if( cp == "ANSI_932" ) conv = new DRW_Conv932Table( DRW_Table932, DRW_LeadTable932, - DRW_DoubleTable932, CPLENGHT932 ); + DRW_DoubleTable932, CPLENGHT932 ); else if( cp == "ANSI_936" ) conv = new DRW_ConvDBCSTable( DRW_Table936, DRW_LeadTable936, - DRW_DoubleTable936, CPLENGHT936 ); + DRW_DoubleTable936, CPLENGHT936 ); else if( cp == "ANSI_949" ) conv = new DRW_ConvDBCSTable( DRW_Table949, DRW_LeadTable949, - DRW_DoubleTable949, CPLENGHT949 ); + DRW_DoubleTable949, CPLENGHT949 ); else if( cp == "ANSI_950" ) conv = new DRW_ConvDBCSTable( DRW_Table950, DRW_LeadTable950, - DRW_DoubleTable950, CPLENGHT950 ); + DRW_DoubleTable950, CPLENGHT950 ); else if( cp == "ANSI_1250" ) conv = new DRW_ConvTable( DRW_Table1250, CPLENGHTCOMMON ); else if( cp == "ANSI_1251" ) @@ -117,9 +117,9 @@ std::string DRW_TextCodec::fromUtf8( std::string s ) std::string DRW_Converter::toUtf8( std::string* s ) { - std::string result; - int j = 0; - unsigned int i = 0; + std::string result; + int j = 0; + unsigned int i = 0; for( i = 0; i < s->length(); i++ ) { @@ -127,8 +127,7 @@ std::string DRW_Converter::toUtf8( std::string* s ) if( c < 0x80 ) // ascii check for /U+???? { - if( c == '\\' && i + 6 < s->length() && s->at( i + 1 ) == 'U' && s->at( i + 2 ) == - '+' ) + if( c == '\\' && i + 6 < s->length() && s->at( i + 1 ) == 'U' && s->at( i + 2 ) == '+' ) { result += s->substr( j, i - j ); result += encodeText( s->substr( i, 7 ) ); @@ -159,10 +158,10 @@ std::string DRW_Converter::toUtf8( std::string* s ) std::string DRW_ConvTable::fromUtf8( std::string* s ) { std::string result; - bool notFound; - int code; + bool notFound; + int code; - int j = 0; + int j = 0; for( unsigned int i = 0; i < s->length(); i++ ) { @@ -172,17 +171,17 @@ std::string DRW_ConvTable::fromUtf8( std::string* s ) { result += s->substr( j, i - j ); std::string part1 = s->substr( i, 4 ); - int l; + int l; code = decodeNum( part1, &l ); - j = i + l; - i = j - 1; + j = i + l; + i = j - 1; notFound = true; for( int k = 0; kbegin(); it < s->end(); it++ ) + for( it = s->begin(); it < s->end(); ++it ) { unsigned char c = *it; @@ -313,21 +312,21 @@ std::string DRW_Converter::encodeNum( int c ) **/ int DRW_Converter::decodeNum( std::string s, int* b ) { - int code = 0; - unsigned char c = s.at( 0 ); + int code = 0; + unsigned char c = s.at( 0 ); if( (c & 0xE0) == 0xC0 ) // 2 bytes { code = ( c & 0x1F) << 6; code = (s.at( 1 ) & 0x3F) | code; - *b = 2; + *b = 2; } else if( (c & 0xF0) == 0xE0 ) // 3 bytes { code = ( c & 0x0F) << 12; code = ( (s.at( 1 ) & 0x3F) << 6 ) | code; code = (s.at( 2 ) & 0x3F) | code; - *b = 3; + *b = 3; } else if( (c & 0xF8) == 0xF0 ) // 4 bytes { @@ -335,7 +334,7 @@ int DRW_Converter::decodeNum( std::string s, int* b ) code = ( (s.at( 1 ) & 0x3F) << 12 ) | code; code = ( (s.at( 2 ) & 0x3F) << 6 ) | code; code = (s.at( 3 ) & 0x3F) | code; - *b = 4; + *b = 4; } return code; @@ -345,10 +344,10 @@ int DRW_Converter::decodeNum( std::string s, int* b ) std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) { std::string result; - bool notFound; - int code; + bool notFound; + int code; - int j = 0; + int j = 0; for( unsigned int i = 0; i < s->length(); i++ ) { @@ -358,21 +357,21 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) { result += s->substr( j, i - j ); std::string part1 = s->substr( i, 4 ); - int l; + int l; code = decodeNum( part1, &l ); - j = i + l; - i = j - 1; + j = i + l; + i = j - 1; notFound = true; for( int k = 0; k> 8; - d[1] = data & 0xFF; - d[2] = '\0'; + int data = doubleTable[k][0]; + char d[3]; + d[0] = data >> 8; + d[1] = data & 0xFF; + d[2] = '\0'; result += d; // translate from table notFound = false; break; @@ -392,13 +391,13 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) std::string DRW_ConvDBCSTable::toUtf8( std::string* s ) { - std::string res; - std::string::iterator it; + std::string res; + std::string::iterator it; - for( it = s->begin(); it < s->end(); it++ ) + for( it = s->begin(); it < s->end(); ++it ) { - bool notFound = true; - unsigned char c = *it; + bool notFound = true; + unsigned char c = *it; if( c < 0x80 ) { @@ -455,10 +454,10 @@ std::string DRW_ConvDBCSTable::toUtf8( std::string* s ) std::string DRW_Conv932Table::fromUtf8( std::string* s ) { std::string result; - bool notFound; - int code; + bool notFound; + int code; - int j = 0; + int j = 0; for( unsigned int i = 0; i < s->length(); i++ ) { @@ -468,16 +467,16 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) { result += s->substr( j, i - j ); std::string part1 = s->substr( i, 4 ); - int l; + int l; code = decodeNum( part1, &l ); - j = i + l; - i = j - 1; + j = i + l; + i = j - 1; notFound = true; // 1 byte table if( code > 0xff60 && code < 0xFFA0 ) { - result += code - CPOFFSET932; // translate from table + result += code - CPOFFSET932; // translate from table notFound = false; } @@ -488,12 +487,12 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) { if( doubleTable[k][1] == code ) { - int data = doubleTable[k][0]; - char d[3]; - d[0] = data >> 8; - d[1] = data & 0xFF; - d[2] = '\0'; - result += d; // translate from table + int data = doubleTable[k][0]; + char d[3]; + d[0] = data >> 8; + d[1] = data & 0xFF; + d[2] = '\0'; + result += d; // translate from table notFound = false; break; } @@ -513,13 +512,13 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) std::string DRW_Conv932Table::toUtf8( std::string* s ) { - std::string res; - std::string::iterator it; + std::string res; + std::string::iterator it; - for( it = s->begin(); it < s->end(); it++ ) + for( it = s->begin(); it < s->end(); ++it ) { - bool notFound = true; - unsigned char c = *it; + bool notFound = true; + unsigned char c = *it; if( c < 0x80 ) { @@ -661,7 +660,7 @@ std::string DRW_TextCodec::correctCodePage( const std::string& s ) } else if( cp=="ANSI_936" || cp=="GBK" || cp=="GB2312" || cp=="CHINESE" || cp=="CN-GB" || cp=="CSGB2312" || cp=="CSGB231280" || cp=="CSISO58BG231280" - || cp=="GB_2312-80" || cp=="GB231280" || cp=="GB2312-80" || cp=="GBK" + || cp=="GB_2312-80" || cp=="GB231280" || cp=="GB2312-80" || cp=="ISO-IR-58" || cp=="GB18030" ) { return "ANSI_936"; diff --git a/lib_dxf/intern/drw_textcodec.h b/lib_dxf/intern/drw_textcodec.h index f7e26201b9..1a8c56a410 100644 --- a/lib_dxf/intern/drw_textcodec.h +++ b/lib_dxf/intern/drw_textcodec.h @@ -14,20 +14,21 @@ public: std::string toUtf8( std::string s ); int getVersion() { return version; } - void setVersion( std::string* v ); + void setVersion( std::string* v ); void setVersion( int v ) { version = v; } - void setCodePage( std::string* c ); + void setCodePage( std::string* c ); void setCodePage( std::string c ) { setCodePage( &c ); } std::string getCodePage() { return cp; } + private: std::string correctCodePage( const std::string& s ); private: - int version; - std::string cp; - DRW_Converter* conv; + int version; + std::string cp; + DRW_Converter* conv; }; class DRW_Converter @@ -47,8 +48,8 @@ public: std::string encodeNum( int c ); int decodeNum( std::string s, int* b ); - const int* table; - int cpLenght; + const int* table; + int cpLenght; }; class DRW_ConvTable : public DRW_Converter @@ -63,9 +64,9 @@ class DRW_ConvDBCSTable : public DRW_Converter { public: DRW_ConvDBCSTable( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t, - l ) + l ) { - leadTable = lt; + leadTable = lt; doubleTable = dt; } @@ -81,9 +82,9 @@ class DRW_Conv932Table : public DRW_Converter { public: DRW_Conv932Table( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t, - l ) + l ) { - leadTable = lt; + leadTable = lt; doubleTable = dt; } diff --git a/lib_dxf/intern/dxfreader.cpp b/lib_dxf/intern/dxfreader.cpp index 38629bb486..5ca2df083b 100644 --- a/lib_dxf/intern/dxfreader.cpp +++ b/lib_dxf/intern/dxfreader.cpp @@ -127,7 +127,7 @@ int dxfReader::getHandleString() bool dxfReaderBinary::readCode( int* code ) { unsigned short* int16p; - char buffer[2]; + char buffer[2]; filestr->read( buffer, 2 ); int16p = (unsigned short*) buffer; @@ -179,8 +179,8 @@ bool dxfReaderBinary::readInt() bool dxfReaderBinary::readInt32() { - unsigned int* int32p; - char buffer[4]; + unsigned int* int32p; + char buffer[4]; filestr->read( buffer, 4 ); int32p = (unsigned int*) buffer; @@ -206,11 +206,11 @@ bool dxfReaderBinary::readInt64() bool dxfReaderBinary::readDouble() { double* result; - char buffer[8]; + char buffer[8]; filestr->read( buffer, 8 ); - result = (double*) buffer; - doubleData = *result; + result = (double*) buffer; + doubleData = *result; DBG( doubleData ); DBG( "\n" ); return filestr->good(); } diff --git a/lib_dxf/intern/dxfreader.h b/lib_dxf/intern/dxfreader.h index a401c33575..845244955c 100644 --- a/lib_dxf/intern/dxfreader.h +++ b/lib_dxf/intern/dxfreader.h @@ -21,6 +21,9 @@ public: dxfReader( std::ifstream* stream ) { filestr = stream; + doubleData = 0.0; + intData = 0; + int64 = 0; #ifdef DRW_DBG count = 0; #endif @@ -31,14 +34,14 @@ public: virtual bool readString( std::string* text ) = 0; virtual bool readString() = 0; bool readRec( int* code, bool skip ); - virtual bool readInt() = 0; + virtual bool readInt() = 0; virtual bool readInt32() = 0; virtual bool readInt64() = 0; virtual bool readDouble() = 0; - virtual bool readBool() = 0; + virtual bool readBool() = 0; std::string getString() { return strData; } - int getHandleString(); // Convert hex string to int + int getHandleString(); // Convert hex string to int std::string toUtf8String( std::string t ) { return decoder.toUtf8( t ); } std::string getUtf8String() { return decoder.toUtf8( strData ); } @@ -51,22 +54,24 @@ public: void setCodePage( std::string* c ) { decoder.setCodePage( c ); } std::string getCodePage() { return decoder.getCodePage(); } #ifdef DRW_DBG - int count; // DBG + int count; // DBG #endif + protected: - std::ifstream* filestr; - std::string strData; - double doubleData; - signed int intData; // 32 bits integer - unsigned long long int int64; // 64 bits integer + std::ifstream* filestr; + std::string strData; + double doubleData; + signed int intData; // 32 bits integer + unsigned long long int int64; // 64 bits integer + private: - DRW_TextCodec decoder; + DRW_TextCodec decoder; }; class dxfReaderBinary : public dxfReader { public: - dxfReaderBinary( std::ifstream* stream ) : dxfReader( stream ) { } + dxfReaderBinary( std::ifstream* stream ) : dxfReader( stream ) {} virtual ~dxfReaderBinary() {} virtual bool readCode( int* code ); virtual bool readString( std::string* text ); @@ -81,7 +86,7 @@ public: class dxfReaderAscii : public dxfReader { public: - dxfReaderAscii( std::ifstream* stream ) : dxfReader( stream ) { } + dxfReaderAscii( std::ifstream* stream ) : dxfReader( stream ) {} virtual ~dxfReaderAscii() {} virtual bool readCode( int* code ); virtual bool readString( std::string* text ); diff --git a/lib_dxf/intern/dxfwriter.h b/lib_dxf/intern/dxfwriter.h index f0da434121..cd9f0bbf3d 100644 --- a/lib_dxf/intern/dxfwriter.h +++ b/lib_dxf/intern/dxfwriter.h @@ -28,22 +28,24 @@ public: virtual bool writeInt16( int code, int data ) = 0; virtual bool writeInt32( int code, int data ) = 0; virtual bool writeInt64( int code, unsigned long long int data ) = 0; - virtual bool writeDouble( int code, double data ) = 0; - virtual bool writeBool( int code, bool data ) = 0; + virtual bool writeDouble( int code, double data ) = 0; + virtual bool writeBool( int code, bool data ) = 0; void setVersion( std::string* v ) { encoder.setVersion( v ); } void setCodePage( std::string* c ) { encoder.setCodePage( c ); } std::string getCodePage() { return encoder.getCodePage(); } + protected: - std::ofstream* filestr; + std::ofstream* filestr; + private: - DRW_TextCodec encoder; + DRW_TextCodec encoder; }; class dxfWriterBinary : public dxfWriter { public: - dxfWriterBinary( std::ofstream* stream ) : dxfWriter( stream ) { } + dxfWriterBinary( std::ofstream* stream ) : dxfWriter( stream ) {} virtual ~dxfWriterBinary() {} virtual bool writeString( int code, std::string text ); virtual bool writeInt16( int code, int data ); @@ -56,7 +58,7 @@ public: class dxfWriterAscii : public dxfWriter { public: - dxfWriterAscii( std::ofstream* stream ) : dxfWriter( stream ) { } + dxfWriterAscii( std::ofstream* stream ) : dxfWriter( stream ) {} virtual ~dxfWriterAscii() {} virtual bool writeString( int code, std::string text ); virtual bool writeInt16( int code, int data ); diff --git a/lib_dxf/libdxfrw.cpp b/lib_dxf/libdxfrw.cpp index ce4c7a532a..1c2a1d64cf 100644 --- a/lib_dxf/libdxfrw.cpp +++ b/lib_dxf/libdxfrw.cpp @@ -40,11 +40,19 @@ dxfRW::dxfRW( const char* name ) { - fileName = name; - reader = NULL; - writer = NULL; + fileName = name; + reader = NULL; + writer = NULL; applyExt = false; elParts = 128; // parts munber when convert ellipse to polyline + + binary = false; + iface = NULL; + entCount = 0; + wlayer0 = false; + dimstyleStd = false; + writingBlock = false; + currHandle = 0; } @@ -52,15 +60,23 @@ dxfRW::~dxfRW() { if( reader != NULL ) delete reader; + + if( writer != NULL ) + delete writer; + + for( std::vector::iterator it = imageDef.begin(); it!=imageDef.end(); ++it ) + delete *it; + + imageDef.clear(); } bool dxfRW::read( DRW_Interface* interface_, bool ext ) { assert( fileName.empty() == false ); - bool isOk = false; + bool isOk = false; applyExt = ext; - std::ifstream filestr; + std::ifstream filestr; if( interface_ == NULL ) return isOk; @@ -109,12 +125,12 @@ bool dxfRW::read( DRW_Interface* interface_, bool ext ) bool dxfRW::write( DRW_Interface* interface_, DRW::Version ver, bool bin ) { - bool isOk = false; - std::ofstream filestr; + bool isOk = false; + std::ofstream filestr; version = ver; binary = bin; - iface = interface_; + iface = interface_; if( binary ) { @@ -322,6 +338,11 @@ bool dxfRW::writeLayer( DRW_Layer* ent ) else writer->writeUtf8Caps( 6, ent->lineType ); + if( !ent->extData.empty() ) + { + writeExtData( ent->extData ); + } + // writer->writeString(347, "10012"); return true; } @@ -391,7 +412,7 @@ bool dxfRW::writeVport( DRW_Vport* ent ) { if( !dimstyleStd ) { - ent->name = "*ACTIVE"; + ent->name = "*ACTIVE"; dimstyleStd = true; } @@ -638,6 +659,33 @@ bool dxfRW::writeDimstyle( DRW_Dimstyle* ent ) } +bool dxfRW::writeAppId( DRW_AppId* ent ) +{ + writer->writeString( 0, "APPID" ); + + if( version > DRW::AC1009 ) + { + writer->writeString( 5, toHexStr( ++entCount ) ); + + if( version > DRW::AC1014 ) + { + writer->writeString( 330, "9" ); + } + + writer->writeString( 100, "AcDbSymbolTableRecord" ); + writer->writeString( 100, "AcDbRegAppTableRecord" ); + writer->writeUtf8String( 2, ent->name ); + } + else + { + writer->writeUtf8Caps( 2, ent->name ); + } + + writer->writeInt16( 70, ent->flags ); + return true; +} + + bool dxfRW::writePoint( DRW_Point* ent ) { writer->writeString( 0, "POINT" ); @@ -1202,44 +1250,44 @@ bool dxfRW::writeHatch( DRW_Hatch* ent ) switch( ( loop->objlist.at( j ) )->eType ) { case DRW::LINE: - { - writer->writeInt16( 72, 1 ); - DRW_Line* l = (DRW_Line*) loop->objlist.at( j ); - writer->writeDouble( 10, l->basePoint.x ); - writer->writeDouble( 20, l->basePoint.y ); - writer->writeDouble( 11, l->secPoint.x ); - writer->writeDouble( 21, l->secPoint.y ); - break; - } + { + writer->writeInt16( 72, 1 ); + DRW_Line* l = (DRW_Line*) loop->objlist.at( j ); + writer->writeDouble( 10, l->basePoint.x ); + writer->writeDouble( 20, l->basePoint.y ); + writer->writeDouble( 11, l->secPoint.x ); + writer->writeDouble( 21, l->secPoint.y ); + break; + } case DRW::ARC: - { - writer->writeInt16( 72, 2 ); - DRW_Arc* a = (DRW_Arc*) loop->objlist.at( j ); - writer->writeDouble( 10, a->basePoint.x ); - writer->writeDouble( 20, a->basePoint.y ); - writer->writeDouble( 40, a->radious ); - writer->writeDouble( 50, a->staangle * ARAD ); - writer->writeDouble( 51, a->endangle * ARAD ); - writer->writeInt16( 73, a->isccw ); - break; - } + { + writer->writeInt16( 72, 2 ); + DRW_Arc* a = (DRW_Arc*) loop->objlist.at( j ); + writer->writeDouble( 10, a->basePoint.x ); + writer->writeDouble( 20, a->basePoint.y ); + writer->writeDouble( 40, a->radious ); + writer->writeDouble( 50, a->staangle * ARAD ); + writer->writeDouble( 51, a->endangle * ARAD ); + writer->writeInt16( 73, a->isccw ); + break; + } case DRW::ELLIPSE: - { - writer->writeInt16( 72, 3 ); - DRW_Ellipse* a = (DRW_Ellipse*) loop->objlist.at( j ); - a->correctAxis(); - writer->writeDouble( 10, a->basePoint.x ); - writer->writeDouble( 20, a->basePoint.y ); - writer->writeDouble( 11, a->secPoint.x ); - writer->writeDouble( 21, a->secPoint.y ); - writer->writeDouble( 40, a->ratio ); - writer->writeDouble( 50, a->staparam * ARAD ); - writer->writeDouble( 51, a->endparam * ARAD ); - writer->writeInt16( 73, a->isccw ); - break; - } + { + writer->writeInt16( 72, 3 ); + DRW_Ellipse* a = (DRW_Ellipse*) loop->objlist.at( j ); + a->correctAxis(); + writer->writeDouble( 10, a->basePoint.x ); + writer->writeDouble( 20, a->basePoint.y ); + writer->writeDouble( 11, a->secPoint.x ); + writer->writeDouble( 21, a->secPoint.y ); + writer->writeDouble( 40, a->ratio ); + writer->writeDouble( 50, a->staparam * ARAD ); + writer->writeDouble( 51, a->endparam * ARAD ); + writer->writeInt16( 73, a->isccw ); + break; + } case DRW::SPLINE: // RLZ: spline boundary writeme @@ -1364,109 +1412,109 @@ bool dxfRW::writeDimension( DRW_Dimension* ent ) { case DRW::DIMALIGNED: case DRW::DIMLINEAR: + { + DRW_DimAligned* dd = (DRW_DimAligned*) ent; + writer->writeString( 100, "AcDbAlignedDimension" ); + DRW_Coord crd = dd->getClonepoint(); + + if( crd.x != 0 || crd.y != 0 || crd.z != 0 ) { - DRW_DimAligned* dd = (DRW_DimAligned*) ent; - writer->writeString( 100, "AcDbAlignedDimension" ); - DRW_Coord crd = dd->getClonepoint(); - - if( crd.x != 0 || crd.y != 0 || crd.z != 0 ) - { - writer->writeDouble( 12, crd.x ); - writer->writeDouble( 22, crd.y ); - writer->writeDouble( 32, crd.z ); - } - - writer->writeDouble( 13, dd->getDef1Point().x ); - writer->writeDouble( 23, dd->getDef1Point().y ); - writer->writeDouble( 33, dd->getDef1Point().z ); - writer->writeDouble( 14, dd->getDef2Point().x ); - writer->writeDouble( 24, dd->getDef2Point().y ); - writer->writeDouble( 34, dd->getDef2Point().z ); - - if( ent->eType == DRW::DIMLINEAR ) - { - DRW_DimLinear* dl = (DRW_DimLinear*) ent; - - if( dl->getAngle() != 0 ) - writer->writeDouble( 50, dl->getAngle() ); - - if( dl->getOblique() != 0 ) - writer->writeDouble( 52, dl->getOblique() ); - - writer->writeString( 100, "AcDbRotatedDimension" ); - } - - break; + writer->writeDouble( 12, crd.x ); + writer->writeDouble( 22, crd.y ); + writer->writeDouble( 32, crd.z ); } + writer->writeDouble( 13, dd->getDef1Point().x ); + writer->writeDouble( 23, dd->getDef1Point().y ); + writer->writeDouble( 33, dd->getDef1Point().z ); + writer->writeDouble( 14, dd->getDef2Point().x ); + writer->writeDouble( 24, dd->getDef2Point().y ); + writer->writeDouble( 34, dd->getDef2Point().z ); + + if( ent->eType == DRW::DIMLINEAR ) + { + DRW_DimLinear* dl = (DRW_DimLinear*) ent; + + if( dl->getAngle() != 0 ) + writer->writeDouble( 50, dl->getAngle() ); + + if( dl->getOblique() != 0 ) + writer->writeDouble( 52, dl->getOblique() ); + + writer->writeString( 100, "AcDbRotatedDimension" ); + } + + break; + } + case DRW::DIMRADIAL: - { - DRW_DimRadial* dd = (DRW_DimRadial*) ent; - writer->writeString( 100, "AcDbRadialDimension" ); - writer->writeDouble( 15, dd->getDiameterPoint().x ); - writer->writeDouble( 25, dd->getDiameterPoint().y ); - writer->writeDouble( 35, dd->getDiameterPoint().z ); - writer->writeDouble( 40, dd->getLeaderLength() ); - break; - } + { + DRW_DimRadial* dd = (DRW_DimRadial*) ent; + writer->writeString( 100, "AcDbRadialDimension" ); + writer->writeDouble( 15, dd->getDiameterPoint().x ); + writer->writeDouble( 25, dd->getDiameterPoint().y ); + writer->writeDouble( 35, dd->getDiameterPoint().z ); + writer->writeDouble( 40, dd->getLeaderLength() ); + break; + } case DRW::DIMDIAMETRIC: - { - DRW_DimDiametric* dd = (DRW_DimDiametric*) ent; - writer->writeString( 100, "AcDbDiametricDimension" ); - writer->writeDouble( 15, dd->getDiameter1Point().x ); - writer->writeDouble( 25, dd->getDiameter1Point().y ); - writer->writeDouble( 35, dd->getDiameter1Point().z ); - writer->writeDouble( 40, dd->getLeaderLength() ); - break; - } + { + DRW_DimDiametric* dd = (DRW_DimDiametric*) ent; + writer->writeString( 100, "AcDbDiametricDimension" ); + writer->writeDouble( 15, dd->getDiameter1Point().x ); + writer->writeDouble( 25, dd->getDiameter1Point().y ); + writer->writeDouble( 35, dd->getDiameter1Point().z ); + writer->writeDouble( 40, dd->getLeaderLength() ); + break; + } case DRW::DIMANGULAR: - { - DRW_DimAngular* dd = (DRW_DimAngular*) ent; - writer->writeString( 100, "AcDb2LineAngularDimension" ); - writer->writeDouble( 13, dd->getFirstLine1().x ); - writer->writeDouble( 23, dd->getFirstLine1().y ); - writer->writeDouble( 33, dd->getFirstLine1().z ); - writer->writeDouble( 14, dd->getFirstLine2().x ); - writer->writeDouble( 24, dd->getFirstLine2().y ); - writer->writeDouble( 34, dd->getFirstLine2().z ); - writer->writeDouble( 15, dd->getSecondLine1().x ); - writer->writeDouble( 25, dd->getSecondLine1().y ); - writer->writeDouble( 35, dd->getSecondLine1().z ); - writer->writeDouble( 16, dd->getDimPoint().x ); - writer->writeDouble( 26, dd->getDimPoint().y ); - writer->writeDouble( 36, dd->getDimPoint().z ); - break; - } + { + DRW_DimAngular* dd = (DRW_DimAngular*) ent; + writer->writeString( 100, "AcDb2LineAngularDimension" ); + writer->writeDouble( 13, dd->getFirstLine1().x ); + writer->writeDouble( 23, dd->getFirstLine1().y ); + writer->writeDouble( 33, dd->getFirstLine1().z ); + writer->writeDouble( 14, dd->getFirstLine2().x ); + writer->writeDouble( 24, dd->getFirstLine2().y ); + writer->writeDouble( 34, dd->getFirstLine2().z ); + writer->writeDouble( 15, dd->getSecondLine1().x ); + writer->writeDouble( 25, dd->getSecondLine1().y ); + writer->writeDouble( 35, dd->getSecondLine1().z ); + writer->writeDouble( 16, dd->getDimPoint().x ); + writer->writeDouble( 26, dd->getDimPoint().y ); + writer->writeDouble( 36, dd->getDimPoint().z ); + break; + } case DRW::DIMANGULAR3P: - { - DRW_DimAngular3p* dd = (DRW_DimAngular3p*) ent; - writer->writeDouble( 13, dd->getFirstLine().x ); - writer->writeDouble( 23, dd->getFirstLine().y ); - writer->writeDouble( 33, dd->getFirstLine().z ); - writer->writeDouble( 14, dd->getSecondLine().x ); - writer->writeDouble( 24, dd->getSecondLine().y ); - writer->writeDouble( 34, dd->getSecondLine().z ); - writer->writeDouble( 15, dd->getVertexPoint().x ); - writer->writeDouble( 25, dd->getVertexPoint().y ); - writer->writeDouble( 35, dd->getVertexPoint().z ); - break; - } + { + DRW_DimAngular3p* dd = (DRW_DimAngular3p*) ent; + writer->writeDouble( 13, dd->getFirstLine().x ); + writer->writeDouble( 23, dd->getFirstLine().y ); + writer->writeDouble( 33, dd->getFirstLine().z ); + writer->writeDouble( 14, dd->getSecondLine().x ); + writer->writeDouble( 24, dd->getSecondLine().y ); + writer->writeDouble( 34, dd->getSecondLine().z ); + writer->writeDouble( 15, dd->getVertexPoint().x ); + writer->writeDouble( 25, dd->getVertexPoint().y ); + writer->writeDouble( 35, dd->getVertexPoint().z ); + break; + } case DRW::DIMORDINATE: - { - DRW_DimOrdinate* dd = (DRW_DimOrdinate*) ent; - writer->writeString( 100, "AcDbOrdinateDimension" ); - writer->writeDouble( 13, dd->getFirstLine().x ); - writer->writeDouble( 23, dd->getFirstLine().y ); - writer->writeDouble( 33, dd->getFirstLine().z ); - writer->writeDouble( 14, dd->getSecondLine().x ); - writer->writeDouble( 24, dd->getSecondLine().y ); - writer->writeDouble( 34, dd->getSecondLine().z ); - break; - } + { + DRW_DimOrdinate* dd = (DRW_DimOrdinate*) ent; + writer->writeString( 100, "AcDbOrdinateDimension" ); + writer->writeDouble( 13, dd->getFirstLine().x ); + writer->writeDouble( 23, dd->getFirstLine().y ); + writer->writeDouble( 33, dd->getFirstLine().z ); + writer->writeDouble( 14, dd->getSecondLine().x ); + writer->writeDouble( 24, dd->getSecondLine().y ); + writer->writeDouble( 34, dd->getSecondLine().z ); + break; + } default: break; @@ -1582,7 +1630,7 @@ bool dxfRW::writeMText( DRW_MText* ent ) writer->writeInt16( 72, ent->alignH ); std::string text = writer->fromUtf8String( ent->text ); - int i; + int i; for( i = 0; (text.size() - i) > 250; ) { @@ -2045,6 +2093,7 @@ bool dxfRW::writeTables() writer->writeString( 2, "ACAD" ); writer->writeInt16( 70, 0 ); + iface->writeAppId(); writer->writeString( 0, "ENDTAB" ); writer->writeString( 0, "TABLE" ); @@ -2324,7 +2373,7 @@ bool dxfRW::writeObjects() DRW_ImageDef* id = imageDef.at( i ); std::map::iterator it; - for( it = id->reactors.begin(); it != id->reactors.end(); it++ ) + for( it = id->reactors.begin(); it != id->reactors.end(); ++it ) { writer->writeString( 0, "IMAGEDEF_REACTOR" ); writer->writeString( 5, (*it).first ); @@ -2368,7 +2417,7 @@ bool dxfRW::writeObjects() writer->writeString( 102, "{ACAD_REACTORS" ); std::map::iterator it; - for( it = id->reactors.begin(); it != id->reactors.end(); it++ ) + for( it = id->reactors.begin(); it != id->reactors.end(); ++it ) { writer->writeString( 330, (*it).first ); } @@ -2395,13 +2444,81 @@ bool dxfRW::writeObjects() } +bool dxfRW::writeExtData( const std::vector& ed ) +{ + for( std::vector::const_iterator it = ed.begin(); it!=ed.end(); ++it ) + { + switch( (*it)->code ) + { + case 1000: + case 1001: + case 1002: + case 1003: + case 1004: + case 1005: + { + int cc = (*it)->code; + + if( (*it)->type == DRW_Variant::STRING ) + writer->writeUtf8String( cc, *(*it)->content.s ); + +// writer->writeUtf8String((*it)->code, (*it)->content.s); + break; + } + + case 1010: + case 1011: + case 1012: + case 1013: + + if( (*it)->type == DRW_Variant::COORD ) + { + writer->writeDouble( (*it)->code, (*it)->content.v->x ); + writer->writeDouble( (*it)->code + 10, (*it)->content.v->y ); + writer->writeDouble( (*it)->code + 20, (*it)->content.v->z ); + } + + break; + + case 1040: + case 1041: + case 1042: + + if( (*it)->type == DRW_Variant::DOUBLE ) + writer->writeDouble( (*it)->code, (*it)->content.d ); + + break; + + case 1070: + + if( (*it)->type == DRW_Variant::INTEGER ) + writer->writeInt16( (*it)->code, (*it)->content.i ); + + break; + + case 1071: + + if( (*it)->type == DRW_Variant::INTEGER ) + writer->writeInt32( (*it)->code, (*it)->content.i ); + + break; + + default: + break; + } + } + + return true; +} + + /********* Reader Process *********/ bool dxfRW::processDxf() { DBG( "dxfRW::processDxf() start processing dxf\n" ); - int code; - bool more = true; + int code; + bool more = true; std::string sectionstr; // section = secUnknown; @@ -2478,7 +2595,7 @@ bool dxfRW::processDxf() bool dxfRW::processHeader() { DBG( "dxfRW::processHeader\n" ); - int code; + int code; std::string sectionstr; while( reader->readRec( &code, !binary ) ) @@ -2509,9 +2626,9 @@ bool dxfRW::processHeader() bool dxfRW::processTables() { DBG( "dxfRW::processTables\n" ); - int code; + int code; std::string sectionstr; - bool more = true; + bool more = true; while( reader->readRec( &code, !binary ) ) { @@ -2562,7 +2679,7 @@ bool dxfRW::processTables() } else if( sectionstr == "APPID" ) { -// processAppId(); + processAppId(); } else if( sectionstr == "DIMSTYLE" ) { @@ -2588,10 +2705,10 @@ bool dxfRW::processTables() bool dxfRW::processLType() { DBG( "dxfRW::processLType\n" ); - int code; + int code; std::string sectionstr; - bool reading = false; - DRW_LType ltype; + bool reading = false; + DRW_LType ltype; while( reader->readRec( &code, !binary ) ) { @@ -2629,10 +2746,10 @@ bool dxfRW::processLType() bool dxfRW::processLayer() { DBG( "dxfRW::processLayer\n" ); - int code; + int code; std::string sectionstr; - bool reading = false; - DRW_Layer layer; + bool reading = false; + DRW_Layer layer; while( reader->readRec( &code, !binary ) ) { @@ -2667,10 +2784,10 @@ bool dxfRW::processLayer() bool dxfRW::processDimStyle() { DBG( "dxfRW::processDimStyle" ); - int code; - std::string sectionstr; - bool reading = false; - DRW_Dimstyle dimSty; + int code; + std::string sectionstr; + bool reading = false; + DRW_Dimstyle dimSty; while( reader->readRec( &code, !binary ) ) { @@ -2705,10 +2822,10 @@ bool dxfRW::processDimStyle() bool dxfRW::processTextStyle() { DBG( "dxfRW::processTextStyle" ); - int code; - std::string sectionstr; - bool reading = false; - DRW_Textstyle TxtSty; + int code; + std::string sectionstr; + bool reading = false; + DRW_Textstyle TxtSty; while( reader->readRec( &code, !binary ) ) { @@ -2743,10 +2860,10 @@ bool dxfRW::processTextStyle() bool dxfRW::processVports() { DBG( "dxfRW::processVports" ); - int code; + int code; std::string sectionstr; - bool reading = false; - DRW_Vport vp; + bool reading = false; + DRW_Vport vp; while( reader->readRec( &code, !binary ) ) { @@ -2778,12 +2895,50 @@ bool dxfRW::processVports() } +bool dxfRW::processAppId() +{ + DBG( "dxfRW::processAppId" ); + int code; + std::string sectionstr; + bool reading = false; + DRW_AppId vp; + + while( reader->readRec( &code, !binary ) ) + { + DBG( code ); DBG( "\n" ); + + if( code == 0 ) + { + if( reading ) + iface->addAppId( vp ); + + sectionstr = reader->getString(); + DBG( sectionstr ); DBG( "\n" ); + + if( sectionstr == "APPID" ) + { + reading = true; + vp.reset(); + } + else if( sectionstr == "ENDTAB" ) + { + return true; // found ENDTAB terminate + } + } + else if( reading ) + vp.parseCode( code, reader ); + } + + return true; +} + + /********* Block Section *********/ bool dxfRW::processBlocks() { DBG( "dxfRW::processBlocks\n" ); - int code; + int code; std::string sectionstr; while( reader->readRec( &code, !binary ) ) @@ -2813,8 +2968,8 @@ bool dxfRW::processBlocks() bool dxfRW::processBlock() { DBG( "dxfRW::processBlock" ); - int code; - DRW_Block block; + int code; + DRW_Block block; while( reader->readRec( &code, !binary ) ) { @@ -2823,23 +2978,23 @@ bool dxfRW::processBlock() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addBlock( block ); + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addBlock( block ); - if( nextentity == "ENDBLK" ) - { - iface->endBlock(); - return true; // found ENDBLK, terminate - } - else - { - processEntities( true ); - iface->endBlock(); - return true; // found ENDBLK, terminate - } + if( nextentity == "ENDBLK" ) + { + iface->endBlock(); + return true; // found ENDBLK, terminate } + else + { + processEntities( true ); + iface->endBlock(); + return true; // found ENDBLK, terminate + } + } default: block.parseCode( code, reader ); @@ -2982,7 +3137,7 @@ bool dxfRW::processEntities( bool isblock ) bool dxfRW::processEllipse() { DBG( "dxfRW::processEllipse" ); - int code; + int code; DRW_Ellipse ellipse; while( reader->readRec( &code, !binary ) ) @@ -2992,16 +3147,16 @@ bool dxfRW::processEllipse() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); - if( applyExt ) - ellipse.applyExtrusion(); + if( applyExt ) + ellipse.applyExtrusion(); - iface->addEllipse( ellipse ); - return true; // found new entity or ENDSEC, terminate - } + iface->addEllipse( ellipse ); + return true; // found new entity or ENDSEC, terminate + } default: ellipse.parseCode( code, reader ); @@ -3016,8 +3171,8 @@ bool dxfRW::processEllipse() bool dxfRW::processTrace() { DBG( "dxfRW::processTrace" ); - int code; - DRW_Trace trace; + int code; + DRW_Trace trace; while( reader->readRec( &code, !binary ) ) { @@ -3026,16 +3181,16 @@ bool dxfRW::processTrace() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); - if( applyExt ) - trace.applyExtrusion(); + if( applyExt ) + trace.applyExtrusion(); - iface->addTrace( trace ); - return true; // found new entity or ENDSEC, terminate - } + iface->addTrace( trace ); + return true; // found new entity or ENDSEC, terminate + } default: trace.parseCode( code, reader ); @@ -3050,8 +3205,8 @@ bool dxfRW::processTrace() bool dxfRW::processSolid() { DBG( "dxfRW::processSolid" ); - int code; - DRW_Solid solid; + int code; + DRW_Solid solid; while( reader->readRec( &code, !binary ) ) { @@ -3060,16 +3215,16 @@ bool dxfRW::processSolid() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); - if( applyExt ) - solid.applyExtrusion(); + if( applyExt ) + solid.applyExtrusion(); - iface->addSolid( solid ); - return true; // found new entity or ENDSEC, terminate - } + iface->addSolid( solid ); + return true; // found new entity or ENDSEC, terminate + } default: solid.parseCode( code, reader ); @@ -3084,8 +3239,8 @@ bool dxfRW::processSolid() bool dxfRW::process3dface() { DBG( "dxfRW::process3dface" ); - int code; - DRW_3Dface face; + int code; + DRW_3Dface face; while( reader->readRec( &code, !binary ) ) { @@ -3094,12 +3249,12 @@ bool dxfRW::process3dface() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->add3dFace( face ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->add3dFace( face ); + return true; // found new entity or ENDSEC, terminate + } default: face.parseCode( code, reader ); @@ -3114,8 +3269,8 @@ bool dxfRW::process3dface() bool dxfRW::processViewport() { DBG( "dxfRW::processViewport" ); - int code; - DRW_Viewport vp; + int code; + DRW_Viewport vp; while( reader->readRec( &code, !binary ) ) { @@ -3124,12 +3279,12 @@ bool dxfRW::processViewport() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addViewport( vp ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addViewport( vp ); + return true; // found new entity or ENDSEC, terminate + } default: vp.parseCode( code, reader ); @@ -3144,8 +3299,8 @@ bool dxfRW::processViewport() bool dxfRW::processPoint() { DBG( "dxfRW::processPoint\n" ); - int code; - DRW_Point point; + int code; + DRW_Point point; while( reader->readRec( &code, !binary ) ) { @@ -3154,12 +3309,12 @@ bool dxfRW::processPoint() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addPoint( point ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addPoint( point ); + return true; // found new entity or ENDSEC, terminate + } default: point.parseCode( code, reader ); @@ -3174,8 +3329,8 @@ bool dxfRW::processPoint() bool dxfRW::processLine() { DBG( "dxfRW::processLine\n" ); - int code; - DRW_Line line; + int code; + DRW_Line line; while( reader->readRec( &code, !binary ) ) { @@ -3184,12 +3339,12 @@ bool dxfRW::processLine() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addLine( line ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addLine( line ); + return true; // found new entity or ENDSEC, terminate + } default: line.parseCode( code, reader ); @@ -3204,7 +3359,7 @@ bool dxfRW::processLine() bool dxfRW::processRay() { DBG( "dxfRW::processRay\n" ); - int code; + int code; DRW_Ray line; while( reader->readRec( &code, !binary ) ) @@ -3214,12 +3369,12 @@ bool dxfRW::processRay() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addRay( line ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addRay( line ); + return true; // found new entity or ENDSEC, terminate + } default: line.parseCode( code, reader ); @@ -3234,8 +3389,8 @@ bool dxfRW::processRay() bool dxfRW::processXline() { DBG( "dxfRW::processXline\n" ); - int code; - DRW_Xline line; + int code; + DRW_Xline line; while( reader->readRec( &code, !binary ) ) { @@ -3244,12 +3399,12 @@ bool dxfRW::processXline() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addXline( line ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addXline( line ); + return true; // found new entity or ENDSEC, terminate + } default: line.parseCode( code, reader ); @@ -3264,8 +3419,8 @@ bool dxfRW::processXline() bool dxfRW::processCircle() { DBG( "dxfRW::processPoint\n" ); - int code; - DRW_Circle circle; + int code; + DRW_Circle circle; while( reader->readRec( &code, !binary ) ) { @@ -3274,16 +3429,16 @@ bool dxfRW::processCircle() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); - if( applyExt ) - circle.applyExtrusion(); + if( applyExt ) + circle.applyExtrusion(); - iface->addCircle( circle ); - return true; // found new entity or ENDSEC, terminate - } + iface->addCircle( circle ); + return true; // found new entity or ENDSEC, terminate + } default: circle.parseCode( code, reader ); @@ -3298,7 +3453,7 @@ bool dxfRW::processCircle() bool dxfRW::processArc() { DBG( "dxfRW::processPoint\n" ); - int code; + int code; DRW_Arc arc; while( reader->readRec( &code, !binary ) ) @@ -3308,16 +3463,16 @@ bool dxfRW::processArc() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); - if( applyExt ) - arc.applyExtrusion(); + if( applyExt ) + arc.applyExtrusion(); - iface->addArc( arc ); - return true; // found new entity or ENDSEC, terminate - } + iface->addArc( arc ); + return true; // found new entity or ENDSEC, terminate + } default: arc.parseCode( code, reader ); @@ -3332,8 +3487,8 @@ bool dxfRW::processArc() bool dxfRW::processInsert() { DBG( "dxfRW::processInsert" ); - int code; - DRW_Insert insert; + int code; + DRW_Insert insert; while( reader->readRec( &code, !binary ) ) { @@ -3342,12 +3497,12 @@ bool dxfRW::processInsert() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addInsert( insert ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addInsert( insert ); + return true; // found new entity or ENDSEC, terminate + } default: insert.parseCode( code, reader ); @@ -3362,8 +3517,8 @@ bool dxfRW::processInsert() bool dxfRW::processLWPolyline() { DBG( "dxfRW::processLWPolyline" ); - int code; - DRW_LWPolyline pl; + int code; + DRW_LWPolyline pl; while( reader->readRec( &code, !binary ) ) { @@ -3372,16 +3527,16 @@ bool dxfRW::processLWPolyline() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); - if( applyExt ) - pl.applyExtrusion(); + if( applyExt ) + pl.applyExtrusion(); - iface->addLWPolyline( pl ); - return true; // found new entity or ENDSEC, terminate - } + iface->addLWPolyline( pl ); + return true; // found new entity or ENDSEC, terminate + } default: pl.parseCode( code, reader ); @@ -3396,8 +3551,8 @@ bool dxfRW::processLWPolyline() bool dxfRW::processPolyline() { DBG( "dxfRW::processPolyline" ); - int code; - DRW_Polyline pl; + int code; + DRW_Polyline pl; while( reader->readRec( &code, !binary ) ) { @@ -3406,20 +3561,20 @@ bool dxfRW::processPolyline() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); - if( nextentity != "VERTEX" ) - { - iface->addPolyline( pl ); - return true; // found new entity or ENDSEC, terminate - } - else - { - processVertex( &pl ); - } + if( nextentity != "VERTEX" ) + { + iface->addPolyline( pl ); + return true; // found new entity or ENDSEC, terminate } + else + { + processVertex( &pl ); + } + } default: pl.parseCode( code, reader ); @@ -3434,7 +3589,7 @@ bool dxfRW::processPolyline() bool dxfRW::processVertex( DRW_Polyline* pl ) { DBG( "dxfRW::processVertex" ); - int code; + int code; DRW_Vertex* v = new DRW_Vertex(); while( reader->readRec( &code, !binary ) ) @@ -3444,20 +3599,20 @@ bool dxfRW::processVertex( DRW_Polyline* pl ) switch( code ) { case 0: - { - pl->appendVertex( v ); - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); + { + pl->appendVertex( v ); + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); - if( nextentity == "SEQEND" ) - { - return true; // found SEQEND no more vertex, terminate - } - else if( nextentity == "VERTEX" ) - { - v = new DRW_Vertex(); // another vertex - } + if( nextentity == "SEQEND" ) + { + return true; // found SEQEND no more vertex, terminate } + else if( nextentity == "VERTEX" ) + { + v = new DRW_Vertex(); // another vertex + } + } default: v->parseCode( code, reader ); @@ -3472,8 +3627,8 @@ bool dxfRW::processVertex( DRW_Polyline* pl ) bool dxfRW::processText() { DBG( "dxfRW::processText" ); - int code; - DRW_Text txt; + int code; + DRW_Text txt; while( reader->readRec( &code, !binary ) ) { @@ -3482,12 +3637,12 @@ bool dxfRW::processText() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addText( txt ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addText( txt ); + return true; // found new entity or ENDSEC, terminate + } default: txt.parseCode( code, reader ); @@ -3502,8 +3657,8 @@ bool dxfRW::processText() bool dxfRW::processMText() { DBG( "dxfRW::processMText" ); - int code; - DRW_MText txt; + int code; + DRW_MText txt; while( reader->readRec( &code, !binary ) ) { @@ -3512,13 +3667,13 @@ bool dxfRW::processMText() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - txt.updateAngle(); - iface->addMText( txt ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + txt.updateAngle(); + iface->addMText( txt ); + return true; // found new entity or ENDSEC, terminate + } default: txt.parseCode( code, reader ); @@ -3533,8 +3688,8 @@ bool dxfRW::processMText() bool dxfRW::processHatch() { DBG( "dxfRW::processHatch" ); - int code; - DRW_Hatch hatch; + int code; + DRW_Hatch hatch; while( reader->readRec( &code, !binary ) ) { @@ -3543,12 +3698,12 @@ bool dxfRW::processHatch() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addHatch( &hatch ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addHatch( &hatch ); + return true; // found new entity or ENDSEC, terminate + } default: hatch.parseCode( code, reader ); @@ -3563,8 +3718,8 @@ bool dxfRW::processHatch() bool dxfRW::processSpline() { DBG( "dxfRW::processSpline" ); - int code; - DRW_Spline sp; + int code; + DRW_Spline sp; while( reader->readRec( &code, !binary ) ) { @@ -3573,12 +3728,12 @@ bool dxfRW::processSpline() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addSpline( &sp ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addSpline( &sp ); + return true; // found new entity or ENDSEC, terminate + } default: sp.parseCode( code, reader ); @@ -3593,8 +3748,8 @@ bool dxfRW::processSpline() bool dxfRW::processImage() { DBG( "dxfRW::processImage" ); - int code; - DRW_Image img; + int code; + DRW_Image img; while( reader->readRec( &code, !binary ) ) { @@ -3603,12 +3758,12 @@ bool dxfRW::processImage() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addImage( &img ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addImage( &img ); + return true; // found new entity or ENDSEC, terminate + } default: img.parseCode( code, reader ); @@ -3623,8 +3778,8 @@ bool dxfRW::processImage() bool dxfRW::processDimension() { DBG( "dxfRW::processDimension" ); - int code; - DRW_Dimension dim; + int code; + DRW_Dimension dim; while( reader->readRec( &code, !binary ) ) { @@ -3633,66 +3788,66 @@ bool dxfRW::processDimension() switch( code ) { case 0: + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + int type = dim.type & 0x0F; + + switch( type ) { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - int type = dim.type & 0x0F; - - switch( type ) - { - case 0: - { - DRW_DimLinear d( dim ); - iface->addDimLinear( &d ); - break; - } - - case 1: - { - DRW_DimAligned d( dim ); - iface->addDimAlign( &d ); - break; - } - - case 2: - { - DRW_DimAngular d( dim ); - iface->addDimAngular( &d ); - break; - } - - case 3: - { - DRW_DimDiametric d( dim ); - iface->addDimDiametric( &d ); - break; - } - - case 4: - { - DRW_DimRadial d( dim ); - iface->addDimRadial( &d ); - break; - } - - case 5: - { - DRW_DimAngular3p d( dim ); - iface->addDimAngular3P( &d ); - break; - } - - case 6: - { - DRW_DimOrdinate d( dim ); - iface->addDimOrdinate( &d ); - break; - } - } - - return true; // found new entity or ENDSEC, terminate + case 0: + { + DRW_DimLinear d( dim ); + iface->addDimLinear( &d ); + break; } + case 1: + { + DRW_DimAligned d( dim ); + iface->addDimAlign( &d ); + break; + } + + case 2: + { + DRW_DimAngular d( dim ); + iface->addDimAngular( &d ); + break; + } + + case 3: + { + DRW_DimDiametric d( dim ); + iface->addDimDiametric( &d ); + break; + } + + case 4: + { + DRW_DimRadial d( dim ); + iface->addDimRadial( &d ); + break; + } + + case 5: + { + DRW_DimAngular3p d( dim ); + iface->addDimAngular3P( &d ); + break; + } + + case 6: + { + DRW_DimOrdinate d( dim ); + iface->addDimOrdinate( &d ); + break; + } + } + + return true; // found new entity or ENDSEC, terminate + } + default: dim.parseCode( code, reader ); break; @@ -3706,8 +3861,8 @@ bool dxfRW::processDimension() bool dxfRW::processLeader() { DBG( "dxfRW::processLeader" ); - int code; - DRW_Leader leader; + int code; + DRW_Leader leader; while( reader->readRec( &code, !binary ) ) { @@ -3716,12 +3871,12 @@ bool dxfRW::processLeader() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->addLeader( &leader ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->addLeader( &leader ); + return true; // found new entity or ENDSEC, terminate + } default: leader.parseCode( code, reader ); @@ -3784,8 +3939,8 @@ bool dxfRW::processObjects() bool dxfRW::processImageDef() { DBG( "dxfRW::processImageDef" ); - int code; - DRW_ImageDef img; + int code; + DRW_ImageDef img; while( reader->readRec( &code, !binary ) ) { @@ -3794,12 +3949,12 @@ bool dxfRW::processImageDef() switch( code ) { case 0: - { - nextentity = reader->getString(); - DBG( nextentity ); DBG( "\n" ); - iface->linkImage( &img ); - return true; // found new entity or ENDSEC, terminate - } + { + nextentity = reader->getString(); + DBG( nextentity ); DBG( "\n" ); + iface->linkImage( &img ); + return true; // found new entity or ENDSEC, terminate + } default: img.parseCode( code, reader ); diff --git a/lib_dxf/libdxfrw.h b/lib_dxf/libdxfrw.h index d7119dce86..c37dcb2f3e 100644 --- a/lib_dxf/libdxfrw.h +++ b/lib_dxf/libdxfrw.h @@ -35,7 +35,7 @@ public: * @param ext should the extrusion be applied to convert in 2D? * @return true for success */ - bool read( DRW_Interface* interface_, bool ext ); + bool read( DRW_Interface* interface_, bool ext ); void setBinary( bool b ) { binary = b; } @@ -45,6 +45,7 @@ public: bool writeDimstyle( DRW_Dimstyle* ent ); bool writeTextstyle( DRW_Textstyle* ent ); bool writeVport( DRW_Vport* ent ); + bool writeAppId( DRW_AppId* ent ); bool writePoint( DRW_Point* ent ); bool writeLine( DRW_Line* ent ); bool writeRay( DRW_Ray* ent ); @@ -70,74 +71,77 @@ public: bool writeDimension( DRW_Dimension* ent ); void setEllipseParts( int parts ) { elParts = parts; } /*!< set parts munber when convert ellipse to polyline */ + private: /// used by read() to parse the content of the file - bool processDxf(); - bool processHeader(); - bool processTables(); - bool processBlocks(); - bool processBlock(); - bool processEntities( bool isblock ); - bool processObjects(); + bool processDxf(); + bool processHeader(); + bool processTables(); + bool processBlocks(); + bool processBlock(); + bool processEntities( bool isblock ); + bool processObjects(); - bool processLType(); - bool processLayer(); - bool processDimStyle(); - bool processTextStyle(); - bool processVports(); + bool processLType(); + bool processLayer(); + bool processDimStyle(); + bool processTextStyle(); + bool processVports(); + bool processAppId(); - bool processPoint(); - bool processLine(); - bool processRay(); - bool processXline(); - bool processCircle(); - bool processArc(); - bool processEllipse(); - bool processTrace(); - bool processSolid(); - bool processInsert(); - bool processLWPolyline(); - bool processPolyline(); - bool processVertex( DRW_Polyline* pl ); - bool processText(); - bool processMText(); - bool processHatch(); - bool processSpline(); - bool process3dface(); - bool processViewport(); - bool processImage(); - bool processImageDef(); - bool processDimension(); - bool processLeader(); + bool processPoint(); + bool processLine(); + bool processRay(); + bool processXline(); + bool processCircle(); + bool processArc(); + bool processEllipse(); + bool processTrace(); + bool processSolid(); + bool processInsert(); + bool processLWPolyline(); + bool processPolyline(); + bool processVertex( DRW_Polyline* pl ); + bool processText(); + bool processMText(); + bool processHatch(); + bool processSpline(); + bool process3dface(); + bool processViewport(); + bool processImage(); + bool processImageDef(); + bool processDimension(); + bool processLeader(); // bool writeHeader(); - bool writeEntity( DRW_Entity* ent ); - bool writeTables(); - bool writeBlocks(); - bool writeObjects(); - std::string toHexStr( int n ); + bool writeEntity( DRW_Entity* ent ); + bool writeTables(); + bool writeBlocks(); + bool writeObjects(); + bool writeExtData( const std::vector& ed ); + std::string toHexStr( int n ); private: - DRW::Version version; - std::string fileName; - std::string codePage; - bool binary; - dxfReader* reader; - dxfWriter* writer; - DRW_Interface* iface; - DRW_Header header; + DRW::Version version; + std::string fileName; + std::string codePage; + bool binary; + dxfReader* reader; + dxfWriter* writer; + DRW_Interface* iface; + DRW_Header header; // int section; - std::string nextentity; - int entCount; - bool wlayer0; - bool dimstyleStd; - bool applyExt; - bool writingBlock; - int elParts; /*!< parts munber when convert ellipse to polyline */ + std::string nextentity; + int entCount; + bool wlayer0; + bool dimstyleStd; + bool applyExt; + bool writingBlock; + int elParts; /*!< parts munber when convert ellipse to polyline */ std::map blockMap; std::vector imageDef; /*!< imageDef list */ - int currHandle; + int currHandle; }; #endif // LIBDXFRW_H diff --git a/pcbnew/import_dxf/dxf2brd_items.h b/pcbnew/import_dxf/dxf2brd_items.h index f4be640138..c95ec0965a 100644 --- a/pcbnew/import_dxf/dxf2brd_items.h +++ b/pcbnew/import_dxf/dxf2brd_items.h @@ -165,6 +165,9 @@ private: void writeLine(); void writeMtext(); + + virtual void addAppId( const DRW_AppId& data ) {} + virtual void writeAppId() {} }; #endif // FILTERDXFRW_H diff --git a/utils/idftools/dxf2idf.h b/utils/idftools/dxf2idf.h index 8c5f995f4a..686ac07a61 100644 --- a/utils/idftools/dxf2idf.h +++ b/utils/idftools/dxf2idf.h @@ -91,6 +91,8 @@ private: virtual void writeTextstyles(){} virtual void writeVports(){} virtual void writeDimstyles(){} + virtual void addAppId( const DRW_AppId& data ) {} + virtual void writeAppId() {} }; #endif // DXF2IDF_H