DGP - updated Rocksim export to support clusters
This commit is contained in:
parent
c329a7d789
commit
e5d891765e
@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
* Transition to a Rocksim Transition.
|
* Transition to a Rocksim Transition.
|
||||||
*/
|
*/
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class AbstractTransitionDTO extends BasePartDTO {
|
public class AbstractTransitionDTO extends BasePartDTO implements AttachedParts {
|
||||||
|
|
||||||
@XmlElement(name = RocksimCommonConstants.SHAPE_CODE)
|
@XmlElement(name = RocksimCommonConstants.SHAPE_CODE)
|
||||||
private int shapeCode = 1;
|
private int shapeCode = 1;
|
||||||
@ -80,7 +80,7 @@ public class AbstractTransitionDTO extends BasePartDTO {
|
|||||||
for (int i = 0; i < children.size(); i++) {
|
for (int i = 0; i < children.size(); i++) {
|
||||||
RocketComponent rocketComponents = children.get(i);
|
RocketComponent rocketComponents = children.get(i);
|
||||||
if (rocketComponents instanceof InnerTube) {
|
if (rocketComponents instanceof InnerTube) {
|
||||||
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents));
|
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents, this));
|
||||||
} else if (rocketComponents instanceof BodyTube) {
|
} else if (rocketComponents instanceof BodyTube) {
|
||||||
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||||
} else if (rocketComponents instanceof Transition) {
|
} else if (rocketComponents instanceof Transition) {
|
||||||
@ -136,4 +136,14 @@ public class AbstractTransitionDTO extends BasePartDTO {
|
|||||||
public void setShapeParameter(double theShapeParameter) {
|
public void setShapeParameter(double theShapeParameter) {
|
||||||
shapeParameter = theShapeParameter;
|
shapeParameter = theShapeParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttachedPart(BasePartDTO part) {
|
||||||
|
attachedParts.add(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAttachedPart(BasePartDTO part) {
|
||||||
|
attachedParts.remove(part);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package net.sf.openrocket.file.rocksim.export;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public interface AttachedParts {
|
||||||
|
void removeAttachedPart(BasePartDTO part);
|
||||||
|
|
||||||
|
void addAttachedPart(BasePartDTO part);
|
||||||
|
}
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@XmlRootElement(name = RocksimCommonConstants.BODY_TUBE)
|
@XmlRootElement(name = RocksimCommonConstants.BODY_TUBE)
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class BodyTubeDTO extends BasePartDTO {
|
public class BodyTubeDTO extends BasePartDTO implements AttachedParts {
|
||||||
|
|
||||||
@XmlElement(name = RocksimCommonConstants.OD)
|
@XmlElement(name = RocksimCommonConstants.OD)
|
||||||
private double od = 0d;
|
private double od = 0d;
|
||||||
@ -77,7 +77,11 @@ public class BodyTubeDTO extends BasePartDTO {
|
|||||||
for (int i = 0; i < children.size(); i++) {
|
for (int i = 0; i < children.size(); i++) {
|
||||||
RocketComponent rocketComponents = children.get(i);
|
RocketComponent rocketComponents = children.get(i);
|
||||||
if (rocketComponents instanceof InnerTube) {
|
if (rocketComponents instanceof InnerTube) {
|
||||||
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents));
|
final InnerTube innerTube = (InnerTube) rocketComponents;
|
||||||
|
final InnerBodyTubeDTO innerBodyTubeDTO = new InnerBodyTubeDTO(innerTube, this);
|
||||||
|
if (innerTube.getClusterCount() == 1) {
|
||||||
|
attachedParts.add(innerBodyTubeDTO);
|
||||||
|
}
|
||||||
} else if (rocketComponents instanceof BodyTube) {
|
} else if (rocketComponents instanceof BodyTube) {
|
||||||
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||||
} else if (rocketComponents instanceof Transition) {
|
} else if (rocketComponents instanceof Transition) {
|
||||||
@ -175,7 +179,13 @@ public class BodyTubeDTO extends BasePartDTO {
|
|||||||
return attachedParts;
|
return attachedParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAttachedParts(BasePartDTO thePart) {
|
@Override
|
||||||
|
public void addAttachedPart(BasePartDTO thePart) {
|
||||||
attachedParts.add(thePart);
|
attachedParts.add(thePart);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void removeAttachedPart(BasePartDTO part) {
|
||||||
|
attachedParts.remove(part);
|
||||||
|
}
|
||||||
|
}
|
@ -24,17 +24,13 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@XmlRootElement(name = RocksimCommonConstants.BODY_TUBE)
|
@XmlRootElement(name = RocksimCommonConstants.BODY_TUBE)
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class InnerBodyTubeDTO extends BodyTubeDTO {
|
public class InnerBodyTubeDTO extends BodyTubeDTO implements AttachedParts {
|
||||||
|
|
||||||
public InnerBodyTubeDTO() {
|
public InnerBodyTubeDTO() {
|
||||||
super.setInsideTube(true);
|
super.setInsideTube(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InnerBodyTubeDTO(InnerTube bt) {
|
public InnerBodyTubeDTO(InnerTube bt, AttachedParts parent) {
|
||||||
this(bt, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InnerBodyTubeDTO(InnerTube bt, boolean deep) {
|
|
||||||
super(bt);
|
super(bt);
|
||||||
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||||
@ -45,12 +41,14 @@ public class InnerBodyTubeDTO extends BodyTubeDTO {
|
|||||||
setRadialAngle(bt.getRadialDirection());
|
setRadialAngle(bt.getRadialDirection());
|
||||||
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
|
|
||||||
if (deep) {
|
|
||||||
List<RocketComponent> children = bt.getChildren();
|
List<RocketComponent> children = bt.getChildren();
|
||||||
for (int i = 0; i < children.size(); i++) {
|
for (int i = 0; i < children.size(); i++) {
|
||||||
RocketComponent rocketComponents = children.get(i);
|
RocketComponent rocketComponents = children.get(i);
|
||||||
if (rocketComponents instanceof InnerTube) {
|
if (rocketComponents instanceof InnerTube) {
|
||||||
attachedParts.add(new InnerBodyTubeDTO((InnerTube) rocketComponents));
|
final InnerTube innerTube = (InnerTube) rocketComponents;
|
||||||
|
if (innerTube.getClusterCount() == 1) {
|
||||||
|
attachedParts.add(new InnerBodyTubeDTO(innerTube, this));
|
||||||
|
}
|
||||||
} else if (rocketComponents instanceof BodyTube) {
|
} else if (rocketComponents instanceof BodyTube) {
|
||||||
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||||
} else if (rocketComponents instanceof Transition) {
|
} else if (rocketComponents instanceof Transition) {
|
||||||
@ -71,17 +69,17 @@ public class InnerBodyTubeDTO extends BodyTubeDTO {
|
|||||||
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Do the cluster. For now this splits the cluster into separate tubes, which is how Rocksim represents it.
|
//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
|
//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.
|
//co-located tubes are a cluster.
|
||||||
if (bt.getClusterConfiguration().getClusterCount() > 1) {
|
if (bt.getClusterConfiguration().getClusterCount() > 1) {
|
||||||
handleCluster(bt);
|
handleCluster(bt, parent);
|
||||||
|
parent.removeAttachedPart(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCluster(InnerTube it) {
|
private void handleCluster(InnerTube it, AttachedParts p) {
|
||||||
|
|
||||||
Coordinate[] coords = {Coordinate.NUL};
|
Coordinate[] coords = {Coordinate.NUL};
|
||||||
coords = it.shiftCoordinates(coords);
|
coords = it.shiftCoordinates(coords);
|
||||||
@ -92,11 +90,21 @@ public class InnerBodyTubeDTO extends BodyTubeDTO {
|
|||||||
copy.setClusterScale(1.0);
|
copy.setClusterScale(1.0);
|
||||||
copy.setRadialShift(coords[x].y, coords[x].z);
|
copy.setRadialShift(coords[x].y, coords[x].z);
|
||||||
copy.setName(copy.getName() + " #" + (x + 1));
|
copy.setName(copy.getName() + " #" + (x + 1));
|
||||||
attachedParts.add(copy(copy));
|
p.addAttachedPart(copy(copy, p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InnerBodyTubeDTO copy(InnerTube it) {
|
private InnerBodyTubeDTO copy(InnerTube it, AttachedParts p) {
|
||||||
return new InnerBodyTubeDTO(it, false);
|
return new InnerBodyTubeDTO(it, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttachedPart(BasePartDTO part) {
|
||||||
|
attachedParts.add(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAttachedPart(BasePartDTO part) {
|
||||||
|
attachedParts.remove(part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user