amulet-core 2.0a5__cp312-cp312-win_amd64.whl → 2.0a6__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of amulet-core might be problematic. Click here for more details.

Files changed (50) hide show
  1. amulet/__init__.cp312-win_amd64.pyd +0 -0
  2. amulet/__init__.py.cpp +39 -0
  3. amulet/_version.py +3 -3
  4. amulet/biome.py.cpp +122 -0
  5. amulet/block.py.cpp +377 -0
  6. amulet/block_entity.py.cpp +115 -0
  7. amulet/chunk.py.cpp +80 -0
  8. amulet/chunk_components/biome_3d_component.cpp +5 -0
  9. amulet/chunk_components/biome_3d_component.hpp +79 -0
  10. amulet/chunk_components/block_component.cpp +41 -0
  11. amulet/chunk_components/block_component.hpp +88 -0
  12. amulet/chunk_components/block_entity_component.cpp +5 -0
  13. amulet/chunk_components/block_entity_component.hpp +147 -0
  14. amulet/chunk_components/section_array_map.cpp +129 -0
  15. amulet/chunk_components/section_array_map.hpp +147 -0
  16. amulet/collections/eq.py.hpp +37 -0
  17. amulet/collections/hash.py.hpp +27 -0
  18. amulet/collections/holder.py.hpp +37 -0
  19. amulet/collections/iterator.py.hpp +80 -0
  20. amulet/collections/mapping.py.hpp +192 -0
  21. amulet/collections/mutable_mapping.py.hpp +215 -0
  22. amulet/collections/sequence.py.hpp +164 -0
  23. amulet/img/missing_world_icon.png +0 -0
  24. amulet/io/binary_reader.hpp +45 -0
  25. amulet/io/binary_writer.hpp +30 -0
  26. amulet/level/java/_raw/java_chunk_decode.cpp +533 -0
  27. amulet/level/java/_raw/java_chunk_decode.hpp +23 -0
  28. amulet/level/java/_raw/java_chunk_encode.cpp +25 -0
  29. amulet/level/java/_raw/java_chunk_encode.hpp +23 -0
  30. amulet/level/java/chunk_components/data_version_component.cpp +32 -0
  31. amulet/level/java/chunk_components/data_version_component.hpp +31 -0
  32. amulet/level/java/chunk_components/java_raw_chunk_component.cpp +56 -0
  33. amulet/level/java/chunk_components/java_raw_chunk_component.hpp +45 -0
  34. amulet/level/java/java_chunk.cpp +170 -0
  35. amulet/level/java/java_chunk.hpp +141 -0
  36. amulet/level/java/long_array.hpp +175 -0
  37. amulet/palette/biome_palette.hpp +85 -0
  38. amulet/palette/block_palette.cpp +32 -0
  39. amulet/palette/block_palette.hpp +93 -0
  40. amulet/pybind11/collections.hpp +76 -0
  41. amulet/pybind11/py_module.hpp +69 -0
  42. amulet/pybind11/python.hpp +14 -0
  43. amulet/pybind11/types.hpp +17 -0
  44. amulet/utils/numpy.hpp +36 -0
  45. amulet/version.py.cpp +281 -0
  46. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/METADATA +2 -2
  47. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/RECORD +50 -7
  48. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/WHEEL +0 -0
  49. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/entry_points.txt +0 -0
  50. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/top_level.txt +0 -0
amulet/chunk.py.cpp ADDED
@@ -0,0 +1,80 @@
1
+ #include <amulet/chunk.hpp>
2
+
3
+ #include <pybind11/pybind11.h>
4
+ #include <pybind11/stl.h>
5
+ #include <pybind11/operators.h>
6
+ #include <pybind11/typing.h>
7
+
8
+
9
+ namespace py = pybind11;
10
+
11
+ void init_chunk(py::module m_parent) {
12
+ auto m = m_parent.def_submodule("chunk");
13
+ py::class_<Amulet::Chunk, std::shared_ptr<Amulet::Chunk>> Chunk(m, "Chunk",
14
+ "A base class for all chunk classes."
15
+ );
16
+ Chunk.def_property_readonly(
17
+ "chunk_id",
18
+ &Amulet::Chunk::get_chunk_id
19
+ );
20
+ Chunk.def_property_readonly(
21
+ "component_ids",
22
+ &Amulet::Chunk::get_component_ids
23
+ );
24
+ auto py_serialise = [](const Amulet::Chunk& self) -> py::typing::Dict<py::str, py::typing::Optional<py::bytes>> {
25
+ py::dict data;
26
+ for (const auto& [k, v] : self.serialise_chunk()) {
27
+ if (v) {
28
+ data[py::str(k)] = py::bytes(v.value());
29
+ }
30
+ else {
31
+ data[py::str(k)] = py::none();
32
+ }
33
+ }
34
+ return data;
35
+ };
36
+ Chunk.def(
37
+ "serialise_chunk",
38
+ py_serialise,
39
+ py::doc("This is private. Do not use this. It will be removed in the future.")
40
+ );
41
+ auto py_deserialise = [](Amulet::Chunk& self, py::typing::Dict<py::str, py::typing::Optional<py::bytes>> data) {
42
+ Amulet::SerialisedComponents component_data;
43
+ for (const auto& [k, v] : data) {
44
+ if (v.is(py::none())) {
45
+ component_data[k.cast<std::string>()];
46
+ }
47
+ else {
48
+ component_data[k.cast<std::string>()] = v.cast<std::string>();
49
+ }
50
+ }
51
+ self.reconstruct_chunk(component_data);
52
+ };
53
+ Chunk.def(
54
+ "reconstruct_chunk",
55
+ py_deserialise,
56
+ py::doc("This is private. Do not use this. It will be removed in the future.")
57
+ );
58
+ Chunk.def(
59
+ py::pickle(
60
+ [py_serialise](const Amulet::Chunk& self) {
61
+ return py::make_tuple(
62
+ self.get_chunk_id(),
63
+ py_serialise(self)
64
+ );
65
+ },
66
+ [py_deserialise](py::tuple state) {
67
+ if (state.size() != 2) { throw std::runtime_error("Invalid state!"); }
68
+ auto self = Amulet::get_null_chunk(state[0].cast<std::string>());
69
+ py_deserialise(*self, state[1]);
70
+ return self;
71
+ }
72
+ )
73
+ );
74
+
75
+ m.def(
76
+ "get_null_chunk",
77
+ &Amulet::get_null_chunk,
78
+ py::doc("This is a private function")
79
+ );
80
+ }
@@ -0,0 +1,5 @@
1
+ #include <amulet/chunk_components/biome_3d_component.hpp>
2
+
3
+ namespace Amulet {
4
+ const std::string Biome3DComponent::ComponentID = "Amulet::Biome3DComponent";
5
+ }
@@ -0,0 +1,79 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <tuple>
5
+ #include <optional>
6
+ #include <cstdint>
7
+ #include <memory>
8
+
9
+ #include <amulet/version.hpp>
10
+ #include <amulet/biome.hpp>
11
+ #include <amulet/palette/biome_palette.hpp>
12
+ #include <amulet/chunk_components/section_array_map.hpp>
13
+
14
+
15
+ namespace Amulet {
16
+ class Biome3DComponentData {
17
+ private:
18
+ std::shared_ptr<BiomePalette> _palette;
19
+ std::shared_ptr<SectionArrayMap> _sections;
20
+ public:
21
+ Biome3DComponentData(
22
+ std::shared_ptr<VersionRange> version_range,
23
+ const SectionShape& array_shape,
24
+ std::shared_ptr<Biome> default_biome
25
+ ):
26
+ _palette(std::make_shared<BiomePalette>(version_range)),
27
+ _sections(std::make_shared<SectionArrayMap>(array_shape, static_cast<std::uint32_t>(0)))
28
+ {
29
+ _palette->biome_to_index(default_biome);
30
+ }
31
+ std::shared_ptr<BiomePalette> get_palette() {
32
+ return _palette;
33
+ }
34
+ std::shared_ptr<SectionArrayMap> get_sections() {
35
+ return _sections;
36
+ }
37
+ };
38
+
39
+ class Biome3DComponent {
40
+ private:
41
+ std::optional<std::shared_ptr<Biome3DComponentData>> _value;
42
+ protected:
43
+ // Null constructor
44
+ Biome3DComponent() {};
45
+ // Default constructor
46
+ void init(
47
+ std::shared_ptr<VersionRange> version_range,
48
+ const SectionShape& array_shape,
49
+ std::shared_ptr<Biome> default_biome
50
+ ) { _value = std::make_shared<Biome3DComponentData>(version_range, array_shape, default_biome); }
51
+
52
+ // Serialise the component data
53
+ std::optional<std::string> serialise() const;
54
+ // Deserialise the component
55
+ void deserialise(std::optional<std::string>);
56
+ public:
57
+ static const std::string ComponentID;
58
+ std::shared_ptr<Biome3DComponentData> get_biome() {
59
+ if (_value) {
60
+ return *_value;
61
+ }
62
+ throw std::runtime_error("BiomeComponent has not been loaded.");
63
+ };
64
+ void set_biome(std::shared_ptr<Biome3DComponentData> component) {
65
+ if (_value) {
66
+ if ((*_value)->get_sections()->get_array_shape() != component->get_sections()->get_array_shape()) {
67
+ throw std::invalid_argument("New biome array shape does not match old array shape.");
68
+ }
69
+ if ((*_value)->get_palette()->get_version_range() != component->get_palette()->get_version_range()) {
70
+ throw std::invalid_argument("New biome version range does not match old version range.");
71
+ }
72
+ _value = component;
73
+ }
74
+ else {
75
+ throw std::runtime_error("BiomeComponent has not been loaded.");
76
+ }
77
+ };
78
+ };
79
+ }
@@ -0,0 +1,41 @@
1
+ #include <amulet/chunk_components/block_component.hpp>
2
+
3
+ namespace Amulet {
4
+ void BlockComponentData::serialise(BinaryWriter& writer) const {
5
+ writer.writeNumeric<std::uint8_t>(1);
6
+ get_palette()->serialise(writer);
7
+ get_sections()->serialise(writer);
8
+ }
9
+ std::shared_ptr<BlockComponentData> BlockComponentData::deserialise(BinaryReader& reader) {
10
+ auto version = reader.readNumeric<std::uint8_t>();
11
+ switch (version) {
12
+ case 1:
13
+ {
14
+ auto palette = BlockPalette::deserialise(reader);
15
+ auto sections = SectionArrayMap::deserialise(reader);
16
+ return std::make_shared<BlockComponentData>(palette, sections);
17
+ }
18
+ default:
19
+ throw std::invalid_argument("Unsupported BlockComponentData version " + std::to_string(version));
20
+ }
21
+ }
22
+
23
+ const std::string BlockComponent::ComponentID = "Amulet::BlockComponent";
24
+
25
+ std::optional<std::string> BlockComponent::serialise() const {
26
+ if (_value) {
27
+ return Amulet::serialise(**_value);
28
+ }
29
+ else {
30
+ return std::nullopt;
31
+ }
32
+ }
33
+ void BlockComponent::deserialise(std::optional<std::string> data) {
34
+ if (data) {
35
+ _value = Amulet::deserialise<BlockComponentData>(*data);
36
+ }
37
+ else {
38
+ _value = std::nullopt;
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,88 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <tuple>
5
+ #include <optional>
6
+
7
+ #include <amulet/version.hpp>
8
+ #include <amulet/block.hpp>
9
+ #include <amulet/palette/block_palette.hpp>
10
+ #include <amulet/chunk_components/section_array_map.hpp>
11
+ #include <amulet/io/binary_writer.hpp>
12
+ #include <amulet/io/binary_reader.hpp>
13
+
14
+
15
+ namespace Amulet {
16
+ class BlockComponentData {
17
+ private:
18
+ std::shared_ptr<BlockPalette> _palette;
19
+ std::shared_ptr<SectionArrayMap> _sections;
20
+ public:
21
+ BlockComponentData(
22
+ std::shared_ptr<VersionRange> version_range,
23
+ const SectionShape& array_shape,
24
+ std::shared_ptr<BlockStack> default_block
25
+ ):
26
+ _palette(std::make_shared<BlockPalette>(version_range)),
27
+ _sections(std::make_shared<SectionArrayMap>(array_shape, static_cast<std::uint32_t>(0)))
28
+ {
29
+ _palette->block_stack_to_index(default_block);
30
+ }
31
+ BlockComponentData(
32
+ std::shared_ptr<BlockPalette> palette,
33
+ std::shared_ptr<SectionArrayMap> sections
34
+ ): _palette(palette), _sections(sections){}
35
+
36
+ void serialise(BinaryWriter&) const;
37
+ static std::shared_ptr<BlockComponentData> deserialise(BinaryReader&);
38
+
39
+ std::shared_ptr<BlockPalette> get_palette() const {
40
+ return _palette;
41
+ }
42
+ std::shared_ptr<SectionArrayMap> get_sections() const {
43
+ return _sections;
44
+ }
45
+
46
+ };
47
+
48
+ class BlockComponent {
49
+ private:
50
+ std::optional<std::shared_ptr<BlockComponentData>> _value;
51
+ protected:
52
+ // Null constructor
53
+ BlockComponent() {};
54
+ // Default constructor
55
+ void init(
56
+ std::shared_ptr<VersionRange> version_range,
57
+ const SectionShape& array_shape,
58
+ std::shared_ptr<BlockStack> default_block
59
+ ) { _value = std::make_shared<BlockComponentData>(version_range, array_shape, default_block); }
60
+
61
+ // Serialise the component data
62
+ std::optional<std::string> serialise() const;
63
+ // Deserialise the component
64
+ void deserialise(std::optional<std::string>);
65
+ public:
66
+ static const std::string ComponentID;
67
+ std::shared_ptr<BlockComponentData> get_block() {
68
+ if (_value) {
69
+ return *_value;
70
+ }
71
+ throw std::runtime_error("BlockComponent has not been loaded.");
72
+ };
73
+ void set_block(std::shared_ptr<BlockComponentData> component) {
74
+ if (_value) {
75
+ if ((*_value)->get_sections()->get_array_shape() != component->get_sections()->get_array_shape()) {
76
+ throw std::invalid_argument("New block array shape does not match old array shape.");
77
+ }
78
+ if ((*_value)->get_palette()->get_version_range() != component->get_palette()->get_version_range()) {
79
+ throw std::invalid_argument("New block version range does not match old version range.");
80
+ }
81
+ _value = component;
82
+ }
83
+ else {
84
+ throw std::runtime_error("BlockComponent has not been loaded.");
85
+ }
86
+ };
87
+ };
88
+ }
@@ -0,0 +1,5 @@
1
+ #include <amulet/chunk_components/block_entity_component.hpp>
2
+
3
+ namespace Amulet {
4
+ const std::string BlockEntityComponent::ComponentID = "Amulet::BlockEntityComponent";
5
+ }
@@ -0,0 +1,147 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <tuple>
5
+ #include <optional>
6
+ #include <cstdint>
7
+ #include <memory>
8
+ #include <map>
9
+
10
+ #include <amulet/version.hpp>
11
+ #include <amulet/block_entity.hpp>
12
+
13
+
14
+ namespace Amulet {
15
+ typedef std::tuple<std::uint16_t, std::int64_t, std::uint16_t> BlockEntityChunkCoord;
16
+ class BlockEntityComponentData: public VersionRangeContainer {
17
+ private:
18
+ std::uint16_t _x_size;
19
+ std::uint16_t _z_size;
20
+ std::map<
21
+ BlockEntityChunkCoord,
22
+ std::shared_ptr<BlockEntity>
23
+ > _block_entities;
24
+ public:
25
+ BlockEntityComponentData(
26
+ std::shared_ptr<VersionRange> version_range,
27
+ const std::uint16_t& x_size,
28
+ const std::uint16_t& z_size
29
+ ) :
30
+ VersionRangeContainer(version_range),
31
+ _x_size(x_size),
32
+ _z_size(z_size),
33
+ _block_entities()
34
+ {}
35
+
36
+ std::uint16_t get_x_size() const { return _x_size; }
37
+ std::uint16_t get_z_size() const { return _z_size; }
38
+
39
+ const std::map<
40
+ BlockEntityChunkCoord,
41
+ std::shared_ptr<BlockEntity>
42
+ >& get_block_entities() const {
43
+ return _block_entities;
44
+ }
45
+
46
+ size_t get_size() const { return _block_entities.size(); }
47
+
48
+ bool contains(
49
+ const BlockEntityChunkCoord& coord
50
+ ) const {
51
+ return _block_entities.contains(coord);
52
+ }
53
+
54
+ std::shared_ptr<BlockEntity> get(
55
+ const BlockEntityChunkCoord& coord
56
+ ) const {
57
+ return _block_entities.at(coord);
58
+ }
59
+
60
+ void set(
61
+ const BlockEntityChunkCoord& coord,
62
+ std::shared_ptr<BlockEntity> block_entity
63
+ ) {
64
+ if (
65
+ std::get<0>(coord) < 0 ||
66
+ std::get<2>(coord) < 0 ||
67
+ _x_size <= std::get<0>(coord) ||
68
+ _z_size <= std::get<2>(coord)
69
+ ){
70
+ throw std::invalid_argument(
71
+ "Coord must be 0 <= " +
72
+ std::to_string(std::get<0>(coord)) +
73
+ " < " +
74
+ std::to_string(_x_size) +
75
+ "and 0 <= " +
76
+ std::to_string(std::get<1>(coord)) +
77
+ " < " +
78
+ std::to_string(_z_size)
79
+ );
80
+ }
81
+ if (!(
82
+ get_version_range()->contains(
83
+ block_entity->get_platform(),
84
+ *block_entity->get_version()
85
+ )
86
+ )){
87
+ throw std::invalid_argument(
88
+ "BlockEntity is incompatible with VersionRange."
89
+ );
90
+ }
91
+ _block_entities[coord] = block_entity;
92
+ }
93
+
94
+ void del(
95
+ const BlockEntityChunkCoord& coord
96
+ ) {
97
+ _block_entities.erase(coord);
98
+ }
99
+
100
+ };
101
+
102
+ class BlockEntityComponent {
103
+ private:
104
+ std::optional<std::shared_ptr<BlockEntityComponentData>> _value;
105
+ protected:
106
+ // Null constructor
107
+ BlockEntityComponent() {};
108
+ // Default constructor
109
+ void init(
110
+ std::shared_ptr<VersionRange> version_range,
111
+ const std::uint16_t& x_size,
112
+ const std::uint16_t& z_size
113
+ ) {
114
+ _value = std::make_shared<BlockEntityComponentData>(version_range, x_size, z_size);
115
+ }
116
+
117
+ // Serialise the component data
118
+ std::optional<std::string> serialise() const;
119
+ // Deserialise the component
120
+ void deserialise(std::optional<std::string>);
121
+ public:
122
+ static const std::string ComponentID;
123
+ std::shared_ptr<BlockEntityComponentData> get_block_entity() {
124
+ if (_value) {
125
+ return *_value;
126
+ }
127
+ throw std::runtime_error("BlockEntityComponent has not been loaded.");
128
+ };
129
+ void set_block_entity(std::shared_ptr<BlockEntityComponentData> component) {
130
+ if (_value) {
131
+ if (
132
+ (*_value)->get_x_size() != component->get_x_size() ||
133
+ (*_value)->get_z_size() != component->get_z_size()
134
+ ) {
135
+ throw std::invalid_argument("New BlockEntityComponent shape does not match old shape.");
136
+ }
137
+ if ((*_value)->get_version_range() != component->get_version_range()) {
138
+ throw std::invalid_argument("New BlockEntityComponent version range does not match old version range.");
139
+ }
140
+ _value = component;
141
+ }
142
+ else {
143
+ throw std::runtime_error("BlockEntityComponent has not been loaded.");
144
+ }
145
+ };
146
+ };
147
+ }
@@ -0,0 +1,129 @@
1
+ #include <string>
2
+
3
+ #include <amulet/io/binary_writer.hpp>
4
+ #include <amulet/io/binary_reader.hpp>
5
+
6
+ #include "section_array_map.hpp"
7
+
8
+ namespace Amulet {
9
+ void IndexArray3D::serialise(BinaryWriter& writer) const {
10
+ writer.writeNumeric<std::uint8_t>(1);
11
+
12
+ // Write array shape
13
+ const auto& array_shape = get_shape();
14
+ writer.writeNumeric<std::uint16_t>(std::get<0>(array_shape));
15
+ writer.writeNumeric<std::uint16_t>(std::get<1>(array_shape));
16
+ writer.writeNumeric<std::uint16_t>(std::get<2>(array_shape));
17
+
18
+ // Write array
19
+ const auto& size = get_size();
20
+ const auto* buffer = get_buffer();
21
+ for (auto i = 0; i < size; i++) {
22
+ writer.writeNumeric<std::uint32_t>(buffer[i]);
23
+ }
24
+ }
25
+ std::shared_ptr<IndexArray3D> IndexArray3D::deserialise(BinaryReader& reader) {
26
+ auto version = reader.readNumeric<std::uint8_t>();
27
+ switch (version) {
28
+ case 1:
29
+ {
30
+ // Read array shape
31
+ auto array_shape = std::make_tuple(
32
+ reader.readNumeric<std::uint16_t>(),
33
+ reader.readNumeric<std::uint16_t>(),
34
+ reader.readNumeric<std::uint16_t>()
35
+ );
36
+
37
+ // Construct instance
38
+ auto self = std::make_shared<IndexArray3D>(array_shape);
39
+
40
+ // Read array
41
+ const auto& size = self->get_size();
42
+ auto* buffer = self->get_buffer();
43
+ for (auto i = 0; i < size; i++) {
44
+ buffer[i] = reader.readNumeric<std::uint32_t>();
45
+ }
46
+
47
+ return self;
48
+ }
49
+ default:
50
+ throw std::invalid_argument("Unsupported IndexArray3D version " + std::to_string(version));
51
+ }
52
+ }
53
+
54
+ void SectionArrayMap::serialise(BinaryWriter& writer) const {
55
+ writer.writeNumeric<std::uint8_t>(1);
56
+
57
+ // Write array shape
58
+ const auto& array_shape = get_array_shape();
59
+ writer.writeNumeric<std::uint16_t>(std::get<0>(array_shape));
60
+ writer.writeNumeric<std::uint16_t>(std::get<1>(array_shape));
61
+ writer.writeNumeric<std::uint16_t>(std::get<2>(array_shape));
62
+
63
+ // Write default array
64
+ std::visit(
65
+ [&writer](auto&& arg) {
66
+ using T = std::decay_t<decltype(arg)>;
67
+ if constexpr (std::is_same_v<T, std::uint32_t>) {
68
+ writer.writeNumeric<std::uint8_t>(0);
69
+ writer.writeNumeric<std::uint32_t>(arg);
70
+ }
71
+ else {
72
+ writer.writeNumeric<std::uint8_t>(1);
73
+ arg->serialise(writer);
74
+ }
75
+ },
76
+ get_default_array()
77
+ );
78
+
79
+ // Write arrays
80
+ const auto& arrays = get_arrays();
81
+ writer.writeNumeric<std::uint64_t>(arrays.size());
82
+ for (const auto& [cy, arr] : arrays) {
83
+ writer.writeNumeric<std::int64_t>(cy);
84
+ arr->serialise(writer);
85
+ }
86
+ }
87
+ std::shared_ptr<SectionArrayMap> SectionArrayMap::deserialise(BinaryReader& reader) {
88
+ auto version = reader.readNumeric<std::uint8_t>();
89
+ switch (version) {
90
+ case 1:
91
+ {
92
+ // Read array shape
93
+ auto array_shape = std::make_tuple(
94
+ reader.readNumeric<std::uint16_t>(),
95
+ reader.readNumeric<std::uint16_t>(),
96
+ reader.readNumeric<std::uint16_t>()
97
+ );
98
+
99
+ // Read default array
100
+ auto default_array_state = reader.readNumeric<std::uint8_t>();
101
+ std::variant<std::uint32_t, std::shared_ptr<IndexArray3D>> default_array;
102
+ switch (default_array_state) {
103
+ case 0:
104
+ default_array = reader.readNumeric<std::uint32_t>();
105
+ break;
106
+ case 1:
107
+ default_array = IndexArray3D::deserialise(reader);
108
+ break;
109
+ default:
110
+ throw std::invalid_argument("Invalid default array state value " + std::to_string(default_array_state));
111
+ }
112
+
113
+ // Construct instance
114
+ auto self = std::make_shared<SectionArrayMap>(array_shape, default_array);
115
+
116
+ // Populate arrays
117
+ auto array_count = reader.readNumeric<std::uint64_t>();
118
+ for (auto i = 0; i < array_count; i++) {
119
+ auto cy = reader.readNumeric<std::int64_t>();
120
+ self->set_section(cy, IndexArray3D::deserialise(reader));
121
+ }
122
+
123
+ return self;
124
+ }
125
+ default:
126
+ throw std::invalid_argument("Unsupported BlockComponentData version " + std::to_string(version));
127
+ }
128
+ }
129
+ }