|
| 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 | +} |
0 commit comments