pye57 0.3.1__cp310-cp310-win_amd64.whl → 0.4.2__cp310-cp310-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 pye57 might be problematic. Click here for more details.

pye57/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.3.1"
1
+ __version__ = "0.4.2"
pye57/e57.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import uuid
2
2
  import os
3
-
4
3
  from typing import Dict
4
+ from enum import Enum
5
5
 
6
6
  import numpy as np
7
7
  from pyquaternion import Quaternion
@@ -9,6 +9,7 @@ from pyquaternion import Quaternion
9
9
  from pye57.__version__ import __version__
10
10
  from pye57 import libe57
11
11
  from pye57 import ScanHeader
12
+ from pye57.utils import convert_spherical_to_cartesian
12
13
 
13
14
  try:
14
15
  from exceptions import WindowsError
@@ -16,10 +17,26 @@ except ImportError:
16
17
  class WindowsError(OSError):
17
18
  pass
18
19
 
19
- SUPPORTED_POINT_FIELDS = {
20
+
21
+ SUPPORTED_CARTESIAN_POINT_FIELDS = {
20
22
  "cartesianX": "d",
21
23
  "cartesianY": "d",
22
24
  "cartesianZ": "d",
25
+ }
26
+
27
+ SUPPORTED_SPHERICAL_POINT_FIELDS = {
28
+ "sphericalRange": "d",
29
+ "sphericalAzimuth": "d",
30
+ "sphericalElevation": "d",
31
+ }
32
+
33
+ class COORDINATE_SYSTEMS(Enum):
34
+ CARTESIAN = SUPPORTED_CARTESIAN_POINT_FIELDS
35
+ SPHERICAL = SUPPORTED_SPHERICAL_POINT_FIELDS
36
+
37
+ SUPPORTED_POINT_FIELDS = {
38
+ **SUPPORTED_CARTESIAN_POINT_FIELDS,
39
+ **SUPPORTED_SPHERICAL_POINT_FIELDS,
23
40
  "intensity": "f",
24
41
  "colorRed": "B",
25
42
  "colorGreen": "B",
@@ -27,6 +44,7 @@ SUPPORTED_POINT_FIELDS = {
27
44
  "rowIndex": "H",
28
45
  "columnIndex": "H",
29
46
  "cartesianInvalidState": "b",
47
+ "sphericalInvalidState": "b",
30
48
  }
31
49
 
32
50
 
@@ -147,7 +165,13 @@ class E57:
147
165
  header = self.get_header(index)
148
166
  n_points = header.point_count
149
167
 
150
- fields = ["cartesianX", "cartesianY", "cartesianZ"]
168
+ coordinate_system = header.get_coordinate_system(COORDINATE_SYSTEMS)
169
+ if coordinate_system is COORDINATE_SYSTEMS.CARTESIAN:
170
+ validState = "cartesianInvalidState"
171
+ fields = list(SUPPORTED_CARTESIAN_POINT_FIELDS.keys())
172
+ elif coordinate_system is COORDINATE_SYSTEMS.SPHERICAL:
173
+ validState = "sphericalInvalidState"
174
+ fields = list(SUPPORTED_SPHERICAL_POINT_FIELDS.keys())
151
175
  if intensity:
152
176
  fields.append("intensity")
153
177
  if colors:
@@ -157,7 +181,7 @@ class E57:
157
181
  if row_column:
158
182
  fields.append("rowIndex")
159
183
  fields.append("columnIndex")
160
- fields.append("cartesianInvalidState")
184
+ fields.append(validState)
161
185
 
162
186
  for field in fields[:]:
163
187
  if field not in header.point_fields:
@@ -170,22 +194,27 @@ class E57:
170
194
  data, buffers = self.make_buffers(fields, n_points)
171
195
  header.points.reader(buffers).read()
172
196
 
173
- if "cartesianInvalidState" in data.keys():
174
- valid = ~data["cartesianInvalidState"].astype("?")
197
+ if validState in data:
198
+ valid = ~data[validState].astype("?")
175
199
 
176
200
  for field in data:
177
201
  data[field] = data[field][valid]
178
202
 
179
- del data["cartesianInvalidState"]
203
+ del data[validState]
180
204
 
181
205
  if transform:
182
- xyz = np.array([data["cartesianX"], data["cartesianY"], data["cartesianZ"]]).T
206
+ if coordinate_system is COORDINATE_SYSTEMS.CARTESIAN:
207
+ xyz = np.array([data["cartesianX"], data["cartesianY"], data["cartesianZ"]]).T
208
+ elif coordinate_system is COORDINATE_SYSTEMS.SPHERICAL:
209
+ rae = np.array([data["sphericalRange"], data["sphericalAzimuth"], data["sphericalElevation"]]).T
210
+ # rae to xyz
211
+ xyz = convert_spherical_to_cartesian(rae)
212
+ # translation to global coordinates
183
213
  if header.has_pose():
184
214
  xyz = self.to_global(xyz, header.rotation, header.translation)
185
215
  data["cartesianX"] = xyz[:, 0]
186
216
  data["cartesianY"] = xyz[:, 1]
187
217
  data["cartesianZ"] = xyz[:, 2]
188
-
189
218
  return data
190
219
 
191
220
  def write_scan_raw(self, data: Dict, *, name=None, rotation=None, translation=None, scan_header=None):
@@ -194,7 +223,7 @@ class E57:
194
223
  raise ValueError("Unsupported point field: %s" % field)
195
224
 
196
225
  if rotation is None:
197
- rotation = getattr(scan_header, "rotation", np.array([0, 0, 0, 0]))
226
+ rotation = getattr(scan_header, "rotation", np.array([1, 0, 0, 0]))
198
227
 
199
228
  if translation is None:
200
229
  translation = getattr(scan_header, "translation", np.array([0, 0, 0]))
Binary file
pye57/scan_header.py CHANGED
@@ -4,7 +4,6 @@ from pyquaternion import Quaternion
4
4
  from pye57 import libe57
5
5
  from pye57.utils import get_fields, get_node
6
6
 
7
-
8
7
  class ScanHeader:
9
8
  def __init__(self, scan_node):
10
9
  self.node = scan_node
@@ -53,6 +52,15 @@ class ScanHeader:
53
52
 
54
53
  def __getitem__(self, item):
55
54
  return self.node[item]
55
+
56
+ def get_coordinate_system(self, COORDINATE_SYSTEMS):
57
+ if all(x in self.point_fields for x in COORDINATE_SYSTEMS.CARTESIAN.value):
58
+ coordinate_system = COORDINATE_SYSTEMS.CARTESIAN
59
+ elif all(x in self.point_fields for x in COORDINATE_SYSTEMS.SPHERICAL.value):
60
+ coordinate_system = COORDINATE_SYSTEMS.SPHERICAL
61
+ else:
62
+ raise Exception(f"Scans coordinate system not supported, unsupported point field {self.point_fields}")
63
+ return coordinate_system
56
64
 
57
65
  @property
58
66
  def guid(self):
@@ -138,6 +146,34 @@ class ScanHeader:
138
146
  def zMaximum(self):
139
147
  return self.cartesianBounds["zMaximum"].value()
140
148
 
149
+ @property
150
+ def sphericalBounds(self):
151
+ return self["sphericalBounds"]
152
+
153
+ @property
154
+ def rangeMinimum(self):
155
+ return self.sphericalBounds["rangeMinimum"].value()
156
+
157
+ @property
158
+ def rangeMaximum(self):
159
+ return self.sphericalBounds["rangeMaximum"].value()
160
+
161
+ @property
162
+ def elevationMinimum(self):
163
+ return self.sphericalBounds["elevationMinimum"].value()
164
+
165
+ @property
166
+ def elevationMaximum(self):
167
+ return self.sphericalBounds["elevationMaximum"].value()
168
+
169
+ @property
170
+ def azimuthStart(self):
171
+ return self.sphericalBounds["azimuthStart"].value()
172
+
173
+ @property
174
+ def azimuthEnd(self):
175
+ return self.sphericalBounds["azimuthEnd"].value()
176
+
141
177
  @property
142
178
  def pose(self):
143
179
  return self["pose"]
pye57/utils.py CHANGED
@@ -1,6 +1,9 @@
1
+ from typing import Type
2
+
1
3
  from pye57 import libe57
2
4
  from pye57.libe57 import NodeType
3
5
 
6
+ import numpy as np
4
7
 
5
8
  def get_fields(node):
6
9
  return [node.get(id_).elementName() for id_ in range(node.childCount())]
@@ -19,3 +22,21 @@ def get_node(node, name):
19
22
  }
20
23
  n = node.get(name)
21
24
  return cast[n.type()](n)
25
+
26
+ def convert_spherical_to_cartesian(rae):
27
+ """
28
+ Converts spherical(rae) to cartesian(xyz), where rae = range, azimuth(theta),
29
+ elevation(phi). Where range is in meters and angles are in radians.
30
+
31
+ Reference for formula: http://www.libe57.org/bestCoordinates.html (Note: the
32
+ formula is different from the one online, so please use formula at the above reference)
33
+ """
34
+ range_ = rae[:, :1]
35
+ theta = rae[:, 1:2]
36
+ phi = rae[:, 2:3]
37
+ range_cos_phi = range_ * np.cos(phi)
38
+ return np.concatenate((
39
+ range_cos_phi * np.cos(theta),
40
+ range_cos_phi * np.sin(theta),
41
+ range_ * np.sin(phi)
42
+ ), axis=1)
pye57/xerces-c_3_2.dll CHANGED
Binary file
@@ -1,144 +1,142 @@
1
- Metadata-Version: 2.1
2
- Name: pye57
3
- Version: 0.3.1
4
- Summary: Python .e57 files reader/writer
5
- Home-page: https://www.github.com/davidcaron/pye57
6
- Author: David Caron
7
- Author-email: dcaron05@gmail.com
8
- License: MIT
9
- Platform: UNKNOWN
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.7
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: Implementation :: CPython
18
- Requires-Python: >=3.7
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: numpy
22
- Requires-Dist: pyquaternion
23
- Provides-Extra: test
24
- Requires-Dist: pytest ; extra == 'test'
25
-
26
-
27
- # pye57
28
-
29
- [![PyPI](https://img.shields.io/pypi/v/pye57.svg)](https://pypi.org/project/pye57)
30
- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pye57.svg)](https://pypi.org/project/pye57)
31
- ![GitHub](https://img.shields.io/github/workflow/status/davidcaron/pye57/build)
32
-
33
- Python wrapper of [LibE57Format](https://github.com/asmaloney/libE57Format) to read and write .e57 point cloud files
34
-
35
- ## Example usage
36
-
37
- ```python
38
- import numpy as np
39
- import pye57
40
-
41
- e57 = pye57.E57("e57_file.e57")
42
-
43
- # read scan at index 0
44
- data = e57.read_scan(0)
45
-
46
- # 'data' is a dictionary with the point types as keys
47
- assert isinstance(data["cartesianX"], np.ndarray)
48
- assert isinstance(data["cartesianY"], np.ndarray)
49
- assert isinstance(data["cartesianZ"], np.ndarray)
50
-
51
- # other attributes can be read using:
52
- data = e57.read_scan(0, intensity=True, colors=True, row_column=True)
53
- assert isinstance(data["cartesianX"], np.ndarray)
54
- assert isinstance(data["cartesianY"], np.ndarray)
55
- assert isinstance(data["cartesianZ"], np.ndarray)
56
- assert isinstance(data["intensity"], np.ndarray)
57
- assert isinstance(data["colorRed"], np.ndarray)
58
- assert isinstance(data["colorGreen"], np.ndarray)
59
- assert isinstance(data["colorBlue"], np.ndarray)
60
- assert isinstance(data["rowIndex"], np.ndarray)
61
- assert isinstance(data["columnIndex"], np.ndarray)
62
-
63
- # the 'read_scan' method filters points using the 'cartesianInvalidState' field
64
- # if you want to get everything as raw, untransformed data, use:
65
- data_raw = e57.read_scan_raw(0)
66
-
67
- # writing is also possible, but only using raw data for now
68
- e57_write = pye57.E57("e57_file_write.e57", mode='w')
69
- e57_write.write_scan_raw(data_raw)
70
- # you can specify a header to copy information from
71
- e57_write.write_scan_raw(data_raw, scan_header=e57.get_header(0))
72
-
73
- # the ScanHeader object wraps most of the scan information:
74
- header = e57.get_header(0)
75
- print(header.point_count)
76
- print(header.rotation_matrix)
77
- print(header.translation)
78
-
79
- # all the header information can be printed using:
80
- for line in header.pretty_print():
81
- print(line)
82
-
83
- # the scan position can be accessed with:
84
- position_scan_0 = e57.scan_position(0)
85
-
86
- # the binding is very close to the E57Foundation API
87
- # you can modify the nodes easily from python
88
- imf = e57.image_file
89
- root = imf.root()
90
- data3d = root["data3D"]
91
- scan_0 = data3d[0]
92
- translation_x = scan_0["pose"]["translation"]["x"]
93
- ```
94
-
95
- ## Installation
96
-
97
- If you're on linux or Windows, a wheel should be available.
98
-
99
- `python -m pip install pye57`
100
-
101
- ## Building from source
102
-
103
- ### Cloning the repository and required submodules
104
-
105
- Clone a new repository along with the required submodules
106
-
107
- `git clone https://github.com/davidcaron/pye57.git --recursive`
108
-
109
- If the repository has already been previously cloned, but without the --recursive flag
110
-
111
- ```
112
- cd pye57 # go to the cloned repository
113
- git submodule init # this will initialise the submodules in the repository
114
- git submodule update # this will update the submodules in the repository
115
- ```
116
-
117
- ### Dependencies on Linux
118
-
119
- Install libxerces-c-dev first.
120
-
121
- `sudo apt install libxerces-c-dev`
122
-
123
- ### Dependencies on Windows
124
-
125
- To get xerces-c, you can either build from source or if you're using conda:
126
-
127
- `conda install -y xerces-c`
128
-
129
- ### Run `pip install` from the repo source
130
-
131
- ```
132
- cd pye57
133
- python -m pip install .
134
- ```
135
-
136
- ### Uninstalling
137
-
138
- Use pip again
139
-
140
- ```
141
- python -m pip uninstall pye57
142
- ```
143
-
144
-
1
+ Metadata-Version: 2.1
2
+ Name: pye57
3
+ Version: 0.4.2
4
+ Summary: Python .e57 files reader/writer
5
+ Home-page: https://www.github.com/davidcaron/pye57
6
+ Author: David Caron
7
+ Author-email: dcaron05@gmail.com
8
+ License: MIT
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: Implementation :: CPython
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: numpy
22
+ Requires-Dist: pyquaternion
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest ; extra == 'test'
25
+
26
+
27
+ # pye57
28
+
29
+ [![PyPI](https://img.shields.io/pypi/v/pye57.svg)](https://pypi.org/project/pye57)
30
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pye57.svg)](https://pypi.org/project/pye57)
31
+ ![GitHub](https://img.shields.io/github/actions/workflow/status/davidcaron/pye57/build.yml?branch=master)
32
+
33
+ Python wrapper of [LibE57Format](https://github.com/asmaloney/libE57Format) to read and write .e57 point cloud files
34
+
35
+ ## Example usage
36
+
37
+ ```python
38
+ import numpy as np
39
+ import pye57
40
+
41
+ e57 = pye57.E57("e57_file.e57")
42
+
43
+ # read scan at index 0
44
+ data = e57.read_scan(0)
45
+
46
+ # 'data' is a dictionary with the point types as keys
47
+ assert isinstance(data["cartesianX"], np.ndarray)
48
+ assert isinstance(data["cartesianY"], np.ndarray)
49
+ assert isinstance(data["cartesianZ"], np.ndarray)
50
+
51
+ # other attributes can be read using:
52
+ data = e57.read_scan(0, intensity=True, colors=True, row_column=True)
53
+ assert isinstance(data["cartesianX"], np.ndarray)
54
+ assert isinstance(data["cartesianY"], np.ndarray)
55
+ assert isinstance(data["cartesianZ"], np.ndarray)
56
+ assert isinstance(data["intensity"], np.ndarray)
57
+ assert isinstance(data["colorRed"], np.ndarray)
58
+ assert isinstance(data["colorGreen"], np.ndarray)
59
+ assert isinstance(data["colorBlue"], np.ndarray)
60
+ assert isinstance(data["rowIndex"], np.ndarray)
61
+ assert isinstance(data["columnIndex"], np.ndarray)
62
+
63
+ # the 'read_scan' method filters points using the 'cartesianInvalidState' field
64
+ # if you want to get everything as raw, untransformed data, use:
65
+ data_raw = e57.read_scan_raw(0)
66
+
67
+ # writing is also possible, but only using raw data for now
68
+ e57_write = pye57.E57("e57_file_write.e57", mode='w')
69
+ e57_write.write_scan_raw(data_raw)
70
+ # you can specify a header to copy information from
71
+ e57_write.write_scan_raw(data_raw, scan_header=e57.get_header(0))
72
+
73
+ # the ScanHeader object wraps most of the scan information:
74
+ header = e57.get_header(0)
75
+ print(header.point_count)
76
+ print(header.rotation_matrix)
77
+ print(header.translation)
78
+
79
+ # all the header information can be printed using:
80
+ for line in header.pretty_print():
81
+ print(line)
82
+
83
+ # the scan position can be accessed with:
84
+ position_scan_0 = e57.scan_position(0)
85
+
86
+ # the binding is very close to the E57Foundation API
87
+ # you can modify the nodes easily from python
88
+ imf = e57.image_file
89
+ root = imf.root()
90
+ data3d = root["data3D"]
91
+ scan_0 = data3d[0]
92
+ translation_x = scan_0["pose"]["translation"]["x"]
93
+ ```
94
+
95
+ ## Installation
96
+
97
+ If you're on linux or Windows, a wheel should be available.
98
+
99
+ `python -m pip install pye57`
100
+
101
+ ## Building from source
102
+
103
+ ### Cloning the repository and required submodules
104
+
105
+ Clone a new repository along with the required submodules
106
+
107
+ `git clone https://github.com/davidcaron/pye57.git --recursive`
108
+
109
+ If the repository has already been previously cloned, but without the --recursive flag
110
+
111
+ ```
112
+ cd pye57 # go to the cloned repository
113
+ git submodule init # this will initialise the submodules in the repository
114
+ git submodule update # this will update the submodules in the repository
115
+ ```
116
+
117
+ ### Dependencies on Linux
118
+
119
+ Install libxerces-c-dev first.
120
+
121
+ `sudo apt install libxerces-c-dev`
122
+
123
+ ### Dependencies on Windows
124
+
125
+ To get xerces-c, you can either build from source or if you're using conda:
126
+
127
+ `conda install -y xerces-c`
128
+
129
+ ### Run `pip install` from the repo source
130
+
131
+ ```
132
+ cd pye57
133
+ python -m pip install .
134
+ ```
135
+
136
+ ### Uninstalling
137
+
138
+ Use pip again
139
+
140
+ ```
141
+ python -m pip uninstall pye57
142
+ ```
@@ -0,0 +1,13 @@
1
+ pye57/__init__.py,sha256=keWVF2W7Jau5voY0aufr6bayvjfDJSWf_bmawIvvj88,95
2
+ pye57/__version__.py,sha256=6fbhlJpSCHhbEgnXa9Y3-1DhheoIUBV900vpMNv9wnw,23
3
+ pye57/e57.py,sha256=ec9_zxTvZ9TlnIVPMrzzB2wRHQg428F6EtWCCeg05K0,18950
4
+ pye57/exception.py,sha256=9Qgriir0IsSpHhStN5uvI5mlbKrc_P5ZURsi_PIW_q8,50
5
+ pye57/libe57.cp310-win_amd64.pyd,sha256=b-LiKSsUhn2mH7uJRlUoHMcAmyv_q9n92-1nIlg0Djs,738304
6
+ pye57/scan_header.py,sha256=39FD40CBcJL5azN_HjVNvSnFrQR3uO-MIQFFNRhUqRU,6036
7
+ pye57/utils.py,sha256=GbuzETqw22KeDpnVc6dB9EUFBAs3gmhstoy67IyJDqU,1418
8
+ pye57/xerces-c_3_2.dll,sha256=uNGJPhQyZPqwjWzp3tijMKE69iRpqUrBf3OAIkT4NG0,2787328
9
+ pye57-0.4.2.dist-info/LICENSE,sha256=Q0K1iCfVm6UmnR4AAyqME5q7flnU6aGh5OarEIa2K6Y,1056
10
+ pye57-0.4.2.dist-info/METADATA,sha256=bTS9FfTB6QmoUz6Z6QWPQDBvSWgOJ4h7gyeycDhBiyw,4359
11
+ pye57-0.4.2.dist-info/WHEEL,sha256=5JPYeYl5ZdvdSkrGS4u21mmpPzpFx42qrXOSIgWf4pg,102
12
+ pye57-0.4.2.dist-info/top_level.txt,sha256=xD9HDzQ3BfGMuz1kI2uNKUR0KXcR-RtNEKigrkh48Nk,6
13
+ pye57-0.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.1)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp310-cp310-win_amd64
5
5
 
pye57/libe57_wrapper.cpp DELETED
@@ -1,526 +0,0 @@
1
-
2
- #include <pybind11/pybind11.h>
3
- #include <pybind11/stl_bind.h>
4
- #include <pybind11/numpy.h>
5
-
6
- #include <E57Exception.h>
7
- #include <E57Format.h>
8
- #include <E57Version.h>
9
-
10
- namespace py = pybind11;
11
- using namespace pybind11::literals;
12
-
13
- using namespace e57;
14
-
15
- PYBIND11_MAKE_OPAQUE(std::vector<SourceDestBuffer>);
16
-
17
- auto cast_node (Node &n) {
18
- NodeType type = n.type();
19
- if (type == NodeType::E57_BLOB)
20
- return py::cast(BlobNode(n));
21
- else if (type == NodeType::E57_COMPRESSED_VECTOR)
22
- return py::cast(CompressedVectorNode(n));
23
- else if (type == NodeType::E57_FLOAT)
24
- return py::cast(FloatNode(n));
25
- else if (type == NodeType::E57_INTEGER)
26
- return py::cast(IntegerNode(n));
27
- else if (type == NodeType::E57_SCALED_INTEGER)
28
- return py::cast(ScaledIntegerNode(n));
29
- else if (type == NodeType::E57_STRING)
30
- return py::cast(StringNode(n));
31
- else if (type == NodeType::E57_STRUCTURE)
32
- return py::cast(StructureNode(n));
33
- else if (type == NodeType::E57_VECTOR)
34
- return py::cast(VectorNode(n));
35
- }
36
-
37
- PYBIND11_MODULE(libe57, m) {
38
- m.doc() = "E57 reader/writer for python.";
39
-
40
- static py::exception<E57Exception> exc(m, "E57Exception");
41
- py::register_exception_translator([](std::exception_ptr p) {
42
- try {
43
- if (p) std::rethrow_exception(p);
44
- } catch (const E57Exception &e) {
45
- exc(Utilities::errorCodeToString(e.errorCode()).c_str());
46
- }
47
- });
48
-
49
- m.attr("E57_FORMAT_MAJOR") = E57_FORMAT_MAJOR;
50
- m.attr("E57_FORMAT_MINOR") = E57_FORMAT_MINOR;
51
- m.attr("E57_LIBRARY_ID") = REVISION_ID;
52
- m.attr("E57_V1_0_URI") = "http://www.astm.org/COMMIT/E57/2010-e57-v1.0";
53
- m.attr("CHECKSUM_POLICY_NONE") = CHECKSUM_POLICY_NONE;
54
- m.attr("CHECKSUM_POLICY_SPARSE") = CHECKSUM_POLICY_SPARSE;
55
- m.attr("CHECKSUM_POLICY_HALF") = CHECKSUM_POLICY_HALF;
56
- m.attr("CHECKSUM_POLICY_ALL") = CHECKSUM_POLICY_ALL;
57
- m.attr("E57_INT8_MIN") = E57_INT8_MIN;
58
- m.attr("E57_INT8_MAX") = E57_INT8_MAX;
59
- m.attr("E57_INT16_MIN") = E57_INT16_MIN;
60
- m.attr("E57_INT16_MAX") = E57_INT16_MAX;
61
- m.attr("E57_INT32_MIN") = E57_INT32_MIN;
62
- m.attr("E57_INT32_MAX") = E57_INT32_MAX;
63
- m.attr("E57_INT64_MIN") = E57_INT64_MIN;
64
- m.attr("E57_INT64_MAX") = E57_INT64_MAX;
65
- m.attr("E57_UINT8_MIN") = E57_UINT8_MIN;
66
- m.attr("E57_UINT8_MAX") = E57_UINT8_MAX;
67
- m.attr("E57_UINT16_MIN") = E57_UINT16_MIN;
68
- m.attr("E57_UINT16_MAX") = E57_UINT16_MAX;
69
- m.attr("E57_UINT32_MIN") = E57_UINT32_MIN;
70
- m.attr("E57_UINT32_MAX") = E57_UINT32_MAX;
71
- m.attr("E57_UINT64_MIN") = E57_UINT64_MIN;
72
- m.attr("E57_UINT64_MAX") = E57_UINT64_MAX;
73
- m.attr("E57_FLOAT_MIN") = E57_FLOAT_MIN;
74
- m.attr("E57_FLOAT_MAX") = E57_FLOAT_MAX;
75
- m.attr("E57_DOUBLE_MIN") = E57_DOUBLE_MIN;
76
- m.attr("E57_DOUBLE_MAX") = E57_DOUBLE_MAX;
77
- py::enum_<NodeType>(m, "NodeType")
78
- .value("E57_STRUCTURE", NodeType::E57_STRUCTURE)
79
- .value("E57_VECTOR", NodeType::E57_VECTOR)
80
- .value("E57_COMPRESSED_VECTOR", NodeType::E57_COMPRESSED_VECTOR)
81
- .value("E57_INTEGER", NodeType::E57_INTEGER)
82
- .value("E57_SCALED_INTEGER", NodeType::E57_SCALED_INTEGER)
83
- .value("E57_FLOAT", NodeType::E57_FLOAT)
84
- .value("E57_STRING", NodeType::E57_STRING)
85
- .value("E57_BLOB", NodeType::E57_BLOB)
86
- .export_values();
87
- py::enum_<FloatPrecision>(m, "FloatPrecision")
88
- .value("E57_SINGLE", FloatPrecision::E57_SINGLE)
89
- .value("E57_DOUBLE", FloatPrecision::E57_DOUBLE)
90
- .export_values();
91
- py::enum_<MemoryRepresentation>(m, "MemoryRepresentation")
92
- .value("E57_INT8", MemoryRepresentation::E57_INT8)
93
- .value("E57_UINT8", MemoryRepresentation::E57_UINT8)
94
- .value("E57_INT16", MemoryRepresentation::E57_INT16)
95
- .value("E57_UINT16", MemoryRepresentation::E57_UINT16)
96
- .value("E57_INT32", MemoryRepresentation::E57_INT32)
97
- .value("E57_UINT32", MemoryRepresentation::E57_UINT32)
98
- .value("E57_INT64", MemoryRepresentation::E57_INT64)
99
- .value("E57_BOOL", MemoryRepresentation::E57_BOOL)
100
- .value("E57_REAL32", MemoryRepresentation::E57_REAL32)
101
- .value("E57_REAL64", MemoryRepresentation::E57_REAL64)
102
- .value("E57_USTRING", MemoryRepresentation::E57_USTRING)
103
- .export_values();
104
- py::enum_<ErrorCode>(m, "ErrorCode")
105
- .value("E57_SUCCESS", ErrorCode::E57_SUCCESS)
106
- .value("E57_ERROR_BAD_CV_HEADER", ErrorCode::E57_ERROR_BAD_CV_HEADER)
107
- .value("E57_ERROR_BAD_CV_PACKET", ErrorCode::E57_ERROR_BAD_CV_PACKET)
108
- .value("E57_ERROR_CHILD_INDEX_OUT_OF_BOUNDS", ErrorCode::E57_ERROR_CHILD_INDEX_OUT_OF_BOUNDS)
109
- .value("E57_ERROR_SET_TWICE", ErrorCode::E57_ERROR_SET_TWICE)
110
- .value("E57_ERROR_HOMOGENEOUS_VIOLATION", ErrorCode::E57_ERROR_HOMOGENEOUS_VIOLATION)
111
- .value("E57_ERROR_VALUE_NOT_REPRESENTABLE", ErrorCode::E57_ERROR_VALUE_NOT_REPRESENTABLE)
112
- .value("E57_ERROR_SCALED_VALUE_NOT_REPRESENTABLE", ErrorCode::E57_ERROR_SCALED_VALUE_NOT_REPRESENTABLE)
113
- .value("E57_ERROR_REAL64_TOO_LARGE", ErrorCode::E57_ERROR_REAL64_TOO_LARGE)
114
- .value("E57_ERROR_EXPECTING_NUMERIC", ErrorCode::E57_ERROR_EXPECTING_NUMERIC)
115
- .value("E57_ERROR_EXPECTING_USTRING", ErrorCode::E57_ERROR_EXPECTING_USTRING)
116
- .value("E57_ERROR_INTERNAL", ErrorCode::E57_ERROR_INTERNAL)
117
- .value("E57_ERROR_BAD_XML_FORMAT", ErrorCode::E57_ERROR_BAD_XML_FORMAT)
118
- .value("E57_ERROR_XML_PARSER", ErrorCode::E57_ERROR_XML_PARSER)
119
- .value("E57_ERROR_BAD_API_ARGUMENT", ErrorCode::E57_ERROR_BAD_API_ARGUMENT)
120
- .value("E57_ERROR_FILE_IS_READ_ONLY", ErrorCode::E57_ERROR_FILE_IS_READ_ONLY)
121
- .value("E57_ERROR_BAD_CHECKSUM", ErrorCode::E57_ERROR_BAD_CHECKSUM)
122
- .value("E57_ERROR_OPEN_FAILED", ErrorCode::E57_ERROR_OPEN_FAILED)
123
- .value("E57_ERROR_CLOSE_FAILED", ErrorCode::E57_ERROR_CLOSE_FAILED)
124
- .value("E57_ERROR_READ_FAILED", ErrorCode::E57_ERROR_READ_FAILED)
125
- .value("E57_ERROR_WRITE_FAILED", ErrorCode::E57_ERROR_WRITE_FAILED)
126
- .value("E57_ERROR_LSEEK_FAILED", ErrorCode::E57_ERROR_LSEEK_FAILED)
127
- .value("E57_ERROR_PATH_UNDEFINED", ErrorCode::E57_ERROR_PATH_UNDEFINED)
128
- .value("E57_ERROR_BAD_BUFFER", ErrorCode::E57_ERROR_BAD_BUFFER)
129
- .value("E57_ERROR_NO_BUFFER_FOR_ELEMENT", ErrorCode::E57_ERROR_NO_BUFFER_FOR_ELEMENT)
130
- .value("E57_ERROR_BUFFER_SIZE_MISMATCH", ErrorCode::E57_ERROR_BUFFER_SIZE_MISMATCH)
131
- .value("E57_ERROR_BUFFER_DUPLICATE_PATHNAME", ErrorCode::E57_ERROR_BUFFER_DUPLICATE_PATHNAME)
132
- .value("E57_ERROR_BAD_FILE_SIGNATURE", ErrorCode::E57_ERROR_BAD_FILE_SIGNATURE)
133
- .value("E57_ERROR_UNKNOWN_FILE_VERSION", ErrorCode::E57_ERROR_UNKNOWN_FILE_VERSION)
134
- .value("E57_ERROR_BAD_FILE_LENGTH", ErrorCode::E57_ERROR_BAD_FILE_LENGTH)
135
- .value("E57_ERROR_XML_PARSER_INIT", ErrorCode::E57_ERROR_XML_PARSER_INIT)
136
- .value("E57_ERROR_DUPLICATE_NAMESPACE_PREFIX", ErrorCode::E57_ERROR_DUPLICATE_NAMESPACE_PREFIX)
137
- .value("E57_ERROR_DUPLICATE_NAMESPACE_URI", ErrorCode::E57_ERROR_DUPLICATE_NAMESPACE_URI)
138
- .value("E57_ERROR_BAD_PROTOTYPE", ErrorCode::E57_ERROR_BAD_PROTOTYPE)
139
- .value("E57_ERROR_BAD_CODECS", ErrorCode::E57_ERROR_BAD_CODECS)
140
- .value("E57_ERROR_VALUE_OUT_OF_BOUNDS", ErrorCode::E57_ERROR_VALUE_OUT_OF_BOUNDS)
141
- .value("E57_ERROR_CONVERSION_REQUIRED", ErrorCode::E57_ERROR_CONVERSION_REQUIRED)
142
- .value("E57_ERROR_BAD_PATH_NAME", ErrorCode::E57_ERROR_BAD_PATH_NAME)
143
- .value("E57_ERROR_NOT_IMPLEMENTED", ErrorCode::E57_ERROR_NOT_IMPLEMENTED)
144
- .value("E57_ERROR_BAD_NODE_DOWNCAST", ErrorCode::E57_ERROR_BAD_NODE_DOWNCAST)
145
- .value("E57_ERROR_WRITER_NOT_OPEN", ErrorCode::E57_ERROR_WRITER_NOT_OPEN)
146
- .value("E57_ERROR_READER_NOT_OPEN", ErrorCode::E57_ERROR_READER_NOT_OPEN)
147
- .value("E57_ERROR_NODE_UNATTACHED", ErrorCode::E57_ERROR_NODE_UNATTACHED)
148
- .value("E57_ERROR_ALREADY_HAS_PARENT", ErrorCode::E57_ERROR_ALREADY_HAS_PARENT)
149
- .value("E57_ERROR_DIFFERENT_DEST_IMAGEFILE", ErrorCode::E57_ERROR_DIFFERENT_DEST_IMAGEFILE)
150
- .value("E57_ERROR_IMAGEFILE_NOT_OPEN", ErrorCode::E57_ERROR_IMAGEFILE_NOT_OPEN)
151
- .value("E57_ERROR_BUFFERS_NOT_COMPATIBLE", ErrorCode::E57_ERROR_BUFFERS_NOT_COMPATIBLE)
152
- .value("E57_ERROR_TOO_MANY_WRITERS", ErrorCode::E57_ERROR_TOO_MANY_WRITERS)
153
- .value("E57_ERROR_TOO_MANY_READERS", ErrorCode::E57_ERROR_TOO_MANY_READERS)
154
- .value("E57_ERROR_BAD_CONFIGURATION", ErrorCode::E57_ERROR_BAD_CONFIGURATION)
155
- .value("E57_ERROR_INVARIANCE_VIOLATION", ErrorCode::E57_ERROR_INVARIANCE_VIOLATION)
156
- .export_values();
157
- py::class_<Node> cls_Node(m, "Node");
158
- cls_Node.def("type", &Node::type);
159
- cls_Node.def("isRoot", &Node::isRoot);
160
- cls_Node.def("parent", &Node::parent);
161
- cls_Node.def("pathName", &Node::pathName);
162
- cls_Node.def("elementName", &Node::elementName);
163
- cls_Node.def("destImageFile", &Node::destImageFile);
164
- cls_Node.def("isAttached", &Node::isAttached);
165
- cls_Node.def("checkInvariant", &Node::checkInvariant, "doRecurse"_a=true, "doDowncast"_a=true);
166
- cls_Node.def("__repr__", [](const Node &node) {
167
- return "<Node '" + node.elementName() + "'>";
168
- });
169
-
170
- py::class_<StructureNode> cls_StructureNode(m, "StructureNode");
171
- cls_StructureNode.def(py::init<e57::ImageFile>(), "destImageFile"_a);
172
- cls_StructureNode.def("childCount", &StructureNode::childCount);
173
- cls_StructureNode.def("isDefined", &StructureNode::isDefined, "pathName"_a);
174
- cls_StructureNode.def("get", (Node (StructureNode::*)(int64_t) const) &StructureNode::get, "index"_a);
175
- cls_StructureNode.def("get", (Node (StructureNode::*)(const std::string &) const) &StructureNode::get, "pathName"_a);
176
- // Maybe there is a more elegant way to do this
177
- cls_StructureNode.def("set", [](StructureNode &node, const std::string &pathName, StructureNode &n){
178
- node.set(pathName, n);
179
- }, "pathName"_a, "n"_a);
180
- cls_StructureNode.def("set", [](StructureNode &node, const std::string &pathName, VectorNode &n){
181
- node.set(pathName, n);
182
- }, "pathName"_a, "n"_a);
183
- cls_StructureNode.def("set", [](StructureNode &node, const std::string &pathName, CompressedVectorNode &n){
184
- node.set(pathName, n);
185
- }, "pathName"_a, "n"_a);
186
- cls_StructureNode.def("set", [](StructureNode &node, const std::string &pathName, IntegerNode &n){
187
- node.set(pathName, n);
188
- }, "pathName"_a, "n"_a);
189
- cls_StructureNode.def("set", [](StructureNode &node, const std::string &pathName, ScaledIntegerNode &n){
190
- node.set(pathName, n);
191
- }, "pathName"_a, "n"_a);
192
- cls_StructureNode.def("set", [](StructureNode &node, const std::string &pathName, FloatNode &n){
193
- node.set(pathName, n);
194
- }, "pathName"_a, "n"_a);
195
- cls_StructureNode.def("set", [](StructureNode &node, const std::string &pathName, StringNode &n){
196
- node.set(pathName, n);
197
- }, "pathName"_a, "n"_a);
198
- cls_StructureNode.def(py::init<const e57::Node &>(), "n"_a);
199
- cls_StructureNode.def("isRoot", &StructureNode::isRoot);
200
- cls_StructureNode.def("parent", &StructureNode::parent);
201
- cls_StructureNode.def("pathName", &StructureNode::pathName);
202
- cls_StructureNode.def("elementName", &StructureNode::elementName);
203
- cls_StructureNode.def("destImageFile", &StructureNode::destImageFile);
204
- cls_StructureNode.def("isAttached", &StructureNode::isAttached);
205
- cls_StructureNode.def("checkInvariant", &StructureNode::checkInvariant, "doRecurse"_a=true, "doUpcast"_a=true);
206
- cls_StructureNode.def("__len__", &StructureNode::childCount);
207
- cls_StructureNode.def("__getitem__", [](const StructureNode &node, const std::string &pathName) {
208
- Node n = node.get(pathName);
209
- return cast_node(n);
210
- });
211
- cls_StructureNode.def("__getitem__", [](const StructureNode &node, int64_t index) {
212
- if (index >= node.childCount() || index < 0)
213
- throw py::index_error();
214
- Node n = node.get(index);
215
- return cast_node(n);
216
- });
217
- cls_StructureNode.def("__repr__", [](const StructureNode &node) {
218
- return "<StructureNode '" + node.elementName() + "'>";
219
- });
220
-
221
- py::class_<VectorNode> cls_VectorNode(m, "VectorNode");
222
- cls_VectorNode.def(py::init<e57::ImageFile, bool>(), "destImageFile"_a, "allowHeteroChildren"_a=false);
223
- cls_VectorNode.def("allowHeteroChildren", &VectorNode::allowHeteroChildren);
224
- cls_VectorNode.def("childCount", &VectorNode::childCount);
225
- cls_VectorNode.def("isDefined", &VectorNode::isDefined, "pathName"_a);
226
- cls_VectorNode.def("get", (Node (VectorNode::*)(int64_t) const) &VectorNode::get, "index"_a);
227
- cls_VectorNode.def("get", (Node (VectorNode::*)(const std::string &) const) &VectorNode::get, "pathName"_a);
228
- // Maybe there is a more elegant way to do this
229
- cls_VectorNode.def("append", [](VectorNode &v, StructureNode &node) { v.append(node); });
230
- cls_VectorNode.def("append", [](VectorNode &v, VectorNode &node) { v.append(node); });
231
- cls_VectorNode.def("append", [](VectorNode &v, CompressedVectorNode &node) { v.append(node); });
232
- cls_VectorNode.def("append", [](VectorNode &v, IntegerNode &node) { v.append(node); });
233
- cls_VectorNode.def("append", [](VectorNode &v, ScaledIntegerNode &node) { v.append(node); });
234
- cls_VectorNode.def("append", [](VectorNode &v, FloatNode &node) { v.append(node); });
235
- cls_VectorNode.def("append", [](VectorNode &v, StringNode &node) { v.append(node); });
236
- cls_VectorNode.def(py::init<const e57::Node &>(), "n"_a);
237
- cls_VectorNode.def("isRoot", &VectorNode::isRoot);
238
- cls_VectorNode.def("parent", &VectorNode::parent);
239
- cls_VectorNode.def("pathName", &VectorNode::pathName);
240
- cls_VectorNode.def("elementName", &VectorNode::elementName);
241
- cls_VectorNode.def("destImageFile", &VectorNode::destImageFile);
242
- cls_VectorNode.def("isAttached", &VectorNode::isAttached);
243
- cls_VectorNode.def("checkInvariant", &VectorNode::checkInvariant, "doRecurse"_a=true, "doUpcast"_a=true);
244
- cls_VectorNode.def("__len__", &VectorNode::childCount);
245
- cls_VectorNode.def("__getitem__", [](const VectorNode &node, const std::string &pathName) {
246
- Node n = node.get(pathName);
247
- return cast_node(n);
248
- });
249
- cls_VectorNode.def("__getitem__", [](const VectorNode &node, int64_t index) {
250
- if (index >= node.childCount() || index < 0)
251
- throw py::index_error();
252
- Node n = node.get(index);
253
- return cast_node(n);
254
- });
255
- cls_VectorNode.def("__repr__", [](const VectorNode &node) {
256
- return "<VectorNode '" + node.elementName() + "'>";
257
- });
258
-
259
- py::class_<SourceDestBuffer> cls_SourceDestBuffer(m, "SourceDestBuffer");
260
- cls_SourceDestBuffer.def("__init__", [](SourceDestBuffer &s,
261
- e57::ImageFile imf,
262
- const std::string pathName,
263
- py::buffer np_array,
264
- const size_t capacity,
265
- bool doConversion,
266
- bool doScaling,
267
- size_t stride=0) {
268
- py::buffer_info info = np_array.request();
269
-
270
- if (info.ndim != 1)
271
- throw std::runtime_error("Incompatible buffer dimension!");
272
-
273
- if (info.format == "b")
274
- new (&s) SourceDestBuffer(imf, pathName, static_cast<int8_t *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(int8_t) : stride);
275
- else if (info.format == "B")
276
- new (&s) SourceDestBuffer(imf, pathName, static_cast<uint8_t *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(uint8_t) : stride);
277
- else if (info.format == "h")
278
- new (&s) SourceDestBuffer(imf, pathName, static_cast<int16_t *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(int16_t) : stride);
279
- else if (info.format == "H")
280
- new (&s) SourceDestBuffer(imf, pathName, static_cast<uint16_t *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(uint16_t) : stride);
281
- else if (info.format == "l")
282
- new (&s) SourceDestBuffer(imf, pathName, static_cast<int32_t *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(int32_t) : stride);
283
- else if (info.format == "L")
284
- new (&s) SourceDestBuffer(imf, pathName, static_cast<uint32_t *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(uint32_t) : stride);
285
- else if (info.format == "q")
286
- new (&s) SourceDestBuffer(imf, pathName, static_cast<int64_t *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(int64_t) : stride);
287
- else if (info.format == "?")
288
- new (&s) SourceDestBuffer(imf, pathName, static_cast<bool *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(bool) : stride);
289
- else if (info.format == "f")
290
- new (&s) SourceDestBuffer(imf, pathName, static_cast<float *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(float) : stride);
291
- else if (info.format == "d")
292
- new (&s) SourceDestBuffer(imf, pathName, static_cast<double *>(info.ptr), capacity, doConversion, doScaling, (stride == 0) ? sizeof(double) : stride);
293
- else
294
- throw py::value_error("Incompatible type (integers: bBhHlLq, bool: ?, floats: fd)");
295
- },
296
- "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=0);
297
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, int8_t *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(int8_t));
298
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, uint8_t *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(uint8_t));
299
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, int16_t *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(int16_t));
300
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, uint16_t *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(uint16_t));
301
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, int32_t *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(int32_t));
302
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, uint32_t *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(uint32_t));
303
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, int64_t *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(int64_t));
304
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, bool *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(bool));
305
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, float *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(float));
306
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, double *, const size_t, bool, bool, size_t>(), "destImageFile"_a, "pathName"_a, "b"_a, "capacity"_a, "doConversion"_a=false, "doScaling"_a=false, "stride"_a=sizeof(double));
307
- // cls_SourceDestBuffer.def(py::init<e57::ImageFile, const std::string, std::vector<ustring> *>(), "destImageFile"_a, "pathName"_a, "b"_a);
308
- cls_SourceDestBuffer.def("pathName", &SourceDestBuffer::pathName);
309
- cls_SourceDestBuffer.def("capacity", &SourceDestBuffer::capacity);
310
- cls_SourceDestBuffer.def("doConversion", &SourceDestBuffer::doConversion);
311
- cls_SourceDestBuffer.def("doScaling", &SourceDestBuffer::doScaling);
312
- cls_SourceDestBuffer.def("stride", &SourceDestBuffer::stride);
313
- cls_SourceDestBuffer.def("checkInvariant", &SourceDestBuffer::checkInvariant, "doRecurse"_a=true);
314
- cls_SourceDestBuffer.def("__repr__", [](const SourceDestBuffer &bf) {
315
- return "<SourceDestBuffer '" + bf.pathName() + "'>";
316
- });
317
-
318
- py::class_<CompressedVectorReader> cls_CompressedVectorReader(m, "CompressedVectorReader");
319
- cls_CompressedVectorReader.def("read", (unsigned (CompressedVectorReader::*)(void)) &CompressedVectorReader::read);
320
- cls_CompressedVectorReader.def("read", (unsigned (CompressedVectorReader::*)(std::vector<SourceDestBuffer> &)) &CompressedVectorReader::read, "dbufs"_a);
321
- cls_CompressedVectorReader.def("seek", &CompressedVectorReader::seek, "recordNumber"_a);
322
- cls_CompressedVectorReader.def("close", &CompressedVectorReader::close);
323
- cls_CompressedVectorReader.def("isOpen", &CompressedVectorReader::isOpen);
324
- cls_CompressedVectorReader.def("compressedVectorNode", &CompressedVectorReader::compressedVectorNode);
325
- cls_CompressedVectorReader.def("checkInvariant", &CompressedVectorReader::checkInvariant, "doRecurse"_a=true);
326
- cls_CompressedVectorReader.def("__del__", [](CompressedVectorReader &r) { r.close(); });
327
-
328
- py::class_<CompressedVectorWriter> cls_CompressedVectorWriter(m, "CompressedVectorWriter");
329
- cls_CompressedVectorWriter.def("write", (void (CompressedVectorWriter::*)(const size_t)) &CompressedVectorWriter::write, "requestedRecordCount"_a);
330
- cls_CompressedVectorWriter.def("write", (void (CompressedVectorWriter::*)(std::vector<SourceDestBuffer> &, const size_t)) &CompressedVectorWriter::write, "sbufs"_a, "requestedRecordCount"_a);
331
- cls_CompressedVectorWriter.def("close", &CompressedVectorWriter::close);
332
- cls_CompressedVectorWriter.def("isOpen", &CompressedVectorWriter::isOpen);
333
- cls_CompressedVectorWriter.def("compressedVectorNode", &CompressedVectorWriter::compressedVectorNode);
334
- cls_CompressedVectorWriter.def("checkInvariant", &CompressedVectorWriter::checkInvariant, "doRecurse"_a=true);
335
- cls_CompressedVectorWriter.def("__del__", [](CompressedVectorWriter &r) { r.close(); });
336
-
337
- py::class_<CompressedVectorNode> cls_CompressedVectorNode(m, "CompressedVectorNode");
338
- cls_CompressedVectorNode.def(py::init<e57::ImageFile, e57::Node, e57::VectorNode>(), "destImageFile"_a, "prototype"_a, "codecs"_a);
339
- cls_CompressedVectorNode.def("__init__", [](CompressedVectorNode &n, e57::ImageFile &imf, e57::StructureNode &node, e57::VectorNode &vector_node) {
340
- new (&n) CompressedVectorNode(imf, node, vector_node);
341
- });
342
- cls_CompressedVectorNode.def("childCount", &CompressedVectorNode::childCount);
343
- cls_CompressedVectorNode.def("prototype", &CompressedVectorNode::prototype);
344
- cls_CompressedVectorNode.def("codecs", &CompressedVectorNode::codecs);
345
- cls_CompressedVectorNode.def("writer", &CompressedVectorNode::writer, "sbufs"_a);
346
- cls_CompressedVectorNode.def("reader", &CompressedVectorNode::reader, "dbufs"_a);
347
- cls_CompressedVectorNode.def(py::init<const e57::Node &>(), "n"_a);
348
- cls_CompressedVectorNode.def("isRoot", &CompressedVectorNode::isRoot);
349
- cls_CompressedVectorNode.def("parent", &CompressedVectorNode::parent);
350
- cls_CompressedVectorNode.def("pathName", &CompressedVectorNode::pathName);
351
- cls_CompressedVectorNode.def("elementName", &CompressedVectorNode::elementName);
352
- cls_CompressedVectorNode.def("destImageFile", &CompressedVectorNode::destImageFile);
353
- cls_CompressedVectorNode.def("isAttached", &CompressedVectorNode::isAttached);
354
- cls_CompressedVectorNode.def("checkInvariant", &CompressedVectorNode::checkInvariant, "doRecurse"_a=true, "doUpcast"_a=true);
355
- cls_CompressedVectorNode.def("__repr__", [](const CompressedVectorNode &node) {
356
- return "<CompressedVectorNode '" + node.elementName() + "'>";
357
- });
358
-
359
- py::class_<IntegerNode> cls_IntegerNode(m, "IntegerNode");
360
- cls_IntegerNode.def(py::init<e57::ImageFile, int64_t, int64_t, int64_t>(), "destImageFile"_a, "value"_a=0, "minimum"_a=E57_INT64_MIN, "maximum"_a=E57_INT64_MAX);
361
- cls_IntegerNode.def("value", &IntegerNode::value);
362
- cls_IntegerNode.def("minimum", &IntegerNode::minimum);
363
- cls_IntegerNode.def("maximum", &IntegerNode::maximum);
364
- cls_IntegerNode.def(py::init<const e57::Node &>(), "n"_a);
365
- cls_IntegerNode.def("isRoot", &IntegerNode::isRoot);
366
- cls_IntegerNode.def("parent", &IntegerNode::parent);
367
- cls_IntegerNode.def("pathName", &IntegerNode::pathName);
368
- cls_IntegerNode.def("elementName", &IntegerNode::elementName);
369
- cls_IntegerNode.def("destImageFile", &IntegerNode::destImageFile);
370
- cls_IntegerNode.def("isAttached", &IntegerNode::isAttached);
371
- cls_IntegerNode.def("checkInvariant", &IntegerNode::checkInvariant, "doRecurse"_a=true, "doUpcast"_a=true);
372
- cls_IntegerNode.def("__repr__", [](const IntegerNode &node) {
373
- return "<IntegerNode '" + node.elementName() + "'>";
374
- });
375
-
376
- py::class_<ScaledIntegerNode> cls_ScaledIntegerNode(m, "ScaledIntegerNode");
377
- cls_ScaledIntegerNode.def(py::init<e57::ImageFile, int64_t, int64_t, int64_t, double, double>(), "destImageFile"_a, "value"_a, "minimum"_a, "maximum"_a, "scale"_a=1.0, "offset"_a=0.0);
378
- cls_ScaledIntegerNode.def(py::init<e57::ImageFile, int, int64_t, int64_t, double, double>(), "destImageFile"_a, "value"_a, "minimum"_a, "maximum"_a, "scale"_a=1.0, "offset"_a=0.0);
379
- cls_ScaledIntegerNode.def(py::init<e57::ImageFile, int, int, int, double, double>(), "destImageFile"_a, "value"_a, "minimum"_a, "maximum"_a, "scale"_a=1.0, "offset"_a=0.0);
380
- cls_ScaledIntegerNode.def(py::init<e57::ImageFile, double, double, double, double, double>(), "destImageFile"_a, "scaledValue"_a, "scaledMinimum"_a, "scaledMaximum"_a, "scale"_a=1.0, "offset"_a=0.0);
381
- cls_ScaledIntegerNode.def("rawValue", &ScaledIntegerNode::rawValue);
382
- cls_ScaledIntegerNode.def("scaledValue", &ScaledIntegerNode::scaledValue);
383
- cls_ScaledIntegerNode.def("minimum", &ScaledIntegerNode::minimum);
384
- cls_ScaledIntegerNode.def("scaledMinimum", &ScaledIntegerNode::scaledMinimum);
385
- cls_ScaledIntegerNode.def("maximum", &ScaledIntegerNode::maximum);
386
- cls_ScaledIntegerNode.def("scaledMaximum", &ScaledIntegerNode::scaledMaximum);
387
- cls_ScaledIntegerNode.def("scale", &ScaledIntegerNode::scale);
388
- cls_ScaledIntegerNode.def("offset", &ScaledIntegerNode::offset);
389
- cls_ScaledIntegerNode.def(py::init<const e57::Node &>(), "n"_a);
390
- cls_ScaledIntegerNode.def("isRoot", &ScaledIntegerNode::isRoot);
391
- cls_ScaledIntegerNode.def("parent", &ScaledIntegerNode::parent);
392
- cls_ScaledIntegerNode.def("pathName", &ScaledIntegerNode::pathName);
393
- cls_ScaledIntegerNode.def("elementName", &ScaledIntegerNode::elementName);
394
- cls_ScaledIntegerNode.def("destImageFile", &ScaledIntegerNode::destImageFile);
395
- cls_ScaledIntegerNode.def("isAttached", &ScaledIntegerNode::isAttached);
396
- cls_ScaledIntegerNode.def("checkInvariant", &ScaledIntegerNode::checkInvariant, "doRecurse"_a=true, "doUpcast"_a=true);
397
- cls_ScaledIntegerNode.def("__repr__", [](const ScaledIntegerNode &node) {
398
- return "<ScaledIntegerNode '" + node.elementName() + "'>";
399
- });
400
-
401
- py::class_<FloatNode> cls_FloatNode(m, "FloatNode");
402
- cls_FloatNode.def(py::init<e57::ImageFile, double, FloatPrecision, double, double>(), "destImageFile"_a, "value"_a=0.0, "precision"_a=E57_DOUBLE, "minimum"_a=E57_DOUBLE_MIN, "maximum"_a=E57_DOUBLE_MAX);
403
- cls_FloatNode.def("value", &FloatNode::value);
404
- cls_FloatNode.def("precision", &FloatNode::precision);
405
- cls_FloatNode.def("minimum", &FloatNode::minimum);
406
- cls_FloatNode.def("maximum", &FloatNode::maximum);
407
- cls_FloatNode.def(py::init<const e57::Node &>(), "n"_a);
408
- cls_FloatNode.def("isRoot", &FloatNode::isRoot);
409
- cls_FloatNode.def("parent", &FloatNode::parent);
410
- cls_FloatNode.def("pathName", &FloatNode::pathName);
411
- cls_FloatNode.def("elementName", &FloatNode::elementName);
412
- cls_FloatNode.def("destImageFile", &FloatNode::destImageFile);
413
- cls_FloatNode.def("isAttached", &FloatNode::isAttached);
414
- cls_FloatNode.def("checkInvariant", &FloatNode::checkInvariant, "doRecurse"_a=true, "doUpcast"_a=true);
415
- cls_FloatNode.def("__repr__", [](const FloatNode &node) {
416
- return "<FloatNode '" + node.elementName() + "'>";
417
- });
418
-
419
- py::class_<StringNode> cls_StringNode(m, "StringNode");
420
- cls_StringNode.def(py::init<e57::ImageFile, const std::string>(), "destImageFile"_a, "value"_a="");
421
- cls_StringNode.def("value", &StringNode::value);
422
- cls_StringNode.def(py::init<const e57::Node &>(), "n"_a);
423
- cls_StringNode.def("isRoot", &StringNode::isRoot);
424
- cls_StringNode.def("parent", &StringNode::parent);
425
- cls_StringNode.def("pathName", &StringNode::pathName);
426
- cls_StringNode.def("elementName", &StringNode::elementName);
427
- cls_StringNode.def("destImageFile", &StringNode::destImageFile);
428
- cls_StringNode.def("isAttached", &StringNode::isAttached);
429
- cls_StringNode.def("checkInvariant", &StringNode::checkInvariant, "doRecurse"_a=true, "doUpcast"_a=true);
430
- cls_StringNode.def("__repr__", [](const StringNode &node) {
431
- return "<StringNode '" + node.elementName() + "'>";
432
- });
433
-
434
- py::class_<BlobNode> cls_BlobNode(m, "BlobNode");
435
- cls_BlobNode.def(py::init<e57::ImageFile, int64_t>(), "destImageFile"_a, "byteCount"_a);
436
- cls_BlobNode.def("byteCount", &BlobNode::byteCount);
437
- cls_BlobNode.def("read", [](BlobNode& node, py::buffer buf, int64_t start, size_t count) {
438
- py::buffer_info info = buf.request();
439
-
440
- if (info.ndim != 1) {
441
- throw std::runtime_error("Incompatible buffer dimension!");
442
- }
443
-
444
- if (info.format != "B") {
445
- throw std::runtime_error("Incompatible buffer type!");
446
- }
447
-
448
- if (static_cast<size_t>(info.shape[0]) < count) {
449
- throw std::runtime_error("Buffer not large enough to read.");
450
- }
451
-
452
- node.read(reinterpret_cast<uint8_t*>(info.ptr), start, count);
453
- });
454
- cls_BlobNode.def("write", [](BlobNode& node, py::buffer buf, int64_t start, size_t count) {
455
- py::buffer_info info = buf.request();
456
-
457
- if (info.ndim != 1) {
458
- throw std::runtime_error("Incompatible buffer dimension!");
459
- }
460
-
461
- if (info.format != "B") {
462
- throw std::runtime_error("Incompatible buffer type!");
463
- }
464
-
465
- if (static_cast<size_t>(info.shape[0]) < count) {
466
- throw std::runtime_error("Buffer not large enough to write.");
467
- }
468
-
469
- node.write(reinterpret_cast<uint8_t*>(info.ptr), start, count);
470
- });
471
- cls_BlobNode.def(py::init<const e57::Node &>(), "n"_a);
472
- cls_BlobNode.def("isRoot", &BlobNode::isRoot);
473
- cls_BlobNode.def("parent", &BlobNode::parent);
474
- cls_BlobNode.def("pathName", &BlobNode::pathName);
475
- cls_BlobNode.def("elementName", &BlobNode::elementName);
476
- cls_BlobNode.def("destImageFile", &BlobNode::destImageFile);
477
- cls_BlobNode.def("isAttached", &BlobNode::isAttached);
478
- cls_BlobNode.def("checkInvariant", &BlobNode::checkInvariant, "doRecurse"_a=true, "doUpcast"_a=true);
479
- cls_BlobNode.def("__repr__", [](const BlobNode &node) {
480
- return "<BlobNode '" + node.elementName() + "'>";
481
- });
482
- cls_BlobNode.def("read_buffer", [](BlobNode &node) -> py::array {
483
- int64_t bufferSizeExpected = node.byteCount();
484
- py::array_t<uint8_t> arr(bufferSizeExpected);
485
- node.read(arr.mutable_data(), 0, bufferSizeExpected);
486
- return arr;
487
- });
488
-
489
- py::class_<ImageFile> cls_ImageFile(m, "ImageFile");
490
- cls_ImageFile.def(py::init<const std::string &, const std::string &, int>(), "fname"_a, "mode"_a, "checksumPolicy"_a=CHECKSUM_POLICY_ALL);
491
- cls_ImageFile.def("root", &ImageFile::root);
492
- cls_ImageFile.def("close", &ImageFile::close);
493
- cls_ImageFile.def("cancel", &ImageFile::cancel);
494
- cls_ImageFile.def("isOpen", &ImageFile::isOpen);
495
- cls_ImageFile.def("isWritable", &ImageFile::isWritable);
496
- cls_ImageFile.def("fileName", &ImageFile::fileName);
497
- cls_ImageFile.def("writerCount", &ImageFile::writerCount);
498
- cls_ImageFile.def("readerCount", &ImageFile::readerCount);
499
- cls_ImageFile.def("extensionsAdd", &ImageFile::extensionsAdd, "prefix"_a, "uri"_a);
500
- cls_ImageFile.def("extensionsLookupPrefix", &ImageFile::extensionsLookupPrefix, "prefix"_a, "uri"_a);
501
- cls_ImageFile.def("extensionsLookupUri", &ImageFile::extensionsLookupUri, "uri"_a, "prefix"_a);
502
- cls_ImageFile.def("extensionsCount", &ImageFile::extensionsCount);
503
- cls_ImageFile.def("extensionsPrefix", &ImageFile::extensionsPrefix, "index"_a);
504
- cls_ImageFile.def("extensionsUri", &ImageFile::extensionsUri, "index"_a);
505
- cls_ImageFile.def("isElementNameExtended", &ImageFile::isElementNameExtended, "elementName"_a);
506
- cls_ImageFile.def("elementNameParse", &ImageFile::elementNameParse, "elementName"_a, "prefix"_a, "localPart"_a);
507
- cls_ImageFile.def("checkInvariant", &ImageFile::checkInvariant, "doRecurse"_a=true);
508
- cls_ImageFile.def("__repr__", [](const ImageFile &im) {
509
- return "<ImageFile '" + im.fileName() + "'>";
510
- });
511
-
512
- // py::class_<E57Exception> cls_E57Exception(m, "E57Exception");
513
- // cls_E57Exception.def("errorCode", &E57Exception::errorCode);
514
- // cls_E57Exception.def("context", &E57Exception::context);
515
- // cls_E57Exception.def("what", &E57Exception::what);
516
- // cls_E57Exception.def("sourceFileName", &E57Exception::sourceFileName);
517
- // cls_E57Exception.def("sourceFunctionName", &E57Exception::sourceFunctionName);
518
- // cls_E57Exception.def("sourceLineNumber", &E57Exception::sourceLineNumber);
519
-
520
- // py::class_<E57Utilities> cls_E57Utilities(m, "E57Utilities");
521
- // cls_E57Utilities.def(py::init<const std::string>(), "&"_a="");
522
- // cls_E57Utilities.def("getVersions", &E57Utilities::getVersions, "astmMajor"_a, "astmMinor"_a, "libraryId"_a);
523
- // cls_E57Utilities.def("errorCodeToString", &E57Utilities::errorCodeToString, "ecode"_a);
524
-
525
- py::bind_vector<std::vector<e57::SourceDestBuffer>>(m, "VectorSourceDestBuffer");
526
- }
@@ -1,14 +0,0 @@
1
- pye57/__init__.py,sha256=keWVF2W7Jau5voY0aufr6bayvjfDJSWf_bmawIvvj88,95
2
- pye57/__version__.py,sha256=sNUIXY4j-uBW0UNJ1UBlk71jQtO-yq-NEWFI_pOQcKY,23
3
- pye57/e57.py,sha256=KZ6FYhgZOQfBP9yUbz5tqyTEuvia4jMTuLV8zqHNvmA,17730
4
- pye57/exception.py,sha256=9Qgriir0IsSpHhStN5uvI5mlbKrc_P5ZURsi_PIW_q8,50
5
- pye57/libe57.cp310-win_amd64.pyd,sha256=coZAJ-SCQE2YgYGsEstYeWc452PuTg3J1kvn574xRpM,733696
6
- pye57/libe57_wrapper.cpp,sha256=zx2z2XuJtsoG2KPoX87qGmUmP-rV_gkn8fsHK5W_KAA,35152
7
- pye57/scan_header.py,sha256=atTRXGDXtdlBxyEXenjBN7H3pjGt5sS8k1Afh5dqDXk,4742
8
- pye57/utils.py,sha256=Dtt1Z7fbjNwgvhy9tF_TVwEJ9dRNDyYcSQJZ3KFUi1M,701
9
- pye57/xerces-c_3_2.dll,sha256=3ATqlJbstvhJxO4YUuPGF6Tbpo31zS4p1nh56lBUSNg,2787328
10
- pye57-0.3.1.dist-info/LICENSE,sha256=Q0K1iCfVm6UmnR4AAyqME5q7flnU6aGh5OarEIa2K6Y,1056
11
- pye57-0.3.1.dist-info/METADATA,sha256=Hy6xYFUNGIWjwG_uOh0TTBld04-95NMcqWDcgEsz4pk,4159
12
- pye57-0.3.1.dist-info/WHEEL,sha256=W26pYN7HLsBT1jrDSL9udgf_mdNKJmYmL23sIP-FcgM,102
13
- pye57-0.3.1.dist-info/top_level.txt,sha256=xD9HDzQ3BfGMuz1kI2uNKUR0KXcR-RtNEKigrkh48Nk,6
14
- pye57-0.3.1.dist-info/RECORD,,
File without changes