Skip to content

Commit

Permalink
Address code review changes - SQUASH ME?
Browse files Browse the repository at this point in the history
  • Loading branch information
joaori committed May 3, 2024
1 parent 50606d8 commit 5c8ba25
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 196 deletions.
81 changes: 78 additions & 3 deletions src/pye57/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Type

from pye57 import libe57
from pye57.libe57 import NodeType

Expand Down Expand Up @@ -39,4 +37,81 @@ def convert_spherical_to_cartesian(rae):
range_cos_phi * np.cos(theta),
range_cos_phi * np.sin(theta),
range_ * np.sin(phi)
), axis=1)
), axis=1)


def copy_node(node, dest_image):
compressed_node_pairs = []
blob_node_pairs = []

out_node = None
# 'Element' Types
if (isinstance(node, libe57.FloatNode)):
out_node = libe57.FloatNode(
dest_image,
value=node.value(),
precision=node.precision(),
minimum=node.minimum(),
maximum=node.maximum())

elif (isinstance(node, libe57.IntegerNode)):
out_node = libe57.IntegerNode(
dest_image,
value=node.value(),
minimum=node.minimum(),
maximum=node.maximum())

elif (isinstance(node, libe57.ScaledIntegerNode)):
out_node = libe57.ScaledIntegerNode(
dest_image,
node.rawValue(),
minimum=node.minimum(),
maximum=node.maximum(),
scale=node.scale(),
offset=node.offset())

elif (isinstance(node, libe57.StringNode)):
out_node = libe57.StringNode(
dest_image,
node.value())

elif (isinstance(node, libe57.BlobNode)):
out_node = libe57.BlobNode(dest_image, node.byteCount())
blob_node_pairs.append({ 'in': node, 'out': out_node })

# 'Container' Types
elif (isinstance(node, libe57.CompressedVectorNode)):
in_prototype = libe57.StructureNode(node.prototype())
out_prototype, _, _ = copy_node(in_prototype, dest_image)
out_codecs, _, _ = copy_node(node.codecs(), dest_image)

out_node = libe57.CompressedVectorNode(dest_image, out_prototype, out_codecs)

compressed_node_pairs.append({
'in': node,
'out': out_node
})

elif isinstance(node, libe57.StructureNode):
out_node = libe57.StructureNode(dest_image)
for i in range(node.childCount()):
in_child = get_node(node, i)
in_child_name = in_child.elementName()
out_child, out_child_compressed_node_pairs, out_child_blob_node_pairs = copy_node(in_child, dest_image)

out_node.set(in_child_name, out_child)
compressed_node_pairs.extend(out_child_compressed_node_pairs)
blob_node_pairs.extend(out_child_blob_node_pairs)

elif isinstance(node, libe57.VectorNode):
out_node = libe57.VectorNode(dest_image, allowHeteroChildren=node.allowHeteroChildren())
for i in range(node.childCount()):
in_child = get_node(node, i)
in_child_name = f'{i}'
out_child, out_child_compressed_node_pairs, out_child_blob_node_pairs = copy_node(in_child, dest_image)

out_node.append(out_child)
compressed_node_pairs.extend(out_child_compressed_node_pairs)
blob_node_pairs.extend(out_child_blob_node_pairs)

return out_node, compressed_node_pairs, blob_node_pairs
193 changes: 0 additions & 193 deletions tests/test_libe57.py

This file was deleted.

Loading

0 comments on commit 5c8ba25

Please sign in to comment.