Ejemplo n.º 1
0
void Atom::loadJSON(const JSON::Value &value, float scale) {
    if (0 < value.size()) type = value.getString(0);
    else THROWS("Atom expected list of at least length 1");
    if (String::toUpper(type) == "UNKNOWN") type = "?";

    if (1 < value.size()) charge = (float)value.getNumber(1);
    if (2 < value.size()) radius = (float)value.getNumber(2) * scale;
    if (3 < value.size()) mass = (float)value.getNumber(3);
    if (4 < value.size()) number = (unsigned)value.getNumber(4);
    else number = numberFromName(type);

    if (!number) number = numberFromName(type);
    if (!charge) charge = chargeFromNumber(number);
    if (!radius) radius = radiusFromNumber(number);
    if (!mass) mass = massFromNumber(number);
}
Ejemplo n.º 2
0
void Tool::read(const JSON::Value &value) {
  setNumber(value.getU32("number", number));

  if (value.hasString("units"))
    units = ToolUnits::parse(value.getString("units"));

  double scale = units == ToolUnits::UNITS_INCH ? 25.4 : 1;

  if (value.hasString("shape"))
    shape = ToolShape::parse(value.getString("shape"));

  if (value.hasNumber("length"))
    setLength(value.getNumber("length") * scale);

  if (value.hasNumber("diameter"))
    setDiameter(value.getNumber("diameter") * scale);

  if (value.hasNumber("snub_diameter"))
    setSnubDiameter(value.getNumber("snub_diameter") * scale);

  if (value.hasNumber("front_angle"))
    setFrontAngle(value.getNumber("front_angle"));

  if (value.hasNumber("back_angle"))
    setBackAngle(value.getNumber("back_angle"));

  if (value.hasNumber("orientation"))
    setOrientation(value.getNumber("orientation"));

  setDescription(value.getString("description", ""));
}
Ejemplo n.º 3
0
void Workpiece::read(const JSON::Value &value) {
  automatic = value.getBoolean("automatic", automatic);
  margin = value.getNumber("margin", margin);
  if (value.hasDict("bounds")) bounds.read(value.getDict("bounds"));
}