DGP - updated Rocksim export to support clusters
This commit is contained in:
parent
dc2690df2f
commit
c329a7d789
@ -35,8 +35,8 @@ public abstract class Warning {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return (o.getClass() == this.getClass());
|
||||
}
|
||||
return o != null && (o.getClass() == this.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* A <code>hashCode</code> method compatible with the <code>equals</code> method.
|
||||
|
@ -64,12 +64,12 @@ public class BodyTubeDTO extends BasePartDTO {
|
||||
super(inner);
|
||||
}
|
||||
|
||||
public BodyTubeDTO(BodyTube bt) {
|
||||
protected BodyTubeDTO(BodyTube bt) {
|
||||
super(bt);
|
||||
|
||||
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setId(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOd(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorMount(bt.isMotorMount());
|
||||
|
||||
@ -103,23 +103,22 @@ public class BodyTubeDTO extends BasePartDTO {
|
||||
} else if (rocketComponents instanceof FinSet) {
|
||||
attachedParts.add(new FinSetDTO((FinSet) rocketComponents));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public double getOd() {
|
||||
public double getOD() {
|
||||
return od;
|
||||
}
|
||||
|
||||
public void setOd(double theOd) {
|
||||
public void setOD(double theOd) {
|
||||
od = theOd;
|
||||
}
|
||||
|
||||
public double getId() {
|
||||
public double getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(double theId) {
|
||||
public void setID(double theId) {
|
||||
id = theId;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
|
||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||
import net.sf.openrocket.rocketcomponent.Bulkhead;
|
||||
import net.sf.openrocket.rocketcomponent.CenteringRing;
|
||||
import net.sf.openrocket.rocketcomponent.ClusterConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
||||
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||
@ -12,6 +13,7 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.Streamer;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
@ -29,38 +31,72 @@ public class InnerBodyTubeDTO extends BodyTubeDTO {
|
||||
}
|
||||
|
||||
public InnerBodyTubeDTO(InnerTube bt) {
|
||||
this(bt, true);
|
||||
}
|
||||
|
||||
public InnerBodyTubeDTO(InnerTube bt, boolean deep) {
|
||||
super(bt);
|
||||
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
setId(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOd(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorMount(bt.isMotorMount());
|
||||
setInsideTube(true);
|
||||
setRadialAngle(bt.getRadialDirection());
|
||||
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
|
||||
List<RocketComponent> children = bt.getChildren();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
RocketComponent rocketComponents = children.get(i);
|
||||
if (rocketComponents instanceof InnerTube) {
|
||||
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof BodyTube) {
|
||||
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof Transition) {
|
||||
attachedParts.add(new TransitionDTO((Transition) rocketComponents));
|
||||
} else if (rocketComponents instanceof EngineBlock) {
|
||||
attachedParts.add(new EngineBlockDTO((EngineBlock) rocketComponents));
|
||||
} else if (rocketComponents instanceof TubeCoupler) {
|
||||
attachedParts.add(new TubeCouplerDTO((TubeCoupler) rocketComponents));
|
||||
} else if (rocketComponents instanceof CenteringRing) {
|
||||
attachedParts.add(new CenteringRingDTO((CenteringRing) rocketComponents));
|
||||
} else if (rocketComponents instanceof Bulkhead) {
|
||||
attachedParts.add(new BulkheadDTO((Bulkhead) rocketComponents));
|
||||
} else if (rocketComponents instanceof Streamer) {
|
||||
attachedParts.add(new StreamerDTO((Streamer) rocketComponents));
|
||||
} else if (rocketComponents instanceof Parachute) {
|
||||
attachedParts.add(new ParachuteDTO((Parachute) rocketComponents));
|
||||
} else if (rocketComponents instanceof MassObject) {
|
||||
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
||||
if (deep) {
|
||||
List<RocketComponent> children = bt.getChildren();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
RocketComponent rocketComponents = children.get(i);
|
||||
if (rocketComponents instanceof InnerTube) {
|
||||
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof BodyTube) {
|
||||
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||
} else if (rocketComponents instanceof Transition) {
|
||||
attachedParts.add(new TransitionDTO((Transition) rocketComponents));
|
||||
} else if (rocketComponents instanceof EngineBlock) {
|
||||
attachedParts.add(new EngineBlockDTO((EngineBlock) rocketComponents));
|
||||
} else if (rocketComponents instanceof TubeCoupler) {
|
||||
attachedParts.add(new TubeCouplerDTO((TubeCoupler) rocketComponents));
|
||||
} else if (rocketComponents instanceof CenteringRing) {
|
||||
attachedParts.add(new CenteringRingDTO((CenteringRing) rocketComponents));
|
||||
} else if (rocketComponents instanceof Bulkhead) {
|
||||
attachedParts.add(new BulkheadDTO((Bulkhead) rocketComponents));
|
||||
} else if (rocketComponents instanceof Streamer) {
|
||||
attachedParts.add(new StreamerDTO((Streamer) rocketComponents));
|
||||
} else if (rocketComponents instanceof Parachute) {
|
||||
attachedParts.add(new ParachuteDTO((Parachute) rocketComponents));
|
||||
} else if (rocketComponents instanceof MassObject) {
|
||||
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
||||
}
|
||||
}
|
||||
}
|
||||
setInsideTube(true);
|
||||
|
||||
//Do the cluster. For now this splits the cluster into separate tubes, which is how Rocksim represents it.
|
||||
//The import (from Rocksim to OR) could be augmented to be more intelligent and try to determine if the
|
||||
//co-located tubes are a cluster.
|
||||
if (bt.getClusterConfiguration().getClusterCount() > 1) {
|
||||
handleCluster(bt);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCluster(InnerTube it) {
|
||||
|
||||
Coordinate[] coords = {Coordinate.NUL};
|
||||
coords = it.shiftCoordinates(coords);
|
||||
for (int x = 0; x < coords.length; x++) {
|
||||
InnerTube copy = (InnerTube) it.copy();
|
||||
copy.setClusterConfiguration(ClusterConfiguration.SINGLE);
|
||||
copy.setClusterRotation(0.0);
|
||||
copy.setClusterScale(1.0);
|
||||
copy.setRadialShift(coords[x].y, coords[x].z);
|
||||
copy.setName(copy.getName() + " #" + (x + 1));
|
||||
attachedParts.add(copy(copy));
|
||||
}
|
||||
}
|
||||
|
||||
private InnerBodyTubeDTO copy(InnerTube it) {
|
||||
return new InnerBodyTubeDTO(it, false);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user