Skip to content

Commit 1526857

Browse files
committed
adding sides to the chamfered cylendar
1 parent 4f871c7 commit 1526857

1 file changed

Lines changed: 44 additions & 30 deletions

File tree

src/main/java/eu/mihosoft/vrl/v3d/ChamferedCylinder.java

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,53 @@
33
import java.util.List;
44

55
public class ChamferedCylinder extends Primitive {
6-
double r, h, chamferHeight;
6+
double r, h, chamferHeight;
7+
int sides = -1;
78

8-
/** The properties. */
9-
private final PropertyStorage properties = new PropertyStorage();
9+
/** The properties. */
10+
private final PropertyStorage properties = new PropertyStorage();
1011

11-
public PropertyStorage getProperties() {
12-
return properties;
13-
}
12+
public PropertyStorage getProperties() {
13+
return properties;
14+
}
1415

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+
}
2831

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+
}
2943

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+
}
4155
}

0 commit comments

Comments
 (0)