chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
13 / 136
9.6%
Branches:
16 / 44
36.4%
Functions:
3 / 44, 1 excl
6.8%

python/src/values.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #pragma once
3
4 #include <cstddef>
5 #include <cstdint>
6 #include <span>
7 #include <string>
8 #include <string_view>
9 #include <type_traits>
10 #include <vector>
11
12 #include <nanobind/nanobind.h>
13 #include <nanobind/stl/string.h>
14
15 #include "bindings.h"
16
17 namespace chrono::batch_render::python {
18
19
16/44
✗ Branch 1 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 41259 times.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 5 times.
✓ Branch 4 taken 122 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 time.
✓ Branch 15 taken 1 time.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 266 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 266 times.
✓ Branch 22 taken 41655 times.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✓ Branch 38 taken 41259 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 122 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
124965 struct ScenePrim {
20 Ref<Scene> scene;
21 Prim prim;
22 };
23
24 10 template <class T> std::vector<std::byte> Bytes(const std::vector<T>& values) {
25 10 const auto bytes = std::as_bytes(std::span(values));
26 10 return {bytes.begin(), bytes.end()};
27 }
28
29 std::vector<std::byte> NumpyBytes(nanobind::handle value, const std::string& dtype);
30 std::vector<std::string> Strings(nanobind::handle value);
31 uint32_t EnumIndex(nanobind::handle value, std::span<const std::string_view> tokens);
32
33 void Assign(bool& out, nanobind::handle value);
34 void Assign(int32_t& out, nanobind::handle value);
35 void Assign(uint32_t& out, nanobind::handle value);
36 void Assign(float& out, nanobind::handle value);
37 void Assign(Float2& out, nanobind::handle value);
38 void Assign(Uint2& out, nanobind::handle value);
39 void Assign(Float3& out, nanobind::handle value);
40 void Assign(Float4& out, nanobind::handle value);
41 void Assign(Double3& out, nanobind::handle value);
42 void Assign(Quatd& out, nanobind::handle value);
43 void Assign(std::string& out, nanobind::handle value);
44 void Assign(std::vector<std::string>& out, nanobind::handle value);
45 void Assign(std::vector<int32_t>& out, nanobind::handle value);
46 void Assign(std::vector<int64_t>& out, nanobind::handle value);
47 void Assign(std::vector<Float3>& out, nanobind::handle value);
48 void Assign(std::vector<float>& out, nanobind::handle value);
49 void Assign(std::vector<Float2>& out, nanobind::handle value);
50 void Assign(std::vector<Float4>& out, nanobind::handle value);
51 void Assign(std::vector<Primvar>& out, nanobind::handle value);
52
53 template <class E>
54 requires std::is_enum_v<E>
55 12 void Assign(E& out, nanobind::handle value, std::span<const std::string_view> tokens) {
56 12 out = E(EnumIndex(value, tokens));
57 12 }
58
59 Prim DefineSchema(Scene& scene, std::string_view path, SchemaId schema,
60 const nanobind::dict& values, const nanobind::dict& apis);
61 void ApplySchema(Scene& scene, Span<const Prim> prims, SchemaId schema, std::string_view instance,
62 const nanobind::dict& values);
63
64 }
65