summaryrefslogtreecommitdiff
path: root/src/import.cc
diff options
context:
space:
mode:
authorMarius Kintel <kintel@sim.no>2010-03-02 18:22:31 (GMT)
committerMarius Kintel <marius@kintel.net>2010-10-31 00:42:34 (GMT)
commit393c5a19fedfa4f97ca939fbcf52c2ccab1cde6a (patch)
treefbcb75d32e8763aac3f0ad28528936a0ec11930b /src/import.cc
parent746159d1838e895e80725cdc892f7bef85feb1af (diff)
Committed current version of visitor refactoring
Diffstat (limited to 'src/import.cc')
-rw-r--r--src/import.cc60
1 files changed, 39 insertions, 21 deletions
diff --git a/src/import.cc b/src/import.cc
index bab13ae..5d0a497 100644
--- a/src/import.cc
+++ b/src/import.cc
@@ -23,8 +23,9 @@
*
*/
+#include "importnode.h"
+
#include "module.h"
-#include "node.h"
#include "polyset.h"
#include "context.h"
#include "builtin.h"
@@ -36,12 +37,7 @@
#include <QFile>
#include <sys/types.h>
#include <sys/stat.h>
-
-enum import_type_e {
- TYPE_STL,
- TYPE_OFF,
- TYPE_DXF
-};
+#include <sstream>
class ImportModule : public AbstractModule
{
@@ -51,20 +47,6 @@ public:
virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const;
};
-class ImportNode : public AbstractPolyNode
-{
-public:
- import_type_e type;
- QString filename;
- QString layername;
- int convexity;
- double fn, fs, fa;
- double origin_x, origin_y, scale;
- ImportNode(const ModuleInstantiation *mi, import_type_e type) : AbstractPolyNode(mi), type(type) { }
- virtual PolySet *render_polyset(render_mode_e mode) const;
- virtual QString dump(QString indent) const;
-};
-
AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
{
ImportNode *node = new ImportNode(inst, type);
@@ -231,3 +213,39 @@ QString ImportNode::dump(QString indent) const
return dump_cache;
}
+std::string ImportNode::toString() const
+{
+ std::stringstream stream;
+ stream << "n" << this->index() << ": ";
+
+ QString text;
+ struct stat st;
+ memset(&st, 0, sizeof(struct stat));
+ stat(this->filename.toAscii().data(), &st);
+
+ switch (this->type) {
+ case TYPE_STL:
+ stream << "import_stl(file = \"" << this->filename << "\", "
+ "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", "
+ "convexity = " << std::dec << this->convexity << ")";
+ break;
+ case TYPE_OFF:
+ stream << "import_off(file = \"" << this->filename << "\", "
+ "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", "
+ "convexity = " << std::dec << this->convexity << ")";
+ break;
+ case TYPE_DXF:
+ stream << "import_dxf(file = \"" << this->filename << "\", "
+ "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", "
+ "layer = \"" << this->layername << "\", "
+ "origin = [ " << std::dec << this->origin_x << " " << this->origin_y << " ], "
+ "scale = " << this->scale << ", "
+ "convexity = " << this->convexity << ", "
+ "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")";
+ break;
+ default:
+ assert(false);
+ }
+
+ return stream.str();
+}
contact: Jan Huwald // Impressum