Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Fixes

- PointInstancer : Fixed accessors to accept Varying primitive variables where Vertex is expected, since the two interpolations are equivalent.

API
---

- IECoreUSD::StageAlgo : Added new namespace with a `sceneInterface()` function, providing a SceneInterface for reading an existing `UsdStage`.

10.7.4.0 (relative to 10.7.3.1)
========

Expand Down
58 changes: 58 additions & 0 deletions contrib/IECoreUSD/include/IECoreUSD/StageAlgo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2026, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of Image Engine Design nor the names of any
// other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#ifndef IECOREUSD_STAGEALGO_H
#define IECOREUSD_STAGEALGO_H

#include "IECoreUSD/Export.h"

#include "IECoreScene/SceneInterface.h"

IECORE_PUSH_DEFAULT_VISIBILITY
#include "pxr/usd/usd/stage.h"
IECORE_POP_DEFAULT_VISIBILITY

namespace IECoreUSD
{

namespace StageAlgo
{

IECOREUSD_API IECoreScene::SceneInterfacePtr sceneInterface( const pxr::UsdStageRefPtr &stage );

} // namespace StageAlgo

} // namespace IECoreUSD

#endif // IECOREUSD_STAGEALGO_H
2 changes: 2 additions & 0 deletions contrib/IECoreUSD/python/IECoreUSD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
__import__( "pxr.Vt" )
__import__( "pxr.Sdf" )

__import__( "IECoreScene" )

from ._IECoreUSD import *

__import__( "IECore" ).loadConfig( "CORTEX_STARTUP_PATHS", subdirectory = "IECoreUSD" )
44 changes: 44 additions & 0 deletions contrib/IECoreUSD/src/IECoreUSD/StageAlgo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2026, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of Image Engine Design nor the names of any
// other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#include "IECoreUSD/StageAlgo.h"

#include "USDScene.h"

using namespace IECoreUSD;

IECoreScene::SceneInterfacePtr IECoreUSD::StageAlgo::sceneInterface( const pxr::UsdStageRefPtr &stage )
{
return new USDScene( stage, IECore::IndexedIO::Read );
}
36 changes: 34 additions & 2 deletions contrib/IECoreUSD/src/IECoreUSD/bindings/IEUSDModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include "IECoreUSD/DataAlgo.h"
#include "IECoreUSD/SceneCacheDataAlgo.h"
#include "IECoreUSD/StageAlgo.h"

#include "IECoreScene/SceneInterface.h"

Expand Down Expand Up @@ -101,8 +102,11 @@ struct PxrBoostConverter
static void registerConverters()
{
boost::python::to_python_converter<T, ToPxrBoost>();
/// \todo Add conversion from Python when we have
/// a use for it. See PyBindConverter for an example.
boost::python::converter::registry::push_back(
&FromPxrBoost::convertible,
&FromPxrBoost::construct,
boost::python::type_id<T>()
);
}

private :
Expand All @@ -117,6 +121,25 @@ struct PxrBoostConverter
}
};

struct FromPxrBoost
{

static void *convertible( PyObject *object )
{
return pxr::pxr_boost::python::extract<T>( object ).check() ? object : nullptr;
}

static void construct( PyObject *object, boost::python::converter::rvalue_from_python_stage1_data *data )
{
void *storage = ( ( boost::python::converter::rvalue_from_python_storage<T> * ) data )->storage.bytes;
T *t = new( storage ) T;
data->convertible = storage;

*t = pxr::pxr_boost::python::extract<T>( object )();
}

};

};

#endif // PXR_VERSION >= 2505
Expand All @@ -129,6 +152,7 @@ BOOST_PYTHON_MODULE( _IECoreUSD )
PxrBoostConverter<pxr::TfToken>::registerConverters();
PxrBoostConverter<pxr::VtValue>::registerConverters();
PxrBoostConverter<pxr::SdfValueTypeName>::registerConverters();
PxrBoostConverter<pxr::UsdStageRefPtr>::registerConverters();
#endif

{
Expand All @@ -152,4 +176,12 @@ BOOST_PYTHON_MODULE( _IECoreUSD )
def( "toInternalPath", toInternalPath );
def( "fromInternalPath", fromInternalPath );
}

{
object stageAlgoModule( handle<>( borrowed( PyImport_AddModule( "IECoreUSD.StageAlgo" ) ) ) );
scope().attr( "StageAlgo" ) = stageAlgoModule;
scope stageAlgoModuleScope( stageAlgoModule );

def( "sceneInterface", &StageAlgo::sceneInterface );
}
}
1 change: 1 addition & 0 deletions contrib/IECoreUSD/test/IECoreUSD/All.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from USDSceneTest import USDSceneTest
from SceneCacheFileFormatTest import SceneCacheFileFormatTest
from DataAlgoTest import DataAlgoTest
from StageAlgoTest import StageAlgoTest

unittest.TestProgram(
testRunner = unittest.TextTestRunner(
Expand Down
58 changes: 58 additions & 0 deletions contrib/IECoreUSD/test/IECoreUSD/StageAlgoTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
##########################################################################
#
# Copyright (c) 2026, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of Image Engine Design nor the names of any
# other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################

import unittest

import pxr.Usd
import pxr.UsdGeom

import IECoreScene
import IECoreUSD

class StageAlgoTest( unittest.TestCase ) :

def testSceneInterface( self ) :

stage = pxr.Usd.Stage.CreateInMemory()
pxr.UsdGeom.Sphere.Define( stage, "/sphere" )

root = IECoreUSD.StageAlgo.sceneInterface( stage )
del stage

self.assertIsInstance( root, IECoreScene.SceneInterface )
self.assertEqual( root.childNames(), [ "sphere" ] )
self.assertIsInstance( root.child( "sphere" ).readObject( 0 ), IECoreScene.SpherePrimitive )

if __name__ == "__main__":
unittest.main()
Loading