openscad/src/CGALEvaluator.h

56 lines
1.8 KiB
C
Raw Normal View History

#ifndef CGALEVALUATOR_H_
#define CGALEVALUATOR_H_
2010-03-19 06:07:01 +03:00
#include "myqhash.h"
2010-09-07 04:01:51 +04:00
#include "visitor.h"
#include "Tree.h"
#include "CGAL_Nef_polyhedron.h"
#include "PolySetCGALEvaluator.h"
2010-03-19 06:07:01 +03:00
#include <string>
#include <map>
#include <list>
2010-03-29 05:31:47 +04:00
2010-03-19 06:07:01 +03:00
using std::string;
using std::map;
using std::list;
using std::pair;
class CGALEvaluator : public Visitor
2010-03-19 06:07:01 +03:00
{
public:
2011-09-07 00:03:52 +04:00
enum CsgOp {CGE_UNION, CGE_INTERSECTION, CGE_DIFFERENCE, CGE_MINKOWSKI};
// FIXME: If a cache is not given, we need to fix this ourselves
CGALEvaluator(QHash<string, CGAL_Nef_polyhedron> &cache, const Tree &tree) : cache(cache), tree(tree), psevaluator(*this) {}
virtual ~CGALEvaluator() {}
2010-03-19 06:07:01 +03:00
2010-09-07 04:01:51 +04:00
virtual Response visit(State &state, const AbstractNode &node);
virtual Response visit(State &state, const AbstractIntersectionNode &node);
virtual Response visit(State &state, const CsgNode &node);
virtual Response visit(State &state, const TransformNode &node);
virtual Response visit(State &state, const AbstractPolyNode &node);
2011-09-06 16:57:24 +04:00
virtual Response visit(State &state, const CgaladvNode &node);
2010-03-19 06:07:01 +03:00
CGAL_Nef_polyhedron evaluateCGALMesh(const AbstractNode &node);
CGAL_Nef_polyhedron evaluateCGALMesh(const PolySet &polyset);
2010-03-29 05:31:47 +04:00
const Tree &getTree() const { return this->tree; }
2010-03-19 06:07:01 +03:00
private:
void addToParent(const State &state, const AbstractNode &node);
2010-03-29 05:31:47 +04:00
bool isCached(const AbstractNode &node) const;
void process(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedron &src, CGALEvaluator::CsgOp op);
void applyToChildren(const AbstractNode &node, CGALEvaluator::CsgOp op);
2011-09-07 00:03:52 +04:00
void applyHull(const CgaladvNode &node);
2010-03-19 06:07:01 +03:00
string currindent;
typedef list<pair<const AbstractNode *, string> > ChildList;
2010-03-19 06:07:01 +03:00
map<int, ChildList> visitedchildren;
QHash<string, CGAL_Nef_polyhedron> &cache;
const Tree &tree;
PolySetCGALEvaluator psevaluator;
2010-03-19 06:07:01 +03:00
};
#endif