summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-26 18:31:37 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-26 18:31:37 (GMT)
commit6535b16a31cf23d65f9c4c44a2e97dfdcdd69419 (patch)
treeecca4e1f641cdd5d75716b3ef41ba5ce282b6209 /src
parent6bac08c33a6c5111efe1f322ae8f6628403b3467 (diff)
enable root-modifier (! character) on gui-cmdline output. reduce duplicate code.
Diffstat (limited to 'src')
-rw-r--r--src/mainwin.cc4
-rw-r--r--src/node.cc11
-rw-r--r--src/node.h1
-rw-r--r--src/openscad.cc7
4 files changed, 21 insertions, 2 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) {
contact: Jan Huwald // Impressum