def TestBug112645(): f1 = Pcp.MapFunction( {'/GuitarRig':'/GuitarRigX', '/GuitarRig/Rig/StringsRig/_Class_StringRig/String': '/GuitarRigX/Anim/Strings/String1'}) f2 = Pcp.MapFunction( {'/StringsRig/String1Rig/String' : '/GuitarRig/Anim/Strings/String1', '/StringsRig' : '/GuitarRig/Rig/StringsRig'}) assert f1.Compose(f2) == Pcp.MapFunction({ '/StringsRig':'/GuitarRigX/Rig/StringsRig', '/StringsRig/_Class_StringRig/String': '/GuitarRigX/Anim/Strings/String1'})
def test_Basic(self): ######################################################################## # A basic reference arc. # self._AssertDepsEqual( self._FindSiteDeps( 'BasicReference/root.sdf', 'BasicReference/ref.sdf', '/PrimA'), [ Pcp.Dependency( '/PrimWithReferences', '/PrimA', Pcp.MapFunction({'/PrimA': '/PrimWithReferences'}) ) ]) ######################################################################## # A reference to a defaultPrim. # self._AssertDepsEqual( self._FindSiteDeps( 'BasicReference/root.sdf', 'BasicReference/defaultRef.sdf', '/Default'), [ Pcp.Dependency( '/PrimWithDefaultReferenceTarget', '/Default', Pcp.MapFunction({ '/Default': '/PrimWithDefaultReferenceTarget'}) ) ]) ######################################################################## # A reference case showing the distinction between ancestral and # direct dependencies. # self._AssertDepsEqual( self._FindSiteDeps( 'BasicAncestralReference/root.sdf', 'BasicAncestralReference/A.sdf', '/A'), [ Pcp.Dependency( '/A', '/A', Pcp.MapFunction({ '/A': '/A'}) ) ]) self._AssertDepsEqual( self._FindSiteDeps( 'BasicAncestralReference/root.sdf', 'BasicAncestralReference/B.sdf', '/B', depMask = Pcp.DependencyTypeDirect | Pcp.DependencyTypeNonVirtual ), [ Pcp.Dependency( '/A/B', '/B', Pcp.MapFunction({ '/B': '/A/B'}) ) ]) self._AssertDepsEqual( self._FindSiteDeps( 'BasicAncestralReference/root.sdf', 'BasicAncestralReference/A.sdf', '/A/B', depMask = Pcp.DependencyTypeAncestral | Pcp.DependencyTypeNonVirtual ), [ Pcp.Dependency( '/A/B', '/A/B', Pcp.MapFunction({ '/A': '/A'}) ) ]) ######################################################################## # An example showing how we can use existing structure to reason about # deps that would apply to sites that do not contain any specs yet. # This case is important for change processing the addition of a new # child prim. # self._AssertDepsEqual( self._FindSiteDeps( 'BasicAncestralReference/root.sdf', 'BasicAncestralReference/A.sdf', '/A.HypotheticalProperty', ), [ Pcp.Dependency( '/A.HypotheticalProperty', '/A.HypotheticalProperty', Pcp.MapFunction({ '/A': '/A'}) ) ]) self._AssertDepsEqual( self._FindSiteDeps( 'BasicAncestralReference/root.sdf', 'BasicAncestralReference/A.sdf', '/A.HypotheticalProperty', recurseOnSite = True, # This should have no effect on the results. ), [ Pcp.Dependency( '/A.HypotheticalProperty', '/A.HypotheticalProperty', Pcp.MapFunction({ '/A': '/A'}) ) ]) self._AssertDepsEqual( self._FindSiteDeps( 'BasicAncestralReference/root.sdf', 'BasicAncestralReference/A.sdf', '/A/B/HypotheticalChildPrim', depMask = Pcp.DependencyTypeAncestral | Pcp.DependencyTypeNonVirtual ), [ Pcp.Dependency( '/A/B/HypotheticalChildPrim', '/A/B/HypotheticalChildPrim', Pcp.MapFunction({ '/A': '/A'}) ) ]) ######################################################################## # Using recurseOnSite to find inbound dependencies on child sites. # This is important for the case of making a significant change to # a prim that contains children inherited elsewhere. self._AssertDepsEqual( self._FindSiteDeps( 'BasicLocalAndGlobalClassCombination/root.sdf', 'BasicLocalAndGlobalClassCombination/model.sdf', '/_class_Model/_class_Nested', depMask = Pcp.DependencyTypeAnyIncludingVirtual, recurseOnSite = True ), [ Pcp.Dependency( '/Model_1/_class_Nested', '/_class_Model/_class_Nested', Pcp.MapFunction({ '/_class_Model': '/Model_1', }) ), Pcp.Dependency( '/Model_1/_class_Nested/Left', '/_class_Model/_class_Nested/Sym', Pcp.MapFunction({ '/_class_Model': '/Model_1', '/_class_Model/_class_Nested/Sym': '/Model_1/_class_Nested/Left', }) ), Pcp.Dependency( '/Model_1/Instance', '/_class_Model/_class_Nested', Pcp.MapFunction({ '/_class_Model': '/Model_1', '/_class_Model/_class_Nested': '/Model_1/Instance', }) ), Pcp.Dependency( '/Model_1/Instance/Left', '/_class_Model/_class_Nested/Sym', Pcp.MapFunction({ '/_class_Model': '/Model_1', '/_class_Model/_class_Nested': '/Model_1/Instance', '/_class_Model/_class_Nested/Sym': '/Model_1/Instance/Left', }) ), ]) ######################################################################## # Because deps are analyzed in terms of prim arcs, recurseOnSite needs # to be careful to work correctly when querying deps on a property path. self._AssertDepsEqual( self._FindSiteDeps( 'BasicVariantWithConnections/root.sdf', 'BasicVariantWithConnections/camera.sdf', '/camera.HypotheticalProperty', recurseOnSite = True, ), [ Pcp.Dependency( '/main_cam.HypotheticalProperty', '/camera.HypotheticalProperty', Pcp.MapFunction({ '/camera': '/main_cam'}) ) ]) ######################################################################## # A reference arc, using recurseOnIndex to pick up child indexes # that do not introduce any new deps. # self._AssertDepsEqual( self._FindSiteDeps( 'BasicReference/root.sdf', 'BasicReference/ref2.sdf', '/PrimB', recurseOnIndex = True), [ Pcp.Dependency( '/PrimWithReferences', '/PrimB', Pcp.MapFunction({'/PrimB': '/PrimWithReferences'}) ), Pcp.Dependency( '/PrimWithReferences/PrimA_Child', '/PrimB/PrimA_Child', Pcp.MapFunction({'/PrimB': '/PrimWithReferences'}) ), Pcp.Dependency( '/PrimWithReferences/PrimB_Child', '/PrimB/PrimB_Child', Pcp.MapFunction({'/PrimB': '/PrimWithReferences'}) ), Pcp.Dependency( '/PrimWithReferences/PrimC_Child', '/PrimB/PrimC_Child', Pcp.MapFunction({'/PrimB': '/PrimWithReferences'}) ) ]) ######################################################################## # A relocation that affects a connection target path. # This requires path translation below the dependency arc. # self._AssertDepsEqual( self._FindSiteDeps( 'TrickyConnectionToRelocatedAttribute/root.sdf', 'TrickyConnectionToRelocatedAttribute/eye_rig.sdf', '/EyeRig/rig/Mover.bar[/EyeRig/Anim.foo]'), [ Pcp.Dependency( '/HumanRig/rig/Face/rig/LEyeRig/rig/Mover.bar[/HumanRig/Anim/Face/LEye.foo]', '/EyeRig/rig/Mover.bar[/EyeRig/Anim.foo]', Pcp.MapFunction({ '/EyeRig': '/HumanRig/rig/Face/rig/LEyeRig', '/EyeRig/Anim': '/HumanRig/Anim/Face/LEye', }) ), Pcp.Dependency( '/HumanRig/rig/Face/rig/REyeRig/rig/Mover.bar[/HumanRig/Anim/Face/REye.foo]', '/EyeRig/rig/Mover.bar[/EyeRig/Anim.foo]', Pcp.MapFunction({ '/EyeRig': '/HumanRig/rig/Face/rig/REyeRig', '/EyeRig/Anim': '/HumanRig/Anim/Face/REye', }) ), Pcp.Dependency( '/HumanRig/rig/Face/rig/SymEyeRig/rig/Mover.bar[/HumanRig/rig/Face/rig/SymEyeRig/Anim.foo]', '/EyeRig/rig/Mover.bar[/EyeRig/Anim.foo]', Pcp.MapFunction({ '/EyeRig': '/HumanRig/rig/Face/rig/SymEyeRig', }) ), ]) ######################################################################## # A relocation that causes a virtual (aka spooky) dependency. # # Virtual deps are not returned when not requested: self._AssertDepsEqual( self._FindSiteDeps( 'TrickyConnectionToRelocatedAttribute/root.sdf', 'TrickyConnectionToRelocatedAttribute/root.sdf', '/HumanRig/rig/Face/rig/LEyeRig/Anim', depMask = (Pcp.DependencyTypeDirect | Pcp.DependencyTypeAncestral | Pcp.DependencyTypeNonVirtual) ), []) # Virtual deps are introduced by relocations: self._AssertDepsEqual( self._FindSiteDeps( 'TrickyConnectionToRelocatedAttribute/root.sdf', 'TrickyConnectionToRelocatedAttribute/root.sdf', '/HumanRig/rig/Face/rig/LEyeRig/Anim', depMask = (Pcp.DependencyTypeDirect | Pcp.DependencyTypeAncestral | Pcp.DependencyTypeVirtual) ), # XXX These deps are duplicated 2x due to the presence of relocates # nodes representing virtual dependencies. Leaving here for now, # but this raises an interesting question w/r/t whether we should # unique the deps. [ Pcp.Dependency( '/HumanRig/Anim/Face/LEye', '/HumanRig/rig/Face/rig/LEyeRig/Anim', Pcp.MapFunction.Identity()), Pcp.Dependency( '/HumanRig/rig/Face/Anim/LEye', '/HumanRig/rig/Face/rig/LEyeRig/Anim', Pcp.MapFunction.Identity()), Pcp.Dependency( '/HumanRig/Anim/Face/LEye', '/HumanRig/rig/Face/rig/LEyeRig/Anim', Pcp.MapFunction.Identity()), Pcp.Dependency( '/HumanRig/rig/Face/Anim/LEye', '/HumanRig/rig/Face/rig/LEyeRig/Anim', Pcp.MapFunction.Identity()), ])
def TestBug74847(): m = Pcp.MapFunction({'/A': '/A/B'}) assert m.MapSourceToTarget('/A/B') == Sdf.Path('/A/B/B') assert m.MapTargetToSource('/A/B/B') == Sdf.Path('/A/B')
# # Unless required by applicable law or agreed to in writing, software # distributed under the Apache License with the above modification is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the Apache License for the specific # language governing permissions and limitations under the Apache License. from pxr import Sdf, Pcp import unittest testPaths = [Sdf.Path(), Sdf.Path('/'), Sdf.Path('/foo'), Sdf.Path('/a/b/c')] testMapFuncs = [] # Test null function null = Pcp.MapFunction() testMapFuncs.append(null) assert null.isNull assert not null.isIdentity assert null.timeOffset == Sdf.LayerOffset() for path in testPaths: assert null.MapSourceToTarget(path).isEmpty # Test identity function identity = Pcp.MapFunction.Identity() testMapFuncs.append(identity) assert not identity.isNull assert identity.isIdentity assert identity.timeOffset == Sdf.LayerOffset() for path in testPaths: assert identity.MapSourceToTarget(path) == path
# language governing permissions and limitations under the Apache License. from pxr import Sdf, Pcp import unittest testPaths = [ Sdf.Path(), Sdf.Path('/'), Sdf.Path('/foo'), Sdf.Path('/a/b/c') ] testMapFuncs = [] # Test null function null = Pcp.MapFunction() testMapFuncs.append(null) assert null.isNull assert not null.isIdentity assert not null.isIdentityPathMapping assert null.timeOffset == Sdf.LayerOffset() for path in testPaths: assert null.MapSourceToTarget( path ).isEmpty # Test identity function identity = Pcp.MapFunction.Identity() testMapFuncs.append(identity) assert not identity.isNull assert identity.isIdentity assert identity.isIdentityPathMapping assert identity.timeOffset == Sdf.LayerOffset()