Added special processing for rocksim csv component files when the mass is specified as 0. In this case, we "reject" the mass and assume it is to be computed based on density.
This commit is contained in:
parent
1acc99b163
commit
573706323f
@ -22,7 +22,7 @@ public abstract class BaseComponentLoader extends RocksimComponentFileLoader {
|
||||
fileColumns.add( new StringColumnParser("Part No.", ComponentPreset.PARTNO));
|
||||
fileColumns.add( new StringColumnParser("Desc.", ComponentPreset.DESCRIPTION));
|
||||
fileColumns.add(new MaterialColumnParser(materials));
|
||||
fileColumns.add(new DoubleUnitColumnParser("Mass","Mass units",ComponentPreset.MASS));
|
||||
fileColumns.add(new MassColumnParser("Mass","Mass units"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
package net.sf.openrocket.preset.loader;
|
||||
|
||||
import net.sf.openrocket.preset.ComponentPreset;
|
||||
import net.sf.openrocket.preset.TypedPropertyMap;
|
||||
|
||||
/**
|
||||
* Special DoubleUnitColumnParser for Mass column. Here we assume that if a mass of 0 is
|
||||
* specified in the csv, then we should not put a mass explicitly in the preset but instead
|
||||
* rely on the density to compute a mass value.
|
||||
*
|
||||
*/
|
||||
public class MassColumnParser extends DoubleUnitColumnParser {
|
||||
|
||||
public MassColumnParser(String columnHeader, String unitHeader) {
|
||||
super(columnHeader, unitHeader, ComponentPreset.MASS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
|
||||
if ( columnData == null || "".equals(columnData.trim())) {
|
||||
return;
|
||||
}
|
||||
double d = Double.valueOf(columnData);
|
||||
if ( d == 0.0 ) {
|
||||
return;
|
||||
}
|
||||
super.doParse(columnData, data, props);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user