diff options
Diffstat (limited to 'tests/cgalpngtest.cc')
-rw-r--r-- | tests/cgalpngtest.cc | 51 |
1 files changed, 10 insertions, 41 deletions
diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc index 734f6eb..e9e1f7b 100644 --- a/tests/cgalpngtest.cc +++ b/tests/cgalpngtest.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf <clifford@clifford.at> + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf <clifford@clifford.at> and + * Marius Kintel <marius@kintel.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +25,7 @@ */ #include "myqhash.h" +#include "tests-common.h" #include "openscad.h" #include "node.h" #include "module.h" @@ -40,7 +42,6 @@ #include "CGAL_renderer.h" #include "cgal.h" #include "OffscreenView.h" -#include "handle_dep.h" #include <QApplication> #include <QFile> @@ -99,8 +100,7 @@ int main(int argc, char **argv) const char *filename = argv[1]; const char *outfile = argv[2]; - initialize_builtin_functions(); - initialize_builtin_modules(); + Builtins::instance()->initialize(); QApplication app(argc, argv, false); QDir original_path = QDir::current(); @@ -127,47 +127,17 @@ int main(int argc, char **argv) } Context root_ctx; - root_ctx.functions_p = &builtin_functions; - root_ctx.modules_p = &builtin_modules; - root_ctx.set_variable("$fn", Value(0.0)); - root_ctx.set_variable("$fs", Value(1.0)); - root_ctx.set_variable("$fa", Value(12.0)); - root_ctx.set_variable("$t", Value(0.0)); - - Value zero3; - zero3.type = Value::VECTOR; - zero3.append(new Value(0.0)); - zero3.append(new Value(0.0)); - zero3.append(new Value(0.0)); - root_ctx.set_variable("$vpt", zero3); - root_ctx.set_variable("$vpr", zero3); - + register_builtin(root_ctx); AbstractModule *root_module; ModuleInstantiation root_inst; - QFileInfo fileInfo(filename); - handle_dep(filename); - FILE *fp = fopen(filename, "rt"); - if (!fp) { - fprintf(stderr, "Can't open input file `%s'!\n", filename); + root_module = parsefile(filename); + if (!root_module) { exit(1); - } else { - std::stringstream text; - char buffer[513]; - int ret; - while ((ret = fread(buffer, 1, 512, fp)) > 0) { - buffer[ret] = 0; - text << buffer; - } - fclose(fp); - text << commandline_commands; - root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false); - if (!root_module) { - exit(1); - } } + QFileInfo fileInfo(filename); QDir::setCurrent(fileInfo.absolutePath()); AbstractNode::resetIndexCounter(); @@ -241,8 +211,7 @@ int main(int argc, char **argv) csgInfo.glview->paintGL(); csgInfo.glview->save(outfile); - destroy_builtin_functions(); - destroy_builtin_modules(); + Builtins::instance(true); return 0; } |