NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
NucMeshJson.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_NUCMESHJSON_H_
30 #define NEMOSYS_NUCMESHJSON_H_
31 
32 #include <jsoncons/json.hpp>
33 #include "Drivers/NemJsonMacros.H"
34 
35 #include "Drivers/NucMeshDriver.H"
36 
37 #include <map>
38 #include <memory>
39 #include <string>
40 #include <type_traits>
41 
43 #include "NucMesh/HexagonalArray.H"
44 #include "NucMesh/PolarArray.H"
46 #include "NucMesh/ShapeBase.H"
47 #include "NucMesh/ShapesArray.H"
48 
49 namespace NEM {
50 namespace DRV {
51 namespace JSON {
52 // primary template.
53 template <typename T>
54 struct function_traits : function_traits<decltype(&T::operator())> {};
55 
56 // function
57 template <typename R, typename... Args>
58 struct function_traits<R(Args...)> {
59  using result_type = R;
60  using argument_types = std::tuple<Args...>;
61 };
62 
63 // function pointers
64 template <typename R, typename... Args>
65 struct function_traits<R (*)(Args...)> {
66  using result_type = R;
67  using argument_types = std::tuple<Args...>;
68 };
69 
70 // member functions
71 template <typename T, typename R, typename... Args>
72 struct function_traits<R (T::*)(Args...)> {
73  using result_type = R;
74  using argument_types = std::tuple<Args...>;
75 };
76 
77 template <typename T>
78 using first_argument_type = typename std::tuple_element<
80 
81 static constexpr auto shapeType = "Type";
82 static constexpr auto arrayPattern = "Pattern";
83 static constexpr auto arrayShapes = "Shapes";
84 
85 template <typename T, typename R, typename... Args>
86 void setter_helper(T &obj, R (T::*setter)(Args...), const jsoncons::json &json,
87  jsoncons::string_view key, bool checkContains) {
88  if (json.contains(key)) {
89  (obj.*setter)(json.at(key)
90  .as<typename std::decay<
92  } else if (checkContains) {
93  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
94  "Not a NEM::NUCMESH::ShapeBase");
95  }
96 }
97 
98 template <typename T>
99 std::unique_ptr<NEM::NUCMESH::ShapeBase> construct_helper(
100  const jsoncons::json &json,
101  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
102  &savedShapes);
103 
104 inline std::unique_ptr<NEM::NUCMESH::ShapeBase> as_shape(
105  const jsoncons::json &json,
106  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
107  &savedShapes);
108 
109 template <typename T>
110 typename std::enable_if<std::is_base_of<NEM::NUCMESH::ShapeBase, T>::value,
111  void>::type
113  const jsoncons::json &json, T &shape,
114  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
115  &savedShapes,
116  bool checkRequired) {}
117 
118 template <>
120  const jsoncons::json &json, NEM::NUCMESH::ShapeBase &shape,
121  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>> &,
122  bool) {
123  if (json.contains("Center")) {
124  auto centerSize = json.at("Center").array_value().size();
125  if (centerSize == 3) {
126  shape.setCenter(json.at("Center").as<std::array<double, 3>>());
127  } else if (centerSize == 5) {
128  auto center = json.at("Center").as<std::array<double, 5>>();
130  {center[0], center[1], center[2]}, {center[3], center[4]}));
131  }
132  }
133 }
134 
135 template <>
137  const jsoncons::json &json, NEM::NUCMESH::Circles &shape,
138  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
139  &savedShapes,
140  bool checkRequired) {
141  setter_helper(shape, &NEM::NUCMESH::Circles::setRings, json, "Rings",
142  checkRequired);
143  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapeBase &>(shape),
144  savedShapes, checkRequired);
145 }
146 
147 template <>
148 std::unique_ptr<NEM::NUCMESH::ShapeBase>
149 construct_helper<NEM::NUCMESH::Circles>(
150  const jsoncons::json &json,
151  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
152  &savedShapes) {
153  auto shape = new NEM::NUCMESH::Circles{{}};
154  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
155  modify_helper(json, *shape, savedShapes, true);
156  return out;
157 }
158 
159 template <>
161  const jsoncons::json &json, NEM::NUCMESH::CirclesAndPolys &shape,
162  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
163  &savedShapes,
164  bool checkRequired) {
166  "Number of Sides", checkRequired);
168  checkRequired);
169  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapeBase &>(shape),
170  savedShapes, checkRequired);
171 }
172 
173 template <>
174 std::unique_ptr<NEM::NUCMESH::ShapeBase>
175 construct_helper<NEM::NUCMESH::CirclesAndPolys>(
176  const jsoncons::json &json,
177  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
178  &savedShapes) {
179  auto shape = new NEM::NUCMESH::CirclesAndPolys{{}, {}};
180  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
181  modify_helper(json, *shape, savedShapes, true);
182  return out;
183 }
184 
185 template <>
187  const jsoncons::json &json, NEM::NUCMESH::ShapesArray &shape,
188  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
189  &savedShapes,
190  bool checkRequired) {
191  if (json.contains(arrayShapes) && json.at(arrayShapes).is_array()) {
192  std::size_t idx = 0;
193  for (auto &shapeJson : json.at(arrayShapes).array_range()) {
194  shape.setPatternShape(idx, as_shape(shapeJson, savedShapes));
195  ++idx;
196  }
197  for (; idx < shape.getNumPatternShapes(); ++idx) {
198  shape.setPatternShape(idx, nullptr);
199  }
200  } else if (checkRequired) {
201  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
202  "Not a NEM::NUCMESH::ShapesArray");
203  }
204  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapeBase &>(shape),
205  savedShapes, checkRequired);
206 }
207 
208 template <>
210  const jsoncons::json &json, NEM::NUCMESH::PolarArray &shape,
211  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
212  &savedShapes,
213  bool checkRequired) {
214  setter_helper(shape, &NEM::NUCMESH::PolarArray::setRadius, json, "Radius",
215  checkRequired);
217  "Start Angle", checkRequired);
219  "End Angle", checkRequired);
221  "Rotate with Array", false);
222  if (json.contains(arrayPattern)) {
223  auto patternIdJson = json.at(arrayPattern).array_value();
224  if (!patternIdJson.empty()) {
225  auto patternIdIter = patternIdJson.begin();
226  const auto patternIdEnd = patternIdJson.end();
227  for (std::size_t patternIdx = 0; patternIdx < shape.getNumSubshapes();
228  ++patternIdx) {
229  shape.setPattern(patternIdx, patternIdIter->as<std::size_t>());
230  ++patternIdIter;
231  if (patternIdIter == patternIdEnd) {
232  patternIdIter = patternIdJson.begin();
233  }
234  }
235  }
236  } else if (checkRequired) {
237  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
238  "Not a NEM::NUCMESH::PolarArray");
239  }
240  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapesArray &>(shape),
241  savedShapes, checkRequired);
242 }
243 
244 template <>
245 std::unique_ptr<NEM::NUCMESH::ShapeBase>
246 construct_helper<NEM::NUCMESH::PolarArray>(
247  const jsoncons::json &json,
248  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
249  &savedShapes) {
250  auto shape = new NEM::NUCMESH::PolarArray{
251  json.at("Pattern").array_value().size(), {}, {}, {}};
252  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
253  modify_helper(json, *shape, savedShapes, true);
254  return out;
255 }
256 
257 template <>
259  const jsoncons::json &json, NEM::NUCMESH::RectangularArray &shape,
260  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
261  &savedShapes,
262  bool checkRequired) {
264  "Grid Distance", checkRequired);
265  if (json.contains(arrayPattern)) {
266  const auto gridSize = shape.getGridDims();
267  auto y = gridSize[1] - 1;
268  for (auto &patternRow : json.at(arrayPattern).array_range()) {
269  std::size_t x = 0;
270  for (auto &patternJson : patternRow.array_range()) {
271  shape.setPattern(x, y, patternJson.as<std::size_t>());
272  ++x;
273  }
274  --y;
275  }
276  } else if (checkRequired) {
277  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
278  "Not a NEM::NUCMESH::RectangularArray");
279  }
280  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapesArray &>(shape),
281  savedShapes, checkRequired);
282 }
283 
284 template <>
285 std::unique_ptr<NEM::NUCMESH::ShapeBase>
286 construct_helper<NEM::NUCMESH::RectangularArray>(
287  const jsoncons::json &json,
288  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
289  &savedShapes) {
290  auto patternJson = json.at("Pattern").array_value();
291  auto shape = new NEM::NUCMESH::RectangularArray{
292  {patternJson[0].size(), patternJson.size()}, {}};
293  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
294  modify_helper(json, *shape, savedShapes, true);
295  return out;
296 }
297 
298 template <>
300  const jsoncons::json &json, NEM::NUCMESH::HexagonalArray &shape,
301  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
302  &savedShapes,
303  bool checkRequired) {
305  "Grid Distance", checkRequired);
306  if (json.contains(arrayPattern)) {
307  int x = 0;
308  for (auto &patternRow : json.at(arrayPattern).array_range()) {
309  int y = 0;
310  for (auto &patternJson : patternRow.array_range()) {
311  shape.setPatternRowCol(x, y, patternJson.as<std::size_t>());
312  ++y;
313  }
314  ++x;
315  }
316  } else if (checkRequired) {
317  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
318  "Not a NEM::NUCMESH::HexagonalArray");
319  }
320  modify_helper(json, dynamic_cast<NEM::NUCMESH::ShapesArray &>(shape),
321  savedShapes, checkRequired);
322 }
323 
324 template <>
325 std::unique_ptr<NEM::NUCMESH::ShapeBase>
326 construct_helper<NEM::NUCMESH::HexagonalArray>(
327  const jsoncons::json &json,
328  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
329  &savedShapes) {
330  auto shape = new NEM::NUCMESH::HexagonalArray{
331  json.at("Pattern").array_value()[0].size(), {}};
332  std::unique_ptr<NEM::NUCMESH::ShapeBase> out{shape};
333  modify_helper(json, *shape, savedShapes, true);
334  return out;
335 }
336 
337 template <typename T>
338 std::unique_ptr<NEM::NUCMESH::ShapeBase> construct_from_alias_helper(
339  const jsoncons::json &json, const T *const aliasShape,
340  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
341  &savedShapes) {
342  auto output = new T{*aliasShape};
343  modify_helper(json, *output, savedShapes, false);
344  return std::unique_ptr<NEM::NUCMESH::ShapeBase>{output};
345 }
346 
347 inline std::unique_ptr<NEM::NUCMESH::ShapeBase> construct_from_alias(
348  const jsoncons::json &json, const NEM::NUCMESH::ShapeBase *const aliasShape,
349  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
350  &savedShapes) {
351  if (auto circles = dynamic_cast<const NEM::NUCMESH::Circles *>(aliasShape)) {
352  return construct_from_alias_helper(json, circles, savedShapes);
353  } else if (auto circlesAndPolys =
354  dynamic_cast<const NEM::NUCMESH::CirclesAndPolys *>(
355  aliasShape)) {
356  return construct_from_alias_helper(json, circlesAndPolys, savedShapes);
357  } else if (auto polar =
358  dynamic_cast<const NEM::NUCMESH::PolarArray *>(aliasShape)) {
359  return construct_from_alias_helper(json, polar, savedShapes);
360  } else if (auto rect = dynamic_cast<const NEM::NUCMESH::RectangularArray *>(
361  aliasShape)) {
362  return construct_from_alias_helper(json, rect, savedShapes);
363  } else if (auto hex = dynamic_cast<const NEM::NUCMESH::HexagonalArray *>(
364  aliasShape)) {
365  return construct_from_alias_helper(json, hex, savedShapes);
366  }
367  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
368  "Not a NEM::NUCMESH::ShapeBase");
369 }
370 
371 inline std::unique_ptr<NEM::NUCMESH::ShapeBase> as_shape(
372  const jsoncons::json &json,
373  const std::map<std::string, std::unique_ptr<NEM::NUCMESH::ShapeBase>>
374  &savedShapes) {
375  if (json.is_null()) {
376  return nullptr;
377  }
378  static constexpr auto loadSavedStr = "Saved Object";
379  if (json.contains(loadSavedStr)) {
380  auto findIter = savedShapes.find(json.at(loadSavedStr).as_string());
381  if (findIter != savedShapes.end() && findIter->second) {
382  return construct_from_alias(json, findIter->second.get(), savedShapes);
383  }
384  }
385  static constexpr auto typeStr = "Type";
386  if (json.contains(typeStr)) {
387  auto jsonType = json.at(typeStr).as_string_view();
388  if (jsonType == "Circles") {
389  return construct_helper<NEM::NUCMESH::Circles>(json, savedShapes);
390  } else if (jsonType == "Circles And Polys") {
391  return construct_helper<NEM::NUCMESH::CirclesAndPolys>(json, savedShapes);
392  } else if (jsonType == "Polar Array") {
393  return construct_helper<NEM::NUCMESH::PolarArray>(json, savedShapes);
394  } else if (jsonType == "Rectangular Array") {
395  return construct_helper<NEM::NUCMESH::RectangularArray>(json,
396  savedShapes);
397  } else if (jsonType == "Hexagonal Array") {
398  return construct_helper<NEM::NUCMESH::HexagonalArray>(json, savedShapes);
399  }
400  }
401  throw jsoncons::convert_error(jsoncons::convert_errc::conversion_failed,
402  "Not a NEM::NUCMESH::ShapeBase");
403 }
404 
405 } // namespace JSON
406 } // namespace DRV
407 } // namespace NEM
408 
411  (getFiles, setFiles, NEM::DRV::JSON::meshFiles),
412  (getOpts, setOpts, "NucMesh Options"),
414  [](const jsoncons::string_view &x) {
416  }))
417 
418 JSONCONS_ENUM_NAME_TRAITS(NEM::NUCMESH::RingMeshOption::MeshingType, (TRI, "T"),
419  (QUAD, "Q"), (STRUCT, "S"))
420 
421 JSONCONS_ENUM_NAME_TRAITS(NEM::NUCMESH::PolyRing::ShapeType, (CIRCLE, "Circle"),
422  (POLYGON, "Poly"))
423 
424 namespace jsoncons {
425 template <typename Json>
426 struct json_type_traits<Json, NEM::NUCMESH::RingMeshOption> {
427  using value_type = NEM::NUCMESH::RingMeshOption;
428  using allocator_type = typename Json::allocator_type;
429  using char_type = typename Json::char_type;
430  using string_view_type = typename Json::string_view_type;
431  static constexpr auto meshingTypeStr = "Type";
432  static constexpr auto elemsStr = "Number of Elems";
433  static bool is(const Json &ajson) noexcept {
434  if (!ajson.is_object()) return false;
435  if (!ajson.contains(meshingTypeStr)) return false;
436  return true;
437  }
438  static value_type as(const Json &ajson) {
439  using namespace NEM::NUCMESH;
440  using namespace NEM::DRV::JSON;
441  if (!is(ajson))
442  throw convert_error(convert_errc::conversion_failed,
443  "Not a NEM::NUCMESH::RingMeshOption");
444  auto meshingType =
445  ajson.at(meshingTypeStr).template as<RingMeshOption::MeshingType>();
446  switch (meshingType) {
447  case RingMeshOption::MeshingType::TRI:
448  return RingMeshOption::ApplyTriMesh();
450  return RingMeshOption::ApplyQuadMesh();
451  case RingMeshOption::MeshingType::STRUCT:
452  if (ajson.contains(elemsStr)) {
453  return RingMeshOption::ApplyStructuredMesh(
454  ajson.at(elemsStr)
455  .template as<std::decay<first_argument_type<
456  decltype(RingMeshOption::ApplyStructuredMesh)>>::type>());
457  }
458  }
459  throw convert_error(convert_errc::conversion_failed,
460  "Not a NEM::NUCMESH::RingMeshOption");
461  }
462 };
463 template <>
464 struct is_json_type_traits_declared<NEM::NUCMESH::RingMeshOption>
465  : public std::true_type {};
466 
467 template <typename Json>
468 struct json_type_traits<Json, NEM::NUCMESH::Ring> {
469  using value_type = NEM::NUCMESH::Ring;
470  using allocator_type = typename Json::allocator_type;
471  using char_type = typename Json::char_type;
472  using string_view_type = typename Json::string_view_type;
473  static constexpr auto radiusStr = "Radius";
474  static constexpr auto meshTypeStr = "Mesh";
475  static constexpr auto materialStr = "Material";
476  static constexpr auto sidesetStr = "Sideset";
477  static bool is(const Json &ajson) noexcept {
478  return ajson.is_object() && ajson.contains(radiusStr) &&
479  ajson.contains(meshTypeStr);
480  }
481  static value_type as(const Json &ajson) {
482  if (!is(ajson))
483  throw convert_error(convert_errc::conversion_failed,
484  "Not a NEM::NUCMESH::Ring");
485  value_type aval(
486  ajson.at(radiusStr).template as<decltype(value_type::radius)>(),
487  ajson.at(meshTypeStr).template as<decltype(value_type::meshType)>());
488  if (ajson.contains(materialStr)) {
489  jsoncons::json_traits_helper<Json>::set_udt_member(ajson, materialStr,
490  aval.material);
491  }
492  if (ajson.contains(sidesetStr)) {
493  jsoncons::json_traits_helper<Json>::set_udt_member(ajson, sidesetStr,
494  aval.sideset);
495  }
496  return aval;
497  }
498 };
499 template <>
500 struct is_json_type_traits_declared<NEM::NUCMESH::Ring>
501  : public std::true_type {};
502 
503 template <typename Json>
504 struct json_type_traits<Json, NEM::NUCMESH::PolyRing> {
505  using value_type = NEM::NUCMESH::PolyRing;
506  using allocator_type = typename Json::allocator_type;
507  using char_type = typename Json::char_type;
508  using string_view_type = typename Json::string_view_type;
509  static constexpr auto radiusStr =
510  json_type_traits<Json, NEM::NUCMESH::Ring>::radiusStr;
511  static constexpr auto meshTypeStr =
512  json_type_traits<Json, NEM::NUCMESH::Ring>::meshTypeStr;
513  static constexpr auto materialStr =
514  json_type_traits<Json, NEM::NUCMESH::Ring>::materialStr;
515  static constexpr auto sidesetStr =
516  json_type_traits<Json, NEM::NUCMESH::Ring>::sidesetStr;
517  static constexpr auto shapeTypeStr = "Shape Type";
518  static constexpr auto rotationStr = "Rotation";
519  static bool is(const Json &ajson) noexcept {
520  return ajson.template is<NEM::NUCMESH::Ring>() &&
521  ajson.contains(meshTypeStr);
522  }
523  static value_type as(const Json &ajson) {
524  if (!is(ajson))
525  throw convert_error(convert_errc::conversion_failed,
526  "Not a NEM::NUCMESH::PolyRing");
527  value_type aval(
528  ajson.at(shapeTypeStr).template as<decltype(value_type::shapeType)>(),
529  ajson.at(radiusStr).template as<decltype(value_type::radius)>(),
530  ajson.at(meshTypeStr).template as<decltype(value_type::meshType)>());
531  if (ajson.contains(rotationStr)) {
532  jsoncons::json_traits_helper<Json>::set_udt_member(ajson, rotationStr,
533  aval.rotation);
534  }
535  if (ajson.contains(materialStr)) {
536  jsoncons::json_traits_helper<Json>::set_udt_member(ajson, materialStr,
537  aval.material);
538  }
539  if (ajson.contains(sidesetStr)) {
540  jsoncons::json_traits_helper<Json>::set_udt_member(ajson, sidesetStr,
541  aval.sideset);
542  }
543  return aval;
544  }
545 };
546 template <>
547 struct is_json_type_traits_declared<NEM::NUCMESH::PolyRing>
548  : public std::true_type {};
549 
550 template <>
551 struct json_type_traits<json, NEM::DRV::NucMeshDriver::Opts> {
552  using Json = json;
553  using value_type = NEM::DRV::NucMeshDriver::Opts;
554  constexpr static auto savedObjectStr = "Saved Objects";
555  constexpr static auto savedObjectNameStr = "Name";
556  constexpr static auto extrudeStr = "Extrude";
557  static bool is(const Json &ajson) noexcept {
558  if (!ajson.contains(NEM::DRV::JSON::arrayShapes) ||
559  !ajson.at(NEM::DRV::JSON::arrayShapes).is_array())
560  return false;
561  if (ajson.contains(savedObjectStr) && !ajson.at(savedObjectStr).is_array())
562  return false;
563  return true;
564  }
565  static value_type as(const Json &ajson) {
566  using namespace NEM::DRV;
567  using namespace NEM::NUCMESH;
568  if (!is(ajson))
569  throw convert_error(convert_errc::conversion_failed,
570  "Not a NEM::DRV::NucMeshDriver::Opts");
571  std::map<std::string, std::unique_ptr<ShapeBase>> savedObjects;
572  if (ajson.contains(savedObjectStr)) {
573  auto &savedObjectsJson = ajson.at(savedObjectStr);
574  for (auto &savedObjectJson : savedObjectsJson.array_range()) {
575  if (savedObjectJson.contains(savedObjectNameStr)) {
576  savedObjects.emplace(
577  savedObjectJson.at(savedObjectNameStr).as_string_view(),
578  JSON::as_shape(savedObjectJson, savedObjects));
579  } else {
580  throw convert_error(convert_errc::conversion_failed,
581  "Not a NEM::DRV::NucMeshDriver");
582  }
583  }
584  }
585  value_type aval{};
586  for (auto &shape : ajson.at(JSON::arrayShapes).array_range()) {
587  aval.geometryAndMesh.emplace_back(JSON::as_shape(shape, savedObjects));
588  }
589  if (ajson.contains(extrudeStr)) {
590  json_traits_helper<Json>::set_udt_member(ajson, extrudeStr,
591  aval.extrudeSteps);
592  }
593  return aval;
594  }
595 };
596 template <>
597 struct is_json_type_traits_declared<NEM::DRV::NucMeshDriver::Opts>
598  : public std::true_type {};
599 } // namespace jsoncons
600 
601 #endif // NEMOSYS_NUCMESHJSON_H_
void setEndAngle(double endAngle)
Definition: PolarArray.H:64
typename std::tuple_element< 0, typename function_traits< T >::argument_types >::type first_argument_type
Definition: NucMeshJson.H:79
base class for drivers
Definition: NemDriver.H:46
const std::array< std::size_t, 2 > & getGridDims() const
void setPatternRowCol(int row, int col, std::size_t patternKey)
void setRings(std::vector< Ring > rings)
std::size_t getNumPatternShapes() const
Definition: ShapesArray.C:45
std::enable_if< std::is_base_of< NEM::NUCMESH::ShapeBase, T >::value, void >::type modify_helper(const jsoncons::json &json, T &shape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes, bool checkRequired)
Definition: NucMeshJson.H:112
Arrange a series of other ShapeBase objects along a circular arc.
Definition: PolarArray.H:43
void setGridDistance(const std::array< double, 2 > &gridDistance)
QUAD
Definition: exoMesh.H:55
std::unique_ptr< NEM::NUCMESH::ShapeBase > construct_from_alias_helper(const jsoncons::json &json, const T *const aliasShape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
Definition: NucMeshJson.H:338
void setRotateWithArray(bool rotateWithArray)
Definition: PolarArray.H:66
static constexpr auto shapeType
Definition: NucMeshJson.H:81
void setNumSides(int numSides)
static std::array< double, 3 > getRotatedPoint(const std::array< double, 3 > &center, const std::array< double, 2 > &rotation)
Definition: ShapeBase.C:58
void setPatternShape(std::size_t idx, const std::shared_ptr< ShapeBase > &shape)
Definition: ShapesArray.C:57
#define NEM_JSON_N_GETTER_SETTER_NAME_TRAITS_FINAL(ValueType, ParentType, NumMandatoryParams,...)
Abstract base class for types that create NEM::GEO::GeoManager.
Definition: ShapeBase.H:52
std::unique_ptr< NEM::NUCMESH::ShapeBase > construct_helper(const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
std::unique_ptr< NEM::NUCMESH::ShapeBase > as_shape(const jsoncons::json &json, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
Definition: NucMeshJson.H:371
void setGridDistance(double gridDistance)
static constexpr auto arrayShapes
Definition: NucMeshJson.H:83
static constexpr auto arrayPattern
Definition: NucMeshJson.H:82
void setCenter(const std::array< double, 3 > &center)
Definition: ShapeBase.C:52
void setRings(std::vector< PolyRing > rings)
static constexpr const char * programType
std::unique_ptr< NEM::NUCMESH::ShapeBase > construct_from_alias(const jsoncons::json &json, const NEM::NUCMESH::ShapeBase *const aliasShape, const std::map< std::string, std::unique_ptr< NEM::NUCMESH::ShapeBase >> &savedShapes)
Definition: NucMeshJson.H:347
NEM::SRV::NucMeshConf Opts
Definition: NucMeshDriver.H:54
void setRadius(double radius)
Definition: PolarArray.H:60
void setter_helper(T &obj, R(T::*setter)(Args...), const jsoncons::json &json, jsoncons::string_view key, bool checkContains)
Definition: NucMeshJson.H:86
A set of concentric circles and polygons and the faces they enclose.
static constexpr auto programType
void setPattern(std::size_t x, std::size_t y, std::size_t patternKey)
The shape at [x, y] will be translated by [(x - (getGridDims()[0] - 1) / 2) * getGridDistance()[0]...
Abstract base class representing a set of other ShapeBase objects, with a transformation applied to e...
Definition: ShapesArray.H:52
Class to create 2d geometry from polygons and circles and mesh it.
Definition: NucMeshDriver.H:50
void setStartAngle(double startAngle)
Definition: PolarArray.H:62
static constexpr auto meshFiles
std::size_t getNumSubshapes() const
Definition: PolarArray.H:58
#define NEM_JSON_RDONLY_OVERRIDE(X)
Definition: NemJsonMacros.H:39
A set of concentric circles and the faces they enclose.
void setPattern(std::size_t idx, std::size_t patternKey)
Definition: ShapesArray.C:77