summaryrefslogtreecommitdiff
path: root/src/node.h
diff options
context:
space:
mode:
authorMarius Kintel <kintel@sim.no>2010-03-02 18:22:31 (GMT)
committerMarius Kintel <marius@kintel.net>2010-10-31 00:42:34 (GMT)
commit393c5a19fedfa4f97ca939fbcf52c2ccab1cde6a (patch)
treefbcb75d32e8763aac3f0ad28528936a0ec11930b /src/node.h
parent746159d1838e895e80725cdc892f7bef85feb1af (diff)
Committed current version of visitor refactoring
Diffstat (limited to 'src/node.h')
-rw-r--r--src/node.h42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/node.h b/src/node.h
index 2e1d718..08a5cb1 100644
--- a/src/node.h
+++ b/src/node.h
@@ -8,6 +8,8 @@
#include "cgal.h"
#endif
+#include "traverser.h"
+
extern int progress_report_count;
extern void (*progress_report_f)(const class AbstractNode*, void*, int);
extern void *progress_report_vp;
@@ -19,20 +21,31 @@ class AbstractNode
{
static int idx_counter; // Node instantiation index
public:
+ AbstractNode(const class ModuleInstantiation *mi);
+ virtual ~AbstractNode();
+ virtual Response accept(const class State &state, class Visitor &visitor) const;
+ virtual std::string toString() const;
+
+ // FIXME: Make return value a reference
+ const std::list<AbstractNode*> getChildren() const {
+ return this->children.toList().toStdList();
+ }
+ int index() const { return this->idx; }
+
static void resetIndexCounter() { idx_counter = 1; }
QVector<AbstractNode*> children;
- const class ModuleInstantiation *modinst;
-
+ const ModuleInstantiation *modinst;
+
int progress_mark;
void progress_prepare();
void progress_report() const;
- int idx;
+ int idx; // Node index (unique per tree)
QString dump_cache;
- AbstractNode(const ModuleInstantiation *mi);
- virtual ~AbstractNode();
+
+
virtual QString mk_cache_id() const;
#ifdef ENABLE_CGAL
struct cgal_nef_cache_entry {
@@ -41,7 +54,7 @@ public:
cgal_nef_cache_entry(const CGAL_Nef_polyhedron &N);
};
static QCache<QString, cgal_nef_cache_entry> cgal_nef_cache;
- virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const;
+ virtual CGAL_Nef_polyhedron renderCSGMesh() const;
class CSGTerm *render_csg_term_from_nef(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background, const char *statement, int convexity) const;
#endif
virtual class CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
@@ -52,8 +65,12 @@ class AbstractIntersectionNode : public AbstractNode
{
public:
AbstractIntersectionNode(const ModuleInstantiation *mi) : AbstractNode(mi) { };
+ virtual ~AbstractIntersectionNode() { };
+ virtual Response accept(const class State &state, class Visitor &visitor) const;
+ virtual std::string toString() const;
+
#ifdef ENABLE_CGAL
- virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const;
+ virtual CGAL_Nef_polyhedron renderCSGMesh() const;
#endif
virtual CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
virtual QString dump(QString indent) const;
@@ -62,17 +79,24 @@ public:
class AbstractPolyNode : public AbstractNode
{
public:
+ AbstractPolyNode(const ModuleInstantiation *mi) : AbstractNode(mi) { };
+ virtual ~AbstractPolyNode() { };
+ virtual Response accept(const class State &state, class Visitor &visitor) const;
+
enum render_mode_e {
RENDER_CGAL,
RENDER_OPENCSG
};
- AbstractPolyNode(const ModuleInstantiation *mi) : AbstractNode(mi) { };
virtual class PolySet *render_polyset(render_mode_e mode) const = 0;
#ifdef ENABLE_CGAL
- virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const;
+ virtual CGAL_Nef_polyhedron renderCSGMesh() const;
#endif
virtual CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
static CSGTerm *render_csg_term_from_ps(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background, PolySet *ps, const ModuleInstantiation *modinst, int idx);
};
+std::ostream &operator<<(std::ostream &stream, const AbstractNode &node);
+// FIXME: Doesn't belong here..
+std::ostream &operator<<(std::ostream &stream, const QString &str);
+
#endif
contact: Jan Huwald // Impressum