summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-07-23 16:00:38 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-07-23 16:00:38 (GMT)
commitf158370f5ef5745c273f2f47c57b77d1fcc2f0db (patch)
tree3051b31f73816d6062f12cf6ed4bb269b83dc077
parent7516cd5e8150e7f6850179ace35622b186237401 (diff)
Clifford Wolf:
Fixed dxf caching Fixed dxf unsupported entity reporting Fixed dumping of vector expressions git-svn-id: http://svn.clifford.at/openscad/trunk@70 b57f626f-c46c-0410-a088-ec61d464b74c
-rw-r--r--dxfdata.cc27
-rw-r--r--dxflinextrude.cc16
-rw-r--r--dxfrotextrude.cc16
-rw-r--r--expr.cc11
4 files changed, 49 insertions, 21 deletions
diff --git a/dxfdata.cc b/dxfdata.cc
index 190e701..157efa3 100644
--- a/dxfdata.cc
+++ b/dxfdata.cc
@@ -64,10 +64,12 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
switch (id)
{
case 0:
- if (mode == "LINE" && (layername.isNull() || layername == layer)) {
+ if (in_entities_section && mode == "LINE" &&
+ (layername.isNull() || layername == layer)) {
ADD_LINE(x1, y1, x2, y2);
}
- if (mode == "CIRCLE" && (layername.isNull() || layername == layer)) {
+ if (in_entities_section && mode == "CIRCLE" &&
+ (layername.isNull() || layername == layer)) {
int n = get_fragments_from_r(radius, fn, fs, fa);
for (int i = 0; i < n; i++) {
double a1 = (2*M_PI*i)/n;
@@ -76,7 +78,8 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
cos(a2)*radius + x1, sin(a2)*radius + y1);
}
}
- if (mode == "ARC" && (layername.isNull() || layername == layer)) {
+ if (in_entities_section && mode == "ARC" &&
+ (layername.isNull() || layername == layer)) {
int n = get_fragments_from_r(radius, fn, fs, fa);
while (start_angle > stop_angle)
stop_angle += 360.0;
@@ -90,10 +93,11 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
cos(a2)*radius + x1, sin(a2)*radius + y1);
}
}
- if (in_entities_section) {
- if (data != "SECTION" && data != "ENDSEC" &&
- data != "LINE" && data != "ARC" && data != "CIRCLE")
- unsupported_entities_list[data]++;
+ if (in_entities_section &&
+ (layername.isNull() || layername == layer)) {
+ if (mode != "SECTION" && mode != "ENDSEC" &&
+ mode != "LINE" && mode != "ARC" && mode != "CIRCLE")
+ unsupported_entities_list[mode]++;
}
mode = data;
break;
@@ -129,8 +133,13 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
QHashIterator<QString, int> i(unsupported_entities_list);
while (i.hasNext()) {
i.next();
- PRINTA("WARNING: Unsupported DXF Entity `%1' (%2x) in `%3'.",
- i.key(), QString::number(i.value()), filename);
+ if (layername.isNull()) {
+ PRINTA("WARNING: Unsupported DXF Entity `%1' (%2x) in `%3'.",
+ i.key(), QString::number(i.value()), filename);
+ } else {
+ PRINTA("WARNING: Unsupported DXF Entity `%1' (%2x) in layer `%3' of `%4'.",
+ i.key(), QString::number(i.value()), layername, filename);
+ }
}
QHash<int, int> enabled_lines;
diff --git a/dxflinextrude.cc b/dxflinextrude.cc
index 3fb1ece..09d98d1 100644
--- a/dxflinextrude.cc
+++ b/dxflinextrude.cc
@@ -22,6 +22,10 @@
#include "openscad.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
class DxfLinearExtrudeModule : public AbstractModule
{
public:
@@ -176,11 +180,13 @@ QString DxfLinearExtrudeNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
QString text;
- text.sprintf("dxf_linear_extrude(file = \"%s\", layer = \"%s\", height = %f, "
- "origin = [ %f %f ], scale = %f, "
- "$fn = %f, $fa = %f, $fs = %f);\n",
- filename.toAscii().data(), layername.toAscii().data(),
- height, origin_x, origin_y, scale, fn, fs, fa);
+ struct stat st;
+ memset(&st, 0, sizeof(struct stat));
+ stat(filename.toAscii().data(), &st);
+ text.sprintf("dxf_linear_extrude(file = \"%s\", cache = \"%x.%x\", layer = \"%s\", height = %f, "
+ "origin = [ %f %f ], scale = %f, $fn = %f, $fa = %f, $fs = %f);\n",
+ filename.toAscii().data(), (int)st.st_mtime, (int)st.st_size,
+ layername.toAscii().data(), height, origin_x, origin_y, scale, fn, fs, fa);
((AbstractNode*)this)->dump_cache = indent + QString("n%1: ").arg(idx) + text;
}
return dump_cache;
diff --git a/dxfrotextrude.cc b/dxfrotextrude.cc
index 3bb1ccd..a622b91 100644
--- a/dxfrotextrude.cc
+++ b/dxfrotextrude.cc
@@ -22,6 +22,10 @@
#include "openscad.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
class DxfRotateExtrudeModule : public AbstractModule
{
public:
@@ -154,11 +158,13 @@ QString DxfRotateExtrudeNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
QString text;
- text.sprintf("dxf_rotate_extrude(file = \"%s\", layer = \"%s\", "
- "origin = [ %f %f ], scale = %f, "
- "$fn = %f, $fa = %f, $fs = %f);\n",
- filename.toAscii().data(), layername.toAscii().data(),
- origin_x, origin_y, scale, fn, fs, fa);
+ struct stat st;
+ memset(&st, 0, sizeof(struct stat));
+ stat(filename.toAscii().data(), &st);
+ text.sprintf("dxf_rotate_extrude(file = \"%s\", cache = \"%x.%x\", layer = \"%s\", "
+ "origin = [ %f %f ], scale = %f, $fn = %f, $fa = %f, $fs = %f);\n",
+ filename.toAscii().data(), (int)st.st_mtime, (int)st.st_size,
+ layername.toAscii().data(), origin_x, origin_y, scale, fn, fs, fa);
((AbstractNode*)this)->dump_cache = indent + QString("n%1: ").arg(idx) + text;
}
return dump_cache;
diff --git a/expr.cc b/expr.cc
index 81fe7b3..e20e977 100644
--- a/expr.cc
+++ b/expr.cc
@@ -150,8 +150,15 @@ QString Expression::dump() const
return const_value->dump();
if (type == "R")
return QString("[%1 : %2 : %3]").arg(children[0]->dump(), children[1]->dump(), children[2]->dump());
- if (type == "V")
- return QString("[%1, %2, %3]").arg(children[0]->dump(), children[1]->dump(), children[2]->dump());
+ if (type == "V") {
+ QString text = QString("[");
+ for (int i=0; i < children.size(); i++) {
+ if (i > 0)
+ text += QString(", ");
+ text += children[i]->dump();
+ }
+ return text + QString("]");
+ }
if (type == "L")
return var_name;
if (type == "N")
contact: Jan Huwald // Impressum