/* * interpreters interpretating module vectors */ #ifndef INTERP_H #define INTERP_H #include #include "lsys.h" #include "interface.h" #include "util.h" #include "matrix.h" #include // FIXME only for simple_interpreter using namespace std; class interpreter { protected: virtual void execute (const module_vec &v, const lsys &l) t_err abstract; virtual bool execute_child (const module &m, const lsys &l) t_err; public: virtual ~interpreter () t_no {}; virtual void operator ()(const module_vec &v, const lsys &l) t_err { execute (v, l); }; }; class simple_interpreter : public interpreter { int maxdepth; int depth; void execute(const module_vec &v, const lsys &l) t_err; public: simple_interpreter (int depth) t_no : maxdepth (depth) {}; void operator ()(const module_vec &v, const lsys &l) t_err; }; class turtle_interpreter : public interpreter { gfx_int &iface; bool flat; double delta, distance; struct state { vec pos; mat dir; /* H L U, up = normal */ attribute_set attr; }; state cur; stack state_stack; points cur_obj; stack obj_stack; void rotate_tl (double phi) t_no; void rotate_pd (double phi) t_no; void rotate_rl (double phi) t_no; void forward (double d) t_no; void attrs_changed () t_err; protected: void execute (const module_vec &v, const lsys &l) t_err; public: turtle_interpreter (gfx_int &interface, bool flat_world = false) t_no; ~turtle_interpreter () t_no {}; void operator ()(const module_vec &v, const lsys &l) t_err; }; #endif