2 * RocksimNoseConeCode.java
4 package net.sf.openrocket.file.rocksim;
6 import net.sf.openrocket.rocketcomponent.Transition;
9 * Models the nose cone shape of a rocket. Maps from Rocksim's notion to OpenRocket's.
11 enum RocksimNoseConeCode {
12 CONICAL (0, Transition.Shape.CONICAL),
13 OGIVE (1, Transition.Shape.OGIVE),
14 PARABOLIC (2, Transition.Shape.ELLIPSOID), //Rocksim' PARABOLIC most closely resembles an ELLIPSOID in OpenRocket
15 ELLIPTICAL (3, Transition.Shape.ELLIPSOID),
16 POWER_SERIES (4, Transition.Shape.POWER),
17 PARABOLIC_SERIES(5, Transition.Shape.PARABOLIC),
18 HAACK (6, Transition.Shape.HAACK);
20 /** The Rocksim enumeration value. Sent in XML. */
21 private final int ordinal;
23 /** The corresponding OpenRocket shape. */
24 private final Transition.Shape shape;
29 * @param idx the Rocksim shape code
30 * @param aShape the corresponding OpenRocket shape
32 private RocksimNoseConeCode(int idx, Transition.Shape aShape) {
38 * Get the OpenRocket shape that corresponds to the Rocksim shape.
42 public Transition.Shape asOpenRocket() {
47 * Lookup an instance of this enum based upon the Rocksim code.
49 * @param rocksimShapeCode the Rocksim code (from XML)
50 * @return an instance of this enum
52 public static RocksimNoseConeCode fromCode(int rocksimShapeCode) {
53 RocksimNoseConeCode[] values = values();
54 for (RocksimNoseConeCode value : values) {
55 if (value.ordinal == rocksimShapeCode) {
59 return PARABOLIC; //Default