From 0e7c6473fa6541fee741d0019ba498747fd6e364 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 6 Sep 2011 18:31:22 +0200 Subject: [PATCH] Implemented render() --- src/CSGTermEvaluator.cc | 13 +++++++++++-- src/PolySetCGALEvaluator.cc | 8 ++++++++ src/PolySetCGALEvaluator.h | 1 + src/PolySetEvaluator.h | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/CSGTermEvaluator.cc b/src/CSGTermEvaluator.cc index b59f4dbd..f280b2b5 100644 --- a/src/CSGTermEvaluator.cc +++ b/src/CSGTermEvaluator.cc @@ -178,9 +178,18 @@ Response CSGTermEvaluator::visit(State &state, const ColorNode &node) // FIXME: If we've got CGAL support, render this node as a CGAL union into a PolySet Response CSGTermEvaluator::visit(State &state, const RenderNode &node) { - PRINT("WARNING: render() statement not implemented"); if (state.isPostfix()) { - applyToChildren(node, CSGT_UNION); + CSGTerm *t1 = NULL; + // FIXME: Calling evaluator directly since we're not a PolyNode. Generalize this. + PolySet *ps = NULL; + if (this->psevaluator) { + ps = this->psevaluator->evaluatePolySet(node, AbstractPolyNode::RENDER_OPENCSG); + } + if (ps) { + t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background, + ps, node.modinst, node); + } + this->stored_term[node.index()] = t1; addToParent(state, node); } return ContinueTraversal; diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index c42d8069..c7ce979f 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -6,6 +6,7 @@ #include "dxflinextrudenode.h" #include "dxfrotextrudenode.h" #include "cgaladvnode.h" +#include "rendernode.h" #include "dxfdata.h" #include "dxftess.h" #include "module.h" @@ -376,6 +377,13 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const CgaladvNode &node, Abstract return ps; } +PolySet *PolySetCGALEvaluator::evaluatePolySet(const RenderNode &node, AbstractPolyNode::render_mode_e) +{ + CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(node); + PolySet *ps = NULL; + if (!N.empty()) ps = N.convertToPolyset(); + return ps; +} PolySet *PolySetCGALEvaluator::rotateDxfData(const DxfRotateExtrudeNode &node, DxfData &dxf) { diff --git a/src/PolySetCGALEvaluator.h b/src/PolySetCGALEvaluator.h index cf3c5b23..f5b8665a 100644 --- a/src/PolySetCGALEvaluator.h +++ b/src/PolySetCGALEvaluator.h @@ -17,6 +17,7 @@ public: virtual PolySet *evaluatePolySet(const DxfLinearExtrudeNode &node, AbstractPolyNode::render_mode_e); virtual PolySet *evaluatePolySet(const DxfRotateExtrudeNode &node, AbstractPolyNode::render_mode_e); virtual PolySet *evaluatePolySet(const CgaladvNode &node, AbstractPolyNode::render_mode_e); + virtual PolySet *evaluatePolySet(const RenderNode &node, AbstractPolyNode::render_mode_e); protected: PolySet *extrudeDxfData(const DxfLinearExtrudeNode &node, class DxfData &dxf); diff --git a/src/PolySetEvaluator.h b/src/PolySetEvaluator.h index 9a72ff7c..70ec7ed7 100644 --- a/src/PolySetEvaluator.h +++ b/src/PolySetEvaluator.h @@ -17,6 +17,7 @@ public: virtual PolySet *evaluatePolySet(const class DxfLinearExtrudeNode &, AbstractPolyNode::render_mode_e) = 0; virtual PolySet *evaluatePolySet(const class DxfRotateExtrudeNode &, AbstractPolyNode::render_mode_e) = 0; virtual PolySet *evaluatePolySet(const class CgaladvNode &, AbstractPolyNode::render_mode_e) = 0; + virtual PolySet *evaluatePolySet(const class RenderNode &, AbstractPolyNode::render_mode_e) = 0; void clearCache() { this->cache.clear();