mirror of
https://github.com/Dark98/SliceBeam.git
synced 2026-07-07 00:39:25 +00:00
WIP: Flatten to surface feature; Fix rotating multiple axis
This commit is contained in:
@@ -156,11 +156,19 @@ public class Bed3D {
|
||||
}
|
||||
|
||||
public void release() {
|
||||
Native.bed_release(pointer);
|
||||
axes.release();
|
||||
if (pointer != 0) {
|
||||
Native.bed_release(pointer);
|
||||
axes.release();
|
||||
pointer = 0;
|
||||
|
||||
// triangles.release();
|
||||
// gridlines.release();
|
||||
// contourlines.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package ru.ytkab0bp.slicebeam.slic3r;
|
||||
import java.io.File;
|
||||
|
||||
public class GCodeProcessorResult {
|
||||
final long pointer;
|
||||
long pointer;
|
||||
|
||||
public GCodeProcessorResult(File f) {
|
||||
pointer = Native.gcoderesult_load_file(f.getAbsolutePath(), f.getName());
|
||||
@@ -26,6 +26,14 @@ public class GCodeProcessorResult {
|
||||
}
|
||||
|
||||
public void release() {
|
||||
Native.gcoderesult_release(pointer);
|
||||
if (pointer != 0) {
|
||||
Native.gcoderesult_release(pointer);
|
||||
pointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class GCodeViewer {
|
||||
}
|
||||
};
|
||||
|
||||
private final long pointer;
|
||||
private long pointer;
|
||||
|
||||
public GCodeViewer() {
|
||||
pointer = Native.vgcode_create();
|
||||
@@ -156,6 +156,14 @@ public class GCodeViewer {
|
||||
}
|
||||
|
||||
public void release() {
|
||||
Native.vgcode_release(pointer);
|
||||
if (pointer != 0) {
|
||||
Native.vgcode_release(pointer);
|
||||
pointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import static ru.ytkab0bp.slicebeam.utils.DebugUtils.assertTrue;
|
||||
import android.graphics.Color;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ru.ytkab0bp.slicebeam.render.Camera;
|
||||
import ru.ytkab0bp.slicebeam.render.GLRenderer;
|
||||
@@ -13,7 +12,7 @@ import ru.ytkab0bp.slicebeam.utils.Prefs;
|
||||
import ru.ytkab0bp.slicebeam.utils.Vec3d;
|
||||
|
||||
public class GLModel {
|
||||
private long pointer;
|
||||
long pointer;
|
||||
private MeshRaycaster raycaster;
|
||||
|
||||
public float hoverProgress;
|
||||
@@ -74,7 +73,10 @@ public class GLModel {
|
||||
}
|
||||
|
||||
public void release() {
|
||||
Native.glmodel_release(pointer);
|
||||
if (pointer != 0) {
|
||||
Native.glmodel_release(pointer);
|
||||
pointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public MeshRaycaster getRaycaster() {
|
||||
@@ -86,7 +88,7 @@ public class GLModel {
|
||||
}
|
||||
|
||||
public final class MeshRaycaster {
|
||||
public List<HitResult> raycast(GLRenderer renderer, ArrayList<HitResult> list, float x, float y) {
|
||||
public void raycast(GLRenderer renderer, ArrayList<HitResult> list, float x, float y) {
|
||||
assertTrue(renderer != null);
|
||||
list.clear();
|
||||
|
||||
@@ -104,7 +106,6 @@ public class GLModel {
|
||||
new Vec3d(v[i + 3], v[i + 4], v[i + 5])
|
||||
));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import ru.ytkab0bp.slicebeam.SliceBeam;
|
||||
import ru.ytkab0bp.slicebeam.utils.IOUtils;
|
||||
|
||||
public class GLShaderProgram {
|
||||
final long pointer;
|
||||
long pointer;
|
||||
private static ThreadLocal<FloatBuffer> matrixBuffer = new ThreadLocal<FloatBuffer>() {
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -140,6 +140,14 @@ public class GLShaderProgram {
|
||||
}
|
||||
|
||||
public void release() {
|
||||
Native.shader_release(pointer);
|
||||
if (pointer != 0) {
|
||||
Native.shader_release(pointer);
|
||||
pointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package ru.ytkab0bp.slicebeam.slic3r;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.ytkab0bp.slicebeam.utils.Vec3d;
|
||||
|
||||
public class Model {
|
||||
public final String key = UUID.randomUUID().toString();
|
||||
final long pointer;
|
||||
long pointer;
|
||||
|
||||
private double[] boundingExact;
|
||||
private double[] boundingApprox;
|
||||
@@ -92,6 +94,10 @@ public class Model {
|
||||
Native.model_rotate(pointer, i, x, y, z);
|
||||
}
|
||||
|
||||
public void flattenRotate(int i, GLModel surface) {
|
||||
Native.model_flatten_rotate(pointer, i, surface.pointer);
|
||||
}
|
||||
|
||||
public int getObjectsCount() {
|
||||
return Native.model_get_objects_count(pointer);
|
||||
}
|
||||
@@ -128,12 +134,29 @@ public class Model {
|
||||
vec.set(tr[0], tr[1], tr[2]);
|
||||
}
|
||||
|
||||
public List<GLModel> createFlattenPlanes(int i) {
|
||||
long[] ptr = Native.model_create_flatten_planes(pointer, i);
|
||||
List<GLModel> list = new ArrayList<>(ptr.length);
|
||||
for (long l : ptr) {
|
||||
list.add(new GLModel(l));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public GCodeProcessorResult slice(String configPath, String gcodePath, SliceListener listener) throws Slic3rRuntimeError {
|
||||
return new GCodeProcessorResult(Native.model_slice(pointer, configPath, gcodePath, listener));
|
||||
}
|
||||
|
||||
public void release() {
|
||||
Native.model_release(pointer);
|
||||
if (pointer != 0) {
|
||||
Native.model_release(pointer);
|
||||
pointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
release();
|
||||
}
|
||||
|
||||
public static Model merge(Model... models) {
|
||||
|
||||
@@ -68,6 +68,8 @@ class Native {
|
||||
static native void model_translate_global(long ptr, double x, double y, double z);
|
||||
static native void model_scale(long ptr, int i, double x, double y, double z);
|
||||
static native void model_rotate(long ptr, int i, double x, double y, double z);
|
||||
static native void model_flatten_rotate(long ptr, int i, long surfacePtr);
|
||||
static native long[] model_create_flatten_planes(long ptr, int i);
|
||||
static native long model_slice(long ptr, String configPath, String path, SliceListener listener) throws Slic3rRuntimeError;
|
||||
static native void model_release(long ptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user