- Notifications
You must be signed in to change notification settings - Fork54
Java implementation of BSP based CSG (Constructive Solid Geometry)
License
Unknown, Unknown licenses found
Licenses found
miho/JCSG
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Java implementation of BSP based CSG (Constructive Solid Geometry). It is the only simple and free Java implementation I am aware of. This implementation uses an optimized CSG algorithm based oncsg.js (seeCSG
andNode
classes). Thanks to the author for creating thecsg.js library.
There's also the relatedVCSG library, aplugin for VRL-Studio and two extension libraries:JCSG-MeshExtension andJCSG-PathExtension.
In addition to CSG this library provides the following features:
- optimized
difference()
andunion()
operations (many thanks to Sebastian Reiter) - extrusion of concave, non-intersecting polygons (usesPoly2Tri for triangulation)
- convex hull (usesQuickHull3D)
- weighted transformations (Scale, Rotation, Translation and Mirror)
- STL import and export (STLLoader fromFiji)
- OBJ export including material information (see screenshot below)
- supports conversion of CSG's to
JavaFX 3D
nodes - 3d text support (usingFXyz)
JCSG onstackoverflow.
To see what's possible with JCSG tryJFXScad.
- Java >= 11
- Internet connection (dependencies are downloaded automatically)
- IDE:Gradle Plugin (not necessary for command line usage)
Open theJCSG
Gradle project in your favourite IDE (tested with NetBeans 7.4) and build itby calling theassemble
task.
Navigate to theGradle project (e.g.,path/to/JCSG
) and enter the following command
bash gradlew assemble
gradlew assemble
// we use cube and sphere as base geometriesCSGcube =newCube(2).toCSG();CSGsphere =newSphere(1.25).toCSG();// perform union, difference and intersectionCSGcubePlusSphere =cube.union(sphere);CSGcubeMinusSphere =cube.difference(sphere);CSGcubeIntersectSphere =cube.intersect(sphere);// translate geometries to prevent overlappingCSGunion =cube.union(sphere.transformed(Transform.unity().translateX(3))).union(cubePlusSphere.transformed(Transform.unity().translateX(6))).union(cubeMinusSphere.transformed(Transform.unity().translateX(9))).union(cubeIntersectSphere.transformed(Transform.unity().translateX(12)));// save union as stltry {FileUtil.write(Paths.get("sample.stl"),union.toStlString() );}catch (IOExceptionex) {Logger.getLogger(Main.class.getName()).log(Level.SEVERE,null,ex);}
JetBrains for theirIntelliJ IDEA license(s)
Evan Wallace for creating the JavaScript librarycsg.js
About
Java implementation of BSP based CSG (Constructive Solid Geometry)