DGP - First pass at Rocksim export
This commit is contained in:
parent
10dd89f569
commit
ec38d3b430
@ -1,15 +1,14 @@
|
||||
package net.sf.openrocket.file;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.file.openrocket.OpenRocketLoader;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.file.openrocket.OpenRocketLoader;
|
||||
import net.sf.openrocket.file.rocksim.RocksimLoader;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
||||
/**
|
||||
@ -31,7 +30,7 @@ public class GeneralRocketLoader extends RocketLoader {
|
||||
|
||||
private final OpenRocketLoader openRocketLoader = new OpenRocketLoader();
|
||||
|
||||
private final RocksimLoader rocksimLoader = new RocksimLoader();
|
||||
private final net.sf.openrocket.file.rocksim.importt.RocksimLoader rocksimLoader = new net.sf.openrocket.file.rocksim.importt.RocksimLoader();
|
||||
|
||||
@Override
|
||||
protected OpenRocketDocument loadFromStream(InputStream source) throws IOException,
|
||||
|
38
src/net/sf/openrocket/file/rocksim/TipShapeCode.java
Normal file
38
src/net/sf/openrocket/file/rocksim/TipShapeCode.java
Normal file
@ -0,0 +1,38 @@
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
|
||||
/**
|
||||
*/
|
||||
public final class TipShapeCode {
|
||||
|
||||
/**
|
||||
* Convert a Rocksim tip shape to an OpenRocket CrossSection.
|
||||
*
|
||||
* @param tipShape the tip shape code from Rocksim
|
||||
*
|
||||
* @return a CrossSection instance
|
||||
*/
|
||||
public static FinSet.CrossSection convertTipShapeCode (int tipShape) {
|
||||
switch (tipShape) {
|
||||
case 0:
|
||||
return FinSet.CrossSection.SQUARE;
|
||||
case 1:
|
||||
return FinSet.CrossSection.ROUNDED;
|
||||
case 2:
|
||||
return FinSet.CrossSection.AIRFOIL;
|
||||
default:
|
||||
return FinSet.CrossSection.SQUARE;
|
||||
}
|
||||
}
|
||||
|
||||
public static int convertTipShapeCode (FinSet.CrossSection cs) {
|
||||
if (FinSet.CrossSection.ROUNDED.equals(cs)) {
|
||||
return 1;
|
||||
}
|
||||
if (FinSet.CrossSection.AIRFOIL.equals(cs)) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimNoseConeCode;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class AbstractTransitionDTO extends BasePartDTO {
|
||||
@XmlElement(name = "ShapeCode")
|
||||
private int shapeCode = 1;
|
||||
@XmlElement(name = "ConstructionType")
|
||||
private int constructionType = 1;
|
||||
@XmlElement(name = "WallThickness")
|
||||
private double wallThickness = 0d;
|
||||
@XmlElement(name = "ShapeParameter")
|
||||
private double shapeParameter = 0d;
|
||||
|
||||
protected AbstractTransitionDTO() {
|
||||
|
||||
}
|
||||
|
||||
protected AbstractTransitionDTO(Transition nc) {
|
||||
super(nc);
|
||||
setConstructionType(nc.isFilled() ? 0 : 1);
|
||||
setShapeCode(RocksimNoseConeCode.toCode(nc.getType()));
|
||||
|
||||
if (Transition.Shape.POWER.equals(nc.getType()) ||
|
||||
Transition.Shape.HAACK.equals(nc.getType()) ||
|
||||
Transition.Shape.PARABOLIC.equals(nc.getType())) {
|
||||
setShapeParameter(nc.getShapeParameter());
|
||||
}
|
||||
|
||||
setWallThickness(nc.getThickness() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
|
||||
}
|
||||
|
||||
public int getShapeCode() {
|
||||
return shapeCode;
|
||||
}
|
||||
|
||||
public void setShapeCode(int theShapeCode) {
|
||||
shapeCode = theShapeCode;
|
||||
}
|
||||
|
||||
public int getConstructionType() {
|
||||
return constructionType;
|
||||
}
|
||||
|
||||
public void setConstructionType(int theConstructionType) {
|
||||
constructionType = theConstructionType;
|
||||
}
|
||||
|
||||
public double getWallThickness() {
|
||||
return wallThickness;
|
||||
}
|
||||
|
||||
public void setWallThickness(double theWallThickness) {
|
||||
wallThickness = theWallThickness;
|
||||
}
|
||||
|
||||
public double getShapeParameter() {
|
||||
return shapeParameter;
|
||||
}
|
||||
|
||||
public void setShapeParameter(double theShapeParameter) {
|
||||
shapeParameter = theShapeParameter;
|
||||
}
|
||||
}
|
238
src/net/sf/openrocket/file/rocksim/export/BasePartDTO.java
Normal file
238
src/net/sf/openrocket/file/rocksim/export/BasePartDTO.java
Normal file
@ -0,0 +1,238 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.BaseHandler;
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimDensityType;
|
||||
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.RecoveryDevice;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.StructuralComponent;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public abstract class BasePartDTO {
|
||||
|
||||
@XmlElement(name = "KnownMass")
|
||||
private Double knownMass = 0d;
|
||||
@XmlElement(name = "Density")
|
||||
private double density = 0d;
|
||||
@XmlElement(name = "Material")
|
||||
private String material = "";
|
||||
@XmlElement(name = "Name")
|
||||
private String name = "";
|
||||
@XmlElement(name = "KnownCG")
|
||||
private Double knownCG = null;
|
||||
@XmlElement(name = "UseKnownCG")
|
||||
private int useKnownCG = 1;
|
||||
@XmlElement(name = "Xb")
|
||||
private double xb = 0;
|
||||
@XmlElement(name = "CalcMass")
|
||||
private double calcMass = 0d;
|
||||
@XmlElement(name = "CalcCG")
|
||||
private double calcCG = 0d;
|
||||
@XmlElement(name = "DensityType")
|
||||
private int densityType = 0;
|
||||
@XmlElement(name = "RadialLoc")
|
||||
private String radialLoc = "0.";
|
||||
@XmlElement(name = "RadialAngle")
|
||||
private double radialAngle = 0;
|
||||
@XmlElement(name = "LocationMode")
|
||||
private int locationMode = 0;
|
||||
@XmlElement(name = "Len")
|
||||
private double len = 0d;
|
||||
@XmlElement(name = "FinishCode")
|
||||
private int finishCode = 0;
|
||||
|
||||
protected BasePartDTO() {
|
||||
}
|
||||
|
||||
protected BasePartDTO(RocketComponent ec) {
|
||||
setCalcCG(ec.getCG().x * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
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);
|
||||
setUseKnownCG(ec.isCGOverridden() || ec.isMassOverridden() ? 1 : 0);
|
||||
setName(ec.getName());
|
||||
|
||||
setXb(ec.getPositionValue() * 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();
|
||||
if (material.startsWith(BaseHandler.ROCKSIM_MATERIAL_PREFIX)) {
|
||||
material = material.substring(BaseHandler.ROCKSIM_MATERIAL_PREFIX.length());
|
||||
}
|
||||
setMaterial(material);
|
||||
|
||||
setFinishCode(RocksimFinishCode.toCode(comp.getFinish()));
|
||||
}
|
||||
else if (ec instanceof StructuralComponent) {
|
||||
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();
|
||||
if (material.startsWith(BaseHandler.ROCKSIM_MATERIAL_PREFIX)) {
|
||||
material = material.substring(BaseHandler.ROCKSIM_MATERIAL_PREFIX.length());
|
||||
}
|
||||
setMaterial(material);
|
||||
}
|
||||
else if (ec instanceof RecoveryDevice) {
|
||||
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();
|
||||
if (material.startsWith(BaseHandler.ROCKSIM_MATERIAL_PREFIX)) {
|
||||
material = material.substring(BaseHandler.ROCKSIM_MATERIAL_PREFIX.length());
|
||||
}
|
||||
setMaterial(material);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Double getKnownMass() {
|
||||
return knownMass;
|
||||
}
|
||||
|
||||
public void setKnownMass(Double theKnownMass) {
|
||||
knownMass = theKnownMass;
|
||||
}
|
||||
|
||||
public double getDensity() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public void setDensity(double theDensity) {
|
||||
density = theDensity;
|
||||
}
|
||||
|
||||
public String getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public void setMaterial(String theMaterial) {
|
||||
material = theMaterial;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String theName) {
|
||||
name = theName;
|
||||
}
|
||||
|
||||
public Double getKnownCG() {
|
||||
return knownCG;
|
||||
}
|
||||
|
||||
public void setKnownCG(Double theKnownCG) {
|
||||
knownCG = theKnownCG;
|
||||
}
|
||||
|
||||
public int getUseKnownCG() {
|
||||
return useKnownCG;
|
||||
}
|
||||
|
||||
public void setUseKnownCG(int theUseKnownCG) {
|
||||
useKnownCG = theUseKnownCG;
|
||||
}
|
||||
|
||||
public double getXb() {
|
||||
return xb;
|
||||
}
|
||||
|
||||
public void setXb(double theXb) {
|
||||
xb = theXb;
|
||||
}
|
||||
|
||||
public double getCalcMass() {
|
||||
return calcMass;
|
||||
}
|
||||
|
||||
public void setCalcMass(double theCalcMass) {
|
||||
calcMass = theCalcMass;
|
||||
}
|
||||
|
||||
public double getCalcCG() {
|
||||
return calcCG;
|
||||
}
|
||||
|
||||
public void setCalcCG(double theCalcCG) {
|
||||
calcCG = theCalcCG;
|
||||
}
|
||||
|
||||
public int getDensityType() {
|
||||
return densityType;
|
||||
}
|
||||
|
||||
public void setDensityType(int theDensityType) {
|
||||
densityType = theDensityType;
|
||||
}
|
||||
|
||||
public String getRadialLoc() {
|
||||
return radialLoc;
|
||||
}
|
||||
|
||||
public void setRadialLoc(String theRadialLoc) {
|
||||
radialLoc = theRadialLoc;
|
||||
}
|
||||
|
||||
public double getRadialAngle() {
|
||||
return radialAngle;
|
||||
}
|
||||
|
||||
public void setRadialAngle(double theRadialAngle) {
|
||||
radialAngle = theRadialAngle;
|
||||
}
|
||||
|
||||
public int getLocationMode() {
|
||||
return locationMode;
|
||||
}
|
||||
|
||||
public void setLocationMode(int theLocationMode) {
|
||||
locationMode = theLocationMode;
|
||||
}
|
||||
|
||||
public double getLen() {
|
||||
return len;
|
||||
}
|
||||
|
||||
public void setLen(double theLen) {
|
||||
len = theLen;
|
||||
}
|
||||
|
||||
public int getFinishCode() {
|
||||
return finishCode;
|
||||
}
|
||||
|
||||
public void setFinishCode(int theFinishCode) {
|
||||
finishCode = theFinishCode;
|
||||
}
|
||||
|
||||
}
|
182
src/net/sf/openrocket/file/rocksim/export/BodyTubeDTO.java
Normal file
182
src/net/sf/openrocket/file/rocksim/export/BodyTubeDTO.java
Normal file
@ -0,0 +1,182 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||
import net.sf.openrocket.rocketcomponent.Bulkhead;
|
||||
import net.sf.openrocket.rocketcomponent.CenteringRing;
|
||||
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
|
||||
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||
import net.sf.openrocket.rocketcomponent.LaunchLug;
|
||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||
import net.sf.openrocket.rocketcomponent.Parachute;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.Streamer;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlElementRefs;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "BodyTube")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class BodyTubeDTO extends BasePartDTO {
|
||||
|
||||
@XmlElement(name = "OD")
|
||||
private double od = 0d;
|
||||
@XmlElement(name = "ID")
|
||||
private double id = 0d;
|
||||
@XmlElement(name = "IsMotorMount")
|
||||
private int isMotorMount = 0;
|
||||
@XmlElement(name = "MotorDia")
|
||||
private double motorDia = 0d;
|
||||
@XmlElement(name = "EngineOverhang")
|
||||
private double engineOverhang = 0d;
|
||||
@XmlElement(name = "IsInsideTube")
|
||||
private int isInsideTube = 0;
|
||||
@XmlElementWrapper(name = "AttachedParts")
|
||||
@XmlElementRefs({
|
||||
@XmlElementRef(name = "BodyTube", type = BodyTubeDTO.class),
|
||||
@XmlElementRef(name = "BodyTube", type = InnerBodyTubeDTO.class),
|
||||
@XmlElementRef(name = "Ring", type = CenteringRingDTO.class),
|
||||
@XmlElementRef(name = "LaunchLug", type = LaunchLugDTO.class),
|
||||
@XmlElementRef(name = "FinSet", type = FinSetDTO.class),
|
||||
@XmlElementRef(name = "CustomFinSet", type = CustomFinSetDTO.class),
|
||||
@XmlElementRef(name = "Streamer", type = StreamerDTO.class),
|
||||
@XmlElementRef(name = "Parachute", type = ParachuteDTO.class),
|
||||
@XmlElementRef(name = "MassObject", type = MassObjectDTO.class)})
|
||||
List<BasePartDTO> attachedParts = new ArrayList<BasePartDTO>();
|
||||
|
||||
public BodyTubeDTO() {
|
||||
}
|
||||
|
||||
public BodyTubeDTO(InnerTube inner) {
|
||||
super(inner);
|
||||
}
|
||||
|
||||
public BodyTubeDTO(BodyTube bt) {
|
||||
super(bt);
|
||||
|
||||
setEngineOverhang(bt.getMotorOverhang() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setId(bt.getInnerRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOd(bt.getOuterRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorMount(bt.isMotorMount());
|
||||
|
||||
List<RocketComponent> children = bt.getChildren();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
RocketComponent rocketComponents = children.get(i);
|
||||
if (rocketComponents instanceof InnerTube) {
|
||||
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof BodyTube) {
|
||||
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof Transition) {
|
||||
attachedParts.add(new TransitionDTO((Transition) rocketComponents));
|
||||
} else if (rocketComponents instanceof EngineBlock) {
|
||||
attachedParts.add(new EngineBlockDTO((EngineBlock) rocketComponents));
|
||||
} else if (rocketComponents instanceof TubeCoupler) {
|
||||
attachedParts.add(new TubeCouplerDTO((TubeCoupler) rocketComponents));
|
||||
} else if (rocketComponents instanceof CenteringRing) {
|
||||
attachedParts.add(new CenteringRingDTO((CenteringRing) rocketComponents));
|
||||
} else if (rocketComponents instanceof Bulkhead) {
|
||||
attachedParts.add(new BulkheadDTO((Bulkhead) rocketComponents));
|
||||
} else if (rocketComponents instanceof LaunchLug) {
|
||||
attachedParts.add(new LaunchLugDTO((LaunchLug) rocketComponents));
|
||||
} else if (rocketComponents instanceof Streamer) {
|
||||
attachedParts.add(new StreamerDTO((Streamer) rocketComponents));
|
||||
} else if (rocketComponents instanceof Parachute) {
|
||||
attachedParts.add(new ParachuteDTO((Parachute) rocketComponents));
|
||||
} else if (rocketComponents instanceof MassObject) {
|
||||
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
||||
} else if (rocketComponents instanceof FreeformFinSet) {
|
||||
attachedParts.add(new CustomFinSetDTO((FreeformFinSet) rocketComponents));
|
||||
} else if (rocketComponents instanceof FinSet) {
|
||||
attachedParts.add(new FinSetDTO((FinSet) rocketComponents));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public double getOd() {
|
||||
return od;
|
||||
}
|
||||
|
||||
public void setOd(double theOd) {
|
||||
od = theOd;
|
||||
}
|
||||
|
||||
public double getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(double theId) {
|
||||
id = theId;
|
||||
}
|
||||
|
||||
public int getMotorMount() {
|
||||
return isMotorMount;
|
||||
}
|
||||
|
||||
public void setMotorMount(boolean motorMount) {
|
||||
if (motorMount) {
|
||||
isMotorMount = 1;
|
||||
} else {
|
||||
isMotorMount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMotorMount(int theMotorMount) {
|
||||
isMotorMount = theMotorMount;
|
||||
}
|
||||
|
||||
public double getMotorDia() {
|
||||
return motorDia;
|
||||
}
|
||||
|
||||
public void setMotorDia(double theMotorDia) {
|
||||
motorDia = theMotorDia;
|
||||
}
|
||||
|
||||
public double getEngineOverhang() {
|
||||
return engineOverhang;
|
||||
}
|
||||
|
||||
public void setEngineOverhang(double theEngineOverhang) {
|
||||
engineOverhang = theEngineOverhang;
|
||||
}
|
||||
|
||||
public int getInsideTube() {
|
||||
return isInsideTube;
|
||||
}
|
||||
|
||||
public void setInsideTube(boolean inside) {
|
||||
if (inside) {
|
||||
isInsideTube = 1;
|
||||
} else {
|
||||
isInsideTube = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setInsideTube(int theInsideTube) {
|
||||
isInsideTube = theInsideTube;
|
||||
}
|
||||
|
||||
public List<BasePartDTO> getAttachedParts() {
|
||||
return attachedParts;
|
||||
}
|
||||
|
||||
public void addAttachedParts(BasePartDTO thePart) {
|
||||
attachedParts.add(thePart);
|
||||
}
|
||||
}
|
18
src/net/sf/openrocket/file/rocksim/export/BulkheadDTO.java
Normal file
18
src/net/sf/openrocket/file/rocksim/export/BulkheadDTO.java
Normal file
@ -0,0 +1,18 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.Bulkhead;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "Ring")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class BulkheadDTO extends CenteringRingDTO {
|
||||
public BulkheadDTO(Bulkhead bh) {
|
||||
super(bh);
|
||||
setUsageCode(CenteringRingDTO.UsageCode.Bulkhead);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.RadiusRingComponent;
|
||||
import net.sf.openrocket.rocketcomponent.ThicknessRingComponent;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "Ring")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class CenteringRingDTO extends BasePartDTO {
|
||||
|
||||
@XmlTransient
|
||||
protected enum UsageCode {
|
||||
//UsageCode
|
||||
CenteringRing(0),
|
||||
Bulkhead(1),
|
||||
EngineBlock(2),
|
||||
Sleeve(3),
|
||||
TubeCoupler(4);
|
||||
|
||||
int ordinal;
|
||||
|
||||
UsageCode(int x) {
|
||||
ordinal = x;
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "OD")
|
||||
private double od = 0d;
|
||||
@XmlElement(name = "ID")
|
||||
private double id = 0d;
|
||||
@XmlElement(name = "UsageCode")
|
||||
private int usageCode = UsageCode.CenteringRing.ordinal;
|
||||
@XmlElement(name = "AutoSize")
|
||||
private int autoSize = 0;
|
||||
|
||||
public CenteringRingDTO() {
|
||||
|
||||
}
|
||||
public CenteringRingDTO(RadiusRingComponent cr) {
|
||||
super(cr);
|
||||
setId(cr.getInnerRadius()* RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOd(cr.getOuterRadius()* RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
}
|
||||
|
||||
public CenteringRingDTO(ThicknessRingComponent trc) {
|
||||
super(trc);
|
||||
setId(trc.getInnerRadius()* RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOd(trc.getOuterRadius()* RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
}
|
||||
public double getOd() {
|
||||
return od;
|
||||
}
|
||||
|
||||
public void setOd(double theOd) {
|
||||
od = theOd;
|
||||
}
|
||||
|
||||
public double getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(double theId) {
|
||||
id = theId;
|
||||
}
|
||||
|
||||
public int getUsageCode() {
|
||||
return usageCode;
|
||||
}
|
||||
|
||||
public void setUsageCode(int theUsageCode) {
|
||||
usageCode = theUsageCode;
|
||||
}
|
||||
|
||||
public void setUsageCode(UsageCode theUsageCode) {
|
||||
usageCode = theUsageCode.ordinal;
|
||||
}
|
||||
|
||||
public int getAutoSize() {
|
||||
return autoSize;
|
||||
}
|
||||
|
||||
public void setAutoSize(int theAutoSize) {
|
||||
autoSize = theAutoSize;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "CustomFinSet")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class CustomFinSetDTO extends FinSetDTO {
|
||||
|
||||
@XmlElement(name = "PointList")
|
||||
private String pointList = "";
|
||||
|
||||
public CustomFinSetDTO() {
|
||||
}
|
||||
|
||||
public CustomFinSetDTO(FreeformFinSet ec) {
|
||||
super(ec);
|
||||
setPointList(convertFreeFormPoints(ec.getFinPoints()));
|
||||
}
|
||||
|
||||
|
||||
private String convertFreeFormPoints(Coordinate[] points) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
Coordinate point = points[i];
|
||||
sb.append(point.x * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH).append(",")
|
||||
.append(point.y * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH).append("|");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getPointList() {
|
||||
return pointList;
|
||||
}
|
||||
|
||||
public void setPointList(String thePointList) {
|
||||
pointList = thePointList;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "Ring")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class EngineBlockDTO extends CenteringRingDTO{
|
||||
|
||||
public EngineBlockDTO(EngineBlock eb) {
|
||||
super(eb);
|
||||
setUsageCode(UsageCode.EngineBlock);
|
||||
}
|
||||
}
|
191
src/net/sf/openrocket/file/rocksim/export/FinSetDTO.java
Normal file
191
src/net/sf/openrocket/file/rocksim/export/FinSetDTO.java
Normal file
@ -0,0 +1,191 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.TipShapeCode;
|
||||
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;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "FinSet")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class FinSetDTO extends BasePartDTO {
|
||||
|
||||
@XmlElement(name = "FinCount")
|
||||
private int finCount = 0;
|
||||
@XmlElement(name = "RootChord")
|
||||
private double rootChord = 0d;
|
||||
@XmlElement(name = "TipChord")
|
||||
private double tipChord = 0d;
|
||||
@XmlElement(name = "SemiSpan")
|
||||
private double semiSpan = 0d;
|
||||
@XmlElement(name = "SweepDistance")
|
||||
private double sweepDistance = 0d;
|
||||
@XmlElement(name = "Thickness")
|
||||
private double thickness = 0d;
|
||||
@XmlElement(name = "ShapeCode")
|
||||
private int shapeCode = 0;
|
||||
@XmlElement(name = "TipShapeCode")
|
||||
private int tipShapeCode = 0;
|
||||
@XmlElement(name = "TabLength")
|
||||
private double tabLength = 0d;
|
||||
@XmlElement(name = "TabDepth")
|
||||
private double tabDepth = 0d;
|
||||
@XmlElement(name = "TabOffset")
|
||||
private double tabOffset = 0d;
|
||||
@XmlElement(name = "SweepMode")
|
||||
private int sweepMode = 1;
|
||||
@XmlElement(name = "CantAngle")
|
||||
private double cantAngle = 0d;
|
||||
|
||||
public FinSetDTO() {
|
||||
}
|
||||
|
||||
public FinSetDTO(FinSet ec) {
|
||||
super(ec);
|
||||
|
||||
setCantAngle(ec.getCantAngle());
|
||||
setFinCount(ec.getFinCount());
|
||||
setRootChord(ec.getLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
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);
|
||||
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);
|
||||
setSemiSpan(efs.getHeight() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setLen(efs.getLength() *RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
}
|
||||
else if (ec instanceof FreeformFinSet) {
|
||||
setShapeCode(2);
|
||||
}
|
||||
}
|
||||
|
||||
public int getFinCount() {
|
||||
return finCount;
|
||||
}
|
||||
|
||||
public void setFinCount(int theFinCount) {
|
||||
finCount = theFinCount;
|
||||
}
|
||||
|
||||
public double getRootChord() {
|
||||
return rootChord;
|
||||
}
|
||||
|
||||
public void setRootChord(double theRootChord) {
|
||||
rootChord = theRootChord;
|
||||
}
|
||||
|
||||
public double getTipChord() {
|
||||
return tipChord;
|
||||
}
|
||||
|
||||
public void setTipChord(double theTipChord) {
|
||||
tipChord = theTipChord;
|
||||
}
|
||||
|
||||
public double getSemiSpan() {
|
||||
return semiSpan;
|
||||
}
|
||||
|
||||
public void setSemiSpan(double theSemiSpan) {
|
||||
semiSpan = theSemiSpan;
|
||||
}
|
||||
|
||||
public double getSweepDistance() {
|
||||
return sweepDistance;
|
||||
}
|
||||
|
||||
public void setSweepDistance(double theSweepDistance) {
|
||||
sweepDistance = theSweepDistance;
|
||||
}
|
||||
|
||||
public double getThickness() {
|
||||
return thickness;
|
||||
}
|
||||
|
||||
public void setThickness(double theThickness) {
|
||||
thickness = theThickness;
|
||||
}
|
||||
|
||||
public int getShapeCode() {
|
||||
return shapeCode;
|
||||
}
|
||||
|
||||
public void setShapeCode(int theShapeCode) {
|
||||
shapeCode = theShapeCode;
|
||||
}
|
||||
|
||||
public int getTipShapeCode() {
|
||||
return tipShapeCode;
|
||||
}
|
||||
|
||||
public void setTipShapeCode(int theTipShapeCode) {
|
||||
tipShapeCode = theTipShapeCode;
|
||||
}
|
||||
|
||||
public double getTabLength() {
|
||||
return tabLength;
|
||||
}
|
||||
|
||||
public void setTabLength(double theTabLength) {
|
||||
tabLength = theTabLength;
|
||||
}
|
||||
|
||||
public double getTabDepth() {
|
||||
return tabDepth;
|
||||
}
|
||||
|
||||
public void setTabDepth(double theTabDepth) {
|
||||
tabDepth = theTabDepth;
|
||||
}
|
||||
|
||||
public double getTabOffset() {
|
||||
return tabOffset;
|
||||
}
|
||||
|
||||
public void setTabOffset(double theTabOffset) {
|
||||
tabOffset = theTabOffset;
|
||||
}
|
||||
|
||||
public int getSweepMode() {
|
||||
return sweepMode;
|
||||
}
|
||||
|
||||
public void setSweepMode(int theSweepMode) {
|
||||
sweepMode = theSweepMode;
|
||||
}
|
||||
|
||||
public double getCantAngle() {
|
||||
return cantAngle;
|
||||
}
|
||||
|
||||
public void setCantAngle(double theCantAngle) {
|
||||
cantAngle = theCantAngle;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||
import net.sf.openrocket.rocketcomponent.Bulkhead;
|
||||
import net.sf.openrocket.rocketcomponent.CenteringRing;
|
||||
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
||||
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||
import net.sf.openrocket.rocketcomponent.Parachute;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.Streamer;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "BodyTube")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class InnerBodyTubeDTO extends BodyTubeDTO {
|
||||
|
||||
public InnerBodyTubeDTO() {
|
||||
super.setInsideTube(true);
|
||||
}
|
||||
|
||||
public InnerBodyTubeDTO(InnerTube bt) {
|
||||
super(bt);
|
||||
setEngineOverhang(bt.getMotorOverhang() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setId(bt.getInnerRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOd(bt.getOuterRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorMount(bt.isMotorMount());
|
||||
|
||||
List<RocketComponent> children = bt.getChildren();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
RocketComponent rocketComponents = children.get(i);
|
||||
if (rocketComponents instanceof InnerTube) {
|
||||
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof BodyTube) {
|
||||
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof Transition) {
|
||||
attachedParts.add(new TransitionDTO((Transition) rocketComponents));
|
||||
} else if (rocketComponents instanceof EngineBlock) {
|
||||
attachedParts.add(new EngineBlockDTO((EngineBlock) rocketComponents));
|
||||
} else if (rocketComponents instanceof TubeCoupler) {
|
||||
attachedParts.add(new TubeCouplerDTO((TubeCoupler) rocketComponents));
|
||||
} else if (rocketComponents instanceof CenteringRing) {
|
||||
attachedParts.add(new CenteringRingDTO((CenteringRing) rocketComponents));
|
||||
} else if (rocketComponents instanceof Bulkhead) {
|
||||
attachedParts.add(new BulkheadDTO((Bulkhead) rocketComponents));
|
||||
} else if (rocketComponents instanceof Streamer) {
|
||||
attachedParts.add(new StreamerDTO((Streamer) rocketComponents));
|
||||
} else if (rocketComponents instanceof Parachute) {
|
||||
attachedParts.add(new ParachuteDTO((Parachute) rocketComponents));
|
||||
} else if (rocketComponents instanceof MassObject) {
|
||||
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
||||
}
|
||||
}
|
||||
setInsideTube(true);
|
||||
}
|
||||
}
|
47
src/net/sf/openrocket/file/rocksim/export/LaunchLugDTO.java
Normal file
47
src/net/sf/openrocket/file/rocksim/export/LaunchLugDTO.java
Normal file
@ -0,0 +1,47 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.LaunchLug;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "LaunchLug")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class LaunchLugDTO extends BasePartDTO {
|
||||
|
||||
@XmlElement(name = "OD")
|
||||
private double od = 0d;
|
||||
@XmlElement(name = "ID")
|
||||
private double id = 0d;
|
||||
|
||||
public LaunchLugDTO() {
|
||||
}
|
||||
|
||||
public LaunchLugDTO(LaunchLug ec) {
|
||||
super(ec);
|
||||
setId(ec.getInnerRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOd(ec.getOuterRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setRadialAngle(ec.getRadialDirection());
|
||||
}
|
||||
|
||||
public double getOd() {
|
||||
return od;
|
||||
}
|
||||
|
||||
public void setOd(double theOd) {
|
||||
od = theOd;
|
||||
}
|
||||
|
||||
public double getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(double theId) {
|
||||
id = theId;
|
||||
}
|
||||
}
|
25
src/net/sf/openrocket/file/rocksim/export/MassObjectDTO.java
Normal file
25
src/net/sf/openrocket/file/rocksim/export/MassObjectDTO.java
Normal file
@ -0,0 +1,25 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "MassObject")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class MassObjectDTO extends BasePartDTO{
|
||||
|
||||
@XmlElement(name = "TypeCode")
|
||||
private int typeCode = 0;
|
||||
|
||||
public MassObjectDTO() {
|
||||
}
|
||||
|
||||
public MassObjectDTO(MassObject ec) {
|
||||
super(ec);
|
||||
}
|
||||
}
|
114
src/net/sf/openrocket/file/rocksim/export/NoseConeDTO.java
Normal file
114
src/net/sf/openrocket/file/rocksim/export/NoseConeDTO.java
Normal file
@ -0,0 +1,114 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||
import net.sf.openrocket.rocketcomponent.Bulkhead;
|
||||
import net.sf.openrocket.rocketcomponent.CenteringRing;
|
||||
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
|
||||
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||
import net.sf.openrocket.rocketcomponent.NoseCone;
|
||||
import net.sf.openrocket.rocketcomponent.Parachute;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlElementRefs;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "NoseCone")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class NoseConeDTO extends AbstractTransitionDTO {
|
||||
|
||||
|
||||
@XmlElement(name = "BaseDia")
|
||||
private double baseDia = 0d;
|
||||
@XmlElement(name = "ShoulderLen")
|
||||
private double shoulderLen = 0d;
|
||||
@XmlElement(name = "ShoulderOD")
|
||||
private double shoulderOD = 0d;
|
||||
|
||||
@XmlElementWrapper(name = "AttachedParts")
|
||||
@XmlElementRefs({
|
||||
@XmlElementRef(name = "BodyTube", type = BodyTubeDTO.class),
|
||||
@XmlElementRef(name = "BodyTube", type = InnerBodyTubeDTO.class),
|
||||
@XmlElementRef(name = "FinSet", type = FinSetDTO.class),
|
||||
@XmlElementRef(name = "CustomFinSet", type = CustomFinSetDTO.class),
|
||||
@XmlElementRef(name = "Ring", type = CenteringRingDTO.class),
|
||||
@XmlElementRef(name = "Parachute", type = ParachuteDTO.class),
|
||||
@XmlElementRef(name = "MassObject", type = MassObjectDTO.class)})
|
||||
List<BasePartDTO> attachedParts = new ArrayList<BasePartDTO>();
|
||||
|
||||
public NoseConeDTO() {
|
||||
}
|
||||
|
||||
public NoseConeDTO(NoseCone nc) {
|
||||
super(nc);
|
||||
setBaseDia(nc.getAftRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setShoulderLen(nc.getAftShoulderLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setShoulderOD(nc.getAftShoulderRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
|
||||
List<RocketComponent> children = nc.getChildren();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
RocketComponent rocketComponents = children.get(i);
|
||||
if (rocketComponents instanceof InnerTube) {
|
||||
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof BodyTube) {
|
||||
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof Transition) {
|
||||
attachedParts.add(new TransitionDTO((Transition) rocketComponents));
|
||||
} else if (rocketComponents instanceof EngineBlock) {
|
||||
attachedParts.add(new EngineBlockDTO((EngineBlock) rocketComponents));
|
||||
} else if (rocketComponents instanceof TubeCoupler) {
|
||||
attachedParts.add(new TubeCouplerDTO((TubeCoupler) rocketComponents));
|
||||
} else if (rocketComponents instanceof CenteringRing) {
|
||||
attachedParts.add(new CenteringRingDTO((CenteringRing) rocketComponents));
|
||||
} else if (rocketComponents instanceof Bulkhead) {
|
||||
attachedParts.add(new BulkheadDTO((Bulkhead) rocketComponents));
|
||||
} else if (rocketComponents instanceof Parachute) {
|
||||
attachedParts.add(new ParachuteDTO((Parachute) rocketComponents));
|
||||
} else if (rocketComponents instanceof MassObject) {
|
||||
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
||||
} else if (rocketComponents instanceof FreeformFinSet) {
|
||||
attachedParts.add(new CustomFinSetDTO((FreeformFinSet) rocketComponents));
|
||||
} else if (rocketComponents instanceof FinSet) {
|
||||
attachedParts.add(new FinSetDTO((FinSet) rocketComponents));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getBaseDia() {
|
||||
return baseDia;
|
||||
}
|
||||
|
||||
public void setBaseDia(double theBaseDia) {
|
||||
baseDia = theBaseDia;
|
||||
}
|
||||
|
||||
public double getShoulderLen() {
|
||||
return shoulderLen;
|
||||
}
|
||||
|
||||
public void setShoulderLen(double theShoulderLen) {
|
||||
shoulderLen = theShoulderLen;
|
||||
}
|
||||
|
||||
public double getShoulderOD() {
|
||||
return shoulderOD;
|
||||
}
|
||||
|
||||
public void setShoulderOD(double theShoulderOD) {
|
||||
shoulderOD = theShoulderOD;
|
||||
}
|
||||
}
|
129
src/net/sf/openrocket/file/rocksim/export/ParachuteDTO.java
Normal file
129
src/net/sf/openrocket/file/rocksim/export/ParachuteDTO.java
Normal file
@ -0,0 +1,129 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.BaseHandler;
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.Parachute;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "Parachute")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class ParachuteDTO extends BasePartDTO {
|
||||
|
||||
@XmlElement(name = "Dia")
|
||||
private double dia = 0d;
|
||||
@XmlElement(name = "SpillHoleDia")
|
||||
private double spillHoleDia = 0d;
|
||||
@XmlElement(name = "ShroudLineCount")
|
||||
private int ShroudLineCount = 0;
|
||||
@XmlElement(name = "Thickness")
|
||||
private double thickness = 0d;
|
||||
@XmlElement(name = "ShroudLineLen")
|
||||
private double shroudLineLen = 0d;
|
||||
@XmlElement(name = "ChuteCount")
|
||||
private int chuteCount = 1;
|
||||
@XmlElement(name = "ShroudLineMassPerMM")
|
||||
private double shroudLineMassPerMM = 0d;
|
||||
@XmlElement(name = "ShroudLineMaterial")
|
||||
private String shroudLineMaterial = "";
|
||||
@XmlElement(name = "DragCoefficient")
|
||||
private double dragCoefficient = 0.75d;
|
||||
|
||||
public ParachuteDTO() {
|
||||
}
|
||||
|
||||
public ParachuteDTO(Parachute ec) {
|
||||
super(ec);
|
||||
|
||||
setChuteCount(1);
|
||||
setDia(ec.getDiameter() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setDragCoefficient(ec.getCD());
|
||||
setShroudLineCount(ec.getLineCount());
|
||||
setShroudLineLen(ec.getLineLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
|
||||
String material = ec.getLineMaterial().getName();
|
||||
setShroudLineMassPerMM(ec.getLineMaterial().getDensity() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LINE_DENSITY);
|
||||
|
||||
if (material.startsWith(BaseHandler.ROCKSIM_MATERIAL_PREFIX)) {
|
||||
material = material.substring(BaseHandler.ROCKSIM_MATERIAL_PREFIX.length());
|
||||
}
|
||||
setShroudLineMaterial(material);
|
||||
}
|
||||
|
||||
public double getDia() {
|
||||
return dia;
|
||||
}
|
||||
|
||||
public void setDia(double theDia) {
|
||||
dia = theDia;
|
||||
}
|
||||
|
||||
public double getSpillHoleDia() {
|
||||
return spillHoleDia;
|
||||
}
|
||||
|
||||
public void setSpillHoleDia(double theSpillHoleDia) {
|
||||
spillHoleDia = theSpillHoleDia;
|
||||
}
|
||||
|
||||
public int getShroudLineCount() {
|
||||
return ShroudLineCount;
|
||||
}
|
||||
|
||||
public void setShroudLineCount(int theShroudLineCount) {
|
||||
ShroudLineCount = theShroudLineCount;
|
||||
}
|
||||
|
||||
public double getThickness() {
|
||||
return thickness;
|
||||
}
|
||||
|
||||
public void setThickness(double theThickness) {
|
||||
thickness = theThickness;
|
||||
}
|
||||
|
||||
public double getShroudLineLen() {
|
||||
return shroudLineLen;
|
||||
}
|
||||
|
||||
public void setShroudLineLen(double theShroudLineLen) {
|
||||
shroudLineLen = theShroudLineLen;
|
||||
}
|
||||
|
||||
public int getChuteCount() {
|
||||
return chuteCount;
|
||||
}
|
||||
|
||||
public void setChuteCount(int theChuteCount) {
|
||||
chuteCount = theChuteCount;
|
||||
}
|
||||
|
||||
public double getShroudLineMassPerMM() {
|
||||
return shroudLineMassPerMM;
|
||||
}
|
||||
|
||||
public void setShroudLineMassPerMM(double theShroudLineMassPerMM) {
|
||||
shroudLineMassPerMM = theShroudLineMassPerMM;
|
||||
}
|
||||
|
||||
public String getShroudLineMaterial() {
|
||||
return shroudLineMaterial;
|
||||
}
|
||||
|
||||
public void setShroudLineMaterial(String theShroudLineMaterial) {
|
||||
shroudLineMaterial = theShroudLineMaterial;
|
||||
}
|
||||
|
||||
public double getDragCoefficient() {
|
||||
return dragCoefficient;
|
||||
}
|
||||
|
||||
public void setDragCoefficient(double theDragCoefficient) {
|
||||
dragCoefficient = theDragCoefficient;
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class RocketDesignDTO {
|
||||
|
||||
@XmlElement(name = "Name")
|
||||
private String name;
|
||||
@XmlElement(name = "StageCount")
|
||||
private int stageCount = 1;
|
||||
@XmlElement(name = "ViewType")
|
||||
private int viewType = 0;
|
||||
@XmlElement(name = "ViewStageCount")
|
||||
private int viewStageCount = 3;
|
||||
@XmlElement(name = "ViewTypeEdit")
|
||||
private int viewTypeEdit = 0;
|
||||
@XmlElement(name = "ViewStageCountEdit")
|
||||
private int viewStageCountEdit = 3;
|
||||
@XmlElement(name = "ZoomFactor")
|
||||
private double zoomFactor = 0d;
|
||||
@XmlElement (name = "ZoomFactorEdit")
|
||||
private double zoomFactorEdit = 0d;
|
||||
@XmlElement(name = "ScrollPosX")
|
||||
private int scrollPosX = 0;
|
||||
@XmlElement(name = "ScrollPosY")
|
||||
private int scrollPosY = 0;
|
||||
@XmlElement(name = "ScrollPosXEdit")
|
||||
private int scrollPosXEdit = 0;
|
||||
@XmlElement(name = "ScrollPosYEdit")
|
||||
private int scrollPosYEdit = 0;
|
||||
@XmlElement(name = "ThreeDFlags")
|
||||
private int threeDFlags = 0;
|
||||
@XmlElement(name = "ThreeDFlagsEdit")
|
||||
private int threeDFlagsEdit = 0;
|
||||
|
||||
@XmlElement(name = "CPCalcFlags")
|
||||
private String cpCalcFlags = "1";
|
||||
@XmlElement(name = "UseKnownMass")
|
||||
private String useKnownMass = "0";
|
||||
@XmlElement(name = "Stage3Parts")
|
||||
private StageDTO stage3 = new StageDTO();
|
||||
@XmlElement(name = "Stage2Parts", required = true, nillable = false)
|
||||
private StageDTO stage2 = new StageDTO();
|
||||
@XmlElement(name = "Stage1Parts", required = false, nillable = false)
|
||||
private StageDTO stage1 = new StageDTO();
|
||||
|
||||
public RocketDesignDTO() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String theName) {
|
||||
name = theName;
|
||||
}
|
||||
|
||||
public int getStageCount() {
|
||||
return stageCount;
|
||||
}
|
||||
|
||||
public void setStageCount(int theStageCount) {
|
||||
stageCount = theStageCount;
|
||||
}
|
||||
|
||||
public StageDTO getStage3() {
|
||||
return stage3;
|
||||
}
|
||||
|
||||
public void setStage3(StageDTO theStage3) {
|
||||
stage3 = theStage3;
|
||||
}
|
||||
|
||||
public StageDTO getStage2() {
|
||||
return stage2;
|
||||
}
|
||||
|
||||
public void setStage2(StageDTO theStage2) {
|
||||
stage2 = theStage2;
|
||||
}
|
||||
|
||||
public StageDTO getStage1() {
|
||||
return stage1;
|
||||
}
|
||||
|
||||
public void setStage1(StageDTO theStage1) {
|
||||
stage1 = theStage1;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class RocksimDesignDTO {
|
||||
|
||||
@XmlElement(name = "RocketDesign")
|
||||
private RocketDesignDTO design;
|
||||
|
||||
public RocksimDesignDTO() {
|
||||
}
|
||||
|
||||
public RocketDesignDTO getDesign() {
|
||||
return design;
|
||||
}
|
||||
|
||||
public void setDesign(RocketDesignDTO theDesign) {
|
||||
design = theDesign;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "RockSimDocument")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class RocksimDocumentDTO {
|
||||
|
||||
@XmlElement(name = "FileVersion")
|
||||
private final String version = "4";
|
||||
|
||||
@XmlElement(name = "DesignInformation")
|
||||
private RocksimDesignDTO design;
|
||||
|
||||
public RocksimDocumentDTO() {
|
||||
}
|
||||
|
||||
public RocksimDesignDTO getDesign() {
|
||||
return design;
|
||||
}
|
||||
|
||||
public void setDesign(RocksimDesignDTO theDesign) {
|
||||
this.design = theDesign;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
122
src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java
Normal file
122
src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java
Normal file
@ -0,0 +1,122 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.StorageOptions;
|
||||
import net.sf.openrocket.file.RocketSaver;
|
||||
import net.sf.openrocket.logging.LogHelper;
|
||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||
import net.sf.openrocket.rocketcomponent.NoseCone;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.Stage;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class RocksimSaver extends RocketSaver {
|
||||
|
||||
private static final LogHelper log = Application.getLogger();
|
||||
|
||||
public String marshalToRocksim(OpenRocketDocument doc) {
|
||||
|
||||
try {
|
||||
JAXBContext binder = JAXBContext.newInstance(RocksimDocumentDTO.class);
|
||||
Marshaller marshaller = binder.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
marshaller.marshal(toRocksimDocumentDTO(doc), sw);
|
||||
return sw.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(OutputStream dest, OpenRocketDocument doc, StorageOptions options) throws IOException {
|
||||
log.info("Saving .rkt file");
|
||||
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, "UTF-8"));
|
||||
writer.write(marshalToRocksim(doc));
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long estimateFileSize(OpenRocketDocument doc, StorageOptions options) {
|
||||
return marshalToRocksim(doc).length();
|
||||
}
|
||||
|
||||
private RocksimDocumentDTO toRocksimDocumentDTO(OpenRocketDocument doc) {
|
||||
RocksimDocumentDTO rsd = new RocksimDocumentDTO();
|
||||
|
||||
rsd.setDesign(toRocksimDesignDTO(doc.getRocket()));
|
||||
|
||||
return rsd;
|
||||
}
|
||||
|
||||
private RocksimDesignDTO toRocksimDesignDTO(Rocket rocket) {
|
||||
RocksimDesignDTO result = new RocksimDesignDTO();
|
||||
result.setDesign(toRocketDesignDTO(rocket));
|
||||
return result;
|
||||
}
|
||||
|
||||
private RocketDesignDTO toRocketDesignDTO(Rocket rocket) {
|
||||
RocketDesignDTO result = new RocketDesignDTO();
|
||||
result.setName(rocket.getName());
|
||||
int stageCount = rocket.getStageCount();
|
||||
result.setStageCount(stageCount);
|
||||
if (stageCount > 0) {
|
||||
result.setStage3(toStageDTO(rocket.getChild(0).getStage()));
|
||||
}
|
||||
if (stageCount > 1) {
|
||||
result.setStage2(toStageDTO(rocket.getChild(1).getStage()));
|
||||
}
|
||||
if (stageCount > 2) {
|
||||
result.setStage1(toStageDTO(rocket.getChild(2).getStage()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private StageDTO toStageDTO(Stage stage) {
|
||||
StageDTO result = new StageDTO();
|
||||
|
||||
List<RocketComponent> children = stage.getChildren();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
RocketComponent rocketComponents = children.get(i);
|
||||
if (rocketComponents instanceof NoseCone) {
|
||||
result.addExternalPart(toNoseConeDTO((NoseCone) rocketComponents));
|
||||
} else if (rocketComponents instanceof BodyTube) {
|
||||
result.addExternalPart(toBodyTubeDTO((BodyTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof Transition) {
|
||||
result.addExternalPart(toTransitionDTO((Transition) rocketComponents));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private NoseConeDTO toNoseConeDTO(NoseCone nc) {
|
||||
return new NoseConeDTO(nc);
|
||||
}
|
||||
|
||||
private BodyTubeDTO toBodyTubeDTO(BodyTube bt) {
|
||||
return new BodyTubeDTO(bt);
|
||||
}
|
||||
|
||||
private TransitionDTO toTransitionDTO(Transition tran) {
|
||||
return new TransitionDTO(tran);
|
||||
}
|
||||
}
|
33
src/net/sf/openrocket/file/rocksim/export/StageDTO.java
Normal file
33
src/net/sf/openrocket/file/rocksim/export/StageDTO.java
Normal file
@ -0,0 +1,33 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.util.ArrayList;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlElementRefs;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class StageDTO {
|
||||
|
||||
@XmlElementRefs({
|
||||
@XmlElementRef(name = "BodyTube", type = BodyTubeDTO.class),
|
||||
@XmlElementRef(name = "NoseCone", type = NoseConeDTO.class),
|
||||
@XmlElementRef(name = "Transition", type = TransitionDTO.class)
|
||||
})
|
||||
private List<BasePartDTO> externalPart = new ArrayList<BasePartDTO>();
|
||||
|
||||
public StageDTO() {
|
||||
}
|
||||
|
||||
public List<BasePartDTO> getExternalPart() {
|
||||
return externalPart;
|
||||
}
|
||||
|
||||
public void addExternalPart(BasePartDTO theExternalPartDTO) {
|
||||
externalPart.add(theExternalPartDTO);
|
||||
}
|
||||
}
|
46
src/net/sf/openrocket/file/rocksim/export/StreamerDTO.java
Normal file
46
src/net/sf/openrocket/file/rocksim/export/StreamerDTO.java
Normal file
@ -0,0 +1,46 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.Streamer;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "Streamer")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class StreamerDTO extends BasePartDTO {
|
||||
|
||||
@XmlElement(name = "Width")
|
||||
private double width = 0d;
|
||||
@XmlElement(name = "DragCoefficient")
|
||||
private double dragCoefficient = 0.75d;
|
||||
|
||||
public StreamerDTO() {
|
||||
}
|
||||
|
||||
public StreamerDTO(Streamer ec) {
|
||||
super(ec);
|
||||
setWidth(ec.getStripWidth() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setDragCoefficient(ec.getCD());
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(double theWidth) {
|
||||
width = theWidth;
|
||||
}
|
||||
|
||||
public double getDragCoefficient() {
|
||||
return dragCoefficient;
|
||||
}
|
||||
|
||||
public void setDragCoefficient(double theDragCoefficient) {
|
||||
dragCoefficient = theDragCoefficient;
|
||||
}
|
||||
}
|
92
src/net/sf/openrocket/file/rocksim/export/TransitionDTO.java
Normal file
92
src/net/sf/openrocket/file/rocksim/export/TransitionDTO.java
Normal file
@ -0,0 +1,92 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "Transition")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class TransitionDTO extends AbstractTransitionDTO {
|
||||
|
||||
|
||||
@XmlElement(name = "FrontShoulderLen")
|
||||
private double frontShoulderLen = 0d;
|
||||
@XmlElement(name = "RearShoulderLen")
|
||||
private double rearShoulderLen = 0d;
|
||||
@XmlElement(name = "FrontShoulderDia")
|
||||
private double frontShoulderDia = 0d;
|
||||
@XmlElement(name = "RearShoulderDia")
|
||||
private double rearShoulderDia = 0d;
|
||||
@XmlElement(name = "FrontDia")
|
||||
private double frontDia = 0d;
|
||||
@XmlElement(name = "RearDia")
|
||||
private double rearDia = 0d;
|
||||
|
||||
public TransitionDTO() {
|
||||
}
|
||||
|
||||
public TransitionDTO(Transition tran) {
|
||||
super(tran);
|
||||
setFrontDia(tran.getForeRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setRearDia(tran.getAftRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setFrontShoulderDia(tran.getForeShoulderRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setFrontShoulderLen(tran.getForeShoulderLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setRearShoulderDia(tran.getAftShoulderRadius() * RocksimHandler.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setRearShoulderLen(tran.getAftShoulderLength() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
|
||||
|
||||
}
|
||||
public double getFrontShoulderLen() {
|
||||
return frontShoulderLen;
|
||||
}
|
||||
|
||||
public void setFrontShoulderLen(double theFrontShoulderLen) {
|
||||
frontShoulderLen = theFrontShoulderLen;
|
||||
}
|
||||
|
||||
public double getRearShoulderLen() {
|
||||
return rearShoulderLen;
|
||||
}
|
||||
|
||||
public void setRearShoulderLen(double theRearShoulderLen) {
|
||||
rearShoulderLen = theRearShoulderLen;
|
||||
}
|
||||
|
||||
public double getFrontShoulderDia() {
|
||||
return frontShoulderDia;
|
||||
}
|
||||
|
||||
public void setFrontShoulderDia(double theFrontShoulderDia) {
|
||||
frontShoulderDia = theFrontShoulderDia;
|
||||
}
|
||||
|
||||
public double getRearShoulderDia() {
|
||||
return rearShoulderDia;
|
||||
}
|
||||
|
||||
public void setRearShoulderDia(double theRearShoulderDia) {
|
||||
rearShoulderDia = theRearShoulderDia;
|
||||
}
|
||||
|
||||
public double getFrontDia() {
|
||||
return frontDia;
|
||||
}
|
||||
|
||||
public void setFrontDia(double theFrontDia) {
|
||||
frontDia = theFrontDia;
|
||||
}
|
||||
|
||||
public double getRearDia() {
|
||||
return rearDia;
|
||||
}
|
||||
|
||||
public void setRearDia(double theRearDia) {
|
||||
rearDia = theRearDia;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*/
|
||||
@XmlRootElement(name = "Ring")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class TubeCouplerDTO extends CenteringRingDTO {
|
||||
|
||||
public TubeCouplerDTO(TubeCoupler tc) {
|
||||
super(tc);
|
||||
setUsageCode(UsageCode.TubeCoupler);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* AttachedPartsHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* BaseHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
||||
@ -20,6 +20,10 @@ import java.util.HashMap;
|
||||
*/
|
||||
public abstract class BaseHandler<C extends RocketComponent> extends ElementHandler {
|
||||
|
||||
/**
|
||||
* Prepend rocksim materials.
|
||||
*/
|
||||
public static final String ROCKSIM_MATERIAL_PREFIX = "RS: ";
|
||||
/**
|
||||
* The overridden mass.
|
||||
*/
|
||||
@ -211,7 +215,7 @@ public abstract class BaseHandler<C extends RocketComponent> extends ElementHand
|
||||
* @return a Material instance
|
||||
*/
|
||||
public static Material createCustomMaterial(Material.Type type, String name, double density) {
|
||||
return Material.newMaterial(type, "RS: " + name, density, true);
|
||||
return Material.newMaterial(type, ROCKSIM_MATERIAL_PREFIX + name, density, true);
|
||||
}
|
||||
|
||||
/**
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* BodyTubeHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FinSetHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
||||
@ -366,7 +366,7 @@ class FinSetHandler extends ElementHandler {
|
||||
*
|
||||
* @return a CrossSection instance
|
||||
*/
|
||||
private FinSet.CrossSection convertTipShapeCode (int tipShape) {
|
||||
public static FinSet.CrossSection convertTipShapeCode (int tipShape) {
|
||||
switch (tipShape) {
|
||||
case 0:
|
||||
return FinSet.CrossSection.SQUARE;
|
||||
@ -378,6 +378,16 @@ class FinSetHandler extends ElementHandler {
|
||||
return FinSet.CrossSection.SQUARE;
|
||||
}
|
||||
}
|
||||
|
||||
public static int convertTipShapeCode (FinSet.CrossSection cs) {
|
||||
if (FinSet.CrossSection.ROUNDED.equals(cs)) {
|
||||
return 1;
|
||||
}
|
||||
if (FinSet.CrossSection.AIRFOIL.equals(cs)) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* InnerBodyTubeHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* LaunchLugHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* MassObjectHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* NoseConeHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ParachuteHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
||||
@ -93,7 +93,7 @@ class ParachuteHandler extends RecoveryDeviceHandler<Parachute> {
|
||||
shroudLineDensity = Double.parseDouble(content) / RocksimHandler.ROCKSIM_TO_OPENROCKET_LINE_DENSITY;
|
||||
}
|
||||
if ("ShroudLineMaterial".equals(element)) {
|
||||
chute.setLineMaterial(BaseHandler.createCustomMaterial(Material.Type.LINE, content, shroudLineDensity));
|
||||
chute.setLineMaterial(createCustomMaterial(Material.Type.LINE, content, shroudLineDensity));
|
||||
}
|
||||
if ("DragCoefficient".equals(element)) {
|
||||
chute.setCD(Double.parseDouble(content));
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* PositionDependentHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RecoveryDeviceHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.material.Material;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RingHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
||||
@ -168,7 +168,7 @@ class RingHandler extends PositionDependentHandler<CenteringRing> {
|
||||
result.setInnerRadius(ring.getInnerRadius());
|
||||
result.setLength(ring.getLength());
|
||||
result.setName(ring.getName());
|
||||
PositionDependentHandler.setOverride(result, ring.isOverrideSubcomponentsEnabled(), ring.getOverrideMass(), ring.getOverrideCGX());
|
||||
setOverride(result, ring.isOverrideSubcomponentsEnabled(), ring.getOverrideMass(), ring.getOverrideCGX());
|
||||
result.setRelativePosition(ring.getRelativePosition());
|
||||
result.setPositionValue(ring.getPositionValue());
|
||||
result.setMaterial(ring.getMaterial());
|
@ -1,12 +1,14 @@
|
||||
/*
|
||||
* RocksimDensityType.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.material.Material;
|
||||
|
||||
/**
|
||||
* Models the nose cone shape of a rocket. Maps from Rocksim's notion to OpenRocket's.
|
||||
*/
|
||||
enum RocksimDensityType {
|
||||
public enum RocksimDensityType {
|
||||
ROCKSIM_BULK (0, RocksimHandler.ROCKSIM_TO_OPENROCKET_BULK_DENSITY),
|
||||
ROCKSIM_SURFACE(1, RocksimHandler.ROCKSIM_TO_OPENROCKET_SURFACE_DENSITY),
|
||||
ROCKSIM_LINE (2, RocksimHandler.ROCKSIM_TO_OPENROCKET_LINE_DENSITY);
|
||||
@ -52,5 +54,25 @@ enum RocksimDensityType {
|
||||
}
|
||||
return ROCKSIM_BULK; //Default
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ordinal code.
|
||||
*
|
||||
* @param type the OR type
|
||||
*
|
||||
* @return the Rocksim XML value
|
||||
*/
|
||||
public static int toCode(Material.Type type) {
|
||||
if (type.equals(Material.Type.BULK)) {
|
||||
return ROCKSIM_BULK.ordinal;
|
||||
}
|
||||
if (type.equals(Material.Type.LINE)) {
|
||||
return ROCKSIM_LINE.ordinal;
|
||||
}
|
||||
if (type.equals(Material.Type.SURFACE)) {
|
||||
return ROCKSIM_SURFACE.ordinal;
|
||||
}
|
||||
return ROCKSIM_BULK.ordinal;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* RocksimFinishCode.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.ExternalComponent;
|
||||
|
||||
/**
|
||||
* Models the finish of a component.
|
||||
*/
|
||||
enum RocksimFinishCode {
|
||||
public enum RocksimFinishCode {
|
||||
POLISHED(0, ExternalComponent.Finish.POLISHED),
|
||||
GLOSS(1, ExternalComponent.Finish.SMOOTH),
|
||||
MATT(2, ExternalComponent.Finish.NORMAL),
|
||||
@ -57,5 +57,25 @@ enum RocksimFinishCode {
|
||||
return MATT; //Default
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ordinal code.
|
||||
*
|
||||
* @param type the OR type
|
||||
*
|
||||
* @return the Rocksim XML value
|
||||
*/
|
||||
public static int toCode(ExternalComponent.Finish type) {
|
||||
if (type.equals(ExternalComponent.Finish.UNFINISHED)) {
|
||||
return UNFINISHED.ordinal;
|
||||
}
|
||||
if (type.equals(ExternalComponent.Finish.POLISHED)) {
|
||||
return POLISHED.ordinal;
|
||||
}
|
||||
if (type.equals(ExternalComponent.Finish.SMOOTH)) {
|
||||
return GLOSS.ordinal;
|
||||
}
|
||||
return MATT.ordinal;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* RocksimHandler.java
|
||||
*
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.Warning;
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
@ -1,19 +1,18 @@
|
||||
/*
|
||||
* RocksimLoader.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.file.RocketLoadException;
|
||||
import net.sf.openrocket.file.RocketLoader;
|
||||
import net.sf.openrocket.file.simplesax.SimpleSAX;
|
||||
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* This class is the main entry point for Rocksim design file imported to OpenRocket. Currently only Rocksim v9
|
||||
* file formats are supported, although it is possible that v8 formats will work for most components.
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* RocksimLocationMode.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
|
||||
/**
|
||||
* Models the relative position of parts on a rocket. Maps from Rocksim's notion to OpenRocket's.
|
||||
*/
|
||||
enum RocksimLocationMode {
|
||||
public enum RocksimLocationMode {
|
||||
FRONT_OF_OWNING_PART (0, RocketComponent.Position.TOP),
|
||||
FROM_TIP_OF_NOSE (1, RocketComponent.Position.ABSOLUTE),
|
||||
BACK_OF_OWNING_PART (2, RocketComponent.Position.BOTTOM);
|
||||
@ -56,4 +56,16 @@ enum RocksimLocationMode {
|
||||
return FRONT_OF_OWNING_PART;
|
||||
}
|
||||
|
||||
public static int toCode(RocketComponent.Position position) {
|
||||
if (RocketComponent.Position.TOP.equals(position)) {
|
||||
return 0;
|
||||
}
|
||||
if (RocketComponent.Position.ABSOLUTE.equals(position)) {
|
||||
return 1;
|
||||
}
|
||||
if (RocketComponent.Position.BOTTOM.equals(position)) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* RocksimNoseConeCode.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
|
||||
/**
|
||||
* Models the nose cone shape of a rocket. Maps from Rocksim's notion to OpenRocket's.
|
||||
*/
|
||||
enum RocksimNoseConeCode {
|
||||
public enum RocksimNoseConeCode {
|
||||
CONICAL (0, Transition.Shape.CONICAL),
|
||||
OGIVE (1, Transition.Shape.OGIVE),
|
||||
PARABOLIC (2, Transition.Shape.ELLIPSOID), //Rocksim' PARABOLIC most closely resembles an ELLIPSOID in OpenRocket
|
||||
@ -58,4 +58,24 @@ enum RocksimNoseConeCode {
|
||||
}
|
||||
return PARABOLIC; //Default
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup an ordinal value for the Rocksim code.
|
||||
*
|
||||
* @param type the OR Shape
|
||||
*
|
||||
* @return the Rocksim code
|
||||
*/
|
||||
public static int toCode(Transition.Shape type) {
|
||||
RocksimNoseConeCode[] values = values();
|
||||
for (RocksimNoseConeCode value : values) {
|
||||
if (value.shape.equals(type)) {
|
||||
if (value.ordinal == 2) {
|
||||
return 3;
|
||||
}
|
||||
return value.ordinal;
|
||||
}
|
||||
}
|
||||
return ELLIPTICAL.ordinal; //Default
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* StreamerHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* TransitionHandler.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
@ -1,62 +1,5 @@
|
||||
package net.sf.openrocket.gui.main;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.InputMap;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.DefaultTreeSelectionModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
@ -65,6 +8,7 @@ import net.sf.openrocket.file.RocketLoadException;
|
||||
import net.sf.openrocket.file.RocketLoader;
|
||||
import net.sf.openrocket.file.RocketSaver;
|
||||
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
||||
import net.sf.openrocket.file.rocksim.export.RocksimSaver;
|
||||
import net.sf.openrocket.gui.StorageOptionChooser;
|
||||
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
||||
import net.sf.openrocket.gui.dialogs.AboutDialog;
|
||||
@ -104,6 +48,38 @@ import net.sf.openrocket.util.MemoryManagement.MemoryData;
|
||||
import net.sf.openrocket.util.Reflection;
|
||||
import net.sf.openrocket.util.TestRockets;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.DefaultTreeSelectionModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class BasicFrame extends JFrame {
|
||||
private static final LogHelper log = Application.getLogger();
|
||||
|
||||
@ -1277,7 +1253,9 @@ public class BasicFrame extends JFrame {
|
||||
StorageOptionChooser storageChooser =
|
||||
new StorageOptionChooser(document, document.getDefaultStorageOptions());
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
||||
chooser.addChoosableFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
||||
chooser.addChoosableFileFilter(FileHelper.ROCKSIM_DESIGN_FILTER);
|
||||
chooser.setFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
||||
chooser.setCurrentDirectory(((SwingPreferences) Application.getPreferences()).getDefaultDirectory());
|
||||
chooser.setAccessory(storageChooser);
|
||||
if (document.getFile() != null)
|
||||
@ -1298,12 +1276,30 @@ public class BasicFrame extends JFrame {
|
||||
((SwingPreferences) Application.getPreferences()).setDefaultDirectory(chooser.getCurrentDirectory());
|
||||
storageChooser.storeOptions(document.getDefaultStorageOptions());
|
||||
|
||||
file = FileHelper.ensureExtension(file, "ork");
|
||||
if (!FileHelper.confirmWrite(file, this)) {
|
||||
return false;
|
||||
}
|
||||
if (chooser.getFileFilter().equals(FileHelper.OPENROCKET_DESIGN_FILTER)) {
|
||||
file = FileHelper.ensureExtension(file, "ork");
|
||||
if (!FileHelper.confirmWrite(file, this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return saveAs(file);
|
||||
return saveAs(file);
|
||||
}
|
||||
else if (chooser.getFileFilter().equals(FileHelper.ROCKSIM_DESIGN_FILTER)) {
|
||||
file = FileHelper.ensureExtension(file, "rkt");
|
||||
if (!FileHelper.confirmWrite(file, this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
new RocksimSaver().save(file, document);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean saveAs(File file) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A set of trapezoidal fins. The root and tip chords are perpendicular to the rocket
|
||||
* base line, while the leading and aft edges may be slanted.
|
||||
@ -109,7 +109,7 @@ public class TrapezoidFinSet extends FinSet {
|
||||
|
||||
/**
|
||||
* Get the sweep angle. This is calculated from the true sweep and height, and is not
|
||||
* stored separetely.
|
||||
* stored separately.
|
||||
*/
|
||||
public double getSweepAngle() {
|
||||
if (height == 0) {
|
||||
|
@ -1,21 +1,20 @@
|
||||
package net.sf.openrocket.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.StorageOptions;
|
||||
import net.sf.openrocket.file.RocketLoadException;
|
||||
import net.sf.openrocket.file.RocketLoader;
|
||||
import net.sf.openrocket.file.RocketSaver;
|
||||
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
||||
import net.sf.openrocket.file.rocksim.RocksimLoader;
|
||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||
import net.sf.openrocket.l10n.ResourceBundleTranslator;
|
||||
import net.sf.openrocket.logging.LogLevel;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Utility that loads Rocksim file formats and saves them in ORK format.
|
||||
* File is saved with the .rkt extension replaced with .ork.
|
||||
@ -32,7 +31,7 @@ public class RocksimConverter {
|
||||
|
||||
setup();
|
||||
|
||||
RocketLoader loader = new RocksimLoader();
|
||||
RocketLoader loader = new net.sf.openrocket.file.rocksim.importt.RocksimLoader();
|
||||
RocketSaver saver = new OpenRocketSaver();
|
||||
|
||||
for (String inputFile : args) {
|
||||
|
@ -0,0 +1,66 @@
|
||||
package net.sf.openrocket.file.rocksim.export;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimLoader;
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimLoaderTest;
|
||||
import net.sf.openrocket.file.rocksim.importt.RocksimTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class RocksimDocumentDTOTest extends RocksimTestBase {
|
||||
|
||||
@Test
|
||||
public void testDTO() throws Exception {
|
||||
JAXBContext binder = JAXBContext.newInstance(RocksimDocumentDTO.class);
|
||||
Marshaller marshaller = binder.createMarshaller();
|
||||
marshaller.setProperty("jaxb.fragment", Boolean.TRUE);
|
||||
|
||||
NoseConeDTO noseCone = new NoseConeDTO();
|
||||
noseCone.setBaseDia(10d);
|
||||
noseCone.setCalcCG(1.3d);
|
||||
|
||||
StageDTO stage1 = new StageDTO();
|
||||
stage1.addExternalPart(noseCone);
|
||||
|
||||
RocketDesignDTO design2 = new RocketDesignDTO();
|
||||
design2.setName("Test");
|
||||
design2.setStage3(stage1);
|
||||
|
||||
RocksimDesignDTO design = new RocksimDesignDTO();
|
||||
design.setDesign(design2);
|
||||
RocksimDocumentDTO message = new RocksimDocumentDTO();
|
||||
message.setDesign(design);
|
||||
|
||||
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
marshaller.marshal(message, stringWriter);
|
||||
|
||||
String response = stringWriter.toString();
|
||||
|
||||
System.err.println(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoundTrip() throws Exception {
|
||||
OpenRocketDocument ord = RocksimLoaderTest.loadRocksimRocket3(new RocksimLoader());
|
||||
|
||||
Assert.assertNotNull(ord);
|
||||
String result = new RocksimSaver().marshalToRocksim(ord);
|
||||
|
||||
// System.err.println(result);
|
||||
|
||||
File output = new File("rt.rkt");
|
||||
FileWriter fw = new FileWriter(output);
|
||||
fw.write(result);
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* BodyTubeHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* FinSetHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* InnerBodyTubeHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* LaunchLugHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* MassObjectHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* NoseConeHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ParachuteHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RingHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* RocksimContentHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -2,9 +2,10 @@
|
||||
* RocksimLoaderTest.java
|
||||
*
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.file.RocketLoadException;
|
||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||
import net.sf.openrocket.rocketcomponent.LaunchLug;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
@ -12,11 +13,11 @@ import net.sf.openrocket.rocketcomponent.Stage;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* RocksimLoader Tester.
|
||||
*
|
||||
*/
|
||||
public class RocksimLoaderTest {
|
||||
|
||||
@ -35,27 +36,24 @@ public class RocksimLoaderTest {
|
||||
Assert.assertNotNull(doc);
|
||||
Rocket rocket = doc.getRocket();
|
||||
Assert.assertNotNull(rocket);
|
||||
}
|
||||
catch (IllegalStateException ise) {
|
||||
} catch (IllegalStateException ise) {
|
||||
Assert.fail(ise.getMessage());
|
||||
}
|
||||
Assert.assertTrue(loader.getWarnings().size() == 2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Method: loadFromStream(InputStream source)
|
||||
*
|
||||
* @throws Exception thrown if something goes awry
|
||||
* @throws Exception thrown if something goes awry
|
||||
*/
|
||||
@org.junit.Test
|
||||
public void testLoadFromStream() throws Exception {
|
||||
RocksimLoader loader = new RocksimLoader();
|
||||
//Stupid single stage rocket
|
||||
InputStream stream = this.getClass().getResourceAsStream("rocksimTestRocket1.rkt");
|
||||
Assert.assertNotNull("Could not open rocksimTestRocket1.rkt", stream);
|
||||
OpenRocketDocument doc = loader.loadFromStream(new BufferedInputStream(stream));
|
||||
|
||||
OpenRocketDocument doc = loadRocksimRocket(loader);
|
||||
InputStream stream;
|
||||
|
||||
Assert.assertNotNull(doc);
|
||||
Rocket rocket = doc.getRocket();
|
||||
Assert.assertNotNull(rocket);
|
||||
@ -65,7 +63,7 @@ public class RocksimLoaderTest {
|
||||
stream = this.getClass().getResourceAsStream("rocksimTestRocket2.rkt");
|
||||
Assert.assertNotNull("Could not open rocksimTestRocket2.rkt", stream);
|
||||
doc = loader.loadFromStream(new BufferedInputStream(stream));
|
||||
|
||||
|
||||
Assert.assertNotNull(doc);
|
||||
rocket = doc.getRocket();
|
||||
Assert.assertNotNull(rocket);
|
||||
@ -75,29 +73,29 @@ public class RocksimLoaderTest {
|
||||
Assert.assertEquals("Three Stage Everything Included Rocket", doc.getRocket().getName());
|
||||
Assert.assertEquals(1, loader.getWarnings().size());
|
||||
Assert.assertEquals(3, rocket.getStageCount());
|
||||
Stage stage1 = (Stage)rocket.getChild(0);
|
||||
Stage stage1 = (Stage) rocket.getChild(0);
|
||||
Assert.assertFalse(stage1.isMassOverridden());
|
||||
Assert.assertFalse(stage1.isCGOverridden());
|
||||
Stage stage2 = (Stage)rocket.getChild(1);
|
||||
Stage stage2 = (Stage) rocket.getChild(1);
|
||||
Assert.assertFalse(stage2.isMassOverridden());
|
||||
Assert.assertFalse(stage2.isCGOverridden());
|
||||
Stage stage3 = (Stage)rocket.getChild(2);
|
||||
Stage stage3 = (Stage) rocket.getChild(2);
|
||||
Assert.assertFalse(stage3.isMassOverridden());
|
||||
Assert.assertFalse(stage3.isCGOverridden());
|
||||
|
||||
stream = this.getClass().getResourceAsStream("rocksimTestRocket3.rkt");
|
||||
Assert.assertNotNull("Could not open rocksimTestRocket3.rkt", stream);
|
||||
doc = loader.loadFromStream(new BufferedInputStream(stream));
|
||||
|
||||
|
||||
Assert.assertNotNull(doc);
|
||||
rocket = doc.getRocket();
|
||||
Assert.assertNotNull(rocket);
|
||||
Assert.assertEquals("Three Stage Everything Included Rocket - Override Total Mass/CG", doc.getRocket().getName());
|
||||
Assert.assertEquals(3, rocket.getStageCount());
|
||||
stage1 = (Stage)rocket.getChild(0);
|
||||
stage2 = (Stage)rocket.getChild(1);
|
||||
stage3 = (Stage)rocket.getChild(2);
|
||||
|
||||
stage1 = (Stage) rocket.getChild(0);
|
||||
stage2 = (Stage) rocket.getChild(1);
|
||||
stage3 = (Stage) rocket.getChild(2);
|
||||
|
||||
//Do some 1st level and simple asserts; the idea here is to not do a deep validation as that
|
||||
//should have been covered elsewhere. Assert that the stage overrides are correct.
|
||||
Assert.assertEquals(2, stage1.getChildCount());
|
||||
@ -108,18 +106,18 @@ public class RocksimLoaderTest {
|
||||
Assert.assertTrue(stage1.isCGOverridden());
|
||||
Assert.assertEquals(0.3d, stage1.getOverrideCG().x, 0.001);
|
||||
Assert.assertEquals(4, loader.getWarnings().size());
|
||||
|
||||
|
||||
Assert.assertEquals(1, stage2.getChildCount());
|
||||
Assert.assertEquals("2nd Stage Tube", stage2.getChild(0).getName());
|
||||
Assert.assertTrue(stage2.isMassOverridden());
|
||||
Assert.assertEquals(0.21d, stage2.getOverrideMass(), 0.001);
|
||||
Assert.assertTrue(stage2.isCGOverridden());
|
||||
Assert.assertEquals(0.4d, stage2.getOverrideCG().x, 0.001);
|
||||
|
||||
BodyTube bt = (BodyTube)stage2.getChild(0);
|
||||
LaunchLug ll = (LaunchLug)bt.getChild(6);
|
||||
|
||||
BodyTube bt = (BodyTube) stage2.getChild(0);
|
||||
LaunchLug ll = (LaunchLug) bt.getChild(6);
|
||||
Assert.assertEquals(1.22d, ll.getRadialDirection(), 0.001);
|
||||
|
||||
|
||||
Assert.assertEquals(2, stage3.getChildCount());
|
||||
Assert.assertEquals("Transition", stage3.getChild(0).getName());
|
||||
Assert.assertEquals("Body tube", stage3.getChild(1).getName());
|
||||
@ -129,4 +127,24 @@ public class RocksimLoaderTest {
|
||||
Assert.assertEquals(0.5d, stage3.getOverrideCG().x, 0.001);
|
||||
}
|
||||
|
||||
public static OpenRocketDocument loadRocksimRocket(RocksimLoader theLoader) throws IOException, RocketLoadException {
|
||||
InputStream stream = RocksimLoaderTest.class.getResourceAsStream("rocksimTestRocket1.rkt");
|
||||
try {
|
||||
Assert.assertNotNull("Could not open rocksimTestRocket1.rkt", stream);
|
||||
return theLoader.loadFromStream(new BufferedInputStream(stream));
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static OpenRocketDocument loadRocksimRocket3(RocksimLoader theLoader) throws IOException, RocketLoadException {
|
||||
InputStream stream = RocksimLoaderTest.class.getResourceAsStream("rocksimTestRocket3.rkt");
|
||||
try {
|
||||
Assert.assertNotNull("Could not open rocksimTestRocket3.rkt", stream);
|
||||
return theLoader.loadFromStream(new BufferedInputStream(stream));
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* BaseRocksimTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* StreamerHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
||||
@ -153,7 +153,7 @@ public class StreamerHandlerTest extends RocksimTestBase {
|
||||
handler.closeElement("LocationMode", attributes, "2", warnings);
|
||||
handler.endHandler("Streamer", attributes, null, warnings);
|
||||
Assert.assertEquals(RocketComponent.Position.BOTTOM, component.getRelativePosition());
|
||||
Assert.assertEquals(component.getPositionValue(), 10d/RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001);
|
||||
Assert.assertEquals(component.getPositionValue(), 10d/ RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH, 0.001);
|
||||
|
||||
handler.closeElement("Thickness", attributes, "0.02", warnings);
|
||||
Assert.assertEquals(0.01848, handler.computeDensity(RocksimDensityType.ROCKSIM_BULK, 924d), 0.001);
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* TransitionHandlerTest.java
|
||||
*/
|
||||
package net.sf.openrocket.file.rocksim;
|
||||
package net.sf.openrocket.file.rocksim.importt;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
Loading…
x
Reference in New Issue
Block a user