openscad/src/CGALEvaluator.h

52 lines
1.8 KiB
C
Raw Normal View History

#ifndef CGALEVALUATOR_H_
#define CGALEVALUATOR_H_
2010-03-19 06:07:01 +03:00
2010-09-07 04:01:51 +04:00
#include "visitor.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
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};
2011-10-01 03:36:30 +04:00
CGALEvaluator(const class Tree &tree) : 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, const CGAL_Nef_polyhedron &N);
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);
2011-09-11 12:51:55 +04:00
CGAL_Nef_polyhedron applyToChildren(const AbstractNode &node, CGALEvaluator::CsgOp op);
CGAL_Nef_polyhedron applyHull(const CgaladvNode &node);
CGAL_Nef_polyhedron applyResize(const CgaladvNode &node);
2010-03-19 06:07:01 +03:00
typedef std::pair<const AbstractNode *, CGAL_Nef_polyhedron> ChildItem;
typedef std::list<ChildItem> ChildList;
2011-10-01 03:36:30 +04:00
std::map<int, ChildList> visitedchildren;
2010-03-19 06:07:01 +03:00
const Tree &tree;
CGAL_Nef_polyhedron root;
public:
// FIXME: Do we need to make this visible? Used for cache management
// Note: psevaluator constructor needs this->tree to be initialized first
PolySetCGALEvaluator psevaluator;
2010-03-19 06:07:01 +03:00
};
#endif