DGP - changes to relative position; custom fin set points
authorrodinia814 <rodinia814@180e2498-e6e9-4542-8430-84ac67f01cd8>
Mon, 9 Jan 2012 03:36:14 +0000 (03:36 +0000)
committerrodinia814 <rodinia814@180e2498-e6e9-4542-8430-84ac67f01cd8>
Mon, 9 Jan 2012 03:36:14 +0000 (03:36 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@320 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/file/rocksim/export/BasePartDTO.java
core/src/net/sf/openrocket/file/rocksim/export/CustomFinSetDTO.java
core/src/net/sf/openrocket/file/rocksim/export/FinSetDTO.java
core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java

index 48a4d91080e5eb34edcb2f36986b08be3f3b15a8..a76eb45c00aa37f6842cee6cf3f69bf4292b612a 100644 (file)
@@ -6,6 +6,7 @@ import net.sf.openrocket.file.rocksim.importt.RocksimFinishCode;
 import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
 import net.sf.openrocket.file.rocksim.importt.RocksimLocationMode;
 import net.sf.openrocket.rocketcomponent.ExternalComponent;
+import net.sf.openrocket.rocketcomponent.FinSet;
 import net.sf.openrocket.rocketcomponent.RecoveryDevice;
 import net.sf.openrocket.rocketcomponent.RocketComponent;
 import net.sf.openrocket.rocketcomponent.StructuralComponent;
@@ -47,7 +48,7 @@ public abstract class BasePartDTO {
     private double radialAngle = 0;
     @XmlElement(name = "LocationMode")
     private int locationMode = 0;
-    @XmlElement(name = "Len")
+    @XmlElement(name = "Len", required = false, nillable = false)
     private double len = 0d;
     @XmlElement(name = "FinishCode")
     private int finishCode = 0;
@@ -60,18 +61,29 @@ public abstract class BasePartDTO {
         setCalcMass(ec.getComponentMass() * RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS);
         setKnownCG(ec.getOverrideCGX() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
         setKnownMass(ec.getOverrideMass() * RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS);
-        setLen(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+        if (! (ec instanceof FinSet)) {
+            setLen(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+        }
         setUseKnownCG(ec.isCGOverridden() || ec.isMassOverridden() ? 1 : 0);
         setName(ec.getName());
 
         setXb(ec.getPositionValue() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+
+        //When the relative position is BOTTOM, the position location of the bottom edge of the component is +
+        //to the right of the bottom of the parent, and - to the left.
+        //But in Rocksim, it's + to the left and - to the right
+        if (ec.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) {
+            setXb((-1 * ec.getPositionValue()) * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+        }
+        else if (ec.getRelativePosition().equals(RocketComponent.Position.MIDDLE)) {
+            //Mapped to TOP, so adjust accordingly
+            setXb((ec.getPositionValue() + (ec.getParent().getLength() - ec.getLength()) /2)* RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+        }
+
         if (ec instanceof ExternalComponent) {
             ExternalComponent comp = (ExternalComponent) ec;
             setLocationMode(RocksimLocationMode.toCode(comp.getRelativePosition()));
 
-            if (comp.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) {
-                setXb(-1 * getXb());
-            }
             setDensity(comp.getMaterial().getDensity() * RocksimHandler.ROCKSIM_TO_OPENROCKET_BULK_DENSITY);
             setDensityType(RocksimDensityType.toCode(comp.getMaterial().getType()));
             String material = comp.getMaterial().getName();
@@ -86,9 +98,6 @@ public abstract class BasePartDTO {
             StructuralComponent comp = (StructuralComponent) ec;
 
             setLocationMode(RocksimLocationMode.toCode(comp.getRelativePosition()));
-            if (comp.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) {
-                setXb(-1 * getXb());
-            }
             setDensity(comp.getMaterial().getDensity() * RocksimHandler.ROCKSIM_TO_OPENROCKET_BULK_DENSITY);
             setDensityType(RocksimDensityType.toCode(comp.getMaterial().getType()));
             String material = comp.getMaterial().getName();
@@ -101,9 +110,6 @@ public abstract class BasePartDTO {
             RecoveryDevice comp = (RecoveryDevice) ec;
 
             setLocationMode(RocksimLocationMode.toCode(comp.getRelativePosition()));
-            if (comp.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) {
-                setXb(-1 * getXb());
-            }
             setDensity(comp.getMaterial().getDensity() * RocksimHandler.ROCKSIM_TO_OPENROCKET_SURFACE_DENSITY);
             setDensityType(RocksimDensityType.toCode(comp.getMaterial().getType()));
             String material = comp.getMaterial().getName();
index 99112c9d6289bb363a9065705fd82babee70c40d..f37c9fecfecc747dc9ea86639d46a454efd75367 100644 (file)
@@ -29,7 +29,9 @@ public class CustomFinSetDTO extends FinSetDTO {
 
     private String convertFreeFormPoints(Coordinate[] points) {
         StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < points.length; i++) {
+
+        //Reverse the order for Rocksim
+        for (int i = points.length - 1; i >= 0; i--) {
             Coordinate point = points[i];
             sb.append(point.x * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH).append(",")
                     .append(point.y * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH).append("|");
index b97571c1426a08c9246b6e396e2b58ecfd6aa911..03ba5e377b7a6370cd0f75179bc0f1471be61fb1 100644 (file)
@@ -5,7 +5,6 @@ import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
 import net.sf.openrocket.rocketcomponent.EllipticalFinSet;
 import net.sf.openrocket.rocketcomponent.FinSet;
 import net.sf.openrocket.rocketcomponent.FreeformFinSet;
-import net.sf.openrocket.rocketcomponent.RocketComponent;
 import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
 
 import javax.xml.bind.annotation.XmlAccessType;
@@ -52,33 +51,28 @@ public class FinSetDTO extends BasePartDTO {
     public FinSetDTO(FinSet ec) {
         super(ec);
 
-        setCantAngle(ec.getCantAngle());
         setFinCount(ec.getFinCount());
-        setRootChord(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
+        setCantAngle(ec.getCantAngle());
         setTabDepth(ec.getTabHeight() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
         setTabLength(ec.getTabLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
         setTabOffset(ec.getTabShift() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
         setThickness(ec.getThickness() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
 
-        if (ec.getRelativePosition().equals(RocketComponent.Position.BOTTOM)) {
-            setXb(getXb() + getLen());
-        }
-
         setRadialAngle(ec.getBaseRotation());
         setTipShapeCode(TipShapeCode.convertTipShapeCode(ec.getCrossSection()));
         if (ec instanceof TrapezoidFinSet) {
             TrapezoidFinSet tfs = (TrapezoidFinSet) ec;
             setShapeCode(0);
+            setRootChord(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
             setSemiSpan(tfs.getHeight() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
             setTipChord(tfs.getTipChord() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
             setSweepDistance(tfs.getSweep() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
-            setLen(tfs.getLength());
         }
         else if (ec instanceof EllipticalFinSet) {
             EllipticalFinSet efs = (EllipticalFinSet) ec;
             setShapeCode(1);
+            setRootChord(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
             setSemiSpan(efs.getHeight() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
-            setLen(efs.getLength() *RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
         }
         else if (ec instanceof FreeformFinSet) {
             setShapeCode(2);
index 9abc44646c56fd9dbc80d9f2b610e711c19537f6..85a04105010b57ec5d3f25eda588da4b2491351c 100644 (file)
@@ -13,6 +13,8 @@ public class RocketDesignDTO {
     private String name;
     @XmlElement(name = "StageCount")
     private int stageCount = 1;
+    @XmlElement(name = "DisplayFlags")
+    private int displayFlags = 7;
     @XmlElement(name = "ViewType")
     private int viewType = 0;
     @XmlElement(name = "ViewStageCount")