在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Haskell-Things/ImplicitCAD开源软件地址(OpenSource Url):https://github.com/Haskell-Things/ImplicitCAD开源编程语言(OpenSource Language):Haskell 83.4%开源软件介绍(OpenSource Introduction):ImplicitCAD: Math Inspired CADIntroductionImplicitCAD is a programmatic CAD program, implemented in Haskell. Unlike traditional CAD programs, programmatic CAD programs use text descriptions of objects, as in programming. Concepts like variables, control structures and abstraction are used, just as in programming. This provides a number of advantages:
The traditional example of programmatic CAD is OpenSCAD. Generally, objects in programmatic CAD are built with Constructive Solid Geometry or CSG. Unions, intersections and differences of simpler shapes slowly build the object. ImplicitCAD supports all this and much more! For example, it provides rounded unions so that one can have smooth interfaces between objects. It also directly provides some GCode generation, and has a parser for OpenSCAD to make it easier for people to transition/use. ImplicitCAD is very much a work in progress. The author considers it ready for beta testers and greatly appreciates bug reports. ExtOpenSCAD ExamplesLet's begin with OpenSCAD examples, since they're likely a more comfortable format than Haskell for most readers :) ImplicitCAD supports a modified version of the OpenSCAD language, used by the popular programmatic CAD tool of the same name. Generally, normal OpenSCAD code should work. For example, save the following as // example1.scad -- The union of a square and a circle.
union() {
square([80,80]);
translate ([80,80]) circle(30);
} Running You can read more about standard openscad functionality in the OpenSCAD User Manual. However, there are additional ImplicitCAD specific features. For example a rounded union: //example2.escad -- A rounded union of a square and a circle.
union(r=14) {
square([80,80]);
translate ([80,80]) circle(30);
} (For code like this that is not backwards compatible with OpenSCAD, it is recommended that you save it as a .escad file -- Extended OpenSCAD.) Like openscad, ImplicitCAD supports extruding objects. // example3.escad -- the extruded product of the union of five circles.
linear_extrude (height = 40, center=true){
union ( r = 8) {
circle (10);
translate ([22,0]) circle (10);
translate ([0,22]) circle (10);
translate ([-22,0]) circle (10);
translate ([0,-22]) circle (10);
}
} And we allow you to twist them as you extrude. // example4.escad -- the twisted extruded product of the union of five circles.
linear_extrude (height = 40, center=true, twist=90){
union ( r = 8) {
circle (10);
translate ([22,0]) circle (10);
translate ([0,22]) circle (10);
translate ([-22,0]) circle (10);
translate ([0,-22]) circle (10);
}
} In fact, we've extended this to allow you to twist at non-constant rates and even reverse directions. You just make // example5.escad -- the variably twisted extruded product of the union of 5 circles.
linear_extrude (height = 40, center=true, twist(h) = 35*cos(h*2*pi/60)) {
union ( r = 8) {
circle (10);
translate ([22,0]) circle (10);
translate ([0,22]) circle (10);
translate ([-22,0]) circle (10);
translate ([0,-22]) circle (10);
}
} We also allow you to do rounded extrusions. See, we heard you like rounding, so we set this up so you can rounded extrude your rounded union... // example6.escad -- A rounded extrusion of the rounded union of 5 circles.
linear_extrude (height = 40, center=true, r=5){
union ( r = 8) {
circle (10);
translate ([22,0]) circle (10);
translate ([0,22]) circle (10);
translate ([-22,0]) circle (10);
translate ([0,-22]) circle (10);
}
} This is fully compatible with twisting, of course! // example7.escad -- A twisted rounded extrusion of the rounded union of 5 circles.
linear_extrude (height = 40, center=true, twist=90, r=5){
union ( r = 8) {
circle (10);
translate ([22,0]) circle (10);
translate ([0,22]) circle (10);
translate ([-22,0]) circle (10);
translate ([0,-22]) circle (10);
}
} ImplicitCAD also provides full programmatic functionality, like variable assignment in loops. For example, the trivial program: // Example8.escad -- variable assignment in loops.
a = 5;
for (c = [1, 2, 3]) {
echo(c);
a = a*c;
echo(a);
} Has the output:
As a functional programmer, I couldn't resist adding some other niceties to the language. For example, function currying: // Example9.escad -- function currying.
f = max(4);
echo(f(5));
echo(max(4,5)); And some higher order functions, like my friend map: // Example10.escad -- map!.
echo(map(cos, [0, pi/2, pi])); Haskell ExamplesEverything you saw above can be done with the Haskell API. For example, a simple 2D example, the same as our first ExtOpenSCAD one: -- Example 11 - the union of a square and a circle.
import Graphics.Implicit
out = union [
squareR 0 True (80, 80)
, translate (40, 40) (circle 30)
]
main = writeSVG 2 "test.svg" out A rounded union: -- Example 12 - the rounded union of a square and a circle.
import Graphics.Implicit
out = unionR 14 [
squareR 0 True (80, 80)
, translate (80, 80) (circle 30)
]
main = writeSVG 2 "test.svg" out A simple 3D example: -- Example 13 - the union of a cube and a sphere.
import Graphics.Implicit
out = union [
cubeR 0 False (20, 20, 20)
, translate (20, 20, 20) (sphere 15)
]
main = writeSTL 1 "test.stl" out You can do a whole lot more! Try ImplicitCAD!
DocumentationDocumentation can be generated from the source code of ImplicitCAD by Haddock by running Releases of ImplicitCAD are uploaded to HackageDB which, in addition to making them avaialable through In Implicit CAD, we consider objects as functions of `outwardness'. The boundary is 0, negative is the interior and positive the exterior. The magnitude is how far out or in. A description of the mathematical ideas underpinning ImplicitCAD are in a blog post on colah's blog. Related projectsStatusImplicitCAD is very much a work in progress. What works (January 26th, 2020 -- regressions are possible if not probable):
What still needs to be done:
And a wishlist of things to be done as we go:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论