mirror of https://github.com/vitalif/openscad
Compile fixes
parent
d9ad3a60a0
commit
dc93436da9
|
@ -24,29 +24,29 @@ bool CSGTextRenderer::isCached(const AbstractNode &node)
|
||||||
target = target [op] src
|
target = target [op] src
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CSGTextRenderer::process(string &target, const string &src, CSGTextRenderer::CsgOp op)
|
CSGTextRenderer::process(string &target, const string &src, OpenSCADOperator op)
|
||||||
{
|
{
|
||||||
// if (target.dim != 2 && target.dim != 3) {
|
// if (target.dim != 2 && target.dim != 3) {
|
||||||
// assert(false && "Dimension of Nef polyhedron must be 2 or 3");
|
// assert(false && "Dimension of Nef polyhedron must be 2 or 3");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case UNION:
|
case OPENSCAD_UNION:
|
||||||
target += "+" + src;
|
target += "+" + src;
|
||||||
break;
|
break;
|
||||||
case INTERSECTION:
|
case OPENSCAD_INTERSECTION:
|
||||||
target += "*" + src;
|
target += "*" + src;
|
||||||
break;
|
break;
|
||||||
case DIFFERENCE:
|
case OPENSCAD_DIFFERENCE:
|
||||||
target += "-" + src;
|
target += "-" + src;
|
||||||
break;
|
break;
|
||||||
case MINKOWSKI:
|
case OPENSCAD_MINKOWSKI:
|
||||||
target += "M" + src;
|
target += "M" + src;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSGTextRenderer::applyToChildren(const AbstractNode &node, CSGTextRenderer::CsgOp op)
|
void CSGTextRenderer::applyToChildren(const AbstractNode &node, OpenSCADOperator op)
|
||||||
{
|
{
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << node.name() << node.index();
|
stream << node.name() << node.index();
|
||||||
|
@ -86,7 +86,7 @@ Response CSGTextRenderer::visit(State &state, const AbstractNode &node)
|
||||||
{
|
{
|
||||||
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
||||||
if (state.isPostfix()) {
|
if (state.isPostfix()) {
|
||||||
if (!isCached(node)) applyToChildren(node, UNION);
|
if (!isCached(node)) applyToChildren(node, OPENSCAD_UNION);
|
||||||
addToParent(state, node);
|
addToParent(state, node);
|
||||||
}
|
}
|
||||||
return ContinueTraversal;
|
return ContinueTraversal;
|
||||||
|
@ -96,7 +96,7 @@ Response CSGTextRenderer::visit(State &state, const AbstractIntersectionNode &no
|
||||||
{
|
{
|
||||||
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
||||||
if (state.isPostfix()) {
|
if (state.isPostfix()) {
|
||||||
if (!isCached(node)) applyToChildren(node, INTERSECTION);
|
if (!isCached(node)) applyToChildren(node, OPENSCAD_INTERSECTION);
|
||||||
addToParent(state, node);
|
addToParent(state, node);
|
||||||
}
|
}
|
||||||
return ContinueTraversal;
|
return ContinueTraversal;
|
||||||
|
@ -107,19 +107,7 @@ Response CSGTextRenderer::visit(State &state, const CsgNode &node)
|
||||||
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
if (state.isPrefix() && isCached(node)) return PruneTraversal;
|
||||||
if (state.isPostfix()) {
|
if (state.isPostfix()) {
|
||||||
if (!isCached(node)) {
|
if (!isCached(node)) {
|
||||||
CsgOp op;
|
applyToChildren(node, node.type);
|
||||||
switch (node.type) {
|
|
||||||
case CSG_TYPE_UNION:
|
|
||||||
op = UNION;
|
|
||||||
break;
|
|
||||||
case CSG_TYPE_DIFFERENCE:
|
|
||||||
op = DIFFERENCE;
|
|
||||||
break;
|
|
||||||
case CSG_TYPE_INTERSECTION:
|
|
||||||
op = INTERSECTION;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
applyToChildren(node, op);
|
|
||||||
}
|
}
|
||||||
addToParent(state, node);
|
addToParent(state, node);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +120,7 @@ Response CSGTextRenderer::visit(State &state, const TransformNode &node)
|
||||||
if (state.isPostfix()) {
|
if (state.isPostfix()) {
|
||||||
if (!isCached(node)) {
|
if (!isCached(node)) {
|
||||||
// First union all children
|
// First union all children
|
||||||
applyToChildren(node, UNION);
|
applyToChildren(node, OPENSCAD_UNION);
|
||||||
// FIXME: Then apply transform
|
// FIXME: Then apply transform
|
||||||
}
|
}
|
||||||
addToParent(state, node);
|
addToParent(state, node);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "visitor.h"
|
#include "visitor.h"
|
||||||
#include "CSGTextCache.h"
|
#include "CSGTextCache.h"
|
||||||
|
#include "enums.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -24,11 +25,10 @@ public:
|
||||||
virtual Response visit(State &state, const AbstractPolyNode &node);
|
virtual Response visit(State &state, const AbstractPolyNode &node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum CsgOp {UNION, INTERSECTION, DIFFERENCE, MINKOWSKI};
|
|
||||||
void addToParent(const State &state, const AbstractNode &node);
|
void addToParent(const State &state, const AbstractNode &node);
|
||||||
bool isCached(const AbstractNode &node);
|
bool isCached(const AbstractNode &node);
|
||||||
void process(string &target, const string &src, CSGTextRenderer::CsgOp op);
|
void process(string &target, const string &src, OpenSCADOperator op);
|
||||||
void applyToChildren(const AbstractNode &node, CSGTextRenderer::CsgOp op);
|
void applyToChildren(const AbstractNode &node, OpenSCADOperator op);
|
||||||
|
|
||||||
string currindent;
|
string currindent;
|
||||||
typedef list<const AbstractNode *> ChildList;
|
typedef list<const AbstractNode *> ChildList;
|
||||||
|
|
Loading…
Reference in New Issue