Skip to content

Commit

Permalink
Clifford Wolf:
Browse files Browse the repository at this point in the history
	Fixed scalar subtraction
	Fixed handling of -/+ scalar prefix
	Fixed vector handling [0 1 2] doesn't work anymore now



git-svn-id: http://svn.clifford.at/openscad/trunk@109 b57f626f-c46c-0410-a088-ec61d464b74c
  • Loading branch information
clifford committed Oct 19, 2009
1 parent 7c99871 commit 05b2eb1
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 96 deletions.
9 changes: 5 additions & 4 deletions examples/example001.scad
Expand Up @@ -4,14 +4,15 @@ module example001()
function r_from_dia(d) = d / 2;

module rotcy(rot, r, h) {
rotate(90, rot) cylinder(r = r, h = h, center = true);
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([1 0 0], cy_r, cy_h);
rotcy([ 0 1 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 = 50;
Expand Down
14 changes: 7 additions & 7 deletions examples/example002.scad
Expand Up @@ -4,17 +4,17 @@ module example002()
intersection() {
difference() {
union() {
cube([30 30 30], center = true);
translate([0 0 -25])
cube([15 15 50], center = true);
cube([30, 30, 30], center = true);
translate([0, 0, -25])
cube([15, 15, 50], center = true);
}
union() {
cube([50 10 10], center = true);
cube([10 50 10], center = true);
cube([10 10 50], center = true);
cube([50, 10, 10], center = true);
cube([10, 50, 10], center = true);
cube([10, 10, 50], center = true);
}
}
translate([0 0 5])
translate([0, 0, 5])
cylinder(h = 50, r1 = 20, r2 = 5, center = true);
}
}
Expand Down
14 changes: 7 additions & 7 deletions examples/example003.scad
Expand Up @@ -3,15 +3,15 @@ module example003()
{
difference() {
union() {
cube([30 30 30], center = true);
cube([40 15 15], center = true);
cube([15 40 15], center = true);
cube([15 15 40], 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([50 10 10], center = true);
cube([10 50 10], center = true);
cube([10 10 50], center = true);
cube([50, 10, 10], center = true);
cube([10, 50, 10], center = true);
cube([10, 10, 50], center = true);
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions examples/example005.scad
@@ -1,21 +1,20 @@

module example005()
{
translate([0 0 -120]) {
translate([0, 0, -120]) {
difference() {
cylinder(h = 50, r = 100);
translate([0 0 10]) cylinder(h = 50, r = 80);
translate([100 0 35]) cube(50, center = true);
translate([0, 0, 10]) cylinder(h = 50, r = 80);
translate([100, 0, 35]) cube(50, center = true);
}
for (i = [0:5]) {
echo(360*i/6, sin(360*i/6)*80, cos(360*i/6)*80);
translate([sin(360*i/6)*80, cos(360*i/6)*80, 0 ])
cylinder(h = 200, r=10);
}
translate([0 0 200])
translate([0, 0, 200])
cylinder(h = 80, r1 = 120, r2 = 0);
}
}

example005();

28 changes: 14 additions & 14 deletions examples/example006.scad
Expand Up @@ -4,36 +4,36 @@ module example006()
module edgeprofile()
{
render(convexity = 2) difference() {
cube([20 20 150], center = true);
translate([-10 -10 0])
cube([20, 20, 150], center = true);
translate([-10, -10, 0])
cylinder(h = 80, r = 10, center = true);
translate([-10 -10 +40])
translate([-10, -10, +40])
sphere(r = 10);
translate([-10 -10 -40])
translate([-10, -10, -40])
sphere(r = 10);
}
}

difference()
{
cube(100, center = true);
for (rot = [ [0 0 0], [1 0 0], [0 1 0] ]) {
for (rot = [ [0, 0, 0], [1, 0, 0], [0, 1, 0] ]) {
rotate(90, rot)
for (p = [[+1 +1 0], [-1 +1 90], [-1 -1 180], [+1 -1 270]]) {
for (p = [[+1, +1, 0], [-1, +1, 90], [-1, -1, 180], [+1, -1, 270]]) {
translate([ p[0]*50, p[1]*50, 0 ])
rotate(p[2], [0 0 1])
rotate(p[2], [0, 0, 1])
edgeprofile();
}
}
for (i = [
[ 0, 0, [ [0 0] ] ],
[ 90, 0, [ [-20 -20], [+20 +20] ] ],
[ 180, 0, [ [-20 -25], [-20 0], [-20 +25], [+20 -25], [+20 0], [+20 +25] ] ],
[ 270, 0, [ [0 0], [-25 -25], [+25 -25], [-25 +25], [+25 +25] ] ],
[ 0, 90, [ [-25 -25], [0 0], [+25 +25] ] ],
[ 0, -90, [ [-25 -25], [+25 -25], [-25 +25], [+25 +25] ] ]
[ 0, 0, [ [0, 0] ] ],
[ 90, 0, [ [-20, -20], [+20, +20] ] ],
[ 180, 0, [ [-20, -25], [-20, 0], [-20, +25], [+20, -25], [+20, 0], [+20, +25] ] ],
[ 270, 0, [ [0, 0], [-25, -25], [+25, -25], [-25, +25], [+25, +25] ] ],
[ 0, 90, [ [-25, -25], [0, 0], [+25, +25] ] ],
[ 0, -90, [ [-25, -25], [+25, -25], [-25, +25], [+25, +25] ] ]
]) {
rotate(i[0], [0 0 1]) rotate(i[1], [1 0 0]) translate([0 -50 0])
rotate(i[0], [0, 0, 1]) rotate(i[1], [1, 0, 0]) translate([0, -50, 0])
for (j = i[2])
translate([j[0], 0, j[1]]) sphere(10);
}
Expand Down
32 changes: 16 additions & 16 deletions examples/example007.scad
Expand Up @@ -3,17 +3,17 @@ module cutout()
{
intersection()
{
rotate(90, [1 0 0])
translate([0 0 -50])
rotate(90, [1, 0, 0])
translate([0, 0, -50])
dxf_linear_extrude(
file = "example007.dxf",
layer = "cutout1",
height = 100,
convexity = 1);

rotate(90, [0 0 1])
rotate(90, [1 0 0])
translate([0 0 -50])
rotate(90, [0, 0, 1])
rotate(90, [1, 0, 0])
translate([0, 0, -50])
dxf_linear_extrude(
file = "example007.dxf",
layer = "cutout2",
Expand All @@ -29,8 +29,8 @@ module clip()
file = "example007.dxf",
layer="dorn",
convexity = 3);
for (r = [0 90])
rotate(r, [0 0 1])
for (r = [0, 90])
rotate(r, [0, 0, 1])
cutout();
}
}
Expand All @@ -41,29 +41,29 @@ module cutview()
{
difference()
{
translate([0 0 -10])
translate([0, 0, -10])
clip();

rotate(20, [0 0 1])
rotate(-20, [0 1 0])
translate([18 0 0])
rotate(20, [0, 0, 1])
rotate(-20, [0, 1, 0])
translate([18, 0, 0])
cube(30, center = true);
}

# render(convexity = 5) intersection()
{
translate([0 0 -10])
translate([0, 0, -10])
clip();

rotate(20, [0 0 1])
rotate(-20, [0 1 0])
translate([18 0 0])
rotate(20, [0, 0, 1])
rotate(-20, [0, 1, 0])
translate([18, 0, 0])
cube(30, center = true);
}
}
}

translate([0 0 -10])
translate([0, 0, -10])
clip();

// cutview();
Expand Down
16 changes: 8 additions & 8 deletions examples/example008.scad
Expand Up @@ -3,29 +3,29 @@ difference()
{
intersection()
{
translate([ -25 -25 -25])
translate([ -25, -25, -25])
dxf_linear_extrude(file = "example008.dxf",
layer = "G", height = 50, convexity = 3);

rotate(90, [1 0 0])
translate([ -25 -125 -25])
rotate(90, [1, 0, 0])
translate([ -25, -125, -25])
dxf_linear_extrude(file = "example008.dxf",
layer = "E", height = 50, convexity = 3);

rotate(90, [0 1 0])
translate([ -125 -125 -25])
rotate(90, [0, 1, 0])
translate([ -125, -125, -25])
dxf_linear_extrude(file = "example008.dxf",
layer = "B", height = 50, convexity = 3);
}

intersection()
{
translate([ -125 -25 -25])
translate([ -125, -25, -25])
dxf_linear_extrude(file = "example008.dxf",
layer = "X", height = 50, convexity = 1);

rotate(90, [0 1 0])
translate([ -125 -25 -25])
rotate(90, [0, 1, 0])
translate([ -125, -25, -25])
dxf_linear_extrude(file = "example008.dxf",
layer = "X", height = 50, convexity = 1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/example010.scad
Expand Up @@ -8,7 +8,7 @@ intersection()
surface(file = "example010.dat",
center = true, convexity = 5);

rotate(45, [0 0 1])
rotate(45, [0, 0, 1])
surface(file = "example010.dat",
center = true, convexity = 5);
}
20 changes: 10 additions & 10 deletions examples/example011.scad
@@ -1,16 +1,16 @@
polyeder(
points = [
[10 0 0],
[ 0 10 0],
[ -10 0 0],
[ 0 -10 0],
[ 0 0 10]
[10, 0, 0],
[0, 10, 0],
[-10, 0, 0],
[0, -10, 0],
[0, 0, 10]
],
triangles = [
[0 1 2 3],
[4 1 0],
[4 2 1],
[4 3 2],
[4 0 3]
[0, 1, 2, 3],
[4, 1, 0],
[4, 2, 1],
[4, 3, 2],
[4, 0, 3]
]
);
2 changes: 1 addition & 1 deletion examples/example012.scad
Expand Up @@ -7,6 +7,6 @@ difference()
{
sphere(20);

translate([ -2.92 0.5 +20 ]) rotate([180 0 180])
translate([ -2.92, 0.5, +20 ]) rotate([180, 0, 180])
import_stl("example012.stl", convexity = 5);
}
3 changes: 2 additions & 1 deletion lexer.l
Expand Up @@ -42,6 +42,7 @@ extern const char *parser_input_buffer;
if (*parser_input_buffer) { \
result = 1; \
buf[0] = *(parser_input_buffer++); \
parser_error_pos++; \
} else { \
result = YY_NULL; \
} \
Expand Down Expand Up @@ -86,7 +87,7 @@ extern const char *parser_input_buffer;
"false" return TOK_FALSE;
"undef" return TOK_UNDEF;

[+-]?[0-9][0-9.]* { parserlval.number = atof(yytext); return TOK_NUMBER; }
[0-9][0-9.]* { parserlval.number = atof(yytext); return TOK_NUMBER; }
"$"?[a-zA-Z0-9_]+ { parserlval.text = strdup(yytext); return TOK_ID; }

\"[^"]*\" {
Expand Down
10 changes: 7 additions & 3 deletions mainwin.cc
Expand Up @@ -354,8 +354,12 @@ void MainWindow::compile(bool procevents)
root_ctx.set_variable("$t", Value(e_tval->text().toDouble()));
root_module = parse(editor->toPlainText().toAscii().data(), false);

if (!root_module)
if (!root_module) {
QTextCursor cursor = editor->textCursor();
cursor.setPosition(parser_error_pos);
editor->setTextCursor(cursor);
goto fail;
}

PRINT("Compiling design (CSG Tree generation)...");
if (procevents)
Expand Down Expand Up @@ -608,15 +612,15 @@ void MainWindow::pasteViewportTranslation()
{
QTextCursor cursor = editor->textCursor();
QString txt;
txt.sprintf("[ %.2f %.2f %.2f ]", -screen->object_trans_x, -screen->object_trans_y, -screen->object_trans_z);
txt.sprintf("[ %.2f, %.2f, %.2f ]", -screen->object_trans_x, -screen->object_trans_y, -screen->object_trans_z);
cursor.insertText(txt);
}

void MainWindow::pasteViewportRotation()
{
QTextCursor cursor = editor->textCursor();
QString txt;
txt.sprintf("[ %.2f %.2f %.2f ]",
txt.sprintf("[ %.2f, %.2f, %.2f ]",
fmodf(360 - screen->object_rot_x + 90, 360), fmodf(360 - screen->object_rot_y, 360), fmodf(360 - screen->object_rot_z, 360));
cursor.insertText(txt);
}
Expand Down
1 change: 1 addition & 0 deletions openscad.h
Expand Up @@ -800,6 +800,7 @@ private slots:
extern AbstractModule *parse(const char *text, int debug);
extern int get_fragments_from_r(double r, double fn, double fs, double fa);

extern int parser_error_pos;
extern QPointer<MainWindow> current_win;

#ifdef ENABLE_CGAL
Expand Down

0 comments on commit 05b2eb1

Please sign in to comment.