Skip to content

Commit 778d22c

Browse files
committed
Unify all enum contents tags used in serialization
1 parent 0962d15 commit 778d22c

5 files changed

Lines changed: 22 additions & 22 deletions

File tree

gui/source/solver/BowModel.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,19 @@ void from_json(const nlohmann::json& obj, DrawLength& output) {
183183
void to_json(nlohmann::json& obj, const ProfileSegment& input) {
184184
if(auto value = std::get_if<Line>(&input)) {
185185
obj["type"] = "line";
186-
obj["parameters"] = *value;
186+
obj["value"] = *value;
187187
}
188188
else if(auto value = std::get_if<Arc>(&input)) {
189189
obj["type"] = "arc";
190-
obj["parameters"] = *value;
190+
obj["value"] = *value;
191191
}
192192
else if(auto value = std::get_if<Spiral>(&input)) {
193193
obj["type"] = "spiral";
194-
obj["parameters"] = *value;
194+
obj["value"] = *value;
195195
}
196196
else if(auto value = std::get_if<Spline>(&input)) {
197197
obj["type"] = "spline";
198-
obj["parameters"] = *value;
198+
obj["value"] = *value;
199199
}
200200
else {
201201
throw std::runtime_error("Unknown segment type");
@@ -204,16 +204,16 @@ void to_json(nlohmann::json& obj, const ProfileSegment& input) {
204204

205205
void from_json(const nlohmann::json& obj, ProfileSegment& output) {
206206
if(obj.at("type") == "line") {
207-
output = obj.at("parameters").get<Line>();
207+
output = obj.at("value").get<Line>();
208208
}
209209
else if(obj.at("type") == "arc") {
210-
output = obj.at("parameters").get<Arc>();
210+
output = obj.at("value").get<Arc>();
211211
}
212212
else if(obj.at("type") == "spiral") {
213-
output = obj.at("parameters").get<Spiral>();
213+
output = obj.at("value").get<Spiral>();
214214
}
215215
else if(obj.at("type") == "spline") {
216-
output = obj.at("parameters").get<Spline>();
216+
output = obj.at("value").get<Spline>();
217217
}
218218
else {
219219
throw std::runtime_error("Unknown segment type");
@@ -232,15 +232,15 @@ void to_json(nlohmann::json& obj, const LayerAlignment& input) {
232232
}
233233
else if(auto value = std::get_if<LayerBack>(&input)) {
234234
obj["type"] = "layer_back";
235-
obj["layer"] = value->layer;
235+
obj["value"] = value->layer;
236236
}
237237
else if(auto value = std::get_if<LayerBelly>(&input)) {
238238
obj["type"] = "layer_belly";
239-
obj["layer"] = value->layer;
239+
obj["value"] = value->layer;
240240
}
241241
else if(auto value = std::get_if<LayerCenter>(&input)) {
242242
obj["type"] = "layer_center";
243-
obj["layer"] = value->layer;
243+
obj["value"] = value->layer;
244244
}
245245
else {
246246
throw std::runtime_error("Unknown alignment type");
@@ -259,17 +259,17 @@ void from_json(const nlohmann::json& obj, LayerAlignment& output) {
259259
}
260260
else if(obj.at("type") == "layer_back") {
261261
output = LayerBack {
262-
.layer = obj.at("layer")
262+
.layer = obj.at("value")
263263
};
264264
}
265265
else if(obj.at("type") == "layer_belly") {
266266
output = LayerBelly {
267-
.layer = obj.at("layer")
267+
.layer = obj.at("value")
268268
};
269269
}
270270
else if(obj.at("type") == "layer_center") {
271271
output = LayerCenter {
272-
.layer = obj.at("layer")
272+
.layer = obj.at("value")
273273
};
274274
}
275275
else {

solver/virtualbow/data/input/valid_model.bow

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"comment": "",
44
"settings": {
55
"num_limb_elements": 30,
6-
"num_limb_eval_points": 250,
6+
"num_limb_sample_points": 250,
77
"min_draw_resolution": 100,
88
"max_draw_resolution": 100,
99
"static_iteration_tolerance": 1e-6,
@@ -30,7 +30,7 @@
3030
"segments": [
3131
{
3232
"type": "line",
33-
"parameters": {
33+
"value": {
3434
"length": 0.8
3535
}
3636
}
@@ -59,7 +59,7 @@
5959
"shear_modulus": 6000000000.0,
6060
"tensile_strength": 0.0,
6161
"compressive_strength": 0.0,
62-
"safety_margin": 0.0
62+
"margin_of_safety": 0.0
6363
}
6464
],
6565
"layers": [
@@ -82,7 +82,7 @@
8282
"string": {
8383
"strand_stiffness": 3500.0,
8484
"strand_density": 0.0005,
85-
"n_strands": 12
85+
"num_strands": 12
8686
},
8787
"masses": {
8888
"arrow": {
@@ -91,7 +91,7 @@
9191
},
9292
"limb_tip": 0.0,
9393
"string_center": 0.0,
94-
"string_tip": 0.0
94+
"string_end": 0.0
9595
},
9696
"damping": {
9797
"damping_ratio_limbs": 0.05,
3.15 KB
Binary file not shown.

solver/virtualbow/src/input/versions/latest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub struct Profile {
124124
// - Section: The profile curve is aligned with the back side, belly side, or geometrical center of the combined section
125125
// - Layer: The profile curve is aligned with the back side, belly side, or geometrical center of a specific layer
126126
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
127-
#[serde(tag = "type", content = "layer", rename_all = "snake_case")]
127+
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
128128
pub enum LayerAlignment {
129129
SectionBack,
130130
SectionBelly,
@@ -135,7 +135,7 @@ pub enum LayerAlignment {
135135
}
136136

137137
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
138-
#[serde(tag = "type", content = "parameters", rename_all = "snake_case")]
138+
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
139139
pub enum ProfileSegment {
140140
Line(Line),
141141
Arc(Arc),

solver/virtualbow_num/tests/test_09_nonlinear_beams.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn create_section(name: &str) -> impl CrossSection {
9090
}
9191
}
9292

93-
test_each_path!{ in "virtualbow_num/data/gxbeam" => simulate_and_test_beam}
93+
test_each_path!{ in "virtualbow_num/data/gxbeam" => simulate_and_test_beam }
9494

9595
fn simulate_and_test_beam(path: &Path) {
9696
// Open reference data from path

0 commit comments

Comments
 (0)