[libdxfrw] update to 0.5.11 + librecad changes
Tom Callaway
spot at fedoraproject.org
Mon Jun 2 17:22:36 UTC 2014
commit d9ed9a392927a53502b90ef1380423ec91b65532
Author: Tom Callaway <spot at fedoraproject.org>
Date: Mon Jun 2 13:22:37 2014 -0400
update to 0.5.11 + librecad changes
.gitignore | 1 +
libdxfrw-0.5.11-librecad-changes.patch | 298 ++++++++++++++++++++++++++++++++
libdxfrw.spec | 12 +-
sources | 2 +-
4 files changed, 308 insertions(+), 5 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index f1da008..7c5a6db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/libdxfrw-0.5.7.tar.bz2
+/libdxfrw-0.5.11.tar.bz2
diff --git a/libdxfrw-0.5.11-librecad-changes.patch b/libdxfrw-0.5.11-librecad-changes.patch
new file mode 100644
index 0000000..7655afc
--- /dev/null
+++ b/libdxfrw-0.5.11-librecad-changes.patch
@@ -0,0 +1,298 @@
+diff -aur libdxfrw-0.5.11/src/drw_base.h libdxfrw/src/drw_base.h
+--- libdxfrw-0.5.11/src/drw_base.h 2013-12-29 04:37:22.000000000 -0600
++++ libdxfrw/src/drw_base.h 2014-05-29 22:54:17.000000000 -0500
+@@ -148,20 +148,26 @@
+ DRW_Variant() {
+ 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() {
+- 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) { if (type == COORD) delete content.v; type = t;}
+- void setCoordX(double d) { if (type == COORD) content.v->x = d;}
+- void setCoordY(double d) { if (type == COORD) content.v->y = d;}
+- void setCoordZ(double d) { if (type == COORD) content.v->z = d;}
++ void addCoord() {setType(COORD); vdata.x=0.0; vdata.y=0.0; vdata.z=0.0; content.v = &vdata;}
++ 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 {
+@@ -173,14 +179,12 @@
+
+ public:
+ DRW_VarContent content;
++ enum TYPE type;
++ int code; /*!< dxf code of this value*/
+
+-public:
+- int code;
+-// string version;
+-// string codepage;
+ private:
+-// DRW_VarContent content;
+- std::string data;
++ std::string sdata;
++ DRW_Coord vdata;
+ };
+
+
+diff -aur libdxfrw-0.5.11/src/drw_entities.cpp libdxfrw/src/drw_entities.cpp
+--- libdxfrw-0.5.11/src/drw_entities.cpp 2013-12-29 04:00:40.000000000 -0600
++++ libdxfrw/src/drw_entities.cpp 2014-05-29 22:54:17.000000000 -0500
+@@ -21,19 +21,30 @@
+ * @author Rallaz
+ */
+ 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();
+ }
+ //! Extrude a point using arbitary axis
+@@ -141,6 +152,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);
+ }
+@@ -157,6 +170,26 @@
+ }
+ }
+
++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) {
+ case 50:
+diff -aur libdxfrw-0.5.11/src/drw_entities.h libdxfrw/src/drw_entities.h
+--- libdxfrw-0.5.11/src/drw_entities.h 2013-12-29 04:34:59.000000000 -0600
++++ libdxfrw/src/drw_entities.h 2014-05-29 22:54:17.000000000 -0500
+@@ -223,7 +223,7 @@
+ isccw = 1;
+ }
+
+- virtual void applyExtrusion(){DRW_Circle::applyExtrusion();}
++ virtual void applyExtrusion();
+ void parseCode(int code, dxfReader *reader);
+
+ public:
+@@ -811,7 +811,7 @@
+ 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 */
++ int fade; /*!< Brightness value, code 283, (0-100) default 0 */
+
+ };
+
+@@ -1117,7 +1117,7 @@
+ void parseCode(int code, dxfReader *reader);
+
+ public:
+- UTF8STRING style; /*!< Dimension style name, code 3 */
++ 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 */
+diff -aur libdxfrw-0.5.11/src/drw_objects.cpp libdxfrw/src/drw_objects.cpp
+--- libdxfrw-0.5.11/src/drw_objects.cpp 2013-12-29 04:34:59.000000000 -0600
++++ libdxfrw/src/drw_objects.cpp 2014-05-29 22:54:17.000000000 -0500
+@@ -567,7 +567,7 @@
+ curr->code = code;
+ break;
+ case 10:
+- curr->addCoord(new DRW_Coord());
++ curr->addCoord();
+ curr->setCoordX(reader->getDouble());
+ curr->code = code;
+ break;
+@@ -922,6 +922,34 @@
+ #endif
+ }
+
++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;
+ std::map<std::string,DRW_Variant *>::iterator it;
+diff -aur libdxfrw-0.5.11/src/drw_objects.h libdxfrw/src/drw_objects.h
+--- libdxfrw-0.5.11/src/drw_objects.h 2013-12-29 04:34:59.000000000 -0600
++++ libdxfrw/src/drw_objects.h 2014-05-29 22:54:17.000000000 -0500
+@@ -187,10 +187,6 @@
+ 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
+ }
+
+ void parseCode(int code, dxfReader *reader);
+@@ -229,10 +225,10 @@
+ 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 */
+@@ -347,7 +343,7 @@
+
+ public:
+ std::string handle; /*!< entity identifier, code 5 */
+- UTF8STRING name; /*!< File name of image, code 1 */
++ 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 */
+@@ -362,7 +358,9 @@
+
+ //! 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 {
+@@ -370,13 +368,21 @@
+ DRW_Header() {
+ }
+ ~DRW_Header() {
++ for (std::map<std::string,DRW_Variant*>::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);
+@@ -388,7 +394,7 @@
+ private:
+ std::string comments;
+ std::string name;
+- DRW_Variant *curr;
++ DRW_Variant* curr;
+ int version; //to use on read
+ };
+
+diff -aur libdxfrw-0.5.11/src/intern/dxfreader.cpp libdxfrw/src/intern/dxfreader.cpp
+--- libdxfrw-0.5.11/src/intern/dxfreader.cpp 2013-12-29 04:00:40.000000000 -0600
++++ libdxfrw/src/intern/dxfreader.cpp 2014-05-29 22:54:17.000000000 -0500
+@@ -234,7 +234,7 @@
+ std::string text;
+ if (readString(&text)){
+ #if defined(__APPLE__)
+- int succeeded=sscanf( & (text[0]), "%lg", &doubleData);
++ int succeeded=sscanf( & (text[0]), "%lg", &doubleData);
+ if(succeeded != 1) {
+ DBG("dxfReaderAscii::readDouble(): reading double error: ");
+ DBG(text);
diff --git a/libdxfrw.spec b/libdxfrw.spec
index 9e556f6..c80a2fc 100644
--- a/libdxfrw.spec
+++ b/libdxfrw.spec
@@ -1,11 +1,11 @@
Name: libdxfrw
-Version: 0.5.7
-Release: 4%{?dist}
+Version: 0.5.11
+Release: 1%{?dist}
Summary: Library to read/write DXF files
License: GPLv2+
URL: http://sourceforge.net/p/libdxfrw/home/Home/
Source0: http://downloads.sourceforge.net/project/libdxfrw/%{name}-%{version}.tar.bz2
-Patch0: libdxfrw-0.5.7-librecad-2.0.0beta5-fixes.patch
+Patch0: libdxfrw-0.5.11-librecad-changes.patch
%description
libdxfrw is a free C++ library to read and write DXF files in both formats,
@@ -20,7 +20,7 @@ Development files for libdxfrw.
%prep
%setup -q
-%patch0 -p1 -b .librecad-2.0.0beta5
+%patch0 -p1 -b .librecad
%build
%configure --disable-static
@@ -44,6 +44,10 @@ rm -rf %{buildroot}%{_libdir}/*.la
%{_libdir}/pkgconfig/libdxfrw0.pc
%changelog
+* Mon Jun 2 2014 Tom Callaway <spot at fedoraproject.org> - 0.5.11-1
+- update to 0.5.11
+- resync with librecad changes
+
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.5.7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
diff --git a/sources b/sources
index d66155e..82a0dd0 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-1a43f4be6881d381a31a1e41bb4dc0cd libdxfrw-0.5.7.tar.bz2
+dca5469a553408e65f3e2ffb594e4d63 libdxfrw-0.5.11.tar.bz2
More information about the scm-commits
mailing list