summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--context.cc1
-rw-r--r--example.scad76
-rw-r--r--glview.cc2
-rw-r--r--mainwin.cc24
-rw-r--r--module.cc8
-rw-r--r--transform.cc8
6 files changed, 64 insertions, 55 deletions
diff --git a/context.cc b/context.cc
index 127e367..f847c16 100644
--- a/context.cc
+++ b/context.cc
@@ -89,6 +89,7 @@ AbstractNode *Context::evaluate_module(QString name, const QVector<QString> &arg
return modules_p->value(name)->evaluate(this, argnames, argvalues, child_nodes);
if (parent)
return parent->evaluate_module(name, argnames, argvalues, child_nodes);
+ printf("WARNING: Ignoring unkown module '%s'.\n", name.toAscii().data());
return NULL;
}
diff --git a/example.scad b/example.scad
index e37956c..7df8277 100644
--- a/example.scad
+++ b/example.scad
@@ -4,88 +4,66 @@ module test001()
function r_from_dia(d) = d / 2;
module rotcy(rot, r, h) {
- rot(rot) cylinder(r = r, h = h);
+ rotate(90, rot) cylinder(r = r, h = h, center = true);
}
difference() {
sphere(r = r_from_dia(size));
- rotcy([ 0 0 0], cy_r, cy_h);
- rotcy([90 0 0], cy_r, cy_h);
- rotcy([ 0 90 0], cy_r, cy_h);
+ rotcy([0 0 0], cy_r, cy_h);
+ rotcy([1 0 0], cy_r, cy_h);
+ rotcy([ 0 1 0], cy_r, cy_h);
}
- size = 10;
- hole = 2;
+ size = 50;
+ hole = 25;
cy_r = r_from_dia(hole);
- cy_h = r_from_dia(size * 1.5);
+ cy_h = r_from_dia(size * 2.5);
}
module test002()
{
- difference() {
- cube([2 2 0.5], true);
- cube([0.5 0.5 2], true);
- }
-}
-
-module test003()
-{
intersection() {
difference() {
union() {
- cube([3 3 3], center = true);
- trans([0 0 -2.5]) cube([1.5 1.5 5], center = true);
+ cube([30 30 30], center = true);
+ translate([0 0 -25])
+ cube([15 15 50], center = true);
}
union() {
- cube([5 1 1], center = true);
- cube([1 5 1], center = true);
- cube([1 1 5], center = true);
+ cube([50 10 10], center = true);
+ cube([10 50 10], center = true);
+ cube([10 10 50], center = true);
}
}
- trans([0 0 0.5])
- cylinder(h = 5, r1 = 2, r2 = 0.5, center = true);
+ translate([0 0 5])
+ cylinder(h = 50, r1 = 20, r2 = 5, center = true);
}
}
-module test004()
-{
- intersection() {
- difference() {
- cylinder(h = 5, r1 = 2, r2 = 0.5, center = true);
- cylinder(h = 6, r1 = 0.7, r2 = 0.7, center = true);
- }
- cube(3);
- }
-}
-
-module test005()
+module test003()
{
difference() {
union() {
- cube([3 3 3], center = true);
- cube([4 1.5 1.5], center = true);
- cube([1.5 4 1.5], center = true);
- cube([1.5 1.5 4], center = true);
+ cube([30 30 30], center = true);
+ cube([40 15 15], center = true);
+ cube([15 40 15], center = true);
+ cube([15 15 40], center = true);
}
union() {
- cube([5 1 1], center = true);
- cube([1 5 1], center = true);
- cube([1 1 5], center = true);
+ cube([50 10 10], center = true);
+ cube([10 50 10], center = true);
+ cube([10 10 50], center = true);
}
}
}
-module test006()
+module test004()
{
difference() {
- cube(8, center = true);
- sphere(5);
+ cube(30, center = true);
+ sphere(20);
}
}
-test006();
-
-// cylinder(h=5, r1=3, r2 = 10, center = true);
-// cube(10, center = true);
-// sphere(5);
+test001();
diff --git a/glview.cc b/glview.cc
index 1936663..6f46f12 100644
--- a/glview.cc
+++ b/glview.cc
@@ -27,7 +27,7 @@
GLView::GLView(QWidget *parent) : QGLWidget(parent)
{
- viewer_distance = 20;
+ viewer_distance = 500;
object_rot_y = 35;
object_rot_z = 25;
diff --git a/mainwin.cc b/mainwin.cc
index 15a984a..3bbb64f 100644
--- a/mainwin.cc
+++ b/mainwin.cc
@@ -489,7 +489,20 @@ void MainWindow::viewModeOpenCSG()
#ifdef ENABLE_CGAL
+// a little hackish: we need access to default-private members of
+// CGAL::OGL::Nef3_Converter so we can implement our own draw function
+// that does not scale the model. so we define 'class' to 'struct'
+// for this header..
+//
+// theoretically there could be two problems:
+// 1.) defining language keyword with the pre processor is illegal afair
+// 2.) the compiler could use a different memory layout or name mangling for structs
+//
+// both does not seam to be the case with todays compilers...
+//
+#define class struct
#include <CGAL/Nef_3/OGL_helper.h>
+#undef class
static void renderGLviaCGAL(void *vp)
{
@@ -502,7 +515,18 @@ static void renderGLviaCGAL(void *vp)
P.set_style(CGAL::OGL::SNC_BOUNDARY);
if (m->actViewModeCGALGrid->isChecked())
P.set_style(CGAL::OGL::SNC_SKELETON);
+#if 0
P.draw();
+#else
+ if (P.style == CGAL::OGL::SNC_BOUNDARY) {
+ glCallList(P.object_list_+2);
+ }
+ glCallList(P.object_list_+1);
+ glCallList(P.object_list_);
+ if (P.switches[CGAL::OGL::SNC_AXES]) {
+ glCallList(P.object_list_+3);
+ }
+#endif
}
}
diff --git a/module.cc b/module.cc
index 6d7101c..489e3a4 100644
--- a/module.cc
+++ b/module.cc
@@ -86,7 +86,9 @@ AbstractNode *ModuleInstanciation::evaluate(const Context *ctx) const
}
QVector<AbstractNode*> child_nodes;
foreach (ModuleInstanciation *v, children) {
- child_nodes.append(v->evaluate(ctx));
+ AbstractNode *n = v->evaluate(ctx);
+ if (n != NULL)
+ child_nodes.append(n);
}
return ctx->evaluate_module(modname, argnames, argvalues, child_nodes);
}
@@ -117,7 +119,9 @@ AbstractNode *Module::evaluate(const Context *ctx, const QVector<QString> &call_
AbstractNode *node = new AbstractNode();
for (int i = 0; i < children.size(); i++) {
- node->children.append(children[i]->evaluate(&c));
+ AbstractNode *n = children[i]->evaluate(&c);
+ if (n != NULL)
+ node->children.append(n);
}
foreach (AbstractNode *v, child_nodes)
diff --git a/transform.cc b/transform.cc
index 7ebce98..5951a70 100644
--- a/transform.cc
+++ b/transform.cc
@@ -100,9 +100,11 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const QVector<QStrin
}
if (val_v.type == Value::VECTOR) {
- x = val_v.x; y = val_v.y; z = val_v.z;
- double sn = 1.0 / sqrt(x*x + y*y + z*z);
- x *= sn; y *= sn; z *= sn;
+ if (val_v.x != 0.0 || val_v.y != 0.0 || val_v.z != 0.0) {
+ x = val_v.x; y = val_v.y; z = val_v.z;
+ double sn = 1.0 / sqrt(x*x + y*y + z*z);
+ x *= sn; y *= sn; z *= sn;
+ }
}
double c = cos(a*M_PI/180.0);
contact: Jan Huwald // Impressum