summaryrefslogtreecommitdiff
path: root/csgterm.cc
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-06-25 08:12:41 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-06-25 08:12:41 (GMT)
commit4f7d83c00fa2cd56d60cf399ccf848fdd63e1703 (patch)
tree81d5f09437bf0606bd4c0cf07b46dfda52407f08 /csgterm.cc
parentbea704f141c92d2076a0102556203dab0246e39f (diff)
Clifford Wolf:
Added CsgChain structure Added first OpenCSG demo code git-svn-id: http://svn.clifford.at/openscad/trunk@19 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'csgterm.cc')
-rw-r--r--csgterm.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/csgterm.cc b/csgterm.cc
index 826ec44..c1c6e14 100644
--- a/csgterm.cc
+++ b/csgterm.cc
@@ -164,3 +164,45 @@ QString CSGTerm::dump()
return QString("(%1 - %2)").arg(left->dump(), right->dump());
return label;
}
+
+CSGChain::CSGChain()
+{
+}
+
+void CSGChain::add(PolySet *polyset, CSGTerm::type_e type, QString label)
+{
+ polysets.append(polyset);
+ types.append(type);
+ labels.append(label);
+}
+
+void CSGChain::import(CSGTerm *term, CSGTerm::type_e type)
+{
+ if (term->type == CSGTerm::PRIMITIVE) {
+ add(term->polyset, type, term->label);
+ } else {
+ import(term->left, type);
+ import(term->right, term->type);
+ }
+}
+
+QString CSGChain::dump()
+{
+ QString text;
+ for (int i = 0; i < types.size(); i++)
+ {
+ if (types[i] == CSGTerm::UNION) {
+ if (i != 0)
+ text += "\n";
+ text += "+";
+ }
+ if (types[i] == CSGTerm::DIFFERENCE)
+ text += " -";
+ if (types[i] == CSGTerm::INTERSECTION)
+ text += " *";
+ text += labels[i];
+ }
+ text += "\n";
+ return text;
+}
+
contact: Jan Huwald // Impressum