summaryrefslogtreecommitdiff
path: root/test-code
diff options
context:
space:
mode:
Diffstat (limited to 'test-code')
-rwxr-xr-xtest-code/batch-cgal-tests.sh9
-rwxr-xr-xtest-code/batch-cgal.sh14
-rwxr-xr-xtest-code/batch-dump.sh16
-rw-r--r--test-code/exportdxf.cc (renamed from test-code/dumptest.cc)54
-rw-r--r--test-code/exportdxf.pro (renamed from test-code/dumptest.pro)71
5 files changed, 80 insertions, 84 deletions
diff --git a/test-code/batch-cgal-tests.sh b/test-code/batch-cgal-tests.sh
deleted file mode 100755
index 12b8fe1..0000000
--- a/test-code/batch-cgal-tests.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-cmd="./cgaltest"
-
-for f in ../testdata/scad/*-tests.scad; do
- echo == `basename $f .scad` ==
- "$cmd" "$f"
-done
-
diff --git a/test-code/batch-cgal.sh b/test-code/batch-cgal.sh
deleted file mode 100755
index 031020d..0000000
--- a/test-code/batch-cgal.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-cmd="./cgaltest"
-
-if [ $# == 0 ]; then
- dir=../testdata/scad
-else
- dir=$1
-fi
-
-for f in $dir/*.scad; do
- echo == `basename $f` ==
- "$cmd" "$f"
-done
diff --git a/test-code/batch-dump.sh b/test-code/batch-dump.sh
deleted file mode 100755
index e8c9cd5..0000000
--- a/test-code/batch-dump.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-cmd="./dumptest"
-
-if [ $# == 0 ]; then
- dir=../testdata/scad
-else
- dir=$1
-fi
-
-echo $dir;
-
-for f in $dir/*.scad; do
- echo `basename $f`
- "$cmd" "$f"
-done
diff --git a/test-code/dumptest.cc b/test-code/exportdxf.cc
index 2cb8f12..97d6f49 100644
--- a/test-code/dumptest.cc
+++ b/test-code/exportdxf.cc
@@ -1,7 +1,6 @@
/*
- * OpenSCAD (www.openscad.org)
- * Copyright (C) 2009-2011 Clifford Wolf <clifford@clifford.at> and
- * Marius Kintel <marius@kintel.net>
+ * OpenSCAD (www.openscad.at)
+ * Copyright (C) 2009 Clifford Wolf <clifford@clifford.at>
*
* 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 +23,7 @@
*
*/
+#include "myqhash.h"
#include "openscad.h"
#include "node.h"
#include "module.h"
@@ -31,13 +31,17 @@
#include "value.h"
#include "export.h"
#include "builtin.h"
-//#include "nodedumper.h"
+#include "Tree.h"
+#include "CGALRenderer.h"
+#include "PolySetCGALRenderer.h"
#include <QApplication>
#include <QFile>
#include <QDir>
#include <QSet>
+#include <QTextStream>
#include <getopt.h>
+#include <iostream>
QString commandline_commands;
const char *make_command = NULL;
@@ -46,6 +50,8 @@ QString currentdir;
QString examplesdir;
QString librarydir;
+using std::string;
+
void handle_dep(QString filename)
{
if (filename.startsWith("/"))
@@ -59,6 +65,18 @@ void handle_dep(QString filename)
}
}
+// FIXME: enforce some maximum cache size (old version had 100K vertices as limit)
+QHash<std::string, CGAL_Nef_polyhedron> cache;
+
+void cgalTree(Tree &tree)
+{
+ assert(tree.root());
+
+ CGALRenderer renderer(cache, tree);
+ Traverser render(renderer, *tree.root(), Traverser::PRE_AND_POSTFIX);
+ render.execute();
+}
+
int main(int argc, char **argv)
{
if (argc != 2) {
@@ -144,22 +162,18 @@ int main(int argc, char **argv)
AbstractNode::resetIndexCounter();
root_node = root_module->evaluate(&root_ctx, &root_inst);
- // Cache test
- QString dumpstr = root_node->dump("");
- QString dumpstr_cached = root_node->dump("");
- if (dumpstr != dumpstr_cached) rc = 1;
-
- printf(dumpstr.toUtf8());
-
-#if 0
- NodeDumper dumper;
- Traverser trav(dumper, *root_node, Traverser::PRE_AND_POSTFIX);
- trav.execute();
- std::string dumpstdstr = dumper.getDump();
- trav.execute();
- std::string dumpstdstr_cached = dumper.getDump();
- if (dumpstdstr != dumpstdstr_cached) rc = 1;
-#endif
+ Tree tree;
+ tree.setRoot(root_node);
+
+ cgalTree(tree);
+
+ CGAL_Nef_polyhedron N = cache[tree.getString(*root_node)];
+
+ QDir::setCurrent(original_path.absolutePath());
+ QTextStream outstream(stdout);
+ export_dxf(&N, outstream, NULL);
+
+ PolySetRenderer::setRenderer(NULL);
destroy_builtin_functions();
destroy_builtin_modules();
diff --git a/test-code/dumptest.pro b/test-code/exportdxf.pro
index a6729f7..62c2734 100644
--- a/test-code/dumptest.pro
+++ b/test-code/exportdxf.pro
@@ -1,38 +1,30 @@
DEFINES += OPENSCAD_VERSION=test
TEMPLATE = app
-OBJECTS_DIR = objects
-MOC_DIR = objects
-UI_DIR = objects
-RCC_DIR = objects
+OBJECTS_DIR = cgal-objects
+MOC_DIR = cgal-objects
+UI_DIR = cgal-objects
+RCC_DIR = cgal-objects
INCLUDEPATH += ../src
-TARGET = dumptest
macx {
+ macx {
+ DEPLOYDIR = $$(MACOSX_DEPLOY_DIR)
+ !isEmpty(DEPLOYDIR) {
+ INCLUDEPATH += $$DEPLOYDIR/include
+ LIBS += -L$$DEPLOYDIR/lib
+ }
+ }
CONFIG -= app_bundle
LIBS += -framework Carbon
}
CONFIG += qt
QT += opengl
+CONFIG += cgal
-# Optionally specify location of Eigen2 using the
-# EIGEN2DIR env. variable
-EIGEN2_DIR = $$(EIGEN2DIR)
-!isEmpty(EIGEN2_DIR) {
- INCLUDEPATH += $$EIGEN2_DIR
-}
-else {
- macx {
- INCLUDEPATH += /opt/local/include/eigen2
- }
- else {
- INCLUDEPATH += /usr/include/eigen2
- }
-}
-FORMS += ../src/Preferences.ui
-HEADERS += ../src/Preferences.h
-SOURCES += ../src/Preferences.cc
+include(../cgal.pri)
+include(../eigen2.pri)
LEXSOURCES += ../src/lexer.l
YACCSOURCES += ../src/parser.y
@@ -50,13 +42,32 @@ HEADERS += ../src/builtin.h \
../src/grid.h \
../src/module.h \
../src/node.h \
+ ../src/dxflinextrudenode.h \
+ ../src/dxfrotextrudenode.h \
+ ../src/projectionnode.h \
+ ../src/importnode.h \
+ ../src/csgnode.h \
+ ../src/transformnode.h \
+ ../src/rendernode.h \
../src/openscad.h \
../src/polyset.h \
../src/printutils.h \
../src/value.h \
- ../src/progress.h
+ ../src/progress.h \
+ ../src/traverser.h \
+ ../src/csgnode.h \
+ ../src/visitor.h \
+ ../src/nodedumper.h \
+ ../src/CGALRenderer.h \
+ ../src/nodecache.h \
+ ../src/importnode.h \
+ ../src/state.h \
+ ../src/PolySetRenderer.h \
+ ../src/PolySetCGALRenderer.h \
+ ../src/myqhash.h \
+ ../src/Tree.h
-SOURCES += dumptest.cc \
+SOURCES += exportdxf.cc \
../src/export.cc \
../src/value.cc \
../src/expr.cc \
@@ -71,11 +82,14 @@ SOURCES += dumptest.cc \
../src/primitives.cc \
../src/projection.cc \
../src/cgaladv.cc \
+ ../src/cgaladv_minkowski2.cc \
+ ../src/cgaladv_minkowski3.cc \
../src/surface.cc \
../src/control.cc \
../src/render.cc \
../src/import.cc \
../src/dxfdata.cc \
+ ../src/nef2dxf.cc \
../src/dxftess.cc \
../src/dxftess-glu.cc \
../src/dxftess-cgal.cc \
@@ -83,4 +97,11 @@ SOURCES += dumptest.cc \
../src/dxflinextrude.cc \
../src/dxfrotextrude.cc \
../src/printutils.cc \
- ../src/progress.cc
+ ../src/progress.cc \
+ ../src/nodedumper.cc \
+ ../src/CGALRenderer.cc \
+ ../src/traverser.cc \
+ ../src/PolySetRenderer.cc \
+ ../src/PolySetCGALRenderer.cc \
+ ../src/qhash.cc \
+ ../src/Tree.cc
contact: Jan Huwald // Impressum