MCPcopy Create free account
hub / github.com/MITK/MITK / ReadPoint3D

Function ReadPoint3D

Modules/RESTAPI/src/mitkRenderingController.cpp:685–698  ·  view source on GitHub ↗

Read a JSON array of exactly 3 numbers into `out`. Returns nullopt on OK, or a diagnostic fragment (appended by the caller to the field name) on failure.

Source from the content-addressed store, hash-verified

683 // Read a JSON array of exactly 3 numbers into `out`. Returns nullopt on OK,
684 // or a diagnostic fragment (appended by the caller to the field name) on failure.
685 std::optional<std::string> ReadPoint3D(const nlohmann::json& arr, mitk::Point3D& out)
686 {
687 if (!arr.is_array())
688 return "must be an array of 3 numbers";
689 if (arr.size() != 3)
690 return "must have exactly 3 elements, got " + std::to_string(arr.size());
691 for (std::size_t i = 0; i < 3; ++i)
692 {
693 if (!arr[i].is_number())
694 return "element " + std::to_string(i) + " is not a number";
695 out[i] = arr[i].get<double>();
696 }
697 return std::nullopt;
698 }
699
700 std::optional<std::string> ReadVector3D(const nlohmann::json& arr, mitk::Vector3D& out)
701 {

Callers 1

ParseCameraPatchFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected