From 89f967d43283c20e5f9c5a4bbb68122561cef1a3 Mon Sep 17 00:00:00 2001 From: Kevin harrington Date: Sat, 16 Nov 2024 16:29:13 -0500 Subject: [PATCH] https://github.com/CommonWealthRobotics/BowlerStudio/issues/431 --- .../java/eu/mihosoft/vrl/v3d/TextExtrude.java | 98 ------------------- .../java/eu/mihosoft/vrl/v3d/Vector3d.java | 20 ---- 2 files changed, 118 deletions(-) diff --git a/src/main/java/eu/mihosoft/vrl/v3d/TextExtrude.java b/src/main/java/eu/mihosoft/vrl/v3d/TextExtrude.java index dceeb03c..f97e8f1d 100644 --- a/src/main/java/eu/mihosoft/vrl/v3d/TextExtrude.java +++ b/src/main/java/eu/mihosoft/vrl/v3d/TextExtrude.java @@ -199,104 +199,6 @@ public List getOffset() { .map(LineSegment::getOrigen).collect(Collectors.toList()); } - private void addPoint(Vector3d v) { -// if (!unique.add(v)) { -// -// System.out.println("Skipping Duplicate " + v); -// } else -// points.add(v); - - } - -// private void getPoints(PathElement elem) { -// if (elem instanceof MoveTo) { -// loadPoints(); -// p0 = new Vector3d((float) ((MoveTo) elem).getX(), (float) ((MoveTo) elem).getY(), 0f); -// addPoint(p0); -// } else if (elem instanceof LineTo) { -// addPoint(new Vector3d((float) ((LineTo) elem).getX(), (float) ((LineTo) elem).getY(), 0f)); -// } else if (elem instanceof CubicCurveTo) { -// Vector3d ini = (points.size() > 0 ? points.get(points.size() - 1) : p0); -// IntStream.rangeClosed(1, POINTS_CURVE) -// .forEach(i -> addPoint(evalCubicBezier((CubicCurveTo) elem, ini, ((double) i) / POINTS_CURVE))); -// } else if (elem instanceof QuadCurveTo) { -// Vector3d ini = (points.size() > 0 ? points.get(points.size() - 1) : p0); -// IntStream.rangeClosed(1, POINTS_CURVE) -// .forEach(i -> addPoint(evalQuadBezier((QuadCurveTo) elem, ini, ((double) i) / POINTS_CURVE))); -// } else if (elem instanceof ClosePath) { -// addPoint(p0); -// // Every closed path is a polygon (exterior or interior==hole) -// // the text, the list of points and a new path between them are -// // stored in a LineSegment: a continuous line that can change direction -// if (Math.abs(getArea()) > 0.001) { -// LineSegment line = new LineSegment(text); -// line.setHole(isHole()); -// line.setPoints(points); -// line.setPath(generatePath()); -// line.setOrigen(p0); -// polis.add(line); -// } -// loadPoints(); -// -// } -// } -// -// private void loadPoints() { -// if (points.size() > 4) { -// // points.remove(points.size() - 1); -// boolean hole = Extrude.isCCW(Polygon.fromPoints(points)); -// CSG newLetter = Extrude.points(new Vector3d(0, 0, dir), points); -// -// if (!hole) -// sections.add(newLetter); -// else -// holes.add(newLetter); -// } -// points = new ArrayList<>(); -// } -// -// private Vector3d evalCubicBezier(CubicCurveTo c, Vector3d ini, double t) { -// Vector3d p = new Vector3d( -// (float) (Math.pow(1 - t, 3) * ini.x + 3 * t * Math.pow(1 - t, 2) * c.getControlX1() -// + 3 * (1 - t) * t * t * c.getControlX2() + Math.pow(t, 3) * c.getX()), -// (float) (Math.pow(1 - t, 3) * ini.y + 3 * t * Math.pow(1 - t, 2) * c.getControlY1() -// + 3 * (1 - t) * t * t * c.getControlY2() + Math.pow(t, 3) * c.getY()), -// 0f); -// return p; -// } -// -// private Vector3d evalQuadBezier(QuadCurveTo c, Vector3d ini, double t) { -// Vector3d p = new Vector3d( -// (float) (Math.pow(1 - t, 2) * ini.x + 2 * (1 - t) * t * c.getControlX() + Math.pow(t, 2) * c.getX()), -// (float) (Math.pow(1 - t, 2) * ini.y + 2 * (1 - t) * t * c.getControlY() + Math.pow(t, 2) * c.getY()), -// 0f); -// return p; -// } -// -// private double getArea() { -// DoubleProperty res = new SimpleDoubleProperty(); -// IntStream.range(0, points.size()) -// .forEach(i -> res.set(res.get() + points.get(i).cross(points.get((i + 1) % points.size())).z)); -// // com.neuronrobotics.sdk.common.Log.error("path: "+res.doubleValue()/2); -// -// return res.doubleValue() / 2d; -// } -// -// private boolean isHole() { -// // area>0 -> the path is a hole, clockwise (y up) -// // area<0 -> the path is a polygon, counterclockwise (y up) -// return getArea() > 0; -// } -// -// private Path generatePath() { -// Path path = new Path(new MoveTo(points.get(0).x, points.get(0).y)); -// points.stream().skip(1).forEach(p -> path.getElements().add(new LineTo(p.x, p.y))); -// path.getElements().add(new ClosePath()); -// path.setStroke(Color.GREEN); -// // Path must be filled to allow Shape.intersect -// path.setFill(Color.RED); -// return path; -// } // Below is AI slop private static final double CURVE_SEGMENTS = 6; // Number of segments to approximate curves private static final double POINT_EPSILON = 0.0000001; // Distance threshold for considering points equal diff --git a/src/main/java/eu/mihosoft/vrl/v3d/Vector3d.java b/src/main/java/eu/mihosoft/vrl/v3d/Vector3d.java index 783bab9f..e30dffef 100644 --- a/src/main/java/eu/mihosoft/vrl/v3d/Vector3d.java +++ b/src/main/java/eu/mihosoft/vrl/v3d/Vector3d.java @@ -447,26 +447,6 @@ public int hashCode() { return hash; } -// @Override -// public boolean equals(Object obj) { -// if (obj == null) { -// return false; -// } -// if (getClass() != obj.getClass()) { -// return false; -// } -// final Vector3d other = (Vector3d) obj; -// if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) { -// return false; -// } -// if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y)) { -// return false; -// } -// if (Double.doubleToLongBits(this.z) != Double.doubleToLongBits(other.z)) { -// return false; -// } -// return true; -// } /** * Creates a new vector with specified {@code x}. *