Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/JCSGPublic

Java implementation of BSP based CSG (Constructive Solid Geometry)

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE.txt
Unknown
license-template.txt
NotificationsYou must be signed in to change notification settings

miho/JCSG

Repository files navigation

Build StatusJavadocs


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:

  • optimizeddifference() 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 toJavaFX 3D nodes
  • 3d text support (usingFXyz)

JCSG onstackoverflow.

To see what's possible with JCSG tryJFXScad.

How to Build JCSG

Requirements

  • Java >= 11
  • Internet connection (dependencies are downloaded automatically)
  • IDE:Gradle Plugin (not necessary for command line usage)

IDE

Open theJCSGGradle project in your favourite IDE (tested with NetBeans 7.4) and build itby calling theassemble task.

Command Line

Navigate to theGradle project (e.g.,path/to/JCSG) and enter the following command

Bash (Linux/OS X/Cygwin/other Unix-like shell)

bash gradlew assemble

Windows (CMD)

gradlew assemble

Code Sample:

// 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);}

Thanks to


[8]ページ先頭

©2009-2025 Movatter.jp