DGP - cleanup
This commit is contained in:
parent
293efd20c8
commit
d66a379c05
@ -2,16 +2,35 @@ package net.sf.openrocket.file.rocksim.export;
|
|||||||
|
|
||||||
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
import net.sf.openrocket.file.rocksim.importt.RocksimHandler;
|
||||||
import net.sf.openrocket.file.rocksim.importt.RocksimNoseConeCode;
|
import net.sf.openrocket.file.rocksim.importt.RocksimNoseConeCode;
|
||||||
|
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Bulkhead;
|
||||||
|
import net.sf.openrocket.rocketcomponent.CenteringRing;
|
||||||
|
import net.sf.openrocket.rocketcomponent.EngineBlock;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
|
||||||
|
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||||
|
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Parachute;
|
||||||
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.rocketcomponent.Transition;
|
import net.sf.openrocket.rocketcomponent.Transition;
|
||||||
|
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementRef;
|
||||||
|
import javax.xml.bind.annotation.XmlElementRefs;
|
||||||
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A common ancestor class for nose cones and transitions. This class is responsible for adapting an OpenRocket
|
||||||
|
* Transition to a Rocksim Transition.
|
||||||
*/
|
*/
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class AbstractTransitionDTO extends BasePartDTO {
|
public class AbstractTransitionDTO extends BasePartDTO {
|
||||||
|
|
||||||
@XmlElement(name = "ShapeCode")
|
@XmlElement(name = "ShapeCode")
|
||||||
private int shapeCode = 1;
|
private int shapeCode = 1;
|
||||||
@XmlElement(name = "ConstructionType")
|
@XmlElement(name = "ConstructionType")
|
||||||
@ -21,10 +40,29 @@ public class AbstractTransitionDTO extends BasePartDTO {
|
|||||||
@XmlElement(name = "ShapeParameter")
|
@XmlElement(name = "ShapeParameter")
|
||||||
private double shapeParameter = 0d;
|
private double shapeParameter = 0d;
|
||||||
|
|
||||||
protected AbstractTransitionDTO() {
|
@XmlElementWrapper(name = "AttachedParts")
|
||||||
|
@XmlElementRefs({
|
||||||
|
@XmlElementRef(name = "BodyTube", type = BodyTubeDTO.class),
|
||||||
|
@XmlElementRef(name = "BodyTube", type = InnerBodyTubeDTO.class),
|
||||||
|
@XmlElementRef(name = "FinSet", type = FinSetDTO.class),
|
||||||
|
@XmlElementRef(name = "CustomFinSet", type = CustomFinSetDTO.class),
|
||||||
|
@XmlElementRef(name = "Ring", type = CenteringRingDTO.class),
|
||||||
|
@XmlElementRef(name = "Streamer", type = StreamerDTO.class),
|
||||||
|
@XmlElementRef(name = "Parachute", type = ParachuteDTO.class),
|
||||||
|
@XmlElementRef(name = "MassObject", type = MassObjectDTO.class)})
|
||||||
|
List<BasePartDTO> attachedParts = new ArrayList<BasePartDTO>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
protected AbstractTransitionDTO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion constructor.
|
||||||
|
*
|
||||||
|
* @param nc the OpenRocket component to convert
|
||||||
|
*/
|
||||||
protected AbstractTransitionDTO(Transition nc) {
|
protected AbstractTransitionDTO(Transition nc) {
|
||||||
super(nc);
|
super(nc);
|
||||||
setConstructionType(nc.isFilled() ? 0 : 1);
|
setConstructionType(nc.isFilled() ? 0 : 1);
|
||||||
@ -38,6 +76,33 @@ public class AbstractTransitionDTO extends BasePartDTO {
|
|||||||
|
|
||||||
setWallThickness(nc.getThickness() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
setWallThickness(nc.getThickness() * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
|
|
||||||
|
List<RocketComponent> children = nc.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 Parachute) {
|
||||||
|
attachedParts.add(new ParachuteDTO((Parachute) rocketComponents));
|
||||||
|
} else if (rocketComponents instanceof MassObject) {
|
||||||
|
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
|
||||||
|
} else if (rocketComponents instanceof FreeformFinSet) {
|
||||||
|
attachedParts.add(new CustomFinSetDTO((FreeformFinSet) rocketComponents));
|
||||||
|
} else if (rocketComponents instanceof FinSet) {
|
||||||
|
attachedParts.add(new FinSetDTO((FinSet) rocketComponents));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getShapeCode() {
|
public int getShapeCode() {
|
||||||
|
@ -17,6 +17,7 @@ import javax.xml.bind.annotation.XmlElement;
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The base class for all OpenRocket to Rocksim conversions.
|
||||||
*/
|
*/
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@ -53,9 +54,17 @@ public abstract class BasePartDTO {
|
|||||||
@XmlElement(name = "FinishCode")
|
@XmlElement(name = "FinishCode")
|
||||||
private int finishCode = 0;
|
private int finishCode = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
protected BasePartDTO() {
|
protected BasePartDTO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy constructor of sorts, that performs all common conversions for components.
|
||||||
|
*
|
||||||
|
* @param ec
|
||||||
|
*/
|
||||||
protected BasePartDTO(RocketComponent ec) {
|
protected BasePartDTO(RocketComponent ec) {
|
||||||
setCalcCG(ec.getCG().x * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
setCalcCG(ec.getCG().x * RocksimHandler.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
setCalcMass(ec.getComponentMass() * RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS);
|
setCalcMass(ec.getComponentMass() * RocksimHandler.ROCKSIM_TO_OPENROCKET_MASS);
|
||||||
@ -117,7 +126,6 @@ public abstract class BasePartDTO {
|
|||||||
material = material.substring(BaseHandler.ROCKSIM_MATERIAL_PREFIX.length());
|
material = material.substring(BaseHandler.ROCKSIM_MATERIAL_PREFIX.length());
|
||||||
}
|
}
|
||||||
setMaterial(material);
|
setMaterial(material);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,11 +22,20 @@ import java.io.StringWriter;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This class is responsible for converting an OpenRocket design to a Rocksim design.
|
||||||
*/
|
*/
|
||||||
public class RocksimSaver extends RocketSaver {
|
public class RocksimSaver extends RocketSaver {
|
||||||
|
|
||||||
|
/** The logger. */
|
||||||
private static final LogHelper log = Application.getLogger();
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method marshals an OpenRocketDocument (OR design) to Rocksim-compliant XML.
|
||||||
|
*
|
||||||
|
* @param doc the OR design
|
||||||
|
*
|
||||||
|
* @return Rocksim-compliant XML
|
||||||
|
*/
|
||||||
public String marshalToRocksim(OpenRocketDocument doc) {
|
public String marshalToRocksim(OpenRocketDocument doc) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -60,6 +69,13 @@ public class RocksimSaver extends RocketSaver {
|
|||||||
return marshalToRocksim(doc).length();
|
return marshalToRocksim(doc).length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Root conversion method. It iterates over all subcomponents.
|
||||||
|
*
|
||||||
|
* @param doc the OR design
|
||||||
|
*
|
||||||
|
* @return a corresponding Rocksim representation
|
||||||
|
*/
|
||||||
private RocksimDocumentDTO toRocksimDocumentDTO(OpenRocketDocument doc) {
|
private RocksimDocumentDTO toRocksimDocumentDTO(OpenRocketDocument doc) {
|
||||||
RocksimDocumentDTO rsd = new RocksimDocumentDTO();
|
RocksimDocumentDTO rsd = new RocksimDocumentDTO();
|
||||||
|
|
||||||
|
@ -7,11 +7,17 @@ import javax.xml.bind.annotation.XmlAccessorType;
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Conversion DTO for a TubeCoupler. TubeCoupler's are represented as Rings in Rocksim.
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "Ring")
|
@XmlRootElement(name = "Ring")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class TubeCouplerDTO extends CenteringRingDTO {
|
public class TubeCouplerDTO extends CenteringRingDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param tc an OR TubeCoupler
|
||||||
|
*/
|
||||||
public TubeCouplerDTO(TubeCoupler tc) {
|
public TubeCouplerDTO(TubeCoupler tc) {
|
||||||
super(tc);
|
super(tc);
|
||||||
setUsageCode(UsageCode.TubeCoupler);
|
setUsageCode(UsageCode.TubeCoupler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user