Skip to content

miho/JCSG-MeshExtensions-Sample

Repository files navigation

JCSG-MeshExtensions-Sample

Demonstrates the JCSG-MeshExtensions library, a JCSG extension library for producing high-quality meshes from JCSG mesh objects. The mesh optimization is performed with the cross-platform meshing software ProMesh which is available as ug4 plugin.

optimization

Sample Code

// we use cube and sphere as base geometries
CSG cube   = new Cube(2).toCSG();
CSG sphere = new Sphere(1.25).toCSG();

// compute difference between cube and sphere
CSG cubeMinusSphere = cube.difference(sphere);

// create a copy of cube-sphere that shall be optimized
CSG optimized       = cubeMinusSphere.
        transformed(Transform.unity().translateX(3));

// perform the optimization
CSG all = MeshTools.optimize(
        optimized, // csg object to optimize
        1e-6,      // tolerance
        1e-4,      // max tolerance
        0.25,      // min edge length
        1.5        // max edge length
);

// save combined unoptimized and optimized mesh as "all.stl"
Files.write(Paths.get("all.stl"), all.toStlString().getBytes());

How to Run JCSG-MeshExtensions-Sample

Requirements

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

IDE

Open the JCSG-MeshExtensions-Sample Gradle project in your favourite IDE (tested with NetBeans 8.2) and build it by calling the run task.

Command Line

Navigate to the Gradle project (e.g., path/to/JCSG-MeshExtensions-Sample) and enter the following command

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

bash gradlew run

Windows (CMD)

gradlew run

Releases

No releases published

Packages

No packages published

Languages