2011-07-31 03:58:51 +04:00
|
|
|
#ifndef CGALEVALUATOR_H_
|
|
|
|
#define CGALEVALUATOR_H_
|
2010-03-19 06:07:01 +03:00
|
|
|
|
2010-04-12 08:57:02 +04:00
|
|
|
#include "myqhash.h"
|
2010-09-07 04:01:51 +04:00
|
|
|
#include "visitor.h"
|
|
|
|
#include "Tree.h"
|
2011-09-01 06:09:06 +04:00
|
|
|
#include "CGAL_Nef_polyhedron.h"
|
2011-07-31 03:58:51 +04:00
|
|
|
#include "PolySetCGALEvaluator.h"
|
2010-04-12 08:57:02 +04:00
|
|
|
|
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;
|
|
|
|
|
2011-07-31 03:58:51 +04:00
|
|
|
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};
|
2010-04-12 04:16:36 +04:00
|
|
|
// FIXME: If a cache is not given, we need to fix this ourselves
|
2011-07-31 03:58:51 +04:00
|
|
|
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
|
|
|
|
2011-07-31 03:58:51 +04:00
|
|
|
CGAL_Nef_polyhedron evaluateCGALMesh(const AbstractNode &node);
|
|
|
|
CGAL_Nef_polyhedron evaluateCGALMesh(const PolySet &polyset);
|
2010-03-29 05:31:47 +04:00
|
|
|
|
2010-11-03 21:26:06 +03:00
|
|
|
const Tree &getTree() const { return this->tree; }
|
|
|
|
|
2010-03-19 06:07:01 +03:00
|
|
|
private:
|
2010-03-28 19:57:39 +04:00
|
|
|
void addToParent(const State &state, const AbstractNode &node);
|
2010-03-29 05:31:47 +04:00
|
|
|
bool isCached(const AbstractNode &node) const;
|
2011-07-31 03:58:51 +04:00
|
|
|
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;
|
2010-04-12 08:57:02 +04:00
|
|
|
typedef list<pair<const AbstractNode *, string> > ChildList;
|
2010-03-19 06:07:01 +03:00
|
|
|
map<int, ChildList> visitedchildren;
|
|
|
|
|
2010-04-12 08:57:02 +04:00
|
|
|
QHash<string, CGAL_Nef_polyhedron> &cache;
|
|
|
|
const Tree &tree;
|
2011-07-31 03:58:51 +04:00
|
|
|
PolySetCGALEvaluator psevaluator;
|
2010-03-19 06:07:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|