diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/BodyTubeHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/BodyTubeHandler.java index 41f905912..d7ce9d2e3 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/BodyTubeHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/BodyTubeHandler.java @@ -70,7 +70,8 @@ public class BodyTubeHandler extends BaseHandler { public void endHandler(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.endHandler(element, attributes, content, warnings); this.bodyTube.setLength(length / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); - this.bodyTube.setOuterRadius(diameter/2 / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + this.bodyTube.setOuterRadius(diameter/2 / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); // Not really useful, but included for completeness + this.bodyTube.setOuterRadiusAutomatic(true); this.bodyTube.setThickness(0.002); // Arbitrary value; RASAero doesn't specify this if (launchLugDiameter > 0 && launchLugLength > 0) { diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/BoosterHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/BoosterHandler.java index 0272e06e6..b01f1d886 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/BoosterHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/BoosterHandler.java @@ -22,6 +22,7 @@ public class BoosterHandler extends BodyTubeHandler { final AxialStage boosterStage; private double boatTailLength; private double boatTailRearDiameter; + private double shoulderLength; public BoosterHandler(DocumentLoadingContext context, RocketComponent parent) { super(context); @@ -39,7 +40,8 @@ public class BoosterHandler extends BodyTubeHandler { @Override public ElementHandler openElement(String element, HashMap attributes, WarningSet warnings) throws SAXException { - if (RASAeroCommonConstants.BOAT_TAIL_LENGTH.equals(element) || RASAeroCommonConstants.BOAT_TAIL_REAR_DIAMETER.equals(element)) { + if (RASAeroCommonConstants.BOAT_TAIL_LENGTH.equals(element) || RASAeroCommonConstants.BOAT_TAIL_REAR_DIAMETER.equals(element) + || RASAeroCommonConstants.SHOULDER_LENGTH.equals(element)) { return PlainTextHandler.INSTANCE; } return super.openElement(element, attributes, warnings); @@ -52,6 +54,8 @@ public class BoosterHandler extends BodyTubeHandler { this.boatTailLength = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; } else if (RASAeroCommonConstants.BOAT_TAIL_REAR_DIAMETER.equals(element)) { this.boatTailRearDiameter = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + } else if (RASAeroCommonConstants.SHOULDER_LENGTH.equals(element)) { + this.shoulderLength = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; } } @@ -59,6 +63,20 @@ public class BoosterHandler extends BodyTubeHandler { public void endHandler(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.endHandler(element, attributes, content, warnings); this.bodyTube.setName(this.boosterStage.getName() + " Body Tube"); + this.bodyTube.setOuterRadiusAutomatic(false); + + // Add shoulder (transition) if it exists + if (shoulderLength > 0) { + Transition shoulder = new Transition(); + shoulder.setName(boosterStage.getName() + " Shoulder"); + shoulder.setColor(this.bodyTube.getColor()); + shoulder.setShapeType(Transition.Shape.CONICAL); + shoulder.setLength(shoulderLength); + shoulder.setAftRadiusAutomatic(false); + shoulder.setForeRadiusAutomatic(true); + shoulder.setAftRadius(this.bodyTube.getOuterRadius()); + this.boosterStage.addChild(shoulder, 0); + } // Add boat tail if it exists if (this.boatTailLength > 0 && this.boatTailRearDiameter > 0) { diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/FinCanHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/FinCanHandler.java index 2806ba7cc..6a23d0fc4 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/FinCanHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/FinCanHandler.java @@ -55,11 +55,6 @@ public class FinCanHandler extends BodyTubeHandler { this.finCan.setAngleOffset(0); } - @Override - public ElementHandler openElement(String element, HashMap attributes, WarningSet warnings) throws SAXException { - return super.openElement(element, attributes, warnings); - } - @Override public void closeElement(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.closeElement(element, attributes, content, warnings); @@ -77,6 +72,7 @@ public class FinCanHandler extends BodyTubeHandler { @Override public void endHandler(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.endHandler(element, attributes, content, warnings); + this.bodyTube.setOuterRadiusAutomatic(false); // Add the shoulder to the front of the fin can Transition shoulder = new Transition(); diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/TransitionHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/TransitionHandler.java index 35b004ed9..5efef4f95 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/TransitionHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/TransitionHandler.java @@ -61,7 +61,8 @@ public class TransitionHandler extends BaseHandler { public void endHandler(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.endHandler(element, attributes, content, warnings); this.transition.setLength(length / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); - this.transition.setForeRadius(diameter/2 / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + this.transition.setForeRadius(diameter/2 / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); // Not really useful, but adding it for completeness + this.transition.setForeRadiusAutomatic(true); this.transition.setThickness(0.002); // Arbitrary value; RASAero doesn't specify this } diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java index e3f1cdcd4..e572c7640 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java @@ -1296,6 +1296,10 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab mutex.verify(); return 0; } + + public double getRadiusOffset(RadiusMethod method) { + return method.getRadius(this.parent, this, getRadiusOffset()); + } public RadiusMethod getRadiusMethod() { return RadiusMethod.COAXIAL;