|
3 | 3 | import java.util.List; |
4 | 4 |
|
5 | 5 | public class ChamferedCylinder extends Primitive { |
6 | | - double r, h, chamferHeight; |
| 6 | + double r, h, chamferHeight; |
| 7 | + int sides = -1; |
7 | 8 |
|
8 | | - /** The properties. */ |
9 | | - private final PropertyStorage properties = new PropertyStorage(); |
| 9 | + /** The properties. */ |
| 10 | + private final PropertyStorage properties = new PropertyStorage(); |
10 | 11 |
|
11 | | - public PropertyStorage getProperties() { |
12 | | - return properties; |
13 | | - } |
| 12 | + public PropertyStorage getProperties() { |
| 13 | + return properties; |
| 14 | + } |
14 | 15 |
|
15 | | - /** |
16 | | - * Constructor. Creates a new cuboid with center {@code [0,0,0]} and with the specified |
17 | | - * dimensions. |
18 | | - * |
19 | | - * @param r radius |
20 | | - * @param h height |
21 | | - * @param chamferHeight the chamfer height |
22 | | - */ |
23 | | - public ChamferedCylinder(double r, double h, double chamferHeight) { |
24 | | - this.r = r; |
25 | | - this.h = h; |
26 | | - this.chamferHeight = chamferHeight; |
27 | | - } |
| 16 | + /** |
| 17 | + * Constructor. Creates a new cuboid with center {@code [0,0,0]} and with the |
| 18 | + * specified dimensions. |
| 19 | + * |
| 20 | + * @param r radius |
| 21 | + * @param h height |
| 22 | + * @param chamferHeight the chamfer height |
| 23 | + * @param sides the number of slices the chamfered cylender should have |
| 24 | + */ |
| 25 | + public ChamferedCylinder(double r, double h, double chamferHeight, int sides) { |
| 26 | + this.r = r; |
| 27 | + this.h = h; |
| 28 | + this.chamferHeight = chamferHeight; |
| 29 | + this.sides = sides; |
| 30 | + } |
28 | 31 |
|
| 32 | + /** |
| 33 | + * Constructor. Creates a new cuboid with center {@code [0,0,0]} and with the |
| 34 | + * specified dimensions. |
| 35 | + * |
| 36 | + * @param r radius |
| 37 | + * @param h height |
| 38 | + * @param chamferHeight the chamfer height |
| 39 | + */ |
| 40 | + public ChamferedCylinder(double r, double h, double chamferHeight) { |
| 41 | + this(r, h, chamferHeight, 16); |
| 42 | + } |
29 | 43 |
|
30 | | - /* |
31 | | - * (non-Javadoc) |
32 | | - * |
33 | | - * @see eu.mihosoft.vrl.v3d.Primitive#toPolygons() |
34 | | - */ |
35 | | - @Override |
36 | | - public List<Polygon> toPolygons() { |
37 | | - CSG cube1 = new Cylinder(r - chamferHeight, h).toCSG(); |
38 | | - CSG cube2 = new Cylinder(r, h - chamferHeight * 2).toCSG().movez(chamferHeight); |
39 | | - return cube1.union(cube2).hull().getPolygons(); |
40 | | - } |
| 44 | + /* |
| 45 | + * (non-Javadoc) |
| 46 | + * |
| 47 | + * @see eu.mihosoft.vrl.v3d.Primitive#toPolygons() |
| 48 | + */ |
| 49 | + @Override |
| 50 | + public List<Polygon> toPolygons() { |
| 51 | + CSG cube1 = new Cylinder(r - chamferHeight, r - chamferHeight, h, sides).toCSG(); |
| 52 | + CSG cube2 = new Cylinder(r, r, h - chamferHeight * 2, sides).toCSG().movez(chamferHeight); |
| 53 | + return cube1.union(cube2).hull().getPolygons(); |
| 54 | + } |
41 | 55 | } |
0 commit comments