Don't include inactive stages in Cp calculations

This commit is contained in:
SiboVG 2022-06-24 05:37:30 +02:00
parent 4a79581244
commit 77bad60155
2 changed files with 34 additions and 3 deletions

View File

@ -155,7 +155,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
for( RocketComponent child : comp.getChildren()) { for( RocketComponent child : comp.getChildren()) {
// Ignore inactive stages // Ignore inactive stages
if (child instanceof AxialStage && if (child instanceof AxialStage &&
!child.getRocket().getSelectedConfiguration().isStageActive(child.getStageNumber())) { !((AxialStage) child).isStageActive()) {
continue; continue;
} }
// forces particular to each component // forces particular to each component
@ -278,14 +278,28 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
private boolean testIsContinuous( final RocketComponent treeRoot ){ private boolean testIsContinuous( final RocketComponent treeRoot ){
Queue<RocketComponent> queue = new LinkedList<>(); Queue<RocketComponent> queue = new LinkedList<>();
queue.addAll(treeRoot.getChildren()); for (RocketComponent child : treeRoot.getChildren()) {
// Ignore inactive stages
if (child instanceof AxialStage &&
!((AxialStage) child).isStageActive()) {
continue;
}
queue.add(child);
}
boolean isContinuous = true; boolean isContinuous = true;
SymmetricComponent prevComp = null; SymmetricComponent prevComp = null;
while((isContinuous)&&( null != queue.peek())){ while((isContinuous)&&( null != queue.peek())){
RocketComponent comp = queue.poll(); RocketComponent comp = queue.poll();
if( comp instanceof SymmetricComponent ){ if( comp instanceof SymmetricComponent ){
queue.addAll( comp.getChildren()); for (RocketComponent child : comp.getChildren()) {
// Ignore inactive stages
if (child instanceof AxialStage &&
!((AxialStage) child).isStageActive()) {
continue;
}
queue.add(child);
}
SymmetricComponent sym = (SymmetricComponent) comp; SymmetricComponent sym = (SymmetricComponent) comp;
if( null == prevComp){ if( null == prevComp){

View File

@ -68,6 +68,23 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
return BodyComponent.class.isAssignableFrom(type); return BodyComponent.class.isAssignableFrom(type);
} }
/**
* Returns whether the current stage is active in the currently selected configuration.
* @return true if the stage is active, false if not
*/
public boolean isStageActive() {
return getRocket().getSelectedConfiguration().isStageActive(getStageNumber());
}
/**
* Returns whether the current stage is active in the flight configuration.
* @param fc the flight configuration to check
* @return true if the stage is active, false if not
*/
public boolean isStageActive(FlightConfiguration fc) {
return fc.isStageActive(getStageNumber());
}
@Override @Override
public void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) { public void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
separations.copyFlightConfiguration(oldConfigId, newConfigId); separations.copyFlightConfiguration(oldConfigId, newConfigId);