Add boattail export support

This commit is contained in:
SiboVG 2023-04-06 23:03:22 +02:00
parent 4da46d6869
commit c7aa226995
6 changed files with 66 additions and 10 deletions

View File

@ -1412,6 +1412,8 @@ RASAeroExport.error25 = Invalid stage number '%d' for simulation '%s'
RASAeroExport.error26 = RASAero only supports conical transitions. RASAeroExport.error26 = RASAero only supports conical transitions.
RASAeroExport.error27 = Transition '%s' has no previous component. RASAeroExport.error27 = Transition '%s' has no previous component.
RASAeroExport.error28 = Transition '%s' should have the same fore radius as the aft radius (%f) of its previous component, not %f. RASAeroExport.error28 = Transition '%s' should have the same fore radius as the aft radius (%f) of its previous component, not %f.
RASAeroExport.error29 = Boattail length may not be zero.
RASAeroExport.error30 = Boattail rear diameter may not be zero.
! SaveAsFileChooser ! SaveAsFileChooser
SaveAsFileChooser.illegalFilename.title = Illegal filename SaveAsFileChooser.illegalFilename.title = Illegal filename

View File

@ -0,0 +1,28 @@
package net.sf.openrocket.file.rasaero.export;
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.file.rasaero.export.RASAeroSaver.RASAeroExportException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = RASAeroCommonConstants.BOATTAIL)
@XmlAccessorType(XmlAccessType.FIELD)
public class BoattailDTO extends TransitionDTO {
/**
* We need a default no-args constructor.
*/
public BoattailDTO() {
super();
}
public BoattailDTO(Transition boattail, WarningSet warnings, ErrorSet errors) throws RASAeroExportException {
super(boattail, warnings, errors);
setPartType(RASAeroCommonConstants.BOATTAIL);
}
}

View File

@ -89,11 +89,11 @@ public interface BodyTubeDTOAdapter {
Double getBoattailLength(); Double getBoattailLength();
void setBoattailLength(Double boattailLength); void setBoattailLength(Double boattailLength) throws RASAeroExportException;
Double getBoattailRearDiameter(); Double getBoattailRearDiameter();
void setBoattailRearDiameter(Double boattailRearDiameter); void setBoattailRearDiameter(Double boattailRearDiameter) throws RASAeroExportException;
FinDTO getFin(); FinDTO getFin();

View File

@ -168,6 +168,14 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
finSet = getFinSetFromBodyTube((BodyTube) comp); finSet = getFinSetFromBodyTube((BodyTube) comp);
} }
} else { } else {
// If this booster is the last stage, and the last component is a transition, it could be a boattail
if (stageNr == rocket.getChildCount() - 1 && (comp instanceof Transition && !(comp instanceof NoseCone)) &&
i == stage.getChildCount() - 1) {
Transition transition = (Transition) comp;
setBoattailLength(transition.getLength() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
setBoattailRearDiameter(transition.getAftRadius() * 2 * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
}
// Case: normal body tube // Case: normal body tube
if (stage.getChildPosition(firstTube) == 0) { if (stage.getChildPosition(firstTube) == 0) {
warnings.add(String.format(trans.get("RASAeroExport.warning10"), warnings.add(String.format(trans.get("RASAeroExport.warning10"),
@ -324,7 +332,10 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
return boattailLength; return boattailLength;
} }
public void setBoattailLength(Double boattailLength) { public void setBoattailLength(Double boattailLength) throws RASAeroExportException {
if (boattailLength == 0) {
throw new RASAeroExportException(trans.get("RASAeroExport.error29"));
}
this.boattailLength = boattailLength; this.boattailLength = boattailLength;
} }
@ -332,7 +343,10 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
return boattailRearDiameter; return boattailRearDiameter;
} }
public void setBoattailRearDiameter(Double boattailRearDiameter) { public void setBoattailRearDiameter(Double boattailRearDiameter) throws RASAeroExportException {
if (boattailRearDiameter == 0) {
throw new RASAeroExportException(trans.get("RASAeroExport.error30"));
}
this.boattailRearDiameter = boattailRearDiameter; this.boattailRearDiameter = boattailRearDiameter;
} }

View File

@ -78,8 +78,8 @@ public class RocketDesignDTO {
if (rocket.getChildCount() > 3) { if (rocket.getChildCount() > 3) {
warnings.add(trans.get("RASAeroExport.warning12")); warnings.add(trans.get("RASAeroExport.warning12"));
} }
setUseBooster1(rocket.getStageCount() >= 2); setUseBooster1(rocket.getChildCount() >= 2);
setUseBooster2(rocket.getStageCount() == 3); setUseBooster2(rocket.getChildCount() == 3);
AxialStage sustainer = rocket.getStage(0); AxialStage sustainer = rocket.getStage(0);
@ -106,8 +106,13 @@ public class RocketDesignDTO {
setSurface(RASAeroCommonConstants.OPENROCKET_TO_RASAERO_SURFACE(((NoseCone) component).getFinish(), setSurface(RASAeroCommonConstants.OPENROCKET_TO_RASAERO_SURFACE(((NoseCone) component).getFinish(),
warnings)); warnings));
} else if (component instanceof Transition) { } else if (component instanceof Transition) {
// If there is only a sustainer & this is the last child of the sustainer, it's a boattail
if (rocket.getChildCount() == 1 && (i == sustainer.getChildCount() - 1)) {
addExternalPart(new BoattailDTO((Transition) component, warnings, errors));
} else {
addExternalPart(new TransitionDTO((Transition) component, warnings, errors)); addExternalPart(new TransitionDTO((Transition) component, warnings, errors));
} }
}
} catch (RASAeroExportException e) { } catch (RASAeroExportException e) {
errors.add(e.getMessage()); errors.add(e.getMessage());
} }

View File

@ -10,6 +10,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@ -19,10 +20,9 @@ import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.MathUtil;
import java.util.Objects;
@XmlRootElement(name = RASAeroCommonConstants.TRANSITION) @XmlRootElement(name = RASAeroCommonConstants.TRANSITION)
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlSeeAlso({BoattailDTO.class})
public class TransitionDTO extends BasePartDTO { public class TransitionDTO extends BasePartDTO {
@XmlElement(name = RASAeroCommonConstants.REAR_DIAMETER) @XmlElement(name = RASAeroCommonConstants.REAR_DIAMETER)
@ -31,6 +31,8 @@ public class TransitionDTO extends BasePartDTO {
@XmlTransient @XmlTransient
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
@XmlTransient
private static Transition component = null;
/** /**
* We need a default no-args constructor. * We need a default no-args constructor.
@ -41,6 +43,8 @@ public class TransitionDTO extends BasePartDTO {
public TransitionDTO(Transition transition, WarningSet warnings, ErrorSet errors) throws RASAeroExportException { public TransitionDTO(Transition transition, WarningSet warnings, ErrorSet errors) throws RASAeroExportException {
super(transition, warnings, errors); super(transition, warnings, errors);
component = transition;
if (!transition.getShapeType().equals(Transition.Shape.CONICAL)) { if (!transition.getShapeType().equals(Transition.Shape.CONICAL)) {
throw new RASAeroExportException(trans.get("RASAeroExport.error26")); throw new RASAeroExportException(trans.get("RASAeroExport.error26"));
} }
@ -62,7 +66,10 @@ public class TransitionDTO extends BasePartDTO {
return rearDiameter; return rearDiameter;
} }
public void setRearDiameter(Double rearDiameter) { public void setRearDiameter(Double rearDiameter) throws RASAeroExportException {
if (rearDiameter < 0.0001) {
throw new RASAeroExportException(String.format("'%s' rear diameter must be greater than 0.0001 inch", component));
}
this.rearDiameter = rearDiameter; this.rearDiameter = rearDiameter;
} }
} }