Skip to content

Commit

Permalink
Merge pull request #9 from rsgalloway/master
Browse files Browse the repository at this point in the history
Cask 1.1.1
  • Loading branch information
lamiller0 authored Jan 29, 2018
2 parents fa4723e + ea9e95f commit df8555c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 8 deletions.
16 changes: 14 additions & 2 deletions cask.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
More information can be found at http://docs.alembic.io/python/cask.html
"""
__version__ = "1.1.0"
__version__ = "1.1.1"

import os
import re
Expand Down Expand Up @@ -239,6 +239,7 @@ def uint64(n):
Int8: imath.SignedCharArray,
Int16: imath.ShortArray,
Int32: imath.IntArray,
Int64: imath.DoubleArray,
Uint8: imath.UnsignedCharArray,
Uint16: imath.UnsignedShortArray,
Uint32: imath.UnsignedIntArray
Expand All @@ -259,7 +260,8 @@ def uint64(n):
Int64: (alembic.Util.POD.kInt64POD, -1),
float: (alembic.Util.POD.kFloat64POD, -1),
str: (alembic.Util.POD.kStringPOD, -1),
imath.V3f: (alembic.Util.POD.kFloat32POD, -1),
imath.V3f: (alembic.Util.POD.kFloat32POD, 3),
imath.V3d: (alembic.Util.POD.kFloat64POD, 3),
imath.Color3c: (alembic.Util.POD.kUint8POD, -1),
imath.Color3f: (alembic.Util.POD.kFloat32POD, -1),
imath.Color4c: (alembic.Util.POD.kUint8POD, -1),
Expand All @@ -273,6 +275,8 @@ def uint64(n):
imath.StringArray: (alembic.Util.POD.kStringPOD, -1),
imath.UnsignedCharArray: (alembic.Util.POD.kUint8POD, -1),
imath.IntArray: (alembic.Util.POD.kInt32POD, -1),
imath.V3fArray: (alembic.Util.POD.kFloat32POD, 3),
imath.V3dArray: (alembic.Util.POD.kFloat64POD, 3),
imath.FloatArray: (alembic.Util.POD.kFloat32POD, -1),
imath.DoubleArray: (alembic.Util.POD.kFloat64POD, -1),
}
Expand All @@ -291,6 +295,8 @@ def get_simple_oprop_class(prop):
value = prop.values[0] if len(prop.values) > 0 else []
if prop.iobject:
is_array = prop.iobject.isArray()
elif type(value) in IMATH_ARRAYS_VALUES:
is_array = True
else:
is_array = type(value) in [list, set] and len(value) > 1
if is_array:
Expand Down Expand Up @@ -331,6 +337,7 @@ def get_pod_extent(prop):
pod, extent = POD_EXTENT.get(type(value0))
except TypeError as err:
print "Error getting pod, extent from", prop, value0
print err
return (alembic.Util.POD.kUnknownPOD, 1)
if extent <= 0:
extent = (len(value0)
Expand Down Expand Up @@ -1158,6 +1165,11 @@ def save(self):
up._oobject = prop.object().oobject.getSchema().getUserProperties()
up.properties[prop.name] = prop
prop.parent = up
elif prop.parent.name == ".arbGeomParams":
up = Property()
up._oobject = prop.object().oobject.getSchema().getArbGeomParams()
up.properties[prop.name] = prop
prop.parent = up
else:
prop.parent = self
prop.save()
Expand Down
58 changes: 52 additions & 6 deletions test/testCask.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

"""
TODO
- more tests for getting and setting values/samples
- test creating prototype schema objects
- test name collisions when creating new objects and properties
"""
Expand Down Expand Up @@ -706,7 +705,7 @@ def test_pod_extent(self):
something = foo.properties["something"]

# assert pod, extent values
self.assertEqual(bar.extent(), 5)
self.assertEqual(bar.extent(), 1)
self.assertEqual(bar.pod(), alembic.Util.POD.kUint8POD)
self.assertEqual(bar.values[0], v)
self.assertEqual(baz.extent(), 1)
Expand Down Expand Up @@ -1346,18 +1345,65 @@ def test_issue_26(self):
a.top.children["foo"] = cask.Xform()
p1 = a.top.children["foo"].properties["p1"] = cask.Property()
p2 = a.top.children["foo"].properties["p2"] = cask.Property()
p1.set_value(imath.UnsignedCharArray(6))
p2.set_value(imath.DoubleArray(12))
p3 = a.top.children["foo"].properties["p3"] = cask.Property()
p4 = a.top.children["foo"].properties["p4"] = cask.Property()

ca = imath.UnsignedCharArray(6)
for i in range(6):
ca[i] = i
p1.set_value(ca)

da = imath.DoubleArray(12)
for i in range(12):
da[i] = i * 3.0
p2.set_value(da)

va = imath.V3fArray(3)
for i in range(3):
va[i] = imath.V3f(i, i*2.0, i*3.0)
p3.set_value(va)

p4.set_value([imath.V3f(1, 2, 3), imath.V3f(4, 5, 6), imath.V3f(7, 8, 9)])

a.write_to_file(test_file_1)
a.close()

# open the exported file and assert properties are scalar
a = cask.Archive(test_file_1)
p1 = a.top.children["foo"].properties["p1"]
p2 = a.top.children["foo"].properties["p2"]
self.assertTrue(p1.iobject.isScalar())
self.assertTrue(p2.iobject.isScalar())
p3 = a.top.children["foo"].properties["p3"]
p4 = a.top.children["foo"].properties["p4"]
self.assertTrue(p1.iobject.isArray())
self.assertTrue(p2.iobject.isArray())
self.assertTrue(p3.iobject.isArray())
self.assertTrue(p4.iobject.isArray())
a.close()

def test_issue_8(self):
"""creating arbGeomParams on geom objects
https://github.com/alembic/cask/issues/8"""

test_file_1 = os.path.join(TEMPDIR, "cask_test_issue_8.abc")

a = cask.Archive()
m = a.top.children["meshy"] = cask.PolyMesh()

p1 = m.properties[".geom/.arbGeomParams/test"] = cask.Property()
p1.set_value("somevalue")

a.write_to_file(test_file_1)
a.close()

a1 = cask.Archive(test_file_1)
m1 = a1.top.children["meshy"]
self.assertTrue("test" in m1.properties[".geom/.arbGeomParams"].properties)

self.assertEqual(m1.properties[".geom/.arbGeomParams/test"].values[0],
"somevalue")

a1.close()


if __name__ == '__main__':
unittest.main()

0 comments on commit df8555c

Please sign in to comment.