Skip to content

Commit ce636f9

Browse files
committed
testing the spiral sweep with an STL output first
1 parent 91abd7b commit ce636f9

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package eu.mihosoft.vrl.v3d;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.io.File;
6+
import java.io.IOException;
7+
import java.nio.file.Paths;
8+
import java.util.HashMap;
9+
import java.util.List;
10+
11+
import org.junit.Test;
12+
13+
import eu.mihosoft.vrl.v3d.svg.SVGLoad;
14+
import javafx.scene.text.Font;
15+
16+
public class sweepTest {
17+
18+
@Test
19+
public void test() throws IOException {
20+
21+
22+
File svg = new File("Test.SVG");
23+
if (!svg.exists())
24+
throw new RuntimeException("Test file missing!" + svg.getAbsolutePath());
25+
SVGLoad s = new SVGLoad(svg.toURI());
26+
HashMap<String, List<Polygon>> polys = s.toPolygons();
27+
Polygon p = polys.get(polys.keySet().toArray()[0]).get(0);
28+
Bounds b = p.getBounds();
29+
double sweepTot = 720;
30+
double d = sweepTot / 360;
31+
int steps = (int) (30 * d);
32+
double angle = sweepTot / steps;
33+
34+
double z = 0* d / steps;
35+
double radius = 0;
36+
if (angle < 0)
37+
angle = -angle;
38+
double sprl = 10;
39+
Transform centerandAllignedPolygon = new Transform().movex(-b.getMinX()).movey(-b.getMinY());
40+
Transform increment = new Transform().rotY(-angle).movey(z);
41+
Transform radiusT = new Transform().movex(radius);
42+
Polygon transformedP = p.transformed(centerandAllignedPolygon);
43+
ITransformProvider pr = (unit,domain)->{
44+
return new Transform().movex(sprl*unit*d);
45+
};
46+
CSG text= Extrude.sweep(transformedP, increment, radiusT, steps,pr).rotx(-90);
47+
FileUtil.write(Paths.get("exampleSweep.stl"),
48+
text.toStlString());
49+
}
50+
51+
}

src/test/java/eu/mihosoft/vrl/v3d/textTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
import static org.junit.Assert.*;
44

5+
import java.io.File;
56
import java.io.IOException;
67
import java.nio.file.Paths;
8+
import java.util.HashMap;
9+
import java.util.List;
710

811
import org.junit.Test;
912

13+
import eu.mihosoft.vrl.v3d.parametrics.Parameter;
14+
import eu.mihosoft.vrl.v3d.svg.SVGLoad;
1015
import javafx.scene.text.Font;
1116

1217
public class textTest {
@@ -20,6 +25,7 @@ public void test() throws IOException {
2025
text=new Cube(180,40,10).toCSG().toZMin().toXMin().toYMin().movey(-5).difference(text);
2126
FileUtil.write(Paths.get("exampleText.stl"),
2227
text.toStlString());
28+
2329
}
2430

2531
}

0 commit comments

Comments
 (0)