X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Fmotor%2FThrustCurveMotor.java;h=e795c82308f9197fb241dd01a6fdd290e40a1594;hb=refs%2Fheads%2Fupstream;hp=1f8acd2aa8a0316e877491138d0d3f0d7b9d3f24;hpb=8654c7d5a9d56274a296500d40c7f74229cdf6f1;p=debian%2Fopenrocket diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java index 1f8acd2a..e795c823 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java @@ -1,6 +1,5 @@ package net.sf.openrocket.motor; -import java.io.Serializable; import java.text.Collator; import java.util.Arrays; import java.util.Locale; @@ -8,6 +7,7 @@ import java.util.Locale; import net.sf.openrocket.logging.LogHelper; import net.sf.openrocket.models.atmosphere.AtmosphericConditions; import net.sf.openrocket.startup.Application; +import net.sf.openrocket.util.ArrayUtils; import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Inertia; @@ -26,7 +26,7 @@ public class ThrustCurveMotor implements Motor, Comparable { } private static final DesignationComparator DESIGNATION_COMPARATOR = new DesignationComparator(); - + private final String digest; private final Manufacturer manufacturer; private final String designation; @@ -44,6 +44,31 @@ public class ThrustCurveMotor implements Motor, Comparable { private double averageThrust; private double totalImpulse; + /** + * Deep copy constructor. + * Constructs a new ThrustCurveMotor from an existing ThrustCurveMotor. + * @param m + */ + protected ThrustCurveMotor( ThrustCurveMotor m ) { + this.digest = m.digest; + this.manufacturer = m.manufacturer; + this.designation = m.designation; + this.description = m.description; + this.type = m.type; + this.delays = ArrayUtils.copyOf(m.delays, m.delays.length); + this.diameter = m.diameter; + this.length = m.length; + this.time = ArrayUtils.copyOf(m.time, m.time.length); + this.thrust = ArrayUtils.copyOf(m.thrust, m.thrust.length); + this.cg = new Coordinate[ m.cg.length ]; + for( int i = 0; i< cg.length; i++ ) { + this.cg[i] = m.cg[i].clone(); + } + this.maxThrust = m.maxThrust; + this.burnTime = m.burnTime; + this.averageThrust = m.averageThrust; + this.totalImpulse = m.totalImpulse; + } /** * Sole constructor. Sets all the properties of the motor. @@ -61,8 +86,8 @@ public class ThrustCurveMotor implements Motor, Comparable { */ public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description, Motor.Type type, double[] delays, double diameter, double length, - double[] time, double[] thrust, Coordinate[] cg) { - + double[] time, double[] thrust, Coordinate[] cg, String digest) { + this.digest = digest; // Check argument validity if ((time.length != thrust.length) || (time.length != cg.length)) { throw new IllegalArgumentException("Array lengths do not match, " + @@ -253,6 +278,10 @@ public class ThrustCurveMotor implements Motor, Comparable { return totalImpulse; } + @Override + public String getDigest() { + return digest; + } /** @@ -395,6 +424,7 @@ public class ThrustCurveMotor implements Motor, Comparable { private final double unitRotationalInertia; private final double unitLongitudinalInertia; + private final Motor parentMotor; private int modID = 0; @@ -408,6 +438,12 @@ public class ThrustCurveMotor implements Motor, Comparable { stepCG = cg[0]; unitRotationalInertia = Inertia.filledCylinderRotational(getDiameter() / 2); unitLongitudinalInertia = Inertia.filledCylinderLongitudinal(getDiameter() / 2, getLength()); + parentMotor = ThrustCurveMotor.this; + } + + @Override + public Motor getParentMotor(){ + return parentMotor; } @Override