Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! We cleaned up your code for you! #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ h4. Import
* Surface
@surface(file=filename, convexity=5, center=False)@
<pre><code>#surface.dat
10 9 8 7 6 5 5 5 5 5
9 8 7 6 6 4 3 2 1 0
10 9 8 7 6 5 5 5 5 5
9 8 7 6 6 4 3 2 1 0
8 7 6 6 4 3 2 1 0 0
7 6 6 4 3 2 1 0 0 0
6 6 4 3 2 1 1 0 0 0
Expand Down
2 changes: 1 addition & 1 deletion cgal.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cgal {
DEFINES += ENABLE_CGAL

isEmpty(DEPLOYDIR) {
# Optionally specify location of CGAL using the
# Optionally specify location of CGAL using the
# CGALDIR env. variable
CGAL_DIR = $$(CGALDIR)
!isEmpty(CGAL_DIR) {
Expand Down
22 changes: 11 additions & 11 deletions contrib/scad.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Expand Down Expand Up @@ -45,10 +45,10 @@
:group 'scad-font-lock)

(defcustom scad-functions
'("cos" "acos" "sin" "asin" "tan" "atan"
'("cos" "acos" "sin" "asin" "tan" "atan"
"pow" "log" "ln"
"abs" "min" "max" "sqrt" "round" "ceil" "floor" "lookup"
"str"
"abs" "min" "max" "sqrt" "round" "ceil" "floor" "lookup"
"str"
"dxf_dim" "dxf_cross"
)
"SCAD functions."
Expand All @@ -58,7 +58,7 @@
(defcustom scad-modules
'("for" "if" "assign" "intersection_for"
"echo"
"cube" "sphere" "cylinder" "polyhedron"
"cube" "sphere" "cylinder" "polyhedron"
"scale" "rotate" "translate" "mirror" "multmatrix" "color"
"union" "difference" "intersection" "render" "surface"
"square" "circle" "polygon" "dxf_linear_extrude" "linear_extrude" "dxf_rotate_extrude" "rotate_extrude"
Expand All @@ -70,8 +70,8 @@
:group 'scad-font-lock)

(defcustom scad-operators
'("+" "-" "*" "/" "%"
"&&" "||" "!"
'("+" "-" "*" "/" "%"
"&&" "||" "!"
"<" "<=" "==" "!=" ">" ">="
"?" ":" "=")
"SCAD operators."
Expand All @@ -81,14 +81,14 @@
(defvar scad-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\t" 'scad-indent-line)
(define-key map [return] 'newline-and-indent)
(define-key map [return] 'newline-and-indent)
map)
"Keymap for `scad-mode'.")

(defvar scad-mode-syntax-table
(let ((st (make-syntax-table)))
;; support comment style: “// ...”
;; support comment style: “/* ... */”
;; support comment style: “// ...”
;; support comment style: “/* ... */”
(modify-syntax-entry ?\/ ". 124b" st)
(modify-syntax-entry ?\n "> b" st)
(modify-syntax-entry ?* ". 23" st)
Expand Down
14 changes: 7 additions & 7 deletions doc/TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ Using STL-imported models is tricky and triggers multiple issues:
1) null-faces causes F6 rendering to fail while F5 rendering succeeds.
(null-faces are exported by OpenSCAD). Example: adns2610_dev_circuit_inv.stl
by Andrew Plumb
2) Even very simple imported STL models don't render correctly with F5 when taking
2) Even very simple imported STL models don't render correctly with F5 when taking
a difference(), though F6 looks correct. Example: test_cube.stl by Andrew Plumb
with this scad file:
difference() {
import_stl("test_cube.stl");
translate([2,2,2]) cylinder(h=10);
}
3) More complex STL models with something simple unioned or subtracted fails rendering
3) More complex STL models with something simple unioned or subtracted fails rendering
using F6 even though F5 works. Example: adns2610_dev_circuit_inv.stl
by Andrew Plumb with the three null-faces removed by MeshLab with this scad file:
union() {
import_stl("adns2610_dev_circuit_inv_4.stl");
sphere(r=5);
}
4) More complex STL models cannot be projected (both F5 and F6).
Example: adns2610_dev_circuit_inv.stl by Andrew Plumb with the three
Example: adns2610_dev_circuit_inv.stl by Andrew Plumb with the three
null-faces removed by MeshLab and this scad file:
projection(cut=true) {
import_stl("adns2610_dev_circuit_inv.stl");
Expand Down Expand Up @@ -82,7 +82,7 @@ o 3D View
- Allow specifying viewpoint in the scad file
- overlay indicator displaying current view mode
- OpenCSG rendering: Coincident surfaces causes z-buffer fighting. Is this somehow
avoidable tuning the depth tests in OpenCSG?
avoidable tuning the depth tests in OpenCSG?
- Use OpenGL picking to facilitate ray-tracing like features like measuring
thicknesses, distances, slot thicknesses etc.
o Editor wishlist
Expand All @@ -104,7 +104,7 @@ o Editor wishlist
- C-c/C-v should work on the focused widget, not always in the editor
o Error reporting/debugging
- Provide better error messages when polygon ordering causes CGAL errors:
o Supply syntax highlighting of the exact polygon indices which are
o Supply syntax highlighting of the exact polygon indices which are
reported to be wrong
o Provide some interaction for debug walk-through?
- Provide visual highlighting of geometry corresponding to code
Expand Down Expand Up @@ -169,7 +169,7 @@ o Misc
- When specifying a transparency with the color() statement,
the object is not sorted and will be rendered wrongly
- Go through default values of parameters (e.g. cube() has x,y,z=1 while linear_extrude() has height=100)
- Add support for symbolic names to child() statement
- Add support for symbolic names to child() statement
- Add 'lines' object type for non-solid 2d drawings
- Is there a reason why modules like echo, empty if, empty for loop returns an
empty AbstractNode instead of being ignored?
Expand All @@ -179,7 +179,7 @@ o Grammar
- dim->name -> dim->label
- A random(seed) function
- import_*() -> *_import() (consistent prefix vs. postfix)
- linear_extrude()/rotate_extrude(): Cumbersome names? -> (extrude, revolve, lathe, sweep ?)
- linear_extrude()/rotate_extrude(): Cumbersome names? -> (extrude, revolve, lathe, sweep ?)

IDEAS FOR LANGUAGE CHANGES
--------------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/checklist-macosx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ o Qt4
o Build dependencies from source

scripts/macosx-build-dependencies.sh

o Build and Deploy OpenSCAD

# Update VERSION in publish-macosx.sh
Expand Down
2 changes: 1 addition & 1 deletion eigen2.pri
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Optionally specify location of Eigen2 using the
# Optionally specify location of Eigen2 using the
# EIGEN2DIR env. variable
EIGEN2_DIR = $$(EIGEN2DIR)
!isEmpty(EIGEN2_DIR) {
Expand Down
6 changes: 3 additions & 3 deletions examples/example001.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def r_from_dia(d):
cy_r = r_from_dia(hole)
cy_h = r_from_dia(size * 2.5)

return (openscad.sphere(r_from_dia(size))
- rotcy([0,0,0], cy_r, cy_h)
- rotcy([1,0,0], cy_r, cy_h)
return (openscad.sphere(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))

openscad.assemble( example001() )
2 changes: 1 addition & 1 deletion examples/example005.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def example005():
translate([100, 0, 35], cube(50, True))
])]
+ map(lambda i:
translate([sin(pi*i/3)*80,
translate([sin(pi*i/3)*80,
cos(pi*i/3)*80, 0 ],
cylinder(r=10,h=200)), range(0,6))
+ [translate([0, 0, 200],
Expand Down
8 changes: 4 additions & 4 deletions examples/example006.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def edgeprofile():
+map(lambda rot: rotate(ang=pi/2, vec=rot, children=
map(lambda p: translate([ p[0]*50, p[1]*50, 0 ],
rotate(ang=p[2], vec=[0,0,1], child=edgeprofile())
), [ [+1, +1, 0],
[-1, +1, pi/2],
[-1, -1, pi],
), [ [+1, +1, 0],
[-1, +1, pi/2],
[-1, -1, pi],
[+1, -1, 3*pi/2]])
)
,[ [0, 0, 0], [1, 0, 0], [0, 1, 0] ])
Expand All @@ -32,7 +32,7 @@ def edgeprofile():
)
)
)
),
),
[
[ 0, 0, [ [0, 0] ] ],
[ pi/2, 0, [ [-20, -20], [+20, +20] ] ],
Expand Down
4 changes: 2 additions & 2 deletions examples/example007.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def clip():
)

def cutout():
ext = map(lambda lay: translate([0, 0, -50],
ext = map(lambda lay: translate([0, 0, -50],
dxf_linear_extrude(
file="example007.dxf",
layer=lay,
h=100,
convexity=2)), ["cutout1", "cutout2"])
return intersection([
rotate(pi/2, [1, 0, 0], child=ext[0]),
rotate(pi/2, [0, 0, 1],
rotate(pi/2, [0, 0, 1],
rotate(pi/2, [1, 0, 0], child=ext[1])
)
])
Expand Down
2 changes: 1 addition & 1 deletion examples/example008.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def ext(lay):

rotate(pi/2,[1, 0, 0], child=
translate([ -25, -125, -25], ext("E"))),

rotate(pi/2, [0, 1, 0], child=
translate([ -125, -125, -25], ext("B")))
]),
Expand Down
2 changes: 1 addition & 1 deletion examples/example009.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
frame = union( [
dxf_linear_extrude(dxf, "body",
bodywidth, convexity=10, center=True)]
+map(lambda z:
+map(lambda z:
translate([0, 0, z],
dxf_linear_extrude(dxf, "plate",
platewidth, convexity = 10, center=True)),
Expand Down
2 changes: 1 addition & 1 deletion examples/example012.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

openscad.result = difference([
sphere(20),

translate([ -2.92, 0.5, +20 ], rotate([pi, 0, pi],
import_stl("example012.stl", 5)
))])
Expand Down
2 changes: 1 addition & 1 deletion examples/example015.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def shape():
rotate(-pi/4, child=scale([ 0.7, 1.3 ], circle(5)))
]),
import_dxf( "example009.dxf",
"body",scale=2.0, convexity=10)
"body",scale=2.0, convexity=10)
])


Expand Down
8 changes: 4 additions & 4 deletions examples/example017.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def shape_tripod():
x8 = x7 - thickness
x9 = x8 - thickness
x10 = x9 - thickness

y1 = 0
y2 = y1 + thickness
y3 = y2 + thickness
Expand Down Expand Up @@ -58,12 +58,12 @@ def shape_tripod():
]),
translate([ x5, y1 ],
square([ boltlen - thickness, thickness*2 ])),

translate([ x5 + boltlen - thickness, y2 ],
circle(thickness)),

translate([ x2, y2 ],roundedCorner),

translate([ x8, y5 ],roundedCorner)
])

Expand Down Expand Up @@ -91,7 +91,7 @@ def shape_outer_disc():
midhole + boltlen + inner1_to_inner2 + thickness + locklen1/2,
locklen1,
midhole + boltlen + inner1_to_inner2)


def parts():
tripod_x_off = locklen1 - locklen2 + inner1_to_inner2;
Expand Down
6 changes: 3 additions & 3 deletions examples/example018.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from math import pi

def thing(type):
return [sphere(30),
cube(60, True),
return [sphere(30),
cube(60, True),
cylinder(50, 30, center=True),
union([cube(45, True)]+
[rotate([0,0,pi/4][i:i+3], cube(50, True)) for i in [0,1,2]]
Expand All @@ -12,6 +12,6 @@ def thing(type):


openscad.result = union(
[translate([x*100-150,y*100-150], thing(x+y))
[translate([x*100-150,y*100-150], thing(x+y))
for x in range(0,4) for y in range(0,4)]
)
4 changes: 2 additions & 2 deletions examples/example020.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ def pointFromWirealpha(wirealpha):
points1.append(pointFromWirealpha(wirealpha))
points2.append(pointFromWirealpha(wirealpha-pi))
return linear_extrude(child=polygon(points1+points2),h=height, twist=pi*height/hr, convexity=5).fn( steps*hr/r2 )

openscad.result = union([

translate([ -30, 0, 0 ],
screw()),

translate([ 30, 0, 0 ],
nut()),

spring()
])
2 changes: 1 addition & 1 deletion examples/example022.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def roundedBox(size, radius, sidesonly):
res = []
def r(x):
res.append(x)
if sidesonly:
if sidesonly:
r(cube([size[0]-2*radius, size[1], size[2]], True))
r(cube([size[0], size[1]-2*radius, size[2]], True))

Expand Down
6 changes: 3 additions & 3 deletions examples/sierpinsky.scad.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def sierpinski_rec(iters, size, inverse, square):
[0, -size+tiny, 0],
[size-tiny, 0, 0],
[-size+tiny, 0, 0],
[0, size-tiny, 0],
[0, size-tiny, 0],
[0, 0, height-tiny]
]
else:
Expand All @@ -95,7 +95,7 @@ def sierpinski_rec(iters, size, inverse, square):
[-sval+tiny, -cval+tiny, 0],
[0, 0, height-tiny]
]

pyramids = []
for t in trans:
pyramids.append(
Expand All @@ -105,7 +105,7 @@ def sierpinski_rec(iters, size, inverse, square):
pyramids.append(
translate([0, 0, 0], sierpinski(iters-1, size*2, True, square))
)

return union(pyramids)

def sierpinski(iters=4, size=35, inverse=False, square=True):
Expand Down
4 changes: 2 additions & 2 deletions examples/sponge.scad.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
def bars(maxIter = 1, offx=0,offy=0,iter=1):
s3 = cubesize / pow(3, iter)
res = [
translate([s3+offx,s3+offy,-1],
translate([s3+offx,s3+offy,-1],
cube([s3, s3, cubesize+2]))]
if iter < maxIter:
iter+=1
res += [
bars(maxIter,offx+x*s3,offy+y*s3,iter)
bars(maxIter,offx+x*s3,offy+y*s3,iter)
for x in range(0,3) for y in range (0,3)]
return union(res)

Expand Down
2 changes: 1 addition & 1 deletion glew.pri
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
glew {
isEmpty(DEPLOYDIR) {
# Optionally specify location of GLEW using the
# Optionally specify location of GLEW using the
# GLEWDIR env. variable
GLEW_DIR = $$(GLEWDIR)
isEmpty(GLEW_DIR) {
Expand Down
Loading