def testObjectWasDeleted(self): mesh = self.mesh() sop = self.emptySop() converter = IECoreHoudini.ToHoudiniCortexObjectConverter(mesh) self.assertTrue(converter.convert(sop)) self.verifySop(sop, mesh) del mesh result = IECoreHoudini.FromHoudiniCortexObjectConverter(sop).convert() self.verifySop(sop, result)
def testAttributeFilter(self): mesh = self.mesh() sop = self.emptySop() converter = IECoreHoudini.ToHoudiniCortexObjectConverter(mesh) self.assertTrue(converter.convert(sop)) result = IECoreHoudini.FromHoudiniCortexObjectConverter(sop).convert() self.assertEqual(result.keys(), [ 'P', 'color3fPoint', 'color3fPrim', 'color3fVert', 'floatPoint', 'floatPrim', 'floatVert', 'stringPoint', 'stringPointIndices', 'stringPrim', 'stringPrimIndices', 'stringVert', 'stringVertIndices' ]) converter.parameters()["attributeFilter"].setTypedValue("P *3f*") self.assertTrue(converter.convert(sop)) result = IECoreHoudini.FromHoudiniCortexObjectConverter(sop).convert() self.assertEqual(result.keys(), ['P', 'color3fPoint', 'color3fPrim', 'color3fVert']) converter.parameters()["attributeFilter"].setTypedValue( "* ^color* ^string*") self.assertTrue(converter.convert(sop)) result = IECoreHoudini.FromHoudiniCortexObjectConverter(sop).convert() self.assertEqual(result.keys(), ['P', 'floatPoint', 'floatPrim', 'floatVert']) # verify From filter works as well fromConverter = IECoreHoudini.FromHoudiniCortexObjectConverter(sop) fromConverter.parameters()["attributeFilter"].setTypedValue("P *Prim") result = fromConverter.convert() self.assertEqual(result.keys(), ['P', 'floatPrim']) # verify we can filter uvs mesh = IECore.MeshPrimitive.createPlane( IECore.Box2f(IECore.V2f(0), IECore.V2f(1))) IECore.TriangulateOp()(input=mesh, copyInput=False) IECore.MeshNormalsOp()(input=mesh, copyInput=False) mesh["Cs"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData([IECore.V3f(1, 0, 0)] * 6, IECore.GeometricData.Interpretation.Color)) mesh["width"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData([1] * 4)) mesh["Pref"] = mesh["P"] # have to filter the source attrs s, t and not uv converter = IECoreHoudini.ToHoudiniCortexObjectConverter(mesh) converter.parameters()["attributeFilter"].setTypedValue( "* ^uv ^pscale ^rest") self.assertTrue(converter.convert(sop)) result = IECoreHoudini.FromHoudiniCortexObjectConverter(sop).convert() self.assertEqual(result.keys(), ['Cs', 'N', 'P', 'Pref', 's', 't', 'width']) converter.parameters()["attributeFilter"].setTypedValue( "* ^s ^t ^width ^Pref") self.assertTrue(converter.convert(sop)) result = IECoreHoudini.FromHoudiniCortexObjectConverter(sop).convert() self.assertEqual(result.keys(), ['Cs', 'N', 'P']) # verify non-primitives do not break converter = IECoreHoudini.ToHoudiniCortexObjectConverter( IECore.IntData(1)) converter.parameters()["attributeFilter"].setTypedValue( "* ^uv ^pscale ^rest") self.assertTrue(converter.convert(sop)) self.assertEqual( IECoreHoudini.FromHoudiniCortexObjectConverter(sop).convert(), IECore.IntData(1))