Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with IFaceSet schema #129

Closed
aferrall opened this issue May 25, 2017 · 5 comments
Closed

Issue with IFaceSet schema #129

aferrall opened this issue May 25, 2017 · 5 comments
Assignees
Labels
Milestone

Comments

@aferrall
Copy link

I've found what seems to be a bug in the IFaceSet schema implementation, where a valid schema can be written out by PyAlembic, read and validated by PyAlembic, and then throw an exception when calling the getFaceExclusivity method. Note that this isn't specific to the Python bindings, but rather an exception originating within the C++ code (I'm just using Python as a simple way to describe the repro steps).

Here's the code to generate a simple cube cache with two facesets (relying on default behavior and not explicitly setting face exclusivity values):

import alembic
import imath

def toArray(traits, values):
    array = traits.arrayType(len(values))
    for i in range(len(values)):
        array[i] = values[i]
    return array

def meshOut(filename):
    oarchive = alembic.Abc.OArchive(filename)
    top = oarchive.getTop()

    mesh = alembic.AbcGeom.OPolyMesh(top, "cube")
    meshSample = alembic.AbcGeom.OPolyMeshSchemaSample()
    meshSchema = mesh.getSchema()

    meshPositions = toArray(alembic.Abc.V3fTPTraits,
    [imath.V3f(-0.5, -0.5, 0.5),
    imath.V3f(0.5, -0.5, 0.5),
    imath.V3f(-0.5, 0.5, 0.5),
    imath.V3f(0.5, 0.5, 0.5),
    imath.V3f(-0.5, -0.5, -0.5),
    imath.V3f(0.5, -0.5, -0.5),
    imath.V3f(-0.5, 0.5, -0.5),
    imath.V3f(0.5, 0.5, -0.5)])

    faceCounts = toArray(alembic.Abc.Int32TPTraits, [4, 4, 4, 4, 4, 4])
    faceIndices = toArray(alembic.Abc.Int32TPTraits, [2, 3, 1, 0, 6, 7, 3, 2, 4, 5, 7, 6, 0, 1, 5, 4, 3, 7, 5, 1, 6, 2, 0, 4])

    meshSample.setPositions(meshPositions)
    meshSample.setFaceCounts(faceCounts)
    meshSample.setFaceIndices(faceIndices)

    meshSchema.set(meshSample)
    meshSchema.valid()

    faceset1 = alembic.AbcGeom.OFaceSet(mesh, "faceset1")
    faceset1Schema = faceset1.getSchema()
    print faceset1Schema.valid()

    faces1 = toArray(alembic.Abc.Int32TPTraits, [2, 3, 5])
    faceset1Sample = alembic.AbcGeom.OFaceSetSchemaSample(faces1)
    faceset1Schema.set(faceset1Sample)

    faceset2 = alembic.AbcGeom.OFaceSet(mesh, "faceset2")
    faceset2Schema = faceset2.getSchema()
    faces2 = toArray(alembic.Abc.Int32TPTraits, [0, 1, 4])
    faceset2Sample = alembic.AbcGeom.OFaceSetSchemaSample(faces2)
    faceset2Schema.set(faceset2Sample)
    print faceset2Schema.valid()

meshOut("facesetTest.abc")

And here's the code to read that cache back in and query information about one of the facesets:

import alembic

iarchive = alembic.Abc.IArchive("facesetTest.abc")
top = iarchive.getTop()
mesh = top.getChild("cube")
faceset1 = mesh.getChild("faceset1")
faceset1Schema = alembic.AbcGeom.IFaceSetSchema(faceset1.getProperties())
print faceset1Schema.valid()
print faceset1Schema.getFaceExclusivity()

The getFaceExclusivity call will throw an exception because the ".facesExclusive" property doesn't exist, even though it's supposed to be optional and we just wrote out a valid faceset schema in the first code block. From looking at the implementation in IFaceSet.cpp, it also appears as though the intention is that this property should be optional, but that doesn't prove out in testing.

I wanted to confirm that this seems erroneous, as it seems to be to me.

Thanks,
-A

@lamiller0
Copy link
Contributor

What version of Alembic are you using?

In:
https://github.com/alembic/alembic/blob/master/lib/Alembic/AbcGeom/IFaceSet.cpp#L100

It looks like its properly protected.

@aferrall
Copy link
Author

Hey Lucas -- I just tested this against the latest in the Alembic master branch (which I built yesterday) and was able to reproduce the same issue. I looked at the line you've pointed out as well and thought things were properly protected, but I believe the exception is actually thrown when trying to construct the Abc::IUInt32Property itself.

@lamiller0 lamiller0 self-assigned this May 25, 2017
@lamiller0 lamiller0 added this to the 1.7.2 milestone May 25, 2017
@lamiller0 lamiller0 added the bug label May 25, 2017
@lamiller0
Copy link
Contributor

Ahhhh, thanks for the hint, we can get this fixed for the next release.

@aferrall
Copy link
Author

Great, thanks Lucas!

@lamiller0
Copy link
Contributor

This should now be fixed in 1.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants