diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/FinsOnTransitions.rkt b/core/test/net/sf/openrocket/file/rocksim/importt/FinsOnTransitions.rkt new file mode 100644 index 000000000..f1d2388cc --- /dev/null +++ b/core/test/net/sf/openrocket/file/rocksim/importt/FinsOnTransitions.rkt @@ -0,0 +1,448 @@ + +4 + + +FinsOnTransitions +1 +1 +1 +0.75 +0.8 +0.81 +0.95 +0.95 +1 +0. +0. +0. +0. +0. +0. +0. +0. +4 +914.4 +0 +0 +0 +1 +0 +4 +4 +1 +0 +0,51.854,0,0 +0,24.095,0,0 +0,70.2027,0,0 +0,51.2803,0,0 +0,0,0,0 +0,0,0,0 +0 +1 +0 +1 +0. +0. +0 +0 +0 +0 +0 +0 +0 +0 +0. +10. +10. +10. +10. +0 +0 +0 +10. +0.15 +black +141.176 +50. +150. +150. +0. +150. +0,50,0,0 +0,150,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0) +1. +0. +1. +0. +1. +blue +blue +white +1 +1 +1 +0 +0 +blue +6. +0.0416667 +6. +0.0416667 +1 +0 +8 +0 +0. +25. +50. +75. +0 +0. +0. +0 +0. +0. +0. +0. +0 +0. +150. +75. + + +Custom +0. +0.0446449 +1/2 in. tubular kevlar +Fin set 1 +0. +0 +0. +0.000805757 +41.0078 +0.00245034 +0.00735103 +0. +2 +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0) +1. +0. +1. +0. +1. +blue +blue +white +1 +2 +0 +0 +0 +blue +10.3073 +0.0301389 +14.8561 +0.0301389 +1 +0 +8 +0 +0. +3 +75. +37.5 +30. +34.1184 +35. +3.18 +0 +0 +0 +50. +7.5 +10. +1 +0.859994 +0. +25.8333 +8.57716 +0.5 +0. +0. + + + + + + +Custom +0. +361.377 +1/16 Aircraft Plywood +Transition 2 +0. +0 +0. +31.0433 +29.4643 +0.00895163 +0.00895163 +0. +0 +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0) +1. +0. +1. +0. +1. +blue +blue +white +1 +3 +1 +0 +0 +blue +-6. +0.108333 +-6. +0.108333 +1 +0 +8 +0 +75. +50. +25. +75. +0 +0. +0. +0 +0. +0. +0. +0. +0 +0. +150. +75. + + +Custom +0. +128.148 +Balsa +Fin set 2 +0. +0 +0. +2.37494 +31.6988 +0.00343529 +0.0103059 +0. +0 +0. +0. +file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0) +1. +0. +1. +0. +1. +blue +rgb(126,150,121) +white +1 +4 +0 +0 +0 +rgb(61,177,187) +13.7877 +0.0970988 +36.4242 +0.097525 +1 +0 +8 +0 +75. +3 +60. +10.84 +35. +35.5414 +30.76 +3.18 +2 +0 +0 +30. +10. +0. +1 +0. +0. +42.5214 +21.0295 +0.180667 +0. +0. +40.1 +10.8353 +60,0|50,30|25,35|0,0| +0,0,0,0,0,0,0 +10,10,10,10,10,10,10 +0,0,0,0,0,0,0 +0.5,10,0.5,0.5,0.00018939,0.001,1 +0.25,5,0.1,0.1,0.00018939,0.001,1 +0,0,0,0,0,0,0 +10,10,10,10,10,10,10 +0,0,0,0,0,0,0 +0.5,10,0.5,0.5,0.00018939,0.001,1 +0.25,5,0.1,0.1,0.00018939,0.001,1 + + + + + + + + + + + + + + + + + + + + + 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 f6fef9447..c6d3cbbb8 100644 --- a/core/test/net/sf/openrocket/file/rocksim/importt/RockSimLoaderTest.java +++ b/core/test/net/sf/openrocket/file/rocksim/importt/RockSimLoaderTest.java @@ -8,8 +8,12 @@ import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; +import net.sf.openrocket.rocketcomponent.FreeformFinSet; import net.sf.openrocket.rocketcomponent.NoseCone; +import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.Transition; +import net.sf.openrocket.util.Coordinate; +import net.sf.openrocket.util.MathUtil; import org.junit.Assert; import net.sf.openrocket.document.OpenRocketDocument; @@ -53,6 +57,88 @@ public class RockSimLoaderTest extends BaseTestCase { Assert.assertTrue(loader.getWarnings().size() == 2); } + @Test + public void testFinsOnTransitions() throws IOException, RocketLoadException { + RockSimLoader loader = new RockSimLoader(); + OpenRocketDocument doc = loadRockSimRocket(loader, "FinsOnTransitions.rkt"); + + Assert.assertNotNull(doc); + Rocket rocket = doc.getRocket(); + Assert.assertNotNull(rocket); + Assert.assertEquals("FinsOnTransitions", doc.getRocket().getName()); + Assert.assertTrue(loader.getWarnings().isEmpty()); + + InputStream stream = this.getClass().getResourceAsStream("FinsOnTransitions.rkt"); + Assert.assertNotNull("Could not open FinsOnTransitions.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()); + AxialStage stage1 = (AxialStage) rocket.getChild(0); + + RocketComponent transition1 = stage1.getChild(0); + RocketComponent transition2 = stage1.getChild(1); + Assert.assertEquals(" Component should have been transition", Transition.class, transition1.getClass()); + Assert.assertEquals(" Component should have been transition", Transition.class, transition2.getClass()); + Assert.assertEquals("Transition 1", transition1.getName()); + Assert.assertEquals("Transition 2", transition2.getName()); + Assert.assertEquals(1, transition1.getChildCount()); + Assert.assertEquals(1, transition2.getChildCount()); + + Assert.assertEquals(" Transition 1 length does not match", 0.075, transition1.getLength(), MathUtil.EPSILON); + Assert.assertEquals(" Transition 1 fore radius does not match", 0.0125,((Transition) transition1).getForeRadius(), MathUtil.EPSILON); + Assert.assertEquals(" Transition 1 aft radius does not match", 0.025, ((Transition) transition1).getAftRadius(), MathUtil.EPSILON); + Assert.assertEquals(" Transition 1 shape does not match", Transition.Shape.CONICAL, ((Transition) transition1).getType()); + + Assert.assertEquals(" Transition 2 length does not match", 0.075, transition2.getLength(), MathUtil.EPSILON); + Assert.assertEquals(" Transition 2 fore radius does not match", 0.025,((Transition) transition2).getForeRadius(), MathUtil.EPSILON); + Assert.assertEquals(" Transition 2 aft radius does not match", 0.0125, ((Transition) transition2).getAftRadius(), MathUtil.EPSILON); + Assert.assertEquals(" Transition 2 shape does not match", Transition.Shape.CONICAL, ((Transition) transition2).getType()); + + RocketComponent finSet1 = transition1.getChild(0); + RocketComponent finSet2 = transition2.getChild(0); + Assert.assertEquals(" Component should have been free form fin set", FreeformFinSet.class, finSet1.getClass()); + Assert.assertEquals(" Component should have been free form fin set", FreeformFinSet.class, finSet2.getClass()); + Assert.assertEquals("Fin set 1", finSet1.getName()); + Assert.assertEquals("Fin set 2", finSet2.getName()); + + FreeformFinSet freeformFinSet1 = (FreeformFinSet) finSet1; + FreeformFinSet freeformFinSet2 = (FreeformFinSet) finSet2; + Assert.assertEquals(3, freeformFinSet1.getFinCount()); + Assert.assertEquals(3, freeformFinSet2.getFinCount()); + + Coordinate[] points1 = freeformFinSet1.getFinPoints(); + Coordinate[] expectedPoints1 = new Coordinate[] { + new Coordinate(0.0, 0.0, 0.0), + new Coordinate(0.035, 0.03, 0.0), + new Coordinate(0.07250, 0.03, 0.0), + new Coordinate(0.07500, 0.01250, 0.0) + }; + Assert.assertArrayEquals(" Fin set 1 fin points do not match", expectedPoints1, points1); + Assert.assertEquals(" Fin set 1 fin tab length does not match", 0.05, freeformFinSet1.getTabLength(), MathUtil.EPSILON); + Assert.assertEquals(" Fin set 1 fin tab height does not match", 0.0075, freeformFinSet1.getTabHeight(), MathUtil.EPSILON); + Assert.assertEquals(" Fin set 1 fin tab offset does not match", 0.01, freeformFinSet1.getTabOffset(), MathUtil.EPSILON); + + Coordinate[] points2 = freeformFinSet2.getFinPoints(); + Coordinate[] expectedPoints2 = new Coordinate[] { + new Coordinate(0.0, 0.0, 0.0), + new Coordinate(0.025, 0.035, 0.0), + new Coordinate(0.05, 0.03, 0.0), + new Coordinate(0.06, -0.01, 0.0) + }; + Assert.assertArrayEquals(" Fin set 2 fin points do not match", expectedPoints2, points2); + Assert.assertEquals(" Fin set 2 fin tab length does not match", 0.03, freeformFinSet2.getTabLength(), MathUtil.EPSILON); + Assert.assertEquals(" Fin set 2 fin tab height does not match", 0.005, freeformFinSet2.getTabHeight(), MathUtil.EPSILON); + Assert.assertEquals(" Fin set 2 fin tab offset does not match", 0, freeformFinSet2.getTabOffset(), MathUtil.EPSILON); + } + /** * Method: loadFromStream(InputStream source) * diff --git a/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java b/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java index 0fb5106ad..38769db88 100644 --- a/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java +++ b/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java @@ -321,6 +321,8 @@ public class RocketFigure3d extends JPanel implements GLEventListener { gl.glEnable(GL.GL_MULTISAMPLE); gl.glEnable(GLLightingFunc.GL_LIGHTING); + + updateFigure(); } rr.render(drawable, configuration, selection);