diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-06-25 08:12:41 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-06-25 08:12:41 (GMT) |
commit | 4f7d83c00fa2cd56d60cf399ccf848fdd63e1703 (patch) | |
tree | 81d5f09437bf0606bd4c0cf07b46dfda52407f08 /csgterm.cc | |
parent | bea704f141c92d2076a0102556203dab0246e39f (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.cc | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -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; +} + |