diff --git a/core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java b/core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java
index bde3d072a..86cc5861d 100644
--- a/core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java
+++ b/core/src/net/sf/openrocket/file/rocksim/RocksimCommonConstants.java
@@ -9,6 +9,7 @@ public class RocksimCommonConstants {
public static final String WALL_THICKNESS = "WallThickness";
public static final String SHAPE_PARAMETER = "ShapeParameter";
public static final String ATTACHED_PARTS = "AttachedParts";
+ public static final String SUBASSEMBLY = "SubAssembly";
public static final String BODY_TUBE = "BodyTube";
public static final String FIN_SET = "FinSet";
public static final String CUSTOM_FIN_SET = "CustomFinSet";
diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/AttachedPartsHandler.java b/core/src/net/sf/openrocket/file/rocksim/importt/AttachedPartsHandler.java
index 7a909a4c5..3738a160f 100644
--- a/core/src/net/sf/openrocket/file/rocksim/importt/AttachedPartsHandler.java
+++ b/core/src/net/sf/openrocket/file/rocksim/importt/AttachedPartsHandler.java
@@ -3,8 +3,6 @@
*/
package net.sf.openrocket.file.rocksim.importt;
-import java.util.HashMap;
-
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.file.DocumentLoadingContext;
import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
@@ -12,20 +10,22 @@ import net.sf.openrocket.file.simplesax.AbstractElementHandler;
import net.sf.openrocket.file.simplesax.ElementHandler;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import java.util.HashMap;
+
/**
- * A SAX handler for the Rocksim AttachedParts XML type.
+ * A SAX handler for the Rocksim AttachedParts XML type.
*/
class AttachedPartsHandler extends AbstractElementHandler {
private final DocumentLoadingContext context;
-
+
/** The parent component. */
private final RocketComponent component;
-
+
/**
* Constructor.
- *
+ *
* @param c the parent
- *
+ *
* @throws IllegalArgumentException thrown if c
is null
*/
public AttachedPartsHandler(DocumentLoadingContext context, RocketComponent c) throws IllegalArgumentException {
@@ -33,10 +33,18 @@ class AttachedPartsHandler extends AbstractElementHandler {
throw new IllegalArgumentException("The parent component of any attached part may not be null.");
}
this.context = context;
- component = c;
+ this.component = c;
}
-
- @Override
+
+ DocumentLoadingContext getContext() {
+ return context;
+ }
+
+ RocketComponent getComponent() {
+ return component;
+ }
+
+ @Override
public ElementHandler openElement(String element, HashMap attributes, WarningSet warnings) {
if (RocksimCommonConstants.FIN_SET.equals(element)) {
return new FinSetHandler(context, component);
@@ -65,6 +73,9 @@ class AttachedPartsHandler extends AbstractElementHandler {
if (RocksimCommonConstants.TRANSITION.equals(element)) {
return new TransitionHandler(context, component, warnings);
}
+ if (RocksimCommonConstants.SUBASSEMBLY.equals(element)) {
+ return new SubAssemblyHandler(context, component);
+ }
if (RocksimCommonConstants.TUBE_FIN_SET.equals(element)) {
warnings.add("Tube fins are not currently supported. Ignoring.");
}
diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/SubAssemblyHandler.java b/core/src/net/sf/openrocket/file/rocksim/importt/SubAssemblyHandler.java
new file mode 100644
index 000000000..3dbc11628
--- /dev/null
+++ b/core/src/net/sf/openrocket/file/rocksim/importt/SubAssemblyHandler.java
@@ -0,0 +1,43 @@
+
+package net.sf.openrocket.file.rocksim.importt;
+
+import net.sf.openrocket.aerodynamics.WarningSet;
+import net.sf.openrocket.file.DocumentLoadingContext;
+import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
+import net.sf.openrocket.file.simplesax.ElementHandler;
+import net.sf.openrocket.rocketcomponent.RocketComponent;
+
+import java.util.HashMap;
+
+/**
+ * This class handles Rocksim 'SubAssembly' elements. They are similar to 'AttachedParts' (which is why this class is subclassed from
+ * AttachedPartsHandler) with some key differences. In Rocksim, AttachedParts elements can contain SubAssembly elements, which can in turn
+ * contain AttachedParts elements. To represent them in OR, SubAssembly elements are treated as children of the stage - much like a nose cone or
+ * external body tube.
+ */
+public class SubAssemblyHandler extends AttachedPartsHandler {
+
+ public SubAssemblyHandler(final DocumentLoadingContext context, final RocketComponent c)
+ throws IllegalArgumentException {
+ //A bit of a risk here, but assign the subassembly to the stage, not to the component. This is because typically the
+ //first component within the subassembly will be an external component.
+ super(context, c.getStage());
+ }
+
+ @Override
+ public ElementHandler openElement(String element, HashMap attributes, WarningSet warnings) {
+ // We're already part of a subassembly, and then there are attached parts! Can't use an attached parts handler in this situation because
+ // the AttachedPartsHandler assumes that all body tubes are inner body tubes (Rocksim makes no distinction). OR does not allow things
+ // like fins to be attached to inner body tubes - which is often what these Rocksim subassemblies contain. So just return this instance
+ // which treats body tubes as external body tubes.
+ if (RocksimCommonConstants.ATTACHED_PARTS.equals(element)) {
+ return this;
+ }
+ // The key override of this class - treat body tubes as external body tubes.
+ else if (RocksimCommonConstants.BODY_TUBE.equals(element)) {
+ return new BodyTubeHandler(getContext(), getComponent(), warnings);
+ }
+ return super.openElement(element, attributes, warnings);
+ }
+
+}
diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java
index b7e6976e4..7711c463c 100644
--- a/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java
+++ b/core/test/net/sf/openrocket/file/rocksim/importt/RocksimLoaderTest.java
@@ -4,10 +4,6 @@
*/
package net.sf.openrocket.file.rocksim.importt;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.OpenRocketDocumentFactory;
import net.sf.openrocket.file.DatabaseMotorFinder;
@@ -18,161 +14,225 @@ import net.sf.openrocket.rocketcomponent.LaunchLug;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.Stage;
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
-
import org.junit.Assert;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
/**
* RocksimLoader Tester.
*/
public class RocksimLoaderTest extends BaseTestCase {
-
- /**
- * Test a bug reported via automated bug report. I have been unable to reproduce this bug
- * (hanging finset off of an inner body tube) when creating a Rocksim file using Rocksim. The bug
- * is reproducible when manually modifying the Rocksim file, which is what is tested here.
- */
- @org.junit.Test
- public void testFinsOnInnerTube() throws Exception {
- RocksimLoader loader = new RocksimLoader();
- InputStream stream = this.getClass().getResourceAsStream("PodFins.rkt");
- Assert.assertNotNull("Could not open PodFins.rkt", stream);
- try {
- OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
- DocumentLoadingContext context = new DocumentLoadingContext();
- context.setOpenRocketDocument(doc);
- context.setMotorFinder(new DatabaseMotorFinder());
- loader.loadFromStream(context, new BufferedInputStream(stream));
- Rocket rocket = doc.getRocket();
- Assert.assertNotNull(rocket);
- } catch (IllegalStateException ise) {
- Assert.fail(ise.getMessage());
- }
- Assert.assertTrue(loader.getWarnings().size() == 2);
- }
-
- /**
- * Method: loadFromStream(InputStream source)
- *
- * @throws Exception thrown if something goes awry
- */
- @org.junit.Test
- public void testLoadFromStream() throws Exception {
- RocksimLoader loader = new RocksimLoader();
- //Stupid single stage rocket
- OpenRocketDocument doc = loadRocksimRocket(loader);
- InputStream stream;
-
- Assert.assertNotNull(doc);
- Rocket rocket = doc.getRocket();
- Assert.assertNotNull(rocket);
- Assert.assertEquals("FooBar Test", doc.getRocket().getName());
- Assert.assertTrue(loader.getWarnings().isEmpty());
-
- stream = this.getClass().getResourceAsStream("rocksimTestRocket2.rkt");
- Assert.assertNotNull("Could not open rocksimTestRocket2.rkt", stream);
-
- doc = OpenRocketDocumentFactory.createEmptyRocket();
- DocumentLoadingContext context = new DocumentLoadingContext();
- context.setOpenRocketDocument(doc);
- context.setMotorFinder(new DatabaseMotorFinder());
- loader.loadFromStream(context, new BufferedInputStream(stream));
-
- Assert.assertNotNull(doc);
- rocket = doc.getRocket();
- Assert.assertNotNull(rocket);
-
- //Do some simple asserts; the important thing here is just validating that the mass and cg were
- //not overridden for each stage.
- Assert.assertEquals("Three Stage Everything Included Rocket", doc.getRocket().getName());
- Assert.assertEquals(0, loader.getWarnings().size());
- Assert.assertEquals(3, rocket.getStageCount());
- Stage stage1 = (Stage) rocket.getChild(0);
- Assert.assertFalse(stage1.isMassOverridden());
- Assert.assertFalse(stage1.isCGOverridden());
- Stage stage2 = (Stage) rocket.getChild(1);
- Assert.assertFalse(stage2.isMassOverridden());
- Assert.assertFalse(stage2.isCGOverridden());
- 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 = OpenRocketDocumentFactory.createEmptyRocket();
- context = new DocumentLoadingContext();
- context.setOpenRocketDocument(doc);
- context.setMotorFinder(new DatabaseMotorFinder());
- loader.loadFromStream(context, 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);
-
- //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());
- Assert.assertEquals("Nose cone", stage1.getChild(0).getName());
- Assert.assertEquals("Body tube", stage1.getChild(1).getName());
- Assert.assertTrue(stage1.isMassOverridden());
- Assert.assertEquals(0.185d, stage1.getOverrideMass(), 0.001);
- 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);
- 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());
- Assert.assertTrue(stage2.isMassOverridden());
- Assert.assertEquals(0.33d, stage3.getOverrideMass(), 0.001);
- Assert.assertTrue(stage2.isCGOverridden());
- 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);
- OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
- DocumentLoadingContext context = new DocumentLoadingContext();
- context.setOpenRocketDocument(doc);
- context.setMotorFinder(new DatabaseMotorFinder());
- theLoader.loadFromStream(context, new BufferedInputStream(stream));
- return doc;
- } 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);
- OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
- DocumentLoadingContext context = new DocumentLoadingContext();
- context.setOpenRocketDocument(doc);
- context.setMotorFinder(new DatabaseMotorFinder());
- theLoader.loadFromStream(context, new BufferedInputStream(stream));
- return doc;
- } finally {
- stream.close();
- }
- }
-
+
+ /**
+ * Test a bug reported via automated bug report. I have been unable to reproduce this bug (hanging finset off of an inner body tube) when creating
+ * a Rocksim file using Rocksim. The bug is reproducible when manually modifying the Rocksim file, which is what is tested here.
+ */
+ @org.junit.Test
+ public void testFinsOnInnerTube() throws Exception {
+ RocksimLoader loader = new RocksimLoader();
+ InputStream stream = this.getClass().getResourceAsStream("PodFins.rkt");
+ Assert.assertNotNull("Could not open PodFins.rkt", stream);
+ try {
+ OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
+ DocumentLoadingContext context = new DocumentLoadingContext();
+ context.setOpenRocketDocument(doc);
+ context.setMotorFinder(new DatabaseMotorFinder());
+ loader.loadFromStream(context, new BufferedInputStream(stream));
+ Rocket rocket = doc.getRocket();
+ Assert.assertNotNull(rocket);
+ }
+ catch (IllegalStateException ise) {
+ Assert.fail(ise.getMessage());
+ }
+ Assert.assertTrue(loader.getWarnings().size() == 2);
+ }
+
+ /**
+ * Method: loadFromStream(InputStream source)
+ *
+ * @throws Exception thrown if something goes awry
+ */
+ @org.junit.Test
+ public void testLoadFromStream() throws Exception {
+ RocksimLoader loader = new RocksimLoader();
+ //Stupid single stage rocket
+ OpenRocketDocument doc = loadRocksimRocket(loader);
+ InputStream stream;
+
+ Assert.assertNotNull(doc);
+ Rocket rocket = doc.getRocket();
+ Assert.assertNotNull(rocket);
+ Assert.assertEquals("FooBar Test", doc.getRocket().getName());
+ Assert.assertTrue(loader.getWarnings().isEmpty());
+
+ stream = this.getClass().getResourceAsStream("rocksimTestRocket2.rkt");
+ Assert.assertNotNull("Could not open rocksimTestRocket2.rkt", stream);
+
+ doc = OpenRocketDocumentFactory.createEmptyRocket();
+ DocumentLoadingContext context = new DocumentLoadingContext();
+ context.setOpenRocketDocument(doc);
+ context.setMotorFinder(new DatabaseMotorFinder());
+ loader.loadFromStream(context, new BufferedInputStream(stream));
+
+ Assert.assertNotNull(doc);
+ rocket = doc.getRocket();
+ Assert.assertNotNull(rocket);
+
+ //Do some simple asserts; the important thing here is just validating that the mass and cg were
+ //not overridden for each stage.
+ Assert.assertEquals("Three Stage Everything Included Rocket", doc.getRocket().getName());
+ Assert.assertEquals(0, loader.getWarnings().size());
+ Assert.assertEquals(3, rocket.getStageCount());
+ Stage stage1 = (Stage) rocket.getChild(0);
+ Assert.assertFalse(stage1.isMassOverridden());
+ Assert.assertFalse(stage1.isCGOverridden());
+ Stage stage2 = (Stage) rocket.getChild(1);
+ Assert.assertFalse(stage2.isMassOverridden());
+ Assert.assertFalse(stage2.isCGOverridden());
+ 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 = OpenRocketDocumentFactory.createEmptyRocket();
+ context = new DocumentLoadingContext();
+ context.setOpenRocketDocument(doc);
+ context.setMotorFinder(new DatabaseMotorFinder());
+ loader.loadFromStream(context, 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);
+
+ //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());
+ Assert.assertEquals("Nose cone", stage1.getChild(0).getName());
+ Assert.assertEquals("Body tube", stage1.getChild(1).getName());
+ Assert.assertTrue(stage1.isMassOverridden());
+ Assert.assertEquals(0.185d, stage1.getOverrideMass(), 0.001);
+ 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);
+ 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());
+ Assert.assertTrue(stage2.isMassOverridden());
+ Assert.assertEquals(0.33d, stage3.getOverrideMass(), 0.001);
+ Assert.assertTrue(stage2.isCGOverridden());
+ Assert.assertEquals(0.5d, stage3.getOverrideCG().x, 0.001);
+ }
+
+ @org.junit.Test
+ public void testSubAssemblyRocket() throws IOException, RocketLoadException {
+ RocksimLoader loader = new RocksimLoader();
+ //Stupid single stage rocket
+ OpenRocketDocument doc = loadRocksimSubassemblyRocket(loader);
+ InputStream stream;
+
+ Assert.assertNotNull(doc);
+ Rocket rocket = doc.getRocket();
+ Assert.assertNotNull(rocket);
+ Assert.assertEquals("SubAssembly Element Test", doc.getRocket().getName());
+ Assert.assertTrue(loader.getWarnings().isEmpty());
+
+ stream = this.getClass().getResourceAsStream("SubAssemblyTest.rkt");
+ Assert.assertNotNull("Could not open SubAssemblyTest.rkt", stream);
+
+ doc = OpenRocketDocumentFactory.createEmptyRocket();
+ DocumentLoadingContext context = new DocumentLoadingContext();
+ context.setOpenRocketDocument(doc);
+ context.setMotorFinder(new DatabaseMotorFinder());
+ loader.loadFromStream(context, new BufferedInputStream(stream));
+
+ Assert.assertNotNull(doc);
+ rocket = doc.getRocket();
+ Assert.assertNotNull(rocket);
+ Assert.assertEquals(1, rocket.getStageCount());
+ Stage stage1 = (Stage) rocket.getChild(0);
+ Assert.assertEquals("Nose cone", stage1.getChild(0).getName());
+ Assert.assertEquals("Forward Body tube", stage1.getChild(1).getName());
+ Assert.assertEquals("Aft Body tube", stage1.getChild(2).getName());
+
+ BodyTube subassemblyBodyTube = (BodyTube)stage1.getChild(2);
+ Assert.assertEquals(8, subassemblyBodyTube.getChildCount());
+ Assert.assertEquals("Engine block", subassemblyBodyTube.getChild(0).getName());
+ Assert.assertEquals("Fin set-1", subassemblyBodyTube.getChild(1).getName());
+ Assert.assertEquals("Fin set", subassemblyBodyTube.getChild(2).getName());
+ Assert.assertEquals("Fin set-2", subassemblyBodyTube.getChild(3).getName());
+ Assert.assertEquals("Fin set-3", subassemblyBodyTube.getChild(4).getName());
+ Assert.assertEquals("Fin set-4", subassemblyBodyTube.getChild(5).getName());
+ Assert.assertEquals("Centering ring", subassemblyBodyTube.getChild(6).getName());
+ Assert.assertEquals("Centering ring", subassemblyBodyTube.getChild(7).getName());
+ }
+
+ 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);
+ OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
+ DocumentLoadingContext context = new DocumentLoadingContext();
+ context.setOpenRocketDocument(doc);
+ context.setMotorFinder(new DatabaseMotorFinder());
+ theLoader.loadFromStream(context, new BufferedInputStream(stream));
+ return doc;
+ }
+ 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);
+ OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
+ DocumentLoadingContext context = new DocumentLoadingContext();
+ context.setOpenRocketDocument(doc);
+ context.setMotorFinder(new DatabaseMotorFinder());
+ theLoader.loadFromStream(context, new BufferedInputStream(stream));
+ return doc;
+ }
+ finally {
+ stream.close();
+ }
+ }
+
+ public static OpenRocketDocument loadRocksimSubassemblyRocket(RocksimLoader theLoader) throws IOException, RocketLoadException {
+ InputStream stream = RocksimLoaderTest.class.getResourceAsStream("SubAssemblyTest.rkt");
+ try {
+ Assert.assertNotNull("Could not open SubAssemblyTest.rkt", stream);
+ OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
+ DocumentLoadingContext context = new DocumentLoadingContext();
+ context.setOpenRocketDocument(doc);
+ context.setMotorFinder(new DatabaseMotorFinder());
+ theLoader.loadFromStream(context, new BufferedInputStream(stream));
+ return doc;
+ }
+ finally {
+ stream.close();
+ }
+ }
+
}
diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/SubAssemblyTest.rkt b/core/test/net/sf/openrocket/file/rocksim/importt/SubAssemblyTest.rkt
new file mode 100644
index 000000000..7bb84f148
--- /dev/null
+++ b/core/test/net/sf/openrocket/file/rocksim/importt/SubAssemblyTest.rkt
@@ -0,0 +1,483 @@
+
+ 4
+
+
+ SubAssembly Element Test
+ 1
+ 7
+ 0
+ 3
+ 0
+ 3
+ 0.0
+ 0.0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 18
+ 0.0
+ 0.0
+ 0.0
+ 426.6301716552979
+ 0.0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 1
+ 0
+
+
+ 6.107306539734526
+ 1049.21
+ Polystyrene PS
+ Nose cone
+ 0.0
+ 0
+ 0.0
+ 6.107306539734526
+ 53.68748632541546
+ 0
+ 0.0
+ 0.0
+ 0
+ 76.2
+ 0
+ 1
+ 3
+ 1
+ 1.00076
+ 0.0
+
+ 24.8006
+ 19.1008
+ 23.5991
+
+
+ 15.040422946044567
+ 1121.29
+ Paper
+ Forward Body tube
+ 0.0
+ 0
+ 0.0
+ 15.040422946044567
+ 228.6
+ 0
+ 0.0
+ 0.0
+ 0
+ 457.2
+ 0
+ 2
+ 24.892
+ 24.13
+ 0
+ 24.13
+ 0.0
+ 0
+
+
+ 0.0
+ 1121.29
+ Paper
+ Tube coupler
+ 0.0
+ 0
+ 120.65
+ 0.0
+ 31.75
+ 0
+ 0.0
+ 0.0
+ 0
+ 63.5
+ 0
+ 3
+ 27.8892
+ 27.8892
+ 4
+ 0
+
+
+ 10.038912051168
+ 0.00664972
+ Mylar
+ Streamer
+ 0.0
+ 0
+ 44.45
+ 10.038912051168
+ 57.15
+ 1
+ 0.0
+ 0.0
+ 0
+ 114.3
+ 0
+ 4
+ 114.3
+ 0.138
+
+
+ 1.2996672000000002
+ 0.0
+
+ Shock Cord
+ 187.325
+ 1
+ 187.325
+ 0.0
+ 0.0
+ 0
+ 0.0
+ 0.0
+ 0
+ 12.192000000000002
+ 0
+ 5
+ 0
+
+
+ 2.549
+ 0.0
+
+ Mass object - 2.549 g
+ 282.575
+ 1
+ 282.575
+ 0.0
+ 0.0
+ 0
+ 0.0
+ 0.0
+ 0
+ 0.0
+ 0
+ 6
+ 0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 384.175
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 0
+ 6.35
+ 0
+ 7
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 358.775
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 0
+ 6.35
+ 0
+ 8
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 288.925
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 0
+ 6.35
+ 0
+ 9
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+
+
+ 13.498613632777841
+ 1121.29
+ Paper
+ Aft Body tube
+ 0.0
+ 0
+ 0.0
+ 13.498613632777841
+ 165.1
+ 0
+ 0.0
+ 0.0
+ 0
+ 330.2
+ 0
+ 10
+ 29.8704
+ 29.083
+ 1
+ 29.083
+ 12.7
+ 0
+
+
+ 1.25084668869137
+ 1121.29
+ Paper
+ Engine block
+ 0.0
+ 0
+ 252.73000000000002
+ 1.25084668869137
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 0
+ 6.35
+ 0
+ 11
+ 29.083
+ 24.9428
+ 2
+ 0
+
+
+ 0.9977479979838839
+ 128.148
+ Balsa
+ Fin set-1
+ 0.0
+ 0
+ 257.175
+ 0.9977479979838839
+ 54.72939060773481
+ 0
+ 0.0
+ 0.0
+ 0
+ 0.0
+ 0
+ 12
+ 1
+ 66.675
+ 29.8704
+ 50.8
+ 67.4141
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 2.8874580315239995
+ 128.148
+ Balsa
+ Fin set
+ 0.0
+ 0
+ 146.05
+ 2.8874580315239995
+ 61.383333333333326
+ 0
+ 0.0
+ 0.785398
+ 0
+ 0.0
+ 0
+ 13
+ 4
+ 101.6
+ 0.0
+ 34.925
+ 82.55
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 0.9977479979838839
+ 128.148
+ Balsa
+ Fin set-2
+ 0.0
+ 0
+ 257.175
+ 0.9977479979838839
+ 54.72939060773481
+ 0
+ 0.0
+ 1.5708
+ 0
+ 0.0
+ 0
+ 14
+ 1
+ 66.675
+ 29.8704
+ 50.8
+ 67.4141
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 0.9977479979838839
+ 128.148
+ Balsa
+ Fin set-3
+ 0.0
+ 0
+ 257.175
+ 0.9977479979838839
+ 54.72939060773481
+ 0
+ 0.0
+ 3.14159
+ 0
+ 0.0
+ 0
+ 15
+ 1
+ 66.675
+ 29.8704
+ 50.8
+ 67.4141
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 0.9977479979838839
+ 128.148
+ Balsa
+ Fin set-4
+ 0.0
+ 0
+ 257.175
+ 0.9977479979838839
+ 54.72939060773481
+ 0
+ 0.0
+ -1.5708
+ 0
+ 0.0
+ 0
+ 16
+ 1
+ 66.675
+ 29.8704
+ 50.8
+ 67.4141
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 323.85
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 2
+ 6.35
+ 0
+ 17
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 282.575
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 2
+ 6.35
+ 0
+ 18
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+
+
+
+
+
+
+
\ No newline at end of file