diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-08-04 18:55:25 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-08-04 18:55:25 (GMT) |
commit | cf190ff46ee1ce6ffa68ae932682b27438badc91 (patch) | |
tree | fa4ebb74f0f737566755a5da816a30fe388c74d2 | |
parent | cc803576dcc4810d1ba415895b83ac9a3079de2f (diff) |
Stefan Farthofer (aka meta/metaz):
Renamed some enums to avoid collitions with windows.h defines
git-svn-id: http://svn.clifford.at/openscad/trunk@86 b57f626f-c46c-0410-a088-ec61d464b74c
-rw-r--r-- | csgops.cc | 36 | ||||
-rw-r--r-- | csgterm.cc | 54 | ||||
-rw-r--r-- | mainwin.cc | 37 | ||||
-rw-r--r-- | module.cc | 2 | ||||
-rw-r--r-- | openscad.h | 20 | ||||
-rw-r--r-- | polyset.cc | 16 | ||||
-rw-r--r-- | transform.cc | 2 |
7 files changed, 85 insertions, 82 deletions
@@ -23,9 +23,9 @@ #include "openscad.h" enum csg_type_e { - UNION, - DIFFERENCE, - INTERSECTION + CSG_TYPE_UNION, + CSG_TYPE_DIFFERENCE, + CSG_TYPE_INTERSECTION }; class CsgModule : public AbstractModule @@ -77,11 +77,11 @@ CGAL_Nef_polyhedron CsgNode::render_cgal_nef_polyhedron() const if (first) { N = v->render_cgal_nef_polyhedron(); first = false; - } else if (type == UNION) { + } else if (type == CSG_TYPE_UNION) { N += v->render_cgal_nef_polyhedron(); - } else if (type == DIFFERENCE) { + } else if (type == CSG_TYPE_DIFFERENCE) { N -= v->render_cgal_nef_polyhedron(); - } else if (type == INTERSECTION) { + } else if (type == CSG_TYPE_INTERSECTION) { N *= v->render_cgal_nef_polyhedron(); } } @@ -101,12 +101,12 @@ CSGTerm *CsgNode::render_csg_term(double m[16], QVector<CSGTerm*> *highlights, Q if (t2 && !t1) { t1 = t2; } else if (t2 && t1) { - if (type == UNION) { - t1 = new CSGTerm(CSGTerm::UNION, t1, t2); - } else if (type == DIFFERENCE) { - t1 = new CSGTerm(CSGTerm::DIFFERENCE, t1, t2); - } else if (type == INTERSECTION) { - t1 = new CSGTerm(CSGTerm::INTERSECTION, t1, t2); + if (type == CSG_TYPE_UNION) { + t1 = new CSGTerm(CSGTerm::TYPE_UNION, t1, t2); + } else if (type == CSG_TYPE_DIFFERENCE) { + t1 = new CSGTerm(CSGTerm::TYPE_DIFFERENCE, t1, t2); + } else if (type == CSG_TYPE_INTERSECTION) { + t1 = new CSGTerm(CSGTerm::TYPE_INTERSECTION, t1, t2); } } } @@ -123,11 +123,11 @@ QString CsgNode::dump(QString indent) const { if (dump_cache.isEmpty()) { QString text = indent + QString("n%1: ").arg(idx); - if (type == UNION) + if (type == CSG_TYPE_UNION) text += "union() {\n"; - if (type == DIFFERENCE) + if (type == CSG_TYPE_DIFFERENCE) text += "difference() {\n"; - if (type == INTERSECTION) + if (type == CSG_TYPE_INTERSECTION) text += "intersection() {\n"; foreach (AbstractNode *v, children) text += v->dump(indent + QString("\t")); @@ -138,8 +138,8 @@ QString CsgNode::dump(QString indent) const void register_builtin_csgops() { - builtin_modules["union"] = new CsgModule(UNION); - builtin_modules["difference"] = new CsgModule(DIFFERENCE); - builtin_modules["intersection"] = new CsgModule(INTERSECTION); + builtin_modules["union"] = new CsgModule(CSG_TYPE_UNION); + builtin_modules["difference"] = new CsgModule(CSG_TYPE_DIFFERENCE); + builtin_modules["intersection"] = new CsgModule(CSG_TYPE_INTERSECTION); } @@ -24,7 +24,7 @@ CSGTerm::CSGTerm(PolySet *polyset, double m[16], QString label) { - this->type = PRIMITIVE; + this->type = TYPE_PRIMITIVE; this->polyset = polyset; this->label = label; this->left = NULL; @@ -51,7 +51,7 @@ CSGTerm *CSGTerm::normalize() // University of Potsdam, Hasso-Plattner-Institute, Germany // http://www.opencsg.org/data/csg_freenix2005_paper.pdf - if (type == PRIMITIVE) + if (type == TYPE_PRIMITIVE) return link(); CSGTerm *t1, *t2, *x, *y; @@ -89,28 +89,28 @@ CSGTerm *CSGTerm::normalize_tail() z = right->right; // 1. x - (y + z) -> (x - y) - z - if (type == DIFFERENCE && right->type == UNION) - return new CSGTerm(DIFFERENCE, new CSGTerm(DIFFERENCE, x->link(), y->link()), z->link()); + if (type == TYPE_DIFFERENCE && right->type == TYPE_UNION) + return new CSGTerm(TYPE_DIFFERENCE, new CSGTerm(TYPE_DIFFERENCE, x->link(), y->link()), z->link()); // 2. x * (y + z) -> (x * y) + (x * z) - if (type == INTERSECTION && right->type == UNION) - return new CSGTerm(UNION, new CSGTerm(INTERSECTION, x->link(), y->link()), new CSGTerm(INTERSECTION, x->link(), z->link())); + if (type == TYPE_INTERSECTION && right->type == TYPE_UNION) + return new CSGTerm(TYPE_UNION, new CSGTerm(TYPE_INTERSECTION, x->link(), y->link()), new CSGTerm(TYPE_INTERSECTION, x->link(), z->link())); // 3. x - (y * z) -> (x - y) + (x - z) - if (type == DIFFERENCE && right->type == INTERSECTION) - return new CSGTerm(UNION, new CSGTerm(DIFFERENCE, x->link(), y->link()), new CSGTerm(DIFFERENCE, x->link(), z->link())); + if (type == TYPE_DIFFERENCE && right->type == TYPE_INTERSECTION) + return new CSGTerm(TYPE_UNION, new CSGTerm(TYPE_DIFFERENCE, x->link(), y->link()), new CSGTerm(TYPE_DIFFERENCE, x->link(), z->link())); // 4. x * (y * z) -> (x * y) * z - if (type == INTERSECTION && right->type == INTERSECTION) - return new CSGTerm(INTERSECTION, new CSGTerm(INTERSECTION, x->link(), y->link()), z->link()); + if (type == TYPE_INTERSECTION && right->type == TYPE_INTERSECTION) + return new CSGTerm(TYPE_INTERSECTION, new CSGTerm(TYPE_INTERSECTION, x->link(), y->link()), z->link()); // 5. x - (y - z) -> (x - y) + (x * z) - if (type == DIFFERENCE && right->type == DIFFERENCE) - return new CSGTerm(UNION, new CSGTerm(DIFFERENCE, x->link(), y->link()), new CSGTerm(INTERSECTION, x->link(), z->link())); + if (type == TYPE_DIFFERENCE && right->type == TYPE_DIFFERENCE) + return new CSGTerm(TYPE_UNION, new CSGTerm(TYPE_DIFFERENCE, x->link(), y->link()), new CSGTerm(TYPE_INTERSECTION, x->link(), z->link())); // 6. x * (y - z) -> (x * y) - z - if (type == INTERSECTION && right->type == DIFFERENCE) - return new CSGTerm(DIFFERENCE, new CSGTerm(INTERSECTION, x->link(), y->link()), z->link()); + if (type == TYPE_INTERSECTION && right->type == TYPE_DIFFERENCE) + return new CSGTerm(TYPE_DIFFERENCE, new CSGTerm(TYPE_INTERSECTION, x->link(), y->link()), z->link()); // Part B: The '(x . y) . z' expressions @@ -119,16 +119,16 @@ CSGTerm *CSGTerm::normalize_tail() z = right; // 7. (x - y) * z -> (x * z) - y - if (left->type == DIFFERENCE && type == INTERSECTION) - return new CSGTerm(DIFFERENCE, new CSGTerm(INTERSECTION, x->link(), z->link()), y->link()); + if (left->type == TYPE_DIFFERENCE && type == TYPE_INTERSECTION) + return new CSGTerm(TYPE_DIFFERENCE, new CSGTerm(TYPE_INTERSECTION, x->link(), z->link()), y->link()); // 8. (x + y) - z -> (x - z) + (y - z) - if (left->type == UNION && type == DIFFERENCE) - return new CSGTerm(UNION, new CSGTerm(DIFFERENCE, x->link(), z->link()), new CSGTerm(DIFFERENCE, y->link(), z->link())); + if (left->type == TYPE_UNION && type == TYPE_DIFFERENCE) + return new CSGTerm(TYPE_UNION, new CSGTerm(TYPE_DIFFERENCE, x->link(), z->link()), new CSGTerm(TYPE_DIFFERENCE, y->link(), z->link())); // 9. (x + y) * z -> (x * z) + (y * z) - if (left->type == UNION && type == INTERSECTION) - return new CSGTerm(UNION, new CSGTerm(INTERSECTION, x->link(), z->link()), new CSGTerm(INTERSECTION, y->link(), z->link())); + if (left->type == TYPE_UNION && type == TYPE_INTERSECTION) + return new CSGTerm(TYPE_UNION, new CSGTerm(TYPE_INTERSECTION, x->link(), z->link()), new CSGTerm(TYPE_INTERSECTION, y->link(), z->link())); return link(); } @@ -154,11 +154,11 @@ void CSGTerm::unlink() QString CSGTerm::dump() { - if (type == UNION) + if (type == TYPE_UNION) return QString("(%1 + %2)").arg(left->dump(), right->dump()); - if (type == INTERSECTION) + if (type == TYPE_INTERSECTION) return QString("(%1 * %2)").arg(left->dump(), right->dump()); - if (type == DIFFERENCE) + if (type == TYPE_DIFFERENCE) return QString("(%1 - %2)").arg(left->dump(), right->dump()); return label; } @@ -177,7 +177,7 @@ void CSGChain::add(PolySet *polyset, double *m, CSGTerm::type_e type, QString la void CSGChain::import(CSGTerm *term, CSGTerm::type_e type) { - if (term->type == CSGTerm::PRIMITIVE) { + if (term->type == CSGTerm::TYPE_PRIMITIVE) { add(term->polyset, term->m, type, term->label); } else { import(term->left, type); @@ -190,14 +190,14 @@ QString CSGChain::dump() QString text; for (int i = 0; i < types.size(); i++) { - if (types[i] == CSGTerm::UNION) { + if (types[i] == CSGTerm::TYPE_UNION) { if (i != 0) text += "\n"; text += "+"; } - if (types[i] == CSGTerm::DIFFERENCE) + if (types[i] == CSGTerm::TYPE_DIFFERENCE) text += " -"; - if (types[i] == CSGTerm::INTERSECTION) + if (types[i] == CSGTerm::TYPE_INTERSECTION) text += " *"; text += labels[i]; } @@ -33,6 +33,9 @@ #include <QVBoxLayout> #include <QLabel> +//for chdir +#include <unistd.h> + QPointer<MainWindow> current_win; MainWindow::MainWindow(const char *filename) @@ -888,7 +891,7 @@ public: virtual void render() { glPushMatrix(); glMultMatrixd(m); - p->render_surface(PolySet::COLOR_NONE); + p->render_surface(PolySet::COLORMODE_NONE); glPopMatrix(); } }; @@ -901,7 +904,7 @@ static void renderCSGChainviaOpenCSG(CSGChain *chain, GLint *shaderinfo, bool hi { bool last = i == chain->polysets.size(); - if (last || chain->types[i] == CSGTerm::UNION) + if (last || chain->types[i] == CSGTerm::TYPE_UNION) { OpenCSG::render(primitives); glDepthFunc(GL_EQUAL); @@ -911,13 +914,13 @@ static void renderCSGChainviaOpenCSG(CSGChain *chain, GLint *shaderinfo, bool hi glPushMatrix(); glMultMatrixd(chain->matrices[j]); if (highlight) { - chain->polysets[j]->render_surface(PolySet::COLOR_HIGHLIGHT, shaderinfo); + chain->polysets[j]->render_surface(PolySet::COLORMODE_HIGHLIGHT, shaderinfo); } else if (background) { - chain->polysets[j]->render_surface(PolySet::COLOR_BACKGROUND, shaderinfo); - } else if (chain->types[j] == CSGTerm::DIFFERENCE) { - chain->polysets[j]->render_surface(PolySet::COLOR_CUTOUT, shaderinfo); + chain->polysets[j]->render_surface(PolySet::COLORMODE_BACKGROUND, shaderinfo); + } else if (chain->types[j] == CSGTerm::TYPE_DIFFERENCE) { + chain->polysets[j]->render_surface(PolySet::COLORMODE_CUTOUT, shaderinfo); } else { - chain->polysets[j]->render_surface(PolySet::COLOR_MATERIAL, shaderinfo); + chain->polysets[j]->render_surface(PolySet::COLORMODE_MATERIAL, shaderinfo); } glPopMatrix(); } @@ -933,7 +936,7 @@ static void renderCSGChainviaOpenCSG(CSGChain *chain, GLint *shaderinfo, bool hi if (last) break; - OpenCSGPrim *prim = new OpenCSGPrim(chain->types[i] == CSGTerm::DIFFERENCE ? + OpenCSGPrim *prim = new OpenCSGPrim(chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? OpenCSG::Subtraction : OpenCSG::Intersection, chain->polysets[i]->convexity); prim->p = chain->polysets[i]; prim->m = chain->matrices[i]; @@ -1058,31 +1061,31 @@ static void renderGLThrownTogetherChain(MainWindow *m, CSGChain *chain, bool hig glPushMatrix(); glMultMatrixd(chain->matrices[i]); if (highlight) { - chain->polysets[i]->render_surface(PolySet::COLOR_HIGHLIGHT); + chain->polysets[i]->render_surface(PolySet::COLORMODE_HIGHLIGHT); if (showEdges) { glDisable(GL_LIGHTING); - chain->polysets[i]->render_edges(PolySet::COLOR_HIGHLIGHT); + chain->polysets[i]->render_edges(PolySet::COLORMODE_HIGHLIGHT); glEnable(GL_LIGHTING); } } else if (background) { - chain->polysets[i]->render_surface(PolySet::COLOR_BACKGROUND); + chain->polysets[i]->render_surface(PolySet::COLORMODE_BACKGROUND); if (showEdges) { glDisable(GL_LIGHTING); - chain->polysets[i]->render_edges(PolySet::COLOR_BACKGROUND); + chain->polysets[i]->render_edges(PolySet::COLORMODE_BACKGROUND); glEnable(GL_LIGHTING); } - } else if (chain->types[i] == CSGTerm::DIFFERENCE) { - chain->polysets[i]->render_surface(PolySet::COLOR_CUTOUT); + } else if (chain->types[i] == CSGTerm::TYPE_DIFFERENCE) { + chain->polysets[i]->render_surface(PolySet::COLORMODE_CUTOUT); if (showEdges) { glDisable(GL_LIGHTING); - chain->polysets[i]->render_edges(PolySet::COLOR_CUTOUT); + chain->polysets[i]->render_edges(PolySet::COLORMODE_CUTOUT); glEnable(GL_LIGHTING); } } else { - chain->polysets[i]->render_surface(PolySet::COLOR_MATERIAL); + chain->polysets[i]->render_surface(PolySet::COLORMODE_MATERIAL); if (showEdges) { glDisable(GL_LIGHTING); - chain->polysets[i]->render_edges(PolySet::COLOR_MATERIAL); + chain->polysets[i]->render_edges(PolySet::COLORMODE_MATERIAL); glEnable(GL_LIGHTING); } } @@ -261,7 +261,7 @@ CSGTerm *AbstractNode::render_csg_term(double m[16], QVector<CSGTerm*> *highligh if (t2 && !t1) { t1 = t2; } else if (t2 && t1) { - t1 = new CSGTerm(CSGTerm::UNION, t1, t2); + t1 = new CSGTerm(CSGTerm::TYPE_UNION, t1, t2); } } if (t1 && modinst->tag_highlight && highlights) @@ -500,11 +500,11 @@ public: void insert_vertex(double x, double y, double z); enum colormode_e { - COLOR_NONE, - COLOR_MATERIAL, - COLOR_CUTOUT, - COLOR_HIGHLIGHT, - COLOR_BACKGROUND + COLORMODE_NONE, + COLORMODE_MATERIAL, + COLORMODE_CUTOUT, + COLORMODE_HIGHLIGHT, + COLORMODE_BACKGROUND }; static QCache<QString,PolySetPtr> ps_cache; @@ -537,10 +537,10 @@ class CSGTerm { public: enum type_e { - PRIMITIVE, - UNION, - INTERSECTION, - DIFFERENCE + TYPE_PRIMITIVE, + TYPE_UNION, + TYPE_INTERSECTION, + TYPE_DIFFERENCE }; type_e type; @@ -573,7 +573,7 @@ public: CSGChain(); void add(PolySet *polyset, double *m, CSGTerm::type_e type, QString label); - void import(CSGTerm *term, CSGTerm::type_e type = CSGTerm::UNION); + void import(CSGTerm *term, CSGTerm::type_e type = CSGTerm::TYPE_UNION); QString dump(); }; @@ -106,7 +106,7 @@ static void gl_draw_triangle(GLint *shaderinfo, const PolySet::Point *p0, const void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const { - if (colormode == COLOR_MATERIAL) { + if (colormode == COLORMODE_MATERIAL) { glColor3ub(249, 215, 44); #ifdef ENABLE_OPENCSG if (shaderinfo) { @@ -115,7 +115,7 @@ void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const } #endif /* ENABLE_OPENCSG */ } - if (colormode == COLOR_CUTOUT) { + if (colormode == COLORMODE_CUTOUT) { glColor3ub(157, 203, 81); #ifdef ENABLE_OPENCSG if (shaderinfo) { @@ -124,7 +124,7 @@ void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const } #endif /* ENABLE_OPENCSG */ } - if (colormode == COLOR_HIGHLIGHT) { + if (colormode == COLORMODE_HIGHLIGHT) { glColor4ub(255, 157, 81, 128); #ifdef ENABLE_OPENCSG if (shaderinfo) { @@ -133,7 +133,7 @@ void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const } #endif /* ENABLE_OPENCSG */ } - if (colormode == COLOR_BACKGROUND) { + if (colormode == COLORMODE_BACKGROUND) { glColor4ub(180, 180, 180, 128); #ifdef ENABLE_OPENCSG if (shaderinfo) { @@ -178,13 +178,13 @@ void PolySet::render_surface(colormode_e colormode, GLint *shaderinfo) const void PolySet::render_edges(colormode_e colormode) const { - if (colormode == COLOR_MATERIAL) + if (colormode == COLORMODE_MATERIAL) glColor3ub(255, 236, 94); - if (colormode == COLOR_CUTOUT) + if (colormode == COLORMODE_CUTOUT) glColor3ub(171, 216, 86); - if (colormode == COLOR_HIGHLIGHT) + if (colormode == COLORMODE_HIGHLIGHT) glColor4ub(255, 171, 86, 128); - if (colormode == COLOR_BACKGROUND) + if (colormode == COLORMODE_BACKGROUND) glColor4ub(150, 150, 150, 128); for (int i = 0; i < polygons.size(); i++) { const Polygon *poly = &polygons[i]; diff --git a/transform.cc b/transform.cc index 6e65c3a..879a026 100644 --- a/transform.cc +++ b/transform.cc @@ -192,7 +192,7 @@ CSGTerm *TransformNode::render_csg_term(double c[16], QVector<CSGTerm*> *highlig if (t2 && !t1) { t1 = t2; } else if (t2 && t1) { - t1 = new CSGTerm(CSGTerm::UNION, t1, t2); + t1 = new CSGTerm(CSGTerm::TYPE_UNION, t1, t2); } } if (t1 && modinst->tag_highlight && highlights) |