mirror of https://github.com/vitalif/openscad
Handle CgaladvNodes
parent
11b1966cfb
commit
afd4a6adb8
|
@ -9,6 +9,7 @@
|
|||
#include "linearextrudenode.h"
|
||||
#include "rotateextrudenode.h"
|
||||
#include "csgnode.h"
|
||||
#include "cgaladvnode.h"
|
||||
#include "clipper-utils.h"
|
||||
#include "CGALEvaluator.h"
|
||||
#include "CGALCache.h"
|
||||
|
@ -157,10 +158,31 @@ void GeometryEvaluator::addToParent(const State &state,
|
|||
}
|
||||
|
||||
/*!
|
||||
Fallback: If we don't know how to handle a node, send it to CGAL
|
||||
*/
|
||||
Custom nodes are handled here => implicit union
|
||||
*/
|
||||
Response GeometryEvaluator::visit(State &state, const AbstractNode &node)
|
||||
{
|
||||
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
||||
if (state.isPostfix()) {
|
||||
shared_ptr<const class Geometry> geom;
|
||||
if (!isCached(node)) {
|
||||
const Geometry *geometry = applyToChildren2D(node, OPENSCAD_UNION);
|
||||
const Polygon2d *polygons = dynamic_cast<const Polygon2d*>(geometry);
|
||||
assert(polygons);
|
||||
geom.reset(geometry);
|
||||
}
|
||||
else {
|
||||
geom = GeometryCache::instance()->get(this->tree.getIdString(node));
|
||||
}
|
||||
addToParent(state, node, geom);
|
||||
// FIXME: if 3d node, CGAL?
|
||||
}
|
||||
return ContinueTraversal;
|
||||
}
|
||||
|
||||
/*
|
||||
FIXME: Where do we handle nodes which should be sent to CGAL?
|
||||
|
||||
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
||||
if (state.isPostfix()) {
|
||||
shared_ptr<const Geometry> geom;
|
||||
|
@ -178,7 +200,8 @@ Response GeometryEvaluator::visit(State &state, const AbstractNode &node)
|
|||
addToParent(state, node, geom);
|
||||
}
|
||||
return ContinueTraversal;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
Leaf nodes can create their own geometry, so let them do that
|
||||
|
@ -476,3 +499,29 @@ Response GeometryEvaluator::visit(State &state, const AbstractPolyNode &node)
|
|||
return ContinueTraversal;
|
||||
}
|
||||
|
||||
Response GeometryEvaluator::visit(State &state, const CgaladvNode &node)
|
||||
{
|
||||
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
||||
if (state.isPostfix()) {
|
||||
shared_ptr<const Geometry> geom;
|
||||
if (!isCached(node)) {
|
||||
// if (node.type == RESIZE) {
|
||||
// const Geometry *geometry = applyToChildren2D(node, OPENSCAD_UNION);
|
||||
// // FIXME: find size and transform
|
||||
// }
|
||||
// else {
|
||||
CGAL_Nef_polyhedron N = this->cgalevaluator->evaluateCGALMesh(node);
|
||||
CGALCache::instance()->insert(this->tree.getIdString(node), N);
|
||||
PolySet *ps = N.isNull() ? NULL : N.convertToPolyset();
|
||||
geom.reset(ps);
|
||||
// }
|
||||
// FIXME: handle 3D
|
||||
}
|
||||
else {
|
||||
geom = GeometryCache::instance()->get(this->tree.getIdString(node));
|
||||
}
|
||||
addToParent(state, node, geom);
|
||||
}
|
||||
return ContinueTraversal;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
virtual Response visit(State &state, const LeafNode &node);
|
||||
virtual Response visit(State &state, const TransformNode &node);
|
||||
virtual Response visit(State &state, const CsgNode &node);
|
||||
virtual Response visit(State &state, const CgaladvNode &node);
|
||||
|
||||
const Tree &getTree() const { return this->tree; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue