Support for different size clusters in centering ring template.

This commit is contained in:
Doug Pedrick 2012-05-31 03:06:22 +00:00
parent dbd72738c5
commit 661b16bbda
2 changed files with 60 additions and 19 deletions

View File

@ -37,7 +37,8 @@ public class PrintableCenteringRing extends AbstractPrintable<CenteringRing> {
private Set<CenteringRingStrategy.Dimension> innerCenterPoints = new HashSet<CenteringRingStrategy.Dimension>(); private Set<CenteringRingStrategy.Dimension> innerCenterPoints = new HashSet<CenteringRingStrategy.Dimension>();
/** /**
* Construct a simple, non-clustered, printable centering ring. * Construct a simple, non-clustered, printable centering ring, or if the motor mount represents a clustered
* configuration then get the cluster points to create the centering ring.
* *
* @param theRing the component to print * @param theRing the component to print
* @param theMotorMount the motor mount if clustered, else null * @param theMotorMount the motor mount if clustered, else null
@ -46,17 +47,24 @@ public class PrintableCenteringRing extends AbstractPrintable<CenteringRing> {
super(false, theRing); super(false, theRing);
if (theMotorMount == null || theMotorMount.getClusterConfiguration().equals(ClusterConfiguration.SINGLE)) { if (theMotorMount == null || theMotorMount.getClusterConfiguration().equals(ClusterConfiguration.SINGLE)) {
//Single motor. //Single motor.
innerCenterPoints.add(new CenteringRingStrategy.Dimension((float) PrintUnit.METERS.toPoints(target.getOuterRadius()), final float v = (float) PrintUnit.METERS.toPoints(target.getOuterRadius());
(float) PrintUnit.METERS.toPoints(target.getOuterRadius()))); innerCenterPoints.add(
new CenteringRingStrategy.Dimension(v, v,
(float) PrintUnit.METERS.toPoints((target.getInnerRadius()))));
} }
else { else {
List<Coordinate> coords = theMotorMount.getClusterPoints(); List<Coordinate> coords = theMotorMount.getClusterPoints();
populateCenterPoints(coords); List<Coordinate> points = new ArrayList<Coordinate>();
for (Coordinate coordinate : coords) {
points.add(coordinate.setX(theMotorMount.getOuterRadius()));
}
populateCenterPoints(points);
} }
} }
/** /**
* Constructor for a clustered centering ring. * Constructor for a clustered centering ring. This version is for a "split cluster", where each motor mount tube
* is a distinct entity.
* *
* @param theRing the centering ring component * @param theRing the centering ring component
* @param theMotorMounts a list of the motor mount tubes that are physically supported by the centering ring * @param theMotorMounts a list of the motor mount tubes that are physically supported by the centering ring
@ -66,10 +74,18 @@ public class PrintableCenteringRing extends AbstractPrintable<CenteringRing> {
List<Coordinate> points = new ArrayList<Coordinate>(); List<Coordinate> points = new ArrayList<Coordinate>();
//Transform the radial positions of the tubes. //Transform the radial positions of the tubes.
for (InnerTube it : theMotorMounts) { for (InnerTube it : theMotorMounts) {
double y = it.getRadialShiftY(); if (it.getClusterCount() > 1) {
double z = it.getRadialShiftZ(); List<Coordinate> c = it.getClusterPoints();
Coordinate coordinate = new Coordinate(0, y, z); for (Coordinate coordinate : c) {
points.add(coordinate); points.add(coordinate.setX(it.getOuterRadius()));
}
}
else {
double y = it.getRadialShiftY();
double z = it.getRadialShiftZ();
Coordinate coordinate = new Coordinate(it.getOuterRadius(), y, z);
points.add(coordinate);
}
} }
populateCenterPoints(points); populateCenterPoints(points);
} }
@ -101,9 +117,10 @@ public class PrintableCenteringRing extends AbstractPrintable<CenteringRing> {
private void populateCenterPoints(final List<Coordinate> theCoords) { private void populateCenterPoints(final List<Coordinate> theCoords) {
float radius = (float) PrintUnit.METERS.toPoints(target.getOuterRadius()); float radius = (float) PrintUnit.METERS.toPoints(target.getOuterRadius());
for (Coordinate coordinate : theCoords) { for (Coordinate coordinate : theCoords) {
innerCenterPoints.add(new CenteringRingStrategy.Dimension((float) PrintUnit.METERS.toPoints innerCenterPoints.add(new CenteringRingStrategy.Dimension(
(coordinate.y) + radius, (float) PrintUnit.METERS.toPoints(coordinate.y) + radius, //center point x
(float) PrintUnit.METERS.toPoints(coordinate.z) + radius)); (float) PrintUnit.METERS.toPoints(coordinate.z) + radius, //center point y
(float) PrintUnit.METERS.toPoints(coordinate.x))); //radius of motor mount
} }
} }
@ -137,7 +154,7 @@ public class PrintableCenteringRing extends AbstractPrintable<CenteringRing> {
g2.draw(outerCircle); g2.draw(outerCircle);
for (CenteringRingStrategy.Dimension next : innerCenterPoints) { for (CenteringRingStrategy.Dimension next : innerCenterPoints) {
drawInnerCircle(g2, next.getWidth(), next.getHeight()); drawInnerCircle(g2, next.getWidth(), next.getHeight(), next.getBreadth());
} }
g2.setColor(original); g2.setColor(original);
} }
@ -149,8 +166,8 @@ public class PrintableCenteringRing extends AbstractPrintable<CenteringRing> {
* @param theCenterX the center x in points * @param theCenterX the center x in points
* @param theCenterY the center y in points * @param theCenterY the center y in points
*/ */
private void drawInnerCircle(final Graphics2D g2, final double theCenterX, final double theCenterY) { private void drawInnerCircle(final Graphics2D g2, final double theCenterX, final double theCenterY,
double innerRadius = PrintUnit.METERS.toPoints(target.getInnerRadius()); final double innerRadius) {
Shape innerCircle = new Ellipse2D.Double(theCenterX - innerRadius, theCenterY - innerRadius, innerRadius * 2, innerRadius * 2); Shape innerCircle = new Ellipse2D.Double(theCenterX - innerRadius, theCenterY - innerRadius, innerRadius * 2, innerRadius * 2);
g2.setColor(Color.white); g2.setColor(Color.white);
g2.fill(innerCircle); g2.fill(innerCircle);

View File

@ -107,10 +107,8 @@ public class CenteringRingStrategy {
if (rocketComponents != rc) { if (rocketComponents != rc) {
if (rocketComponents instanceof InnerTube) { if (rocketComponents instanceof InnerTube) {
InnerTube it = (InnerTube) rocketComponents; InnerTube it = (InnerTube) rocketComponents;
if (it.isMotorMount()) { if (overlaps(rc, it)) {
if (overlaps(rc, it)) { mounts.add(it);
mounts.add(it);
}
} }
} }
} }
@ -213,6 +211,10 @@ public class CenteringRingStrategy {
* Height, in points. * Height, in points.
*/ */
public float height; public float height;
/**
* Breadth, in points.
*/
public float breadth = 0f;
/** /**
* Constructor. * Constructor.
@ -225,6 +227,19 @@ public class CenteringRingStrategy {
height = h; height = h;
} }
/**
* Constructor.
*
* @param w width
* @param h height
* @param b breadth; optionally used to represent radius
*/
public Dimension(float w, float h, float b) {
width = w;
height = h;
breadth = b;
}
/** /**
* Get the width. * Get the width.
* *
@ -242,5 +257,14 @@ public class CenteringRingStrategy {
public float getHeight() { public float getHeight() {
return height; return height;
} }
/**
* Get the breadth.
*
* @return the breadth
*/
public float getBreadth() {
return breadth;
}
} }
} }