diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-06-24 10:59:15 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-06-24 10:59:15 (GMT) |
commit | ba42e6c30be19004f0c4351f51005bc5e5dabdca (patch) | |
tree | 718836294c363f8b31e806954f252933a9871795 /csg.cc | |
parent | 12e8d77bc0e4a059feb0ead66de0a04a71fb8d67 (diff) |
Clifford Wolf:
Preps for OpenCSG interface
Invented AbstractPolyNode
git-svn-id: http://svn.clifford.at/openscad/trunk@15 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'csg.cc')
-rw-r--r-- | csg.cc | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -44,6 +44,9 @@ public: #ifdef ENABLE_CGAL virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; #endif +#ifdef ENABLE_OPENCSG + CSGTerm *render_csg_term(double m[16]) const; +#endif virtual QString dump(QString indent) const; }; @@ -82,9 +85,33 @@ CGAL_Nef_polyhedron CsgNode::render_cgal_nef_polyhedron() const #endif /* ENABLE_CGAL */ +#ifdef ENABLE_OPENCSG + +CSGTerm *CsgNode::render_csg_term(double m[16]) const +{ + CSGTerm *t1 = NULL; + foreach (AbstractNode *v, children) { + CSGTerm *t2 = v->render_csg_term(m); + if (t2 && !t1) { + t1 = t2; + } else if (t2 && t1) { + if (type == UNION) { + t1 = new CSGTerm(CSGTerm::UNION, t1, t2); + } else if (type == DIFFERENCE) { + t1 = new CSGTerm(CSGTerm::DIFFERENCE, t1, t2); + } else if (type == INTERSECTION) { + t1 = new CSGTerm(CSGTerm::INTERSECTION, t1, t2); + } + } + } + return t1; +} + +#endif /* ENABLE_OPENCSG */ + QString CsgNode::dump(QString indent) const { - QString text = indent; + QString text = indent + QString("n%1: ").arg(idx); if (type == UNION) text += "union() {\n"; if (type == DIFFERENCE) |