summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwin.cc4
-rw-r--r--src/node.cc11
-rw-r--r--src/node.h1
-rw-r--r--src/openscad.cc7
-rw-r--r--tests/cgalcachetest.cc4
-rw-r--r--tests/cgalpngtest.cc4
-rw-r--r--tests/cgalstlsanitytest.cc4
-rw-r--r--tests/cgaltest.cc4
-rw-r--r--tests/csgtestcore.cc4
9 files changed, 31 insertions, 12 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 251c6e1..d596186 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -576,14 +576,14 @@ void MainWindow::refreshDocument()
setCurrentOutput();
}
-AbstractNode *MainWindow::find_root_tag(AbstractNode *n)
+/*AbstractNode *MainWindow::find_root_tag(AbstractNode *n)
{
BOOST_FOREACH (AbstractNode *v, n->children) {
if (v->modinst->isRoot()) return v;
if (AbstractNode *vroot = find_root_tag(v)) return vroot;
}
return NULL;
-}
+}*/
/*!
Parse and evaluate the design => this->root_node
diff --git a/src/node.cc b/src/node.cc
index e61174f..4baf29a 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -32,6 +32,7 @@
#include <iostream>
#include <algorithm>
+#include <boost/foreach.hpp>
size_t AbstractNode::idx_counter;
@@ -101,3 +102,13 @@ std::ostream &operator<<(std::ostream &stream, const AbstractNode &node)
stream << node.toString();
return stream;
}
+
+AbstractNode *find_root_tag(AbstractNode *n)
+{
+ BOOST_FOREACH(AbstractNode *v, n->children) {
+ if (v->modinst->tag_root) return v;
+ if (AbstractNode *vroot = find_root_tag(v)) return vroot;
+ }
+ return NULL;
+}
+
diff --git a/src/node.h b/src/node.h
index 42547db..0b2221d 100644
--- a/src/node.h
+++ b/src/node.h
@@ -84,5 +84,6 @@ public:
};
std::ostream &operator<<(std::ostream &stream, const AbstractNode &node);
+AbstractNode *find_root_tag(AbstractNode *n);
#endif
diff --git a/src/openscad.cc b/src/openscad.cc
index 2f1c4d8..f796136 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -265,6 +265,7 @@ int main(int argc, char **argv)
Module *root_module;
ModuleInstantiation root_inst;
AbstractNode *root_node;
+ AbstractNode *absolute_root_node;
handle_dep(filename);
@@ -286,7 +287,13 @@ int main(int argc, char **argv)
fs::current_path(fparent);
AbstractNode::resetIndexCounter();
+ absolute_root_node = root_module->evaluate(&root_ctx, &root_inst);
root_node = root_module->evaluate(&root_ctx, &root_inst);
+
+ // Do we have an explicit root node (! modifier)?
+ if (!(root_node = find_root_tag(absolute_root_node)))
+ root_node = absolute_root_node;
+
tree.setRoot(root_node);
if (csg_output_file) {
diff --git a/tests/cgalcachetest.cc b/tests/cgalcachetest.cc
index 46e0e9a..7f24fc5 100644
--- a/tests/cgalcachetest.cc
+++ b/tests/cgalcachetest.cc
@@ -70,14 +70,14 @@ void cgalTree(Tree &tree)
evaluate.execute();
}
-AbstractNode *find_root_tag(AbstractNode *n)
+/*AbstractNode *find_root_tag(AbstractNode *n)
{
foreach(AbstractNode *v, n->children) {
if (v->modinst->tag_root) return v;
if (AbstractNode *vroot = find_root_tag(v)) return vroot;
}
return NULL;
-}
+}*/
po::variables_map parse_options(int argc, char *argv[])
{
diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc
index 56861c6..dd5084c 100644
--- a/tests/cgalpngtest.cc
+++ b/tests/cgalpngtest.cc
@@ -70,14 +70,14 @@ void cgalTree(Tree &tree)
evaluate.execute();
}
-AbstractNode *find_root_tag(AbstractNode *n)
+/*AbstractNode *find_root_tag(AbstractNode *n)
{
foreach(AbstractNode *v, n->children) {
if (v->modinst->tag_root) return v;
if (AbstractNode *vroot = find_root_tag(v)) return vroot;
}
return NULL;
-}
+}*/
struct CsgInfo
{
diff --git a/tests/cgalstlsanitytest.cc b/tests/cgalstlsanitytest.cc
index 52cfb41..ca44dc7 100644
--- a/tests/cgalstlsanitytest.cc
+++ b/tests/cgalstlsanitytest.cc
@@ -69,14 +69,14 @@ void cgalTree(Tree &tree)
evaluate.execute();
}
-AbstractNode *find_root_tag(AbstractNode *n)
+/*AbstractNode *find_root_tag(AbstractNode *n)
{
foreach(AbstractNode *v, n->children) {
if (v->modinst->tag_root) return v;
if (AbstractNode *vroot = find_root_tag(v)) return vroot;
}
return NULL;
-}
+}*/
int main(int argc, char **argv)
{
diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc
index b546286..5131f17 100644
--- a/tests/cgaltest.cc
+++ b/tests/cgaltest.cc
@@ -65,14 +65,14 @@ void cgalTree(Tree &tree)
evaluate.execute();
}
-AbstractNode *find_root_tag(AbstractNode *n)
+/*AbstractNode *find_root_tag(AbstractNode *n)
{
foreach(AbstractNode *v, n->children) {
if (v->modinst->tag_root) return v;
if (AbstractNode *vroot = find_root_tag(v)) return vroot;
}
return NULL;
-}
+}*/
int main(int argc, char **argv)
{
diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc
index acc7c31..7a031f3 100644
--- a/tests/csgtestcore.cc
+++ b/tests/csgtestcore.cc
@@ -65,14 +65,14 @@ CsgInfo::CsgInfo() {
glview = NULL;
}
-AbstractNode *find_root_tag(AbstractNode *n)
+/*AbstractNode *find_root_tag(AbstractNode *n)
{
foreach(AbstractNode *v, n->children) {
if (v->modinst->tag_root) return v;
if (AbstractNode *vroot = find_root_tag(v)) return vroot;
}
return NULL;
-}
+}*/
string info_dump(OffscreenView *glview)
{
contact: Jan Huwald // Impressum