From 5be3e381e74f3550cd500ff431e8a208cc817268 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Wed, 22 Feb 2023 00:56:06 +0100 Subject: [PATCH] Update geometry check for new next/prev comp behavior --- .../aerodynamics/BarrowmanCalculator.java | 14 ++++++++++++++ .../aerodynamics/BarrowmanCalculatorTest.java | 7 +++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java index bc75f02a6..63ede7ad9 100644 --- a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java @@ -380,6 +380,20 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { } } + } else { + /* + It could be that the component is a child of a PodSet or ParallelStage, and it is flush with + the previous component. In this case, the component is overlapping. + */ + RocketComponent prevCompParent = prevComp.getParent(); + RocketComponent compParent = comp.getParent(); + int prevCompPos = prevCompParent.getChildPosition(prevComp); + RocketComponent nextComp = prevCompPos + 1 >= prevCompParent.getChildCount() ? + null : prevCompParent.getChild(prevCompPos + 1); + if ((compParent instanceof PodSet || compParent instanceof ParallelStage) && + MathUtil.equals(symXfore, prevXaft) && (compParent.getParent() == nextComp)) { + warnings.add(Warning.PODSET_OVERLAP, comp.getParent().toString()); + } } } prevComp = sym; diff --git a/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java b/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java index 710f9780e..f51b9ee99 100644 --- a/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java +++ b/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java @@ -482,20 +482,19 @@ public class BarrowmanCalculatorTest { // move the pod back. pod.setAxialOffset(pod.getAxialOffset() + 0.1); testCP = testCalc.getCP(testConfig, testConditions, warnings).x; - assertFalse("should be warning from gap in airframe", warnings.isEmpty()); + assertEquals("should be warning from gap in airframe", 1, warnings.size()); // move the pod forward. warnings.clear(); pod.setAxialOffset(pod.getAxialOffset() - 0.3); testCP = testCalc.getCP(testConfig, testConditions, warnings).x; - assertFalse("should be warning from airframe overlap", warnings.isEmpty()); + assertEquals("should be warning from airframe overlap", 1, warnings.size()); // move the pod back. warnings.clear(); pod.setAxialOffset(pod.getAxialOffset() + 0.1); - TestRockets.dumpRocket(testRocket, "/Users/SiboVanGool/Downloads/sfs/test.ork"); testCP = testCalc.getCP(testConfig, testConditions, warnings).x; - assertFalse("should be warning from airframe overlap", warnings.isEmpty()); + assertEquals("should be warning from podset airframe overlap", 1, warnings.size()); } }