项目作者: perunlabs

项目描述 :
constructive solid geometry
高级语言: Java
项目地址: git://github.com/perunlabs/jsolid.git
创建时间: 2016-10-21T12:09:11Z
项目社区:https://github.com/perunlabs/jsolid

开源协议:Apache License 2.0

下载


jsolid is a java library for
Constructive Solid Geometry
that internally uses JCSG library which uses
binary space partitioning algorithm.
It’s great for programmatically generating STL shapes for 3d printer.

Tutorial

To use jsolid you need download latest release jar.
Whole API is available via static methods of
JSolid
class so all you need is to import it by adding following line
(which is omitted for simplicity in all following examples).
You may also want to add this line to favorites in your IDE.

  1. import static com.perunlabs.jsolid.JSolid.*;

All curved (rounded) edges are approximated with finite precision,
which is configured by specifying maximal distance allowed between required curve
and closest point of approximated solid.

  1. config().setCircleToPolygonPrecision(0.1);

Once you build your solid you can store it as STL file using

  1. com.perunlabs.jsolid.d3.Stl.toStl(solid, "path/on/disk");

Examples

simple cuboid (preview)

  1. cuboid(2, 4, 8);

cuboid with rounded corners (preview)

  1. cuboid(5, 5, 5)
  2. .cornerR(z(), 1);

simple cylinder (preview)

  1. cylinder(5, 10);

cylinder with many segments (preview)

  1. cylinder(10, 2)
  2. .addSegment(5, 10)
  3. .addFunnel(3, 2)
  4. .addSegment(4);

rotated (preview)

  1. cylinder(2, 10)
  2. .rotate(y(), degrees(45));

adding solids (preview)

  1. cylinder(2, 10)
  2. .add(cuboid(10, 2, 5));

subtracting solids (preview)

  1. cylinder(2, 10)
  2. .sub(cuboid(10, 2, 5));

intersecting solids (preview)

  1. cylinder(2, 10)
  2. .intersect(cuboid(10, 2, 5));

adding with shift (preview)

  1. cylinder(3, 1)
  2. .add(cuboid(6, 6, 1).moveBy(vx(5)));

subtracting with alignment (preview)

  1. cuboid(4, 4, 4)
  2. .sub(cylinder(1, 1), align(maxZ()));

subtracting with two alignments (preview)

  1. cuboid(4, 4, 4)
  2. .sub(cuboid(1, 1, 4), align(maxX()), align(minY()));

adding with outside alignment (preview)

  1. cuboid(4, 4, 4)
  2. .add(cylinder(2, 4), alignOutside(maxZ()));

adding with outside alignment and margin (preview)

  1. cuboid(4, 4, 4)
  2. .add(cylinder(2, 1), alignOutside(maxZ(), 2));

convex hull (preview)

  1. cuboid(4, 4, 1)
  2. .add(cylinder(1, 1).moveBy(vx(5)))
  3. .convexHull();

prism with regular polygon as base (preview)

  1. prism(regularPolygon(4, 8), 4);

cloned step forming stairs (preview)

  1. cuboid(10, 4, 2)
  2. .clone(30, (i, s) -> s.moveBy(v(30, 0, i * 2)).rotate(z(), degrees(i * 6)));