Commit ede0daf9 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

lib_dxf: Update to version 0.5.13 (previous: 0.5.11) due to a bug (memory...

lib_dxf: Update to version 0.5.13 (previous: 0.5.11) due to a bug (memory leak) fixed in 0.5.13, which has also more comments, and try to fix most of coverity warnings (not initialized class members).
These members are now initialized, which also fix some other more serious coverity issues.
parent d5e70c93
Loading
Loading
Loading
Loading
+55 −34
Original line number Original line Diff line number Diff line
@@ -13,7 +13,7 @@
#ifndef DRW_BASE_H
#ifndef DRW_BASE_H
#define DRW_BASE_H
#define DRW_BASE_H


#define DRW_VERSION "0.5.11"
#define DRW_VERSION "0.5.13"


#include <string>
#include <string>
#include <cmath>
#include <cmath>
@@ -42,7 +42,8 @@


namespace DRW {
namespace DRW {
// ! Version numbers for the DXF Format.
// ! Version numbers for the DXF Format.
enum Version {
enum Version
{
    UNKNOWNV,       /*!< UNKNOWN VERSION. */
    UNKNOWNV,       /*!< UNKNOWN VERSION. */
    AC1006,         /*!< R10. */
    AC1006,         /*!< R10. */
    AC1009,         /*!< R11 & R12. */
    AC1009,         /*!< R11 & R12. */
@@ -54,7 +55,8 @@ enum Version {
    AC1024          /*!< ACAD 2010. */
    AC1024          /*!< ACAD 2010. */
};
};


enum error {
enum error
{
    BAD_NONE,               /*!< No error. */
    BAD_NONE,               /*!< No error. */
    BAD_UNKNOWN,            /*!< UNKNOWN. */
    BAD_UNKNOWN,            /*!< UNKNOWN. */
    BAD_OPEN,               /*!< error opening file. */
    BAD_OPEN,               /*!< error opening file. */
@@ -76,7 +78,7 @@ enum error {
class DRW_Coord
class DRW_Coord
{
{
public:
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 )
    DRW_Coord( double ix, double iy, double iz )
    {
    {
        x = ix; y = iy; z = iz;
        x = ix; y = iy; z = iz;
@@ -121,7 +123,7 @@ public:
    DRW_Vertex2D()
    DRW_Vertex2D()
    {
    {
// eType = DRW::LWPOLYLINE;
// eType = DRW::LWPOLYLINE;
        stawidth = endwidth = bulge = 0;
        x = y = stawidth = endwidth = bulge = 0.0;
    }
    }


    DRW_Vertex2D( double sx, double sy, double b )
    DRW_Vertex2D( double sx, double sy, double b )
@@ -149,7 +151,8 @@ public:
class DRW_Variant
class DRW_Variant
{
{
public:
public:
    enum TYPE {
    enum TYPE
    {
        STRING,
        STRING,
        INTEGER,
        INTEGER,
        DOUBLE,
        DOUBLE,
@@ -162,29 +165,46 @@ public:
        type = INVALID;
        type = INVALID;
    }
    }


    ~DRW_Variant()
    DRW_Variant( const DRW_Variant& d )
    {
    {
        if( type == COORD )
        code    = d.code;
            delete content.v;
        type    = d.type;

        if( d.type == COORD ) vdata = d.vdata;

        if( d.type == STRING ) sdata = d.sdata;

        content = d.content;
    }
    }


    enum TYPE type;
    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;
    }


    void addString( UTF8STRING s ) { setType( STRING ); data = s; content.s = &data; }
    ~DRW_Variant()
    {
    }

    void addString( UTF8STRING s ) { setType( STRING ); sdata = s; content.s = &sdata; }
    void addInt( int i ) { setType( INTEGER ); content.i = i; }
    void addInt( int i ) { setType( INTEGER ); content.i = i; }
    void addDouble( double d ) { setType( DOUBLE ); content.d = d; }
    void addDouble( double d ) { setType( DOUBLE ); content.d = d; }
    void addCoord( DRW_Coord* v ) { setType( COORD ); content.v = v; }
    void addCoord()
    void setType( enum TYPE t )
    {
    {
        if( type == COORD )
        setType( COORD ); vdata.x = 0.0; vdata.y = 0.0; vdata.z = 0.0; content.v =
            delete content.v;
            &vdata;

        type = t;
    }
    }


    void setCoordX( double d ) { if( type == COORD ) content.v->x = d; }
    void addCoord( DRW_Coord v ) { setType( COORD ); vdata = v; content.v = &vdata; }
    void setCoordY( double d ) { if( type == COORD ) content.v->y = d; }
    void setType( enum TYPE t ) { type = t; }
    void setCoordZ( double d ) { if( type == COORD ) content.v->z = d; }
    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:
private:
    typedef union
    typedef union
    {
    {
@@ -193,15 +213,15 @@ private:
        double d;
        double d;
        DRW_Coord* v;
        DRW_Coord* v;
    } DRW_VarContent;
    } DRW_VarContent;

public:
public:
    DRW_VarContent content;
    DRW_VarContent content;
public:
    enum TYPE type;
    int             code;
    int code;            /*!< dxf code of this value*/
// string version;

// string codepage;
private:
private:
// DRW_VarContent content;
    std::string sdata;
    std::string data;
    DRW_Coord   vdata;
};
};




@@ -215,7 +235,8 @@ private:
class DRW_LW_Conv
class DRW_LW_Conv
{
{
public:
public:
    enum lineWidth {
    enum lineWidth
    {
        width00 = 0,            /*!< 0.00mm (dxf 0)*/
        width00 = 0,            /*!< 0.00mm (dxf 0)*/
        width01 = 1,            /*!< 0.05mm (dxf 5)*/
        width01 = 1,            /*!< 0.05mm (dxf 5)*/
        width02 = 2,            /*!< 0.09mm (dxf 9)*/
        width02 = 2,            /*!< 0.09mm (dxf 9)*/
+134 −46
Original line number Original line Diff line number Diff line
@@ -22,23 +22,33 @@
 */
 */
void DRW_Entity::calculateAxis( DRW_Coord extPoint )
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( 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.x  = extPoint.z;
        extAxisX.y  = 0;
        extAxisX.y  = 0;
        extAxisX.z  = -extPoint.x;
        extAxisX.z  = -extPoint.x;
    }
    }
    else
    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.x  = -extPoint.y;
        extAxisX.y  = extPoint.x;
        extAxisX.y  = extPoint.x;
        extAxisX.z  = 0;
        extAxisX.z  = 0;
    }
    }


    extAxisX.unitize();
    extAxisX.unitize();

    // Ay = N x Ax
    extAxisY.x  = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
    extAxisY.x  = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
    extAxisY.y  = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
    extAxisY.y  = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
    extAxisY.z  = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);
    extAxisY.z  = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);

    extAxisY.unitize();
    extAxisY.unitize();
}
}


@@ -110,6 +120,58 @@ void DRW_Entity::parseCode( int code, dxfReader* reader )
        space = reader->getInt32();
        space = reader->getInt32();
        break;
        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:
    default:
        break;
        break;
    }
    }
@@ -183,6 +245,8 @@ void DRW_Circle::applyExtrusion()
{
{
    if( haveExtrusion )
    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 );
        calculateAxis( extPoint );
        extrudePoint( extPoint, &basePoint );
        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 )
void DRW_Arc::parseCode( int code, dxfReader* reader )
{
{
    switch( code )
    switch( code )
+296 −252
Original line number Original line Diff line number Diff line
@@ -23,7 +23,8 @@ class DRW_Polyline;


namespace DRW {
namespace DRW {
// ! Entity's type.
// ! Entity's type.
enum ETYPE {
enum ETYPE
{
    POINT,
    POINT,
    LINE,
    LINE,
    CIRCLE,
    CIRCLE,
@@ -82,9 +83,17 @@ public:
        handleBlock = space = 0;                // default ModelSpace (0) & handleBlock = no handle (0)
        handleBlock = space = 0;                // default ModelSpace (0) & handleBlock = no handle (0)
        haveExtrusion = false;
        haveExtrusion = false;
        color24 = -1;                           // default -1 not set
        color24 = -1;                           // default -1 not set
        handle  = 0;
        curr = NULL;
    }
    }


    virtual ~DRW_Entity() {}
    virtual ~DRW_Entity()
    {
        for( std::vector<DRW_Variant*>::iterator it = extData.begin(); it!=extData.end(); ++it )
            delete *it;

        extData.clear();
    }


    DRW_Entity( const DRW_Entity& d )
    DRW_Entity( const DRW_Entity& d )
    {
    {
@@ -101,6 +110,7 @@ public:
        lWeight = d.lWeight;
        lWeight = d.lWeight;
        space = d.space;
        space = d.space;
        haveExtrusion = d.haveExtrusion;
        haveExtrusion = d.haveExtrusion;
        curr = NULL;
    }
    }


    virtual void applyExtrusion() = 0;
    virtual void applyExtrusion() = 0;
@@ -124,9 +134,12 @@ public:
    std::string colorName;                  /*!< color name, code 430 */
    std::string colorName;                  /*!< color name, code 430 */
    int space;                              /*!< space indicator 0 = model, 1 paper, code 67*/
    int space;                              /*!< space indicator 0 = model, 1 paper, code 67*/
    bool haveExtrusion;                     /*!< set to true if the entity have extrusion*/
    bool haveExtrusion;                     /*!< set to true if the entity have extrusion*/
    std::vector<DRW_Variant*> extData;      /*!< FIFO list of extended data, codes 1000 to 1071*/

private:
private:
    DRW_Coord   extAxisX;
    DRW_Coord   extAxisX;
    DRW_Coord   extAxisY;
    DRW_Coord   extAxisY;
    DRW_Variant* curr;
};
};




@@ -216,6 +229,7 @@ public:
    DRW_Circle()
    DRW_Circle()
    {
    {
        eType = DRW::CIRCLE;
        eType = DRW::CIRCLE;
        radious = 0.0;
    }
    }


    virtual void    applyExtrusion();
    virtual void    applyExtrusion();
@@ -237,9 +251,11 @@ public:
    {
    {
        eType   = DRW::ARC;
        eType   = DRW::ARC;
        isccw   = 1;
        isccw   = 1;
        staangle    = 0.0;
        endangle    = 0.0;
    }
    }


    virtual void applyExtrusion() { DRW_Circle::applyExtrusion(); }
    virtual void    applyExtrusion();
    void            parseCode( int code, dxfReader* reader );
    void            parseCode( int code, dxfReader* reader );


public:
public:
@@ -262,6 +278,8 @@ public:
    {
    {
        eType   = DRW::ELLIPSE;
        eType   = DRW::ELLIPSE;
        isccw   = 1;
        isccw   = 1;
        ratio   = 1.0;
        staparam = endparam = 0;
    }
    }


    void            parseCode( int code, dxfReader* reader );
    void            parseCode( int code, dxfReader* reader );
@@ -413,6 +431,7 @@ public:
        extPoint.x  = extPoint.y = 0;
        extPoint.x  = extPoint.y = 0;
        extPoint.z  = 1;
        extPoint.z  = 1;
        vertex = NULL;
        vertex = NULL;
        vertexnum = 0;
    }
    }


    ~DRW_LWPolyline()
    ~DRW_LWPolyline()
@@ -470,7 +489,8 @@ class DRW_Text : public DRW_Line
{
{
public:
public:
    // ! Vertical alignments.
    // ! Vertical alignments.
    enum VAlign {
    enum VAlign
    {
        VBaseLine = 0,      /*!< Top = 0 */
        VBaseLine = 0,      /*!< Top = 0 */
        VBottom,            /*!< Bottom = 1 */
        VBottom,            /*!< Bottom = 1 */
        VMiddle,            /*!< Middle = 2 */
        VMiddle,            /*!< Middle = 2 */
@@ -478,7 +498,8 @@ public:
    };
    };


    // ! Horizontal alignments.
    // ! Horizontal alignments.
    enum HAlign {
    enum HAlign
    {
        HLeft = 0,          /*!< Left = 0 */
        HLeft = 0,          /*!< Left = 0 */
        HCenter,            /*!< Centered = 1 */
        HCenter,            /*!< Centered = 1 */
        HRight,             /*!< Right = 2 */
        HRight,             /*!< Right = 2 */
@@ -497,6 +518,7 @@ public:
        textgen = 0;
        textgen = 0;
        alignH  = HLeft;
        alignH  = HLeft;
        alignV  = VBaseLine;
        alignV  = VBaseLine;
        height  = 0.0;
    }
    }


    virtual void applyExtrusion() {}    // RLZ TODO
    virtual void applyExtrusion() {}    // RLZ TODO
@@ -523,7 +545,8 @@ class DRW_MText : public DRW_Text
{
{
public:
public:
    // ! Attachments.
    // ! Attachments.
    enum Attach {
    enum Attach
    {
        TopLeft = 1,
        TopLeft = 1,
        TopCenter,
        TopCenter,
        TopRight,
        TopRight,
@@ -549,6 +572,7 @@ public:


public:
public:
    double interlin;     /*!< width factor, code 44 */
    double interlin;     /*!< width factor, code 44 */

private:
private:
    bool haveXAxis;
    bool haveXAxis;
};
};
@@ -567,6 +591,7 @@ public:
        stawidth    = endwidth = bulge = 0;
        stawidth    = endwidth = bulge = 0;
        vindex1     = vindex2 = vindex3 = vindex4 = 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 )
    DRW_Vertex( double sx, double sy, double sz, double b )
@@ -578,6 +603,7 @@ public:
        basePoint.y = sy;
        basePoint.y = sy;
        basePoint.z = sz;
        basePoint.z = sz;
        bulge   = b;
        bulge   = b;
        tgdir   = 0.0;
    }
    }


    void parseCode( int code, dxfReader* reader );
    void parseCode( int code, dxfReader* reader );
@@ -670,6 +696,10 @@ public:
        ex  = ey = 0.0;
        ex  = ey = 0.0;
        ez  = 1.0;
        ez  = 1.0;
        tolknot = tolcontrol = tolfit = 0.0000001;
        tolknot = tolcontrol = tolfit = 0.0000001;
        tgsx = tgsy = tgsz = tgex = tgey = tgez = 0.0;
        degree = 0;
        controlpoint = 0;
        fitpoint = 0;
    }
    }


    ~DRW_Spline()
    ~DRW_Spline()
@@ -711,6 +741,7 @@ public:
    std::vector<double> knotslist;          /*!< knots list, code 40 */
    std::vector<double> knotslist;          /*!< knots list, code 40 */
    std::vector<DRW_Coord*> controllist;    /*!< control points list, code 10, 20 & 30 */
    std::vector<DRW_Coord*> controllist;    /*!< control points list, code 10, 20 & 30 */
    std::vector<DRW_Coord*> fitlist;        /*!< fit points list, code 11, 21 & 31 */
    std::vector<DRW_Coord*> fitlist;        /*!< fit points list, code 11, 21 & 31 */

private:
private:
    DRW_Coord*  controlpoint;   /*!< current control point to add data */
    DRW_Coord*  controlpoint;   /*!< current control point to add data */
    DRW_Coord*  fitpoint;       /*!< current fit point to add data */
    DRW_Coord*  fitpoint;       /*!< current fit point to add data */
@@ -773,6 +804,7 @@ public:
        deflines = doubleflag = 0;
        deflines = doubleflag = 0;
        loop = NULL;
        loop = NULL;
        clearEntities();
        clearEntities();
        ispol = false;
    }
    }


    ~DRW_Hatch()
    ~DRW_Hatch()
@@ -804,6 +836,7 @@ public:
    int deflines;                           /*!< number of pattern definition lines, code 78 */
    int deflines;                           /*!< number of pattern definition lines, code 78 */


    std::vector<DRW_HatchLoop*> looplist;   /*!< polyline list */
    std::vector<DRW_HatchLoop*> looplist;   /*!< polyline list */

private:
private:
    void clearEntities()
    void clearEntities()
    {
    {
@@ -884,6 +917,7 @@ public:
        eType = DRW::IMAGE;
        eType = DRW::IMAGE;
        vz = fade = clip = 0;
        vz = fade = clip = 0;
        brightness = contrast = 50;
        brightness = contrast = 50;
        vx = vy = sizeu = sizev = dz = 0.0;
    }
    }


    void parseCode( int code, dxfReader* reader );
    void parseCode( int code, dxfReader* reader );
@@ -922,6 +956,8 @@ public:
        defPoint.z      = extPoint.x = extPoint.y = 0;
        defPoint.z      = extPoint.x = extPoint.y = 0;
        textPoint.z     = rot = 0;
        textPoint.z     = rot = 0;
        clonePoint.x    = clonePoint.y = clonePoint.z = 0;
        clonePoint.x    = clonePoint.y = clonePoint.z = 0;
        type = 0;
        length = 0.0;
    }
    }


    DRW_Dimension( const DRW_Dimension& d ) : DRW_Entity( d )
    DRW_Dimension( const DRW_Dimension& d ) : DRW_Entity( d )
@@ -955,46 +991,49 @@ public:
    virtual void applyExtrusion() {}
    virtual void applyExtrusion() {}


    DRW_Coord getDefPoint() const { return defPoint; }      /*!< Definition point, code 10, 20 & 30 */
    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 */
    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 */
    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 */
    int getAlign() const { return align; }                  /*!< attachment point, code 71 */
    void setAlign( const int a ) { align = a; }
    void setAlign( const int a ) { align = a; }
    int getTextLineStyle() const { return linesty; }        /*!< Dimension text line spacing style, code 72, default 1 */
    int getTextLineStyle() const { return linesty; }        /*!< Dimension text line spacing style, code 72, default 1 */
    void setTextLineStyle( const int l ) { linesty = l; }
    void setTextLineStyle( const int l ) { linesty = l; }
    std::string getText() const { return text; }            /*!< Dimension text explicitly entered by the user, code 1 */
    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? */
    double getTextLineFactor() const { return linefactor; } /*!< Dimension text line spacing factor, code 41, default 1? */
    void setTextLineFactor( const double l ) { linefactor = l; }
    void setTextLineFactor( const double l ) { linefactor = l; }
    double getDir() const { return rot; }                   /*!< rotation angle of the dimension text, code 53 (optional) default 0 */
    double getDir() const { return rot; }                   /*!< rotation angle of the dimension text, code 53 (optional) default 0 */
    void setDir( const double d ) { rot = d; }
    void setDir( const double d ) { rot = d; }


    DRW_Coord getExtrusion() { return extPoint; }               /*!< extrusion, code 210, 220 & 230 */
    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 */
    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 */
// int getType(){ return type;}                      /*!< Dimension type, code 70 */

protected:
protected:
    DRW_Coord getPt2() const { return clonePoint; }
    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; }
    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; }
    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; }
    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; }
    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 */
    double getAn50() const { return angle; }        /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
    void setAn50( const double d ) { angle = d; }
    void setAn50( const double d ) { angle = d; }
    double getOb52() const { return oblique; }      /*!< oblique angle, code 52 */
    double getOb52() const { return oblique; }      /*!< oblique angle, code 52 */
    void setOb52( const double d ) { oblique = d; }
    void setOb52( const double d ) { oblique = d; }
    double getRa40() const { return length; }       /*!< Leader length, code 40 */
    double getRa40() const { return length; }       /*!< Leader length, code 40 */
    void setRa40( const double d ) { length = d; }
    void setRa40( const double d ) { length = d; }

public:
public:
    int type;                  /*!< Dimension type, code 70 */
    int type;                  /*!< Dimension type, code 70 */

private:
private:
    std::string name;           /*!< Name of the block that contains the entities, code 2 */
    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   defPoint;       /*!<  definition point, code 10, 20 & 30 (WCS) */
@@ -1039,14 +1078,14 @@ public:
    }
    }


    DRW_Coord getClonepoint() const { return getPt2(); }      /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */
    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 */
    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 */
    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 */
    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
// ! 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 */
    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 */
    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 */
    double getLeaderLength() const { return getRa40(); }            /*!< Leader length, code 40 */
    void setLeaderLength( const double d ) { setRa40( d ); }
    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 */
    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 */
    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 */
    double getLeaderLength() const { return getRa40(); }            /*!< Leader length, code 40 */
    void setLeaderLength( const double d ) { setRa40( d ); }
    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 */
    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 */
    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 */
    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 */
    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 */
    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 */
    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 */
    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 */
    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 */
    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
// ! Class to handle ordinate dimension entity
@@ -1203,11 +1242,11 @@ public:
    }
    }


    DRW_Coord getOriginPoint() const { return getDefPoint(); }      /*!< Origin definition point, code 10, 20 & 30 */
    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 */
    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 */
    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 ); }
};
};




@@ -1227,6 +1266,10 @@ public:
        extrusionPoint.x = extrusionPoint.y = 0.0;
        extrusionPoint.x = extrusionPoint.y = 0.0;
        arrow = 1;
        arrow = 1;
        extrusionPoint.z = 1.0;
        extrusionPoint.z = 1.0;
        hookline = 0;
        textheight = textwidth = 0.0;
        coloruse = 0;
        vertexpoint = NULL;
    }
    }


    ~DRW_Leader()
    ~DRW_Leader()
@@ -1258,6 +1301,7 @@ public:
    DRW_Coord   offsettext;             /*!< Offset of last leader vertex from annotation, code 213, 223 & 233 */
    DRW_Coord   offsettext;             /*!< Offset of last leader vertex from annotation, code 213, 223 & 233 */


    std::vector<DRW_Coord*> vertexlist; /*!< vertex points list, code 10, 20 & 30 */
    std::vector<DRW_Coord*> vertexlist; /*!< vertex points list, code 10, 20 & 30 */

private:
private:
    DRW_Coord* vertexpoint;    /*!< current control point to add data */
    DRW_Coord* vertexpoint;    /*!< current control point to add data */
};
};
@@ -1273,7 +1317,7 @@ public:
    DRW_Viewport()
    DRW_Viewport()
    {
    {
        eType   = DRW::VIEWPORT;
        eType   = DRW::VIEWPORT;
        vpstatus    = 0;
        vpID    = vpstatus = 0;
        pswidth     = 205;
        pswidth     = 205;
        psheight    = 156;
        psheight    = 156;
        centerPX    = 128.5;
        centerPX    = 128.5;
+49 −45
Original line number Original line Diff line number Diff line
@@ -57,6 +57,9 @@ public:
    /** Called for every text style. */
    /** 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
     * Called for every block. Note: all entities added after this
     * command go into this block until endBlock() is called.
     * command go into this block until endBlock() is called.
@@ -214,6 +217,7 @@ public:
    virtual void    writeTextstyles() = 0;
    virtual void    writeTextstyles() = 0;
    virtual void    writeVports() = 0;
    virtual void    writeVports() = 0;
    virtual void    writeDimstyles() = 0;
    virtual void    writeDimstyles() = 0;
    virtual void    writeAppId() = 0;


protected:
protected:
// DL_Attributes attributes;
// DL_Attributes attributes;
+102 −8
Original line number Original line Diff line number Diff line
@@ -41,6 +41,58 @@ void DRW_TableEntry::parseCode( int code, dxfReader* reader )
        flags = reader->getInt32();
        flags = reader->getInt32();
        break;
        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:
    default:
        break;
        break;
    }
    }
@@ -747,7 +799,7 @@ void DRW_Header::parseCode( int code, dxfReader* reader )
        break;
        break;


    case 10:
    case 10:
        curr->addCoord( new DRW_Coord() );
        curr->addCoord();
        curr->setCoordX( reader->getDouble() );
        curr->setCoordX( reader->getDouble() );
        curr->code = code;
        curr->code = code;
        break;
        break;
@@ -970,6 +1022,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
            writer->writeUtf8String( 7, varStr );
            writer->writeUtf8String( 7, varStr );






    else
    else
        writer->writeString( 7, "STANDARD" );
        writer->writeString( 7, "STANDARD" );


@@ -982,6 +1036,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
            writer->writeUtf8String( 8, varStr );
            writer->writeUtf8String( 8, varStr );






    else
    else
        writer->writeString( 8, "0" );
        writer->writeString( 8, "0" );


@@ -1082,6 +1138,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
            writer->writeUtf8String( 2, varStr );
            writer->writeUtf8String( 2, varStr );






    else
    else
        writer->writeString( 2, "STANDARD" );
        writer->writeString( 2, "STANDARD" );


@@ -1235,7 +1293,7 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
#ifdef DRW_DBG
#ifdef DRW_DBG
    std::map<std::string, DRW_Variant*>::const_iterator it;
    std::map<std::string, DRW_Variant*>::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);
// QString key = QString::fromStdString((*it).first);
        std::cerr << (*it).first << std::endl;
        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 DRW_Header::getDouble( std::string key, double* varDouble )
{
{
    bool result = false;
    bool result = false;
Loading