GithubHelp home page GithubHelp logo

haskell-things / implicitcad Goto Github PK

View Code? Open in Web Editor NEW
1.3K 48.0 140.0 9.02 MB

A math-inspired CAD program in haskell. CSG, bevels, and shells; 2D & 3D geometry; 2D gcode generation...

Home Page: https://implicitcad.org/

License: GNU Affero General Public License v3.0

Haskell 41.05% Makefile 0.75% Nix 0.20% OpenSCAD 0.06% JavaScript 57.95%
haskell openscad csg sdfs 3d-printing

implicitcad's People

Contributors

bergey avatar bgamari avatar canadaduane avatar chicagoduane avatar colah avatar eelis avatar elimohl avatar fisx avatar fuho avatar isovector avatar julialongtin avatar junjihashimoto avatar krakrjak avatar l29ah avatar lepsa avatar matthewsorensen avatar mmachenry avatar mokshasoft avatar raghuugare avatar rotty avatar ryantrinkle avatar sarda-nikhil avatar shkoo avatar shoito avatar silky avatar sorki avatar speps avatar theotherjimmy avatar timlyo avatar tolomea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

implicitcad's Issues

STL Support

What do you think about adding STL support? Although it's a pain to have one more step in between CSG and actually printing/cutting what you create, I think it makes sense. In particular, because of the rapid progress of projects like Slic3r (STL->gcode) and Marlin (firmware for 3D printers) a CSG project decoupled from these efforts would be a great boon to the community. In other words, ImplicitCAD can focus on what it does best, without worrying about gcode incompatibilities between versions of firmware etc.

scad: rotate around an arbitrary axis is not supported

difference() {
sphere(r=25);
rotate(90, [0, 0, 1]) cylinder(r=12.5,h=50,center=true);
rotate(90, [1, 0, 0]) cylinder(r=12.5,h=50,center=true);
rotate(90, [0, 1, 0]) cylinder(r=12.5,h=50,center=true);
}

produces:

Module rotate gave the following warnings:
unused arguments
Module rotate gave the following warnings:
unused arguments
Module rotate gave the following warnings:
unused arguments
Rendering 3D object to bob.stl
DifferenceR3 0.0 [Sphere 25.0,Rotate3 (90.0,0.0,0.0) (Translate3 (0.0,0.0,-25.0) (ExtrudeR 0.0 (Circle 12.5) 50.0)),Rotate3 (90.0,0.0,0.0) (Translate3 (0.0,0.0,-25.0) (ExtrudeR 0.0 (Circle 12.5) 50.0)),Rotate3 (90.0,0.0,0.0) (Translate3 (0.0,0.0,-25.0) (ExtrudeR 0.0 (Circle 12.5) 50.0))]

For Loop

For loop only makes one object

$res = 1;
linear_extrude (height = 10, center=true) {
  for (a = [0:10]) {
    translate ([a * 10,a * 10]) circle (9, $fn=6);
  }
}

function variable binding is not consistent with openscad

In particular it looks like openscad is binding free variables at module invocation and implicitcad at module definition.

This scad:

function bob(x) = x*y;
y=10;
sphere(bob(1));

produces a sphere of size 10 in openscad and the following error in implicitcad:

Module sphere failed with the following messages:
error in computing value for arugment r: Can't multiply objects of types Number and Undefined.
Nothing to render

This scad:

y=10;
function bob(x) = x*y;
y=1;
sphere(bob(1));

produces a sphere of size 1 in openscad and a sphere of size 10 in implicitcad.

I'm not sure how useful this behavior is, but if we were not going to support it we would need to come up with a good error message that catches both cases.

unable to compile head (4c4ea)

$ cabal install
Resolving dependencies...
Configuring implicit-0.0.1...
Preprocessing library implicit-0.0.1...
cabal: can't find source for Graphics.Implicit.Interface in .,
dist/build/autogen
cabal: Error: some packages failed to install:
implicit-0.0.1 failed during the building phase. The exception was:
ExitFailure 1

Generalized extrusion along a path

I just opened a similar issue to this against OpenSCAD itself (openscad/openscad#114), but it applies equally well here.

It would be nice if one could extrude a two-dimensional figure along a path. This would allow the user to specify a path (a series of points or perhaps even a more sophisticated path representation), a 2d figure, and perhaps a basis set to construct the product space of these two spaces. Clearly this is not a trivial request, but it should be recorded nevertheless.

This could be a nice differentiating factor for ImplicitCAD if it is implemented here first. It doesn't seem like it would be too difficult to do this in the implicit function representation.

scad: the second and third angles to rotate are reversed

function rad(x) = x/180.0*3.14159265; // implicitcad
//function rad(x) = x; // openscad

difference()
{
cube(100, center = true);
for (i = [
[0, 0], [90, 0], [180, 0], [270, 0], [0, 90], [0, -90],
]) {
rotate([0, 0, rad(i[0])]) rotate([rad(i[1]), 0, 0]) translate([0, -50, 0]) sphere(10);
}
}

moving rad(i[0]) to the middle position in that list produces the same behavior as openscad

Ambiguous module name `Prelude':

Hello,

Below is the build error with ghc-7.4.1:

cabal install implicit
Resolving dependencies...
Configuring implicit-0.0.1...
Building implicit-0.0.1...
Preprocessing library implicit-0.0.1...

Graphics/Implicit.hs:1:1:
    Ambiguous module name `Prelude':
      it was found in multiple packages: base haskell98-2.0.0.1
cabal: Error: some packages failed to install:
implicit-0.0.1 failed during the building phase. The exception was:
ExitFailure 1

Following the suggestion in the below link, if haskell98 is removed as a dependency
http://stackoverflow.com/questions/9913299/cant-build-cabal-package-due-to-ambiguous-prelude

then the build error is:

Resolving dependencies...
Configuring implicit-0.0.2...
Building implicit-0.0.2...
Preprocessing library implicit-0.0.2...
[ 1 of 49] Compiling Graphics.Implicit.Definitions ( Graphics/Implicit/Definitions.hs, dist/build/Graphics/Implicit/Definitions.o )
[ 2 of 49] Compiling Graphics.Implicit.Export.Definitions ( Graphics/Implicit/Export/Definitions.hs, dist/build/Graphics/Implicit/Export/Definitions.o )
[ 3 of 49] Compiling Graphics.Implicit.Export.PolylineFormats ( Graphics/Implicit/Export/PolylineFormats.hs, dist/build/Graphics/Implicit/Export/PolylineFormats.o )
[ 4 of 49] Compiling Graphics.Implicit.Export.TriangleMeshFormats ( Graphics/Implicit/Export/TriangleMeshFormats.hs, dist/build/Graphics/Implicit/Export/TriangleMeshFormats.o )
[ 5 of 49] Compiling Graphics.Implicit.MathUtil ( Graphics/Implicit/MathUtil.hs, dist/build/Graphics/Implicit/MathUtil.o )
[ 6 of 49] Compiling Graphics.Implicit.Operations.Definitions ( Graphics/Implicit/Operations/Definitions.hs, dist/build/Graphics/Implicit/Operations/Definitions.o )
[ 7 of 49] Compiling Graphics.Implicit.Operations.ObjPair ( Graphics/Implicit/Operations/ObjPair.hs, dist/build/Graphics/Implicit/Operations/ObjPair.o )
[ 8 of 49] Compiling Graphics.Implicit.Operations.SymbolicObjPair ( Graphics/Implicit/Operations/SymbolicObjPair.hs, dist/build/Graphics/Implicit/Operations/SymbolicObjPair.o )
[ 9 of 49] Compiling Graphics.Implicit.SaneOperators ( Graphics/Implicit/SaneOperators.hs, dist/build/Graphics/Implicit/SaneOperators.o )
[10 of 49] Compiling Graphics.Implicit.Operations.Obj2 ( Graphics/Implicit/Operations/Obj2.hs, dist/build/Graphics/Implicit/Operations/Obj2.o )
[11 of 49] Compiling Graphics.Implicit.Operations.Obj3 ( Graphics/Implicit/Operations/Obj3.hs, dist/build/Graphics/Implicit/Operations/Obj3.o )
[12 of 49] Compiling Graphics.Implicit.Operations.SymbolicObj2 ( Graphics/Implicit/Operations/SymbolicObj2.hs, dist/build/Graphics/Implicit/Operations/SymbolicObj2.o )
[13 of 49] Compiling Graphics.Implicit.Operations.SymbolicObj3 ( Graphics/Implicit/Operations/SymbolicObj3.hs, dist/build/Graphics/Implicit/Operations/SymbolicObj3.o )
[14 of 49] Compiling Graphics.Implicit.Primitives.Definitions ( Graphics/Implicit/Primitives/Definitions.hs, dist/build/Graphics/Implicit/Primitives/Definitions.o )
[15 of 49] Compiling Graphics.Implicit.Primitives.Obj2 ( Graphics/Implicit/Primitives/Obj2.hs, dist/build/Graphics/Implicit/Primitives/Obj2.o )
[16 of 49] Compiling Graphics.Implicit.Primitives.Obj3 ( Graphics/Implicit/Primitives/Obj3.hs, dist/build/Graphics/Implicit/Primitives/Obj3.o )
[17 of 49] Compiling Graphics.Implicit.Primitives.BoxedObj2 ( Graphics/Implicit/Primitives/BoxedObj2.hs, dist/build/Graphics/Implicit/Primitives/BoxedObj2.o )
[18 of 49] Compiling Graphics.Implicit.Primitives.BoxedObj3 ( Graphics/Implicit/Primitives/BoxedObj3.hs, dist/build/Graphics/Implicit/Primitives/BoxedObj3.o )
[19 of 49] Compiling Graphics.Implicit.Primitives.SymbolicObj2 ( Graphics/Implicit/Primitives/SymbolicObj2.hs, dist/build/Graphics/Implicit/Primitives/SymbolicObj2.o )
[20 of 49] Compiling Graphics.Implicit.Primitives.SymbolicObj3 ( Graphics/Implicit/Primitives/SymbolicObj3.hs, dist/build/Graphics/Implicit/Primitives/SymbolicObj3.o )
[21 of 49] Compiling Graphics.Implicit.Operations.Box2 ( Graphics/Implicit/Operations/Box2.hs, dist/build/Graphics/Implicit/Operations/Box2.o )
[22 of 49] Compiling Graphics.Implicit.Operations.BoxedObj2 ( Graphics/Implicit/Operations/BoxedObj2.hs, dist/build/Graphics/Implicit/Operations/BoxedObj2.o )
[23 of 49] Compiling Graphics.Implicit.Operations.Box3 ( Graphics/Implicit/Operations/Box3.hs, dist/build/Graphics/Implicit/Operations/Box3.o )
[24 of 49] Compiling Graphics.Implicit.Operations.BoxedObj3 ( Graphics/Implicit/Operations/BoxedObj3.hs, dist/build/Graphics/Implicit/Operations/BoxedObj3.o )
[25 of 49] Compiling Graphics.Implicit.Operations.BoxPair ( Graphics/Implicit/Operations/BoxPair.hs, dist/build/Graphics/Implicit/Operations/BoxPair.o )
[26 of 49] Compiling Graphics.Implicit.Operations.BoxedObjPair ( Graphics/Implicit/Operations/BoxedObjPair.hs, dist/build/Graphics/Implicit/Operations/BoxedObjPair.o )
[27 of 49] Compiling Graphics.Implicit.Operations ( Graphics/Implicit/Operations.hs, dist/build/Graphics/Implicit/Operations.o )
[28 of 49] Compiling Graphics.Implicit.Primitives ( Graphics/Implicit/Primitives.hs, dist/build/Graphics/Implicit/Primitives.o )
[29 of 49] Compiling Graphics.Implicit.ExtOpenScad.Definitions ( Graphics/Implicit/ExtOpenScad/Definitions.hs, dist/build/Graphics/Implicit/ExtOpenScad/Definitions.o )
[30 of 49] Compiling Graphics.Implicit.ExtOpenScad.Default ( Graphics/Implicit/ExtOpenScad/Default.hs, dist/build/Graphics/Implicit/ExtOpenScad/Default.o )
[31 of 49] Compiling Graphics.Implicit.ExtOpenScad.Expressions ( Graphics/Implicit/ExtOpenScad/Expressions.hs, dist/build/Graphics/Implicit/ExtOpenScad/Expressions.o )
[32 of 49] Compiling Graphics.Implicit.ExtOpenScad.Util ( Graphics/Implicit/ExtOpenScad/Util.hs, dist/build/Graphics/Implicit/ExtOpenScad/Util.o )
[33 of 49] Compiling Graphics.Implicit.ExtOpenScad.Primitives ( Graphics/Implicit/ExtOpenScad/Primitives.hs, dist/build/Graphics/Implicit/ExtOpenScad/Primitives.o )
[34 of 49] Compiling Graphics.Implicit.ExtOpenScad.Statements ( Graphics/Implicit/ExtOpenScad/Statements.hs, dist/build/Graphics/Implicit/ExtOpenScad/Statements.o )
[35 of 49] Compiling Graphics.Implicit.ExtOpenScad ( Graphics/Implicit/ExtOpenScad.hs, dist/build/Graphics/Implicit/ExtOpenScad.o )
[36 of 49] Compiling Graphics.Implicit.Export.MarchingSquares ( Graphics/Implicit/Export/MarchingSquares.hs, dist/build/Graphics/Implicit/Export/MarchingSquares.o )
[37 of 49] Compiling Graphics.Implicit.Export.BoxedObj2 ( Graphics/Implicit/Export/BoxedObj2.hs, dist/build/Graphics/Implicit/Export/BoxedObj2.o )
[38 of 49] Compiling Graphics.Implicit.Export.MarchingSquaresFill ( Graphics/Implicit/Export/MarchingSquaresFill.hs, dist/build/Graphics/Implicit/Export/MarchingSquaresFill.o )
[39 of 49] Compiling Graphics.Implicit.Export.MarchingCubes ( Graphics/Implicit/Export/MarchingCubes.hs, dist/build/Graphics/Implicit/Export/MarchingCubes.o )
[40 of 49] Compiling Graphics.Implicit.Export.BoxedObj3 ( Graphics/Implicit/Export/BoxedObj3.hs, dist/build/Graphics/Implicit/Export/BoxedObj3.o )
[41 of 49] Compiling Graphics.Implicit.Export.Symbolic.CoerceSymbolic2 ( Graphics/Implicit/Export/Symbolic/CoerceSymbolic2.hs, dist/build/Graphics/Implicit/Export/Symbolic/CoerceSymbolic2.o )
[42 of 49] Compiling Graphics.Implicit.Export.Symbolic.CoerceSymbolic3 ( Graphics/Implicit/Export/Symbolic/CoerceSymbolic3.hs, dist/build/Graphics/Implicit/Export/Symbolic/CoerceSymbolic3.o )
[43 of 49] Compiling Graphics.Implicit.Export.Symbolic.Rebound2 ( Graphics/Implicit/Export/Symbolic/Rebound2.hs, dist/build/Graphics/Implicit/Export/Symbolic/Rebound2.o )
[44 of 49] Compiling Graphics.Implicit.Export.Symbolic.Rebound3 ( Graphics/Implicit/Export/Symbolic/Rebound3.hs, dist/build/Graphics/Implicit/Export/Symbolic/Rebound3.o )
[45 of 49] Compiling Graphics.Implicit.Export.SymbolicObj2 ( Graphics/Implicit/Export/SymbolicObj2.hs, dist/build/Graphics/Implicit/Export/SymbolicObj2.o )
[46 of 49] Compiling Graphics.Implicit.Export.Util ( Graphics/Implicit/Export/Util.hs, dist/build/Graphics/Implicit/Export/Util.o )
[47 of 49] Compiling Graphics.Implicit.Export.SymbolicObj3 ( Graphics/Implicit/Export/SymbolicObj3.hs, dist/build/Graphics/Implicit/Export/SymbolicObj3.o )
[48 of 49] Compiling Graphics.Implicit.Export ( Graphics/Implicit/Export.hs, dist/build/Graphics/Implicit/Export.o )
[49 of 49] Compiling Graphics.Implicit ( Graphics/Implicit.hs, dist/build/Graphics/Implicit.o )
Registering implicit-0.0.2...
Preprocessing executable 'extopenscad' for implicit-0.0.2...

extopenscad.hs:7:8:
    Could not find module `System'
    It is a member of the hidden package `haskell98-2.0.0.1'.
    Perhaps you need to add `haskell98' to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
implicit-0.0.2 failed during the building phase. The exception was:
ExitFailure 1

Module argument errors need improving.

This scad:

cube(x=1);

produces:

Module cube failed with the following messages:
No value and no default for argument size
Nothing to render

and this scad:

cube(x=1,size=1);

produces:

Module cube gave the following warnings:
unused arguments
Rendering 3D object to bob.stl
Rect3R 0.0 (0.0,0.0,0.0) (1.0,1.0,1.0)

Both errors need the file and line of the module call and the name(s) of the offending argument(s).

extrude with sin function as scale behaves strangely

I am trying to create an "undulating cylinder" of some kind, perhaps like a fancy chair leg or something. The thought was to use a 2D circle and extrude it with a varying scale function, a simple sin function to start with. Strange things ensued.

Pleasant3D Screenshot

Blender Screenshot

linear_extrude(height=20, center=true, scale(h)=0.5+cos(h)) {
  circle(10);
}

rotate3 results in hangup

import Graphics.Implicit

stencil = rotate3 (0,0,45) (unionR 1 [
    rect3R 0 (0,0,0) (20,20,80),
    cylinder 5 80 ]
    )

main = writeSTL 1 "test.stl" stencil

results in:

 File "/usr/lib/blender/scripts/addons/io_mesh_stl/__init__.py", line 99, in execute
    tris, pts = stl_utils.read_stl(path)
  File "/usr/lib/blender/scripts/addons/io_mesh_stl/stl_utils.py", line 239, in read_stl
    with mmap_file(filename) as data:
  File "/usr/lib/python3.2/contextlib.py", line 48, in __enter__
    return next(self.gen)
  File "/usr/lib/blender/scripts/addons/io_mesh_stl/stl_utils.py", line 52, in mmap_file
    map = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
ValueError: mmap offset is greater than file size

location:<unknown location>:-1

location:<unknown location>:-1

use unordered-containers instead of hashmap?

it seems that unordered-containers is the current "blessed" hashmap package, and "unordered-containers" and "hashmap" have overlapping module names. It might just be a change in imports to make it work.

STL triangulation not according to spec

Although not crucial now, the STL output is not according to the spec. First of all, all facet normals are zero. In that case programs tend to recalculate the facet normals. This is specified as

nv = (v2-v0) \cross (v1-v0)
with v0, v1, v2, nv R3 points

i.e. using the right-hand rule.

Regression on Cubes Based Rendering

Stack overflow when non-symbolically rendering certain 3D objects. Cause non determined.

eg.

>> extopenscad RoundedUnionCubeExample.escad 
Rendering 3D object to RoundedUnionCubeExample.stl
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize -RTS' to increase it.

Part of the stl is rapidly produced before freezing and then crashing. There's probably infinite recursion in Graphics.Implicit.Export.Obj3.GetMesh.

Issues with polygon primitive

Using ExtOpenSCAD rendering mode, ImplicitScad seems to produce some very odd results with the polygon primitive. For instance, with latest git clone, using the following code to render a triangle:

scale(100) polygon(points=[[1.0, 0.0], [-0.5, 0.8660254038], [-0.5, -0.8660254038], [1.0, 0.0]]);

produces an empty SVG output:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> 
</svg>

The same output is produced for a square and a hexagon as well. Bizarrely, however, if I increase the numerical precision of the points on a hexagon, I obtain an octagon:

scale(100) polygon(points=[[1.0, 0.0], [0.50000000000000011102230246251565404236316680908203125, 0.8660254037844385965883020617184229195117950439453125], [-0.4999999999999997779553950749686919152736663818359375, 0.86602540378443870761060452423407696187496185302734375], [-1.0, 0.000000000000000122464679914735320717376402945839660462569212467758006379625612680683843791484832763671875], [-0.500000000000000444089209850062616169452667236328125, -0.86602540378443837454369713668711483478546142578125], [0.4999999999999993338661852249060757458209991455078125, -0.8660254037844390406775119117810390889644622802734375], [1.0, -0.00000000000000024492935982947064143475280589167932092513842493551601275925122536136768758296966552734375]]
);

produces:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> 
  <polyline points=" 40.000004,161.65807 7.6293945e-6,115.47005" style="stroke:rgb(0,0,255);stroke-width:1;fill:none;"/> 
  <polyline points=" 40.0,161.65807 120.0,161.65807" style="stroke:rgb(0,0,255);stroke-width:1;fill:none;"/> 
  <polyline points=" 120.0,161.65807 160.0,115.47005" style="stroke:rgb(0,0,255);stroke-width:1;fill:none;"/> 
  <polyline points=" 7.6293945e-6,115.47005 0.0,46.18802" style="stroke:rgb(0,0,255);stroke-width:1;fill:none;"/> 
  <polyline points=" 160.0,115.47005 160.0,46.18802" style="stroke:rgb(0,0,255);stroke-width:1;fill:none;"/> 
  <polyline points=" 40.000004,0.0 0.0,46.18802" style="stroke:rgb(0,0,255);stroke-width:1;fill:none;"/> 
  <polyline points=" 40.0,0.0 120.0,0.0" style="stroke:rgb(0,0,255);stroke-width:1;fill:none;"/> 
  <polyline points=" 120.0,0.0 160.0,46.18802" style="stroke:rgb(0,0,255);stroke-width:1;fill:none;"/> 
</svg> 

Edited by @colah to fix formatting
Thanks for helping me figure this all out!

scad: rotate angles are being interpreted as radians

instead of degrees, consider these examples

difference() {
sphere(r=25);
rotate([0, 0, 90]) cylinder(r=12.5,h=50,center=true);
rotate([90, 0, 0]) cylinder(r=12.5,h=50,center=true);
rotate([0, 90, 0]) cylinder(r=12.5,h=50,center=true);
}

difference() {
sphere(r=25);
rotate([0, 0, 1.57079633]) cylinder(r=12.5,h=50,center=true);
rotate([1.57079633, 0, 0]) cylinder(r=12.5,h=50,center=true);
rotate([0, 1.57079633, 0]) cylinder(r=12.5,h=50,center=true);
}

large objects render really slow

this renders in 1/3 seconds (albeit with a rough output):

difference() {
cylinder(h = 5, r = 10, center=true);
cylinder(h = 6, r = 8, center=true);
}

this renders in 1m49:

difference() {
cylinder(h = 50, r = 100, center=true);
cylinder(h = 60, r = 80, center=true);
}

Extruded polygon has detached corners

I tried making a rectangle function ("rect") that takes width, height and depth, and produces a 3D rectangle. (It's an attempt to duplicate what OpenSCAD calls a "cube" which is not a particularly accurate name.) Here's the code:

import Graphics.Implicit

rect w h d = extrude d (polygon [(-w/2,h/2), (w/2,h/2), (w/2,-h/2), (-w/2,-h/2)])

out =
    union [
        rect 10 20 40,
        translate (20,20,20) (sphere 15)
    ]

main = writeSTL (-50,-50,-50) (50,50,50) 1 "test.stl" out

What I see is a rectangle with 2 of the corners "detached" from the rest of the body. [1] What do you think?

[1] http://dl.dropbox.com/u/118766/misc/implicit-cad-detached-corners.png

implicit unions are missing in several of places

In openscad transform modules union their arguments, as does the top level. So these all produce 2 spheres in penscad while in implicitcad they only produce 1 sphere, in all cases of size one, for the first two cases because that one was first, in the third case the difference of the first and second which is the first since they are non intersecting.

sphere(1);
translate([10,10,10]) sphere(2);

translate([0,0,0]){
sphere(1);
translate([10,10,10]) sphere(2);
}

difference(){
translate([0,0,0]){
sphere(1);
translate([10,10,10]) sphere(2);
}
}

DXF Import Not Working

I was able to get basic linear_extrude example working, but as soon as I attempt to import a DXF file for extrusion I run into problems. I tried two approaches.

  1. linear_extrude(file = "path.dxf", height = 20);
    result:
    At line 7:Module linear_extrude gave the following warnings: unused arguments
    Nothing to render
  2. linear_extrude(height = 20) import("path.dxf");
    At line 7:module import is not in scope

Perhaps dxf import is not supported at this time. Is any other import format supported?

More functions as parameters

I love the ability of ImplicitCAD to use a function for the twist parameter of linear_extrude and I think it would be amazing is this were available in more places.
Some good examples would be the radius of circles and spheres. Maybe even the radius of a cylinder, which could vary with the height as well as the arc angle.

I was hoping to produce a wavy circle with this:

Prelude Graphics.Implicit> writeSVG 1 "test.svg" (let r x = sin(x) in circle(r))

<interactive>:1:51:
    Couldn't match expected type `Float' with actual type `a0 -> a0'
    Expected type: Graphics.Implicit.Definitions.â


    In the first argument of `circle', namely `(r)'
    In the expression: circle (r)

getMesh returns empty list on small rect3R

writeSTL 1 "empty.stl" (rect3R 0 (0,0,0) (2, 0.75, 1.5))

produces an STL file with only two lines:

solid ImplictCADExport
endsolid ImplictCADExport

I've traced this as far as getMesh returning an empty list. If I provide getMesh with a larger bounding box, I can get triangles out of it:

> take 1 $ getMesh (-0.2, -0.2, -0.2) (2.2, 1.1, 1.7) 1 (getImplicit3  (rect3R 0 (0,0,0) (2, 0.75, 1.5)))
[((0.6,2.9802322e-8,0.24248523),(0.6,0.0,0.75000006),(0.13543102,0.0,0.75000006))]

(rebound3 gives the bounding box (-0.2,-7.5e-2,-0.15) (2.2,0.825,1.65))

Is an empty list ever a valid result, or would it make sense to check and handle it as an error?

Low resolution on output--configurable resolution for extopenscad?

I'm seeing poor output on small parts, which I assume is due to low default resolution for extopenscad. For example, here is a 2x10mm rectangle extruded to a height of 65mm. The resulting output is of poor quality.

phone_width = 65.0;

linear_extrude(height=phone_width, center=true, translate(h)=[0, sin(h/(phone_width/4))*10]) {
  square([2.0, 10.0]);
}

Low Resolution

Is this configurable? Should it be?

extopenscad --help

extopenscad: --help: openFile: does not exist (No such file or directory)

doesn't build on ghc 7.4

when I cabal install implicit, i get an error about an ambiguous prelude. I'm not quite sure how this is coming up, but i guess cabal can't figure out in ghc 7.4 if you mean the default ghc prelude or one of the haskel98 or 2010 ones. I'm not sure what is the actual cause of this though.

+1 breaks implicitSCAD

for (i = [-1, +1]) {} // this breaks the implicitSCAD

for (i = [-1, 1]) {} // this does not break implicitSCAD

First example doesn't work

translating it translates it to the center of the rectangle, covering it. Is that a mistake or did something change between versions, the rectangle starting from the corner rather than the center?

Suggest at least making the size of the circle in the example between 50 and sqrt(2*40^2) so it is always clear what is happening. (Then they cant completely cover each other)

Wrong object created in some cases

Try this in your browser and look if there is a rotated cube sticking out of the plane. All I see is a nub...

union(){
  rotate([45,0,0]){
    cube([1,1,10]);
    }
  translate([-5,-5,0]){
    cube([10,30,1]);  //If I use cube([10,20,1]); this works without problem.
  }
}

Bad Error Messages

Error messages are an essential part of usability. Ours suck.

As of c8451ba there will be no more quietly failing on syntax errors. Instead, there are messages with line number, column number, and what the parser was expecting when it failed. This is a step in the right direction.

However, there remain severe issues with execution errors. echo("a"+0); will result in Undefined. This must be fixed.

Broken mesh output

This scad file:

difference() {
sphere(20);
cylinder(r=17, h=100, center = true);
}

produces non manifold output, here's the admesh output:

================= Results produced by ADMesh version 0.95 ================
Input file : mesh_death.stl
File type : ASCII STL file
Header : solid ImplictCADExport
============== Size ==============
Min X = -20.000000, Max X = 20.000000
Min Y = -20.000000, Max Y = 20.000000
Min Z = -10.252552, Max Z = 10.252552
========= Facet Status ========== Original ============ Final ====
Number of facets : 13184 12864
Facets with 1 disconnected edge : 328 0
Facets with 2 disconnected edges : 36 0
Facets with 3 disconnected edges : 0 0
Total disconnected facets : 364 0
=== Processing Statistics === ===== Other Statistics =====
Number of parts : 1 Volume : 4499.025879
Degenerate facets : 560
Edges fixed : 0
Facets removed : 560
Facets added : 240
Facets reversed : 24867
Backwards edges : 198
Normals fixed : 12864

rotation problems

I'm currently designing a machine part using ImplicitCAD's Haskell interface, from today's git sources. I ran into an issue when I wanted to create a bolt pattern for a motor by rotation. The public interface was missing "rotate" and "rotate3". So I edited the Implicit.hs file and added those.

However, after this I noticed that "rotate3 (0, 0, 0)" is not an identity operation, "rotate3 (pi/2, 0, 0)" is. That seems somewhat odd... is this the intended behaviour?

" + " -- spaces around plus

At least in some contexts, the parser has issues with whitespace padded pluses. This really shouldn't be happening, but it is :(

Why does a shell get scaled when applied to a scaled object?

Hi,

I'm probably misunderstanding something (or possibly everything), but if I do this:

import Graphics.Implicit
sq = rectR 0 (-100,-100) (100,100)
test = shell 50 (scale (2,1) sq)
main = writeSVG 1 "test.svg" test

I was expecting to see a 400x200 rectangle with a 50 unit shell around the outside, but the shell is twice as thick on the left and right sides as it is top and bottom, as if the scale has been applied after adding the shell rather than before adding the shell.

Where am I going wrong?

Thanks,
Rob.

scad user functions don't parse

This scad:

function noop(x) = x;

produces:

(line 1, column 10):
unexpected "n"
expecting assignment statement, space or "("

Support for $f_ variables

Consider the code

circle(r = R, $fn = 6);

In OpenSCAD, this is a regular hexagon inscribed inside a circle of radius R. In ImplicitCAD (as of today) it's a circle and a compile warning.

OpenSCAD global variables (starting with dollar signs) are a curious variety of scoped globals, which are in effect passed implicitly to every module and function. If I invoke a module M like so:

M($fn = 10);

it overrides the value of $fn inside M and any sub-modules it invokes -- unless they override $fn themselves.

While I often use these globals to adjust quality for 3D printing -- both to add vertices to overly chunky parts, and to remove them to speed up printing -- they're not purely cosmetic. I use $fn specifically for the regular-polygon-in-a-circle case described above, to model things like hex nuts.

In the interest of source compatibility with OpenSCAD I think these are worth implementing, even though they're weird.

weird spikes

>import Graphics.Implicit.Primitives
>import Graphics.Implicit
>import Data.NumInstances

>main =
> writeSTL
>  1
>  "foo.stl" $
>  squarePipe (10,10,10) 1 30 -- Change this value up or down, from 30 try 10 or 100, neither have spikes

>squarePipe
> (x,y,z)
> diameter
> precision
>  =
> union $
> map
>  (\start->
>    translate
>     start
>     (rect3R 0 (0,0,0) (diameter,diameter,diameter))) $
> zip3
>  (map (\n->(n/precision)*x) [0..precision])
>  (map (\n->(n/precision)*y) [0..precision])
>  (map (\n->(n/precision)*z) [0..precision])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.