Skip to content

Commit

Permalink
Update Java bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
cartesian-theatrics committed Mar 31, 2024
1 parent 798d1cf commit 479a44f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions bindings/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@
<include>meshIO.dll</include>
</includes>
</resource>
<resource>
<directory>../../build/_deps/texttopolygon-build/</directory>
<includes>
<include>libTextToPolygon.so</include>
<include>libTextToPolygon.dylib</include>
</includes>
</resource>
<resource>
<directory>../../build/_deps/freetype2-build/</directory>
<includes>
<include>libfreetype.so</include>
<include>libfreetype.6.16.0.dylib</include>
</includes>
</resource>
<resource>
<directory>../../build/src/manifold</directory>
<includes>
Expand Down Expand Up @@ -110,6 +124,8 @@
<includePath>../../src/cross_section/include/</includePath>
<includePath>../../src/third_party/clipper2/CPP/Clipper2Lib/include/</includePath>
<includePath>../../build/_deps/glm-src/</includePath>
<includePath>../../build/_deps/texttopolygon-src/include</includePath>
<includePath>../../build/_deps/freetype2-src/include</includePath>
<includePath>../../src/polygon/include</includePath>
<includePath>../../src/manifold/include/</includePath>
<includePath>../../src/utilities/include/</includePath>
Expand Down
2 changes: 2 additions & 0 deletions bindings/java/src/main/java/manifold3d/LibraryPaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class LibraryPaths {
//public static final String CROSS_SECTION_LIB_DIR = MANIFOLD_BUILD_DIR + "/src/cross_section";
//public static final String QUICKHULL_LIB_DIR = MANIFOLD_BUILD_DIR + "/src/third_party";
public static final String CLIPPER_LIB_DIR = MANIFOLD_BUILD_DIR + "/_deps/clipper2-build";
public static final String FREETYPE_LIB_DIR = MANIFOLD_BUILD_DIR + "/_deps/freetype2-build";
public static final String TEXT_TO_POLYGON_LIB_DIR = MANIFOLD_BUILD_DIR + "/_deps/texttopolygon-build";
public static final String MANIFOLD_LIB_DIR_WINDOWS = MANIFOLD_LIB_DIR + "/Release";
public static final String MESHIO_LIB_DIR = MANIFOLD_BUILD_DIR + "/meshIO";
public static final String MESHIO_LIB_DIR_WINDOWS = MESHIO_LIB_DIR + "/Release";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

@Platform(compiler = "cpp17",
include = { "cross_section.h" },
linkpath = { LibraryPaths.MANIFOLD_LIB_DIR },
link = { "manifold" })
linkpath = { LibraryPaths.MANIFOLD_LIB_DIR,
LibraryPaths.FREETYPE_LIB_DIR,
LibraryPaths.TEXT_TO_POLYGON_LIB_DIR },
link = { "manifold", "TextToPolygon", "freetype" })
@Namespace("manifold")
public class CrossSection extends Pointer {
static { Loader.load(); }
Expand Down Expand Up @@ -98,6 +100,7 @@ public CrossSection translateY(double y) {
public static native @ByVal CrossSection Compose(@ByRef CrossSectionVector crossSection);
@Name("Decompose") public native @ByVal CrossSectionVector decompose();

public static native @ByVal CrossSection Text(@ByRef @StdString String fontFile, @ByRef @StdString String text, int pixelHeight, int interpRes);
public static native @ByVal CrossSection Circle(float radius, int circularSegments);
public static native @ByVal CrossSection Square(@ByRef DoubleVec2 size, boolean center);
public static CrossSection Square(double x, double y, boolean center) {
Expand Down
3 changes: 3 additions & 0 deletions bindings/java/src/test/java/manifold3d/CrossSectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public void testCrossSection() {
CrossSection innerSection = new CrossSection(innerPolygon, FillRule.NonZero.ordinal())
.translate(new DoubleVec2(3, 0));

CrossSection text = CrossSection.Text("DejaVuSans.ttf", "abcdefghijk lmnopqrstuvwxyz", 48, 6);

CrossSection circle = CrossSection.Circle(3.0f, 20);
Manifold cylinder = Manifold.Extrude(circle, 50, 60, 0, new DoubleVec2(1.0, 1.0));

Expand All @@ -47,5 +49,6 @@ public void testCrossSection() {
DoubleMesh mesh = man.getMesh();
ExportOptions opts = new ExportOptions();
MeshIO.ExportMesh("CrossSectionTest.stl", mesh, opts);
MeshIO.ExportMesh("TextExtrusion.stl", Manifold.Extrude(text, 200, 1, 0, new DoubleVec2(1.0, 1.0)).getMesh(), opts);
}
}

0 comments on commit 479a44f

Please sign in to comment.