From 3f66c23731f0711dd1158f2cded7f0bf313617d4 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 7 Sep 2010 02:01:51 +0200 Subject: Reenabled CGAL rendering diff --git a/src/CGALRenderer.cc b/src/CGALRenderer.cc index 0f4bcb9..9bdcfe1 100644 --- a/src/CGALRenderer.cc +++ b/src/CGALRenderer.cc @@ -118,7 +118,7 @@ void CGALRenderer::applyToChildren(const AbstractNode &node, CGALRenderer::CsgOp o In postfix: addToParent() */ -Response CGALRenderer::visit(const State &state, const AbstractNode &node) +Response CGALRenderer::visit(State &state, const AbstractNode &node) { if (state.isPrefix() && isCached(node)) return PruneTraversal; if (state.isPostfix()) { @@ -128,7 +128,7 @@ Response CGALRenderer::visit(const State &state, const AbstractNode &node) return ContinueTraversal; } -Response CGALRenderer::visit(const State &state, const AbstractIntersectionNode &node) +Response CGALRenderer::visit(State &state, const AbstractIntersectionNode &node) { if (state.isPrefix() && isCached(node)) return PruneTraversal; if (state.isPostfix()) { @@ -138,7 +138,7 @@ Response CGALRenderer::visit(const State &state, const AbstractIntersectionNode return ContinueTraversal; } -Response CGALRenderer::visit(const State &state, const CsgNode &node) +Response CGALRenderer::visit(State &state, const CsgNode &node) { if (state.isPrefix() && isCached(node)) return PruneTraversal; if (state.isPostfix()) { @@ -162,7 +162,7 @@ Response CGALRenderer::visit(const State &state, const CsgNode &node) return ContinueTraversal; } -Response CGALRenderer::visit(const State &state, const TransformNode &node) +Response CGALRenderer::visit(State &state, const TransformNode &node) { if (state.isPrefix() && isCached(node)) return PruneTraversal; if (state.isPostfix()) { @@ -180,8 +180,8 @@ Response CGALRenderer::visit(const State &state, const TransformNode &node) // tesselate it and create a new CGAL_Nef_polyhedron2 from it.. What a hack! CGAL_Aff_transformation2 t( - node.m[0], node.m[4], node.m[12], - node.m[1], node.m[5], node.m[13], node.m[15]); + node.matrix[0], node.matrix[4], node.matrix[12], + node.matrix[1], node.matrix[5], node.matrix[13], node.matrix[15]); DxfData dd(N); for (int i=0; i < dd.points.size(); i++) { @@ -200,9 +200,9 @@ Response CGALRenderer::visit(const State &state, const TransformNode &node) } else if (N.dim == 3) { CGAL_Aff_transformation t( - node.m[0], node.m[4], node.m[ 8], node.m[12], - node.m[1], node.m[5], node.m[ 9], node.m[13], - node.m[2], node.m[6], node.m[10], node.m[14], node.m[15]); + node.matrix[0], node.matrix[4], node.matrix[ 8], node.matrix[12], + node.matrix[1], node.matrix[5], node.matrix[ 9], node.matrix[13], + node.matrix[2], node.matrix[6], node.matrix[10], node.matrix[14], node.matrix[15]); N.p3.transform(t); } this->cache.insert(this->tree.getString(node), N); @@ -221,7 +221,7 @@ Response CGALRenderer::visit(const State &state, const TransformNode &node) // DxfRotateExtrudeNode // (SurfaceNode) // (PrimitiveNode) -Response CGALRenderer::visit(const State &state, const AbstractPolyNode &node) +Response CGALRenderer::visit(State &state, const AbstractPolyNode &node) { if (state.isPrefix() && isCached(node)) return PruneTraversal; if (state.isPostfix()) { diff --git a/src/CGALRenderer.h b/src/CGALRenderer.h index 11abaa3..9a36522 100644 --- a/src/CGALRenderer.h +++ b/src/CGALRenderer.h @@ -2,18 +2,16 @@ #define CGALRENDERER_H_ #include "myqhash.h" +#include "visitor.h" +#include "Tree.h" +#include "cgal.h" #include #include #include -#include "visitor.h" -#include "Tree.h" -#include "cgal.h" -#ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); -#endif using std::string; using std::map; @@ -28,11 +26,11 @@ public: CGALRenderer(QHash &cache, const Tree &tree) : cache(cache), tree(tree) {} virtual ~CGALRenderer() {} - virtual Response visit(const State &state, const AbstractNode &node); - virtual Response visit(const State &state, const AbstractIntersectionNode &node); - virtual Response visit(const State &state, const CsgNode &node); - virtual Response visit(const State &state, const TransformNode &node); - virtual Response visit(const State &state, const AbstractPolyNode &node); + 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); CGAL_Nef_polyhedron renderCGALMesh(const AbstractNode &node); CGAL_Nef_polyhedron renderCGALMesh(const PolySet &polyset); diff --git a/src/openscad.cc b/src/openscad.cc index a53d1de..ba4d574 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -300,13 +300,10 @@ int main(int argc, char **argv) AbstractNode::resetIndexCounter(); root_node = root_module->evaluate(&root_ctx, &root_inst); - // FIXME: It shouldn't be necessary to dump manually, only when - // the dumper and the renderer wants to share a cache - // FIXME: Rewrite to non-global dumper -// Traverser trav(*NodeDumper::dumper(), *root_node, Traverser::PRE_AND_POSTFIX); -// trav.execute(); -// CGAL_Nef_polyhedron root_N = CGALRenderer::renderer()->renderCGALMesh(*root_node); - CGAL_Nef_polyhedron root_N; + Tree tree(root_node); + QHash cache; + CGALRenderer renderer(cache, tree); + CGAL_Nef_polyhedron root_N = renderer.renderCGALMesh(*tree.root()); QDir::setCurrent(original_path.absolutePath()); -- cgit v0.10.1