diff --git a/src/org/nschmidt/ldparteditor/dialog/primgen2/PrimGen2Dialog.java b/src/org/nschmidt/ldparteditor/dialog/primgen2/PrimGen2Dialog.java index 7712853a7..02a8b4102 100644 --- a/src/org/nschmidt/ldparteditor/dialog/primgen2/PrimGen2Dialog.java +++ b/src/org/nschmidt/ldparteditor/dialog/primgen2/PrimGen2Dialog.java @@ -75,7 +75,8 @@ public class PrimGen2Dialog extends PrimGen2Design { public static final int CYLINDER_WITHOUT_CONDLINES = -4; public static final int CYLINDER_SLOPED = -5; public static final int CYLINDER_SLOPED_CONVEX = -6; - public static final int EIGHT_SPHERE = -7; + public static final int CYLINDER_SLOPED_HELICAL = -7; + public static final int EIGHT_SPHERE = -8; public static final int DISC = 5; public static final int DISC_NEGATIVE = 6; public static final int DISC_NEGATIVE_TRUNCATED = 7; @@ -725,7 +726,15 @@ public static String buildPrimitiveSource(int pType, int divisions, int segments sb.insert(0, "0 Name: " + prefix + name + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ sb.insert(0, "0 " + resolution + "Cylinder Sloped " + removeTrailingZeros2(decformat4f.format(segments * 1d / divisions)) + " Convex\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - sb.append(cylinderSloped(divisions, segments, ccw, true)); + sb.append(cylinderSloped(divisions, segments, ccw, true, false)); + + break; + case CYLINDER_SLOPED_HELICAL: + name = upper + "-" + lower + "cylh.dat"; //$NON-NLS-1$ //$NON-NLS-2$ + sb.insert(0, "0 Name: " + prefix + name + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + sb.insert(0, "0 " + resolution + "Cylinder Helical " + removeTrailingZeros2(decformat4f.format(segments * 1d / divisions)) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + sb.append(cylinderSloped(divisions, segments, ccw, false, true)); break; case CYLINDER_SLOPED: @@ -733,7 +742,7 @@ public static String buildPrimitiveSource(int pType, int divisions, int segments sb.insert(0, "0 Name: " + prefix + name + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ sb.insert(0, "0 " + resolution + "Cylinder Sloped " + removeTrailingZeros2(decformat4f.format(segments * 1d / divisions)) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - sb.append(cylinderSloped(divisions, segments, ccw, false)); + sb.append(cylinderSloped(divisions, segments, ccw, false, false)); break; case DISC: @@ -1113,7 +1122,7 @@ else if (num == 0) } - private static Object cylinderSloped(int divisions, int segments, boolean ccw, boolean convex) { + private static Object cylinderSloped(int divisions, int segments, boolean ccw, boolean convex, boolean helical) { // Crazy Reverse Engineering from Mike's PrimGen2 // Thanks to Mr. Heidemann! :) @@ -1155,6 +1164,11 @@ private static Object cylinderSloped(int divisions, int segments, boolean ccw, b objdatLinePoint4Y = 1.0 - objdatLinePoint4Y; } + if (helical) { + objdatLinePoint3Y = (num / (divisions / 4.0)); + objdatLinePoint4Y = ((num + 1) / (divisions / 4.0)); + } + sb2.append("4 16 "); //$NON-NLS-1$ if (ccw ^ convex) { sb2.append(removeTrailingZeros(formatDec(objdatLinePoint1X))); @@ -1249,6 +1263,13 @@ else if (num == 0) objdatLinePoint3Y = 0.0; objdatLinePoint4Y = 0.0; } + + if (helical) { + objdatLinePoint2Y = (num / (divisions / 4.0)); + objdatLinePoint3Y = 0.0; + objdatLinePoint4Y = 0.0; + } + sb2.append("5 24 "); //$NON-NLS-1$ sb2.append(removeTrailingZeros(formatDec(objdatLinePoint1X))); sb2.append(" " + removeTrailingZeros(formatDec(objdatLinePoint1Y)) + " "); //$NON-NLS-1$ //$NON-NLS-2$ @@ -2501,7 +2522,7 @@ private boolean isOfficialRules(int typ, double size, double divisions, double s } switch (typ) { - case CIRCLE, CYLINDER, CYLINDER_WITHOUT_CONDLINES, CYLINDER_SLOPED, CYLINDER_SLOPED_CONVEX + case CIRCLE, CYLINDER, CYLINDER_WITHOUT_CONDLINES, CYLINDER_SLOPED, CYLINDER_SLOPED_CONVEX, CYLINDER_SLOPED_HELICAL , DISC, DISC_NEGATIVE, CHORD, TANGENTIAL_RING_SEGMENT: return true; case DISC_NEGATIVE_TRUNCATED: diff --git a/src/org/nschmidt/ldparteditor/text/PrimitiveReplacer.java b/src/org/nschmidt/ldparteditor/text/PrimitiveReplacer.java index f8580255d..f71e7444d 100644 --- a/src/org/nschmidt/ldparteditor/text/PrimitiveReplacer.java +++ b/src/org/nschmidt/ldparteditor/text/PrimitiveReplacer.java @@ -254,6 +254,10 @@ private static List substituteSimplePrimitivesWithFraction(String name, return buildPrimitive(PrimGen2Dialog.CYLINDER_SLOPED_CONVEX, quality, segments); } + if ("cylh".equals(name)) { //$NON-NLS-1$ + return buildPrimitive(PrimGen2Dialog.CYLINDER_SLOPED_HELICAL, quality, segments); + } + // Substitute circular disc segments if ("chrd".equals(name)) { //$NON-NLS-1$ return buildPrimitive(PrimGen2Dialog.CHORD, quality, segments); diff --git a/test/primitive_substitution.txt b/test/primitive_substitution.txt index b58833dfe..359b826b4 100644 --- a/test/primitive_substitution.txt +++ b/test/primitive_substitution.txt @@ -59,3 +59,8 @@ 1 44 -5.56 -1.48 7.05 1 0 0 0 1 0 0 0 1 48\1-8sphe.dat 1 7 -5.56 -1.48 7.05 .9 0 0 0 .9 0 0 0 .9 8-8sphe.dat + +1 7 -7.56 -1.48 7.05 1 0 0 0 1 0 0 0 1 1-8sphc.dat + +1 8 -9.56 -1.48 7.05 1 0 0 0 1 0 0 0 1 1-4edgh.dat +1 9 -11.56 -1.48 7.05 1 0 0 0 1 0 0 0 1 1-4cylh.dat