--- /dev/null
+package com.billkuker.rocketry.motorsim.grain;\r
+\r
+import java.awt.Shape;\r
+import java.awt.geom.Ellipse2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.beans.PropertyVetoException;\r
+\r
+import javax.measure.quantity.Length;\r
+import javax.measure.unit.SI;\r
+\r
+import org.jscience.physics.amount.Amount;\r
+\r
+import com.billkuker.rocketry.motorsim.Validating;\r
+import com.billkuker.rocketry.motorsim.grain.util.BurningShape;\r
+import com.billkuker.rocketry.motorsim.grain.util.ExtrudedShapeGrain;\r
+import com.billkuker.rocketry.motorsim.visual.Editor;\r
+import com.billkuker.rocketry.motorsim.visual.GrainPanel;\r
+\r
+public class CSlot extends ExtrudedShapeGrain implements Validating {\r
+\r
+ private Amount<Length> oD = Amount.valueOf(30, SI.MILLIMETER);\r
+ private Amount<Length> iD = Amount.valueOf(0, SI.MILLIMETER);\r
+ private Amount<Length> slotWidth = Amount.valueOf(5, SI.MILLIMETER);\r
+ private Amount<Length> slotDepth = Amount.valueOf(15, SI.MILLIMETER);\r
+ \r
+ public CSlot(){\r
+ try {\r
+ setLength(Amount.valueOf(70, SI.MILLIMETER));\r
+ } catch (PropertyVetoException e) {\r
+ e.printStackTrace();\r
+ }\r
+ generateGeometry();\r
+ }\r
+\r
+ public Amount<Length> getOD() {\r
+ return oD;\r
+ }\r
+\r
+ public void setOD(Amount<Length> od) throws PropertyVetoException {\r
+ this.oD = od;\r
+ generateGeometry();\r
+ }\r
+ \r
+ public Amount<Length> getSlotWidth() {\r
+ return slotWidth;\r
+ }\r
+\r
+ public void setSlotWidth(Amount<Length> slotWidth) {\r
+ this.slotWidth = slotWidth;\r
+ generateGeometry();\r
+ }\r
+\r
+ public Amount<Length> getSlotDepth() {\r
+ return slotDepth;\r
+ }\r
+\r
+ public void setSlotDepth(Amount<Length> slotDepth) {\r
+ this.slotDepth = slotDepth;\r
+ generateGeometry();\r
+ }\r
+\r
+\r
+\r
+\r
+ private void generateGeometry() {\r
+ double odmm = oD.doubleValue(SI.MILLIMETER);\r
+ double wmm = slotWidth.doubleValue(SI.MILLIMETER);\r
+ double dmm = slotDepth.doubleValue(SI.MILLIMETER);\r
+ xsection = new BurningShape();\r
+ Shape outside = new Ellipse2D.Double(0, 0, odmm, odmm);\r
+ xsection.add(outside);\r
+ xsection.inhibit(outside);\r
+ \r
+ double ymm = odmm/2.0 - wmm/2.0; //The Y position of the slot\r
+ double xmm = odmm - dmm;\r
+ Rectangle2D.Double slot;\r
+ slot = new Rectangle2D.Double(xmm, ymm, dmm, wmm);\r
+ xsection.subtract(slot);\r
+ \r
+ double idmm = iD.doubleValue(SI.MILLIMETER);\r
+ double idymm = odmm/2.0 - idmm/2.0;\r
+ double idxmm = xmm - idmm/2.0;\r
+ Ellipse2D.Double id = new Ellipse2D.Double(idxmm, idymm, idmm, idmm);\r
+ xsection.subtract(id);\r
+ \r
+ webThickness = null;\r
+ }\r
+ \r
+ public Amount<Length> getID() {\r
+ return iD;\r
+ }\r
+\r
+ public void setID(Amount<Length> id) {\r
+ iD = id;\r
+ generateGeometry();\r
+ }\r
+\r
+ public static void main(String args[]) throws Exception {\r
+ CSlot e = new CSlot();\r
+ new Editor(e).showAsWindow();\r
+ new GrainPanel(e).showAsWindow();\r
+ }\r
+ \r
+ public void validate() throws ValidationException{\r
+ if ( oD.equals(Amount.ZERO) )\r
+ throw new ValidationException(this, "Invalid oD");\r
+ if ( getLength().equals(Amount.ZERO) )\r
+ throw new ValidationException(this, "Invalid Length");\r
+ }\r
+\r
+}\r
import com.billkuker.rocketry.motorsim.fuel.KNER;\r
import com.billkuker.rocketry.motorsim.fuel.KNSB;\r
import com.billkuker.rocketry.motorsim.fuel.KNSU;\r
+import com.billkuker.rocketry.motorsim.grain.CSlot;\r
import com.billkuker.rocketry.motorsim.grain.CoredCylindricalGrain;\r
import com.billkuker.rocketry.motorsim.grain.Finocyl;\r
import com.billkuker.rocketry.motorsim.grain.Moonburner;\r
\r
@SuppressWarnings("unchecked")\r
private Class[] grainTypes = { CoredCylindricalGrain.class, Finocyl.class,\r
- Moonburner.class, RodAndTubeGrain.class };\r
+ Moonburner.class, RodAndTubeGrain.class, CSlot.class };\r
\r
@SuppressWarnings("unchecked")\r
private Class[] fuelTypes = { KNSB.class, KNSU.class, KNER.class,\r