本文整理汇总了C++中ContextPtr::set方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextPtr::set方法的具体用法?C++ ContextPtr::set怎么用?C++ ContextPtr::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextPtr
的用法示例。
在下文中一共展示了ContextPtr::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testManyContexts
// A test useful for assessing the performance
// of the Context class.
void GafferTest::testManyContexts()
{
// our typical context doesn't have a huge number of keys - we'll
// use a working set of 20 for this test.
ContextPtr base = new Context();
const int numKeys = 20;
vector<InternedString> keys;
for( int i = 0; i < numKeys; ++i )
{
InternedString key = string( "testKey" ) + lexical_cast<string>( i );
keys.push_back( key );
base->set( key, i );
}
// then typically we create new temporary contexts based on that one,
// change a value or two, and then continue.
Timer t;
for( int i = 0; i < 100000; ++i )
{
ContextPtr tmp = new Context( *base, Context::Borrowed );
tmp->set( keys[i%numKeys], i );
GAFFERTEST_ASSERT( tmp->get<int>( keys[i%numKeys] ) == i );
}
// uncomment to get timing information
//std::cerr << t.stop() << std::endl;
}
示例2: imageHash
IECore::MurmurHash ImagePlug::imageHash() const
{
const Box2i dataWindow = dataWindowPlug()->getValue();
ConstStringVectorDataPtr channelNamesData = channelNamesPlug()->getValue();
const vector<string> &channelNames = channelNamesData->readable();
MurmurHash result = formatPlug()->hash();
result.append( dataWindowPlug()->hash() );
result.append( metadataPlug()->hash() );
result.append( channelNamesPlug()->hash() );
V2i minTileOrigin = tileOrigin( dataWindow.min );
V2i maxTileOrigin = tileOrigin( dataWindow.max );
ContextPtr context = new Context( *Context::current(), Context::Borrowed );
Context::Scope scope( context.get() );
for( vector<string>::const_iterator it = channelNames.begin(), eIt = channelNames.end(); it!=eIt; it++ )
{
context->set( ImagePlug::channelNameContextName, *it );
for( int tileOriginY = minTileOrigin.y; tileOriginY<=maxTileOrigin.y; tileOriginY += tileSize() )
{
for( int tileOriginX = minTileOrigin.x; tileOriginX<=maxTileOrigin.x; tileOriginX += tileSize() )
{
context->set( ImagePlug::tileOriginContextName, V2i( tileOriginX, tileOriginY ) );
channelDataPlug()->hash( result );
}
}
}
return result;
}
示例3: operator
void operator()( const blocked_range2d<size_t>& r ) const
{
ContextPtr context = new Context( *m_parentContext );
const Box2i operationWindow( V2i( r.rows().begin()+m_dataWindow.min.x, r.cols().begin()+m_dataWindow.min.y ), V2i( r.rows().end()+m_dataWindow.min.x-1, r.cols().end()+m_dataWindow.min.y-1 ) );
V2i minTileOrigin = ImagePlug::tileOrigin( operationWindow.min );
V2i maxTileOrigin = ImagePlug::tileOrigin( operationWindow.max );
size_t imageStride = m_dataWindow.size().x + 1;
for( int tileOriginY = minTileOrigin.y; tileOriginY <= maxTileOrigin.y; tileOriginY += m_tileSize )
{
for( int tileOriginX = minTileOrigin.x; tileOriginX <= maxTileOrigin.x; tileOriginX += m_tileSize )
{
for( vector<string>::const_iterator it = m_channelNames.begin(), eIt = m_channelNames.end(); it != eIt; it++ )
{
context->set( ImagePlug::channelNameContextName, *it );
context->set( ImagePlug::tileOriginContextName, V2i( tileOriginX, tileOriginY ) );
Context::Scope scope( context.get() );
Box2i tileBound( V2i( tileOriginX, tileOriginY ), V2i( tileOriginX + m_tileSize - 1, tileOriginY + m_tileSize - 1 ) );
Box2i b = boxIntersection( tileBound, operationWindow );
ConstFloatVectorDataPtr tileData = m_channelDataPlug->getValue();
for( int y = b.min.y; y<=b.max.y; y++ )
{
const float *tilePtr = &(tileData->readable()[0]) + (y - tileOriginY) * m_tileSize + (b.min.x - tileOriginX);
float *channelPtr = m_imageChannelData[it-m_channelNames.begin()] + ( m_dataWindow.size().y - ( y - m_dataWindow.min.y ) ) * imageStride + (b.min.x - m_dataWindow.min.x);
for( int x = b.min.x; x <= b.max.x; x++ )
{
*channelPtr++ = *tilePtr++;
}
}
}
}
}
}
示例4: compute
void ColorProcessor::compute( Gaffer::ValuePlug *output, const Gaffer::Context *context ) const
{
if( output == colorDataPlug() )
{
FloatVectorDataPtr r, g, b;
{
ContextPtr tmpContext = new Context( *context, Context::Borrowed );
Context::Scope scopedContext( tmpContext.get() );
tmpContext->set( ImagePlug::channelNameContextName, string( "R" ) );
r = inPlug()->channelDataPlug()->getValue()->copy();
tmpContext->set( ImagePlug::channelNameContextName, string( "G" ) );
g = inPlug()->channelDataPlug()->getValue()->copy();
tmpContext->set( ImagePlug::channelNameContextName, string( "B" ) );
b = inPlug()->channelDataPlug()->getValue()->copy();
}
processColorData( context, r.get(), g.get(), b.get() );
ObjectVectorPtr result = new ObjectVector();
result->members().push_back( r );
result->members().push_back( g );
result->members().push_back( b );
static_cast<ObjectPlug *>( output )->setValue( result );
return;
}
ImageProcessor::compute( output, context );
}
示例5: channelDataHash
IECore::MurmurHash ImagePlug::channelDataHash( const std::string &channelName, const Imath::V2i &tile ) const
{
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
tmpContext->set( ImagePlug::channelNameContextName, channelName );
tmpContext->set( ImagePlug::tileOriginContextName, tile );
Context::Scope scopedContext( tmpContext.get() );
return channelDataPlug()->hash();
}
示例6: hashColorData
void ColorProcessor::hashColorData( const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
ContextPtr tmpContext = new Context( *context, Context::Borrowed );
Context::Scope scopedContext( tmpContext.get() );
tmpContext->set( ImagePlug::channelNameContextName, string( "R" ) );
inPlug()->channelDataPlug()->hash( h );
tmpContext->set( ImagePlug::channelNameContextName, string( "G" ) );
inPlug()->channelDataPlug()->hash( h );
tmpContext->set( ImagePlug::channelNameContextName, string( "B" ) );
inPlug()->channelDataPlug()->hash( h );
}
示例7: channelData
IECore::ConstFloatVectorDataPtr ImagePlug::channelData( const std::string &channelName, const Imath::V2i &tile ) const
{
if( direction()==In && !getInput<Plug>() )
{
return channelDataPlug()->defaultValue();
}
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
tmpContext->set( ImagePlug::channelNameContextName, channelName );
tmpContext->set( ImagePlug::tileOriginContextName, tile );
Context::Scope scopedContext( tmpContext.get() );
return channelDataPlug()->getValue();
}
示例8: scopedContext
Imath::Box3f ScenePlug::bound( const ScenePath &scenePath ) const
{
ContextPtr tmpContext = new Context( *Context::current() );
tmpContext->set( scenePathContextName, scenePath );
Context::Scope scopedContext( tmpContext );
return boundPlug()->getValue();
}
示例9: childNamesHash
IECore::MurmurHash ScenePlug::childNamesHash( const ScenePath &scenePath ) const
{
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
tmpContext->set( scenePathContextName, scenePath );
Context::Scope scopedContext( tmpContext.get() );
return childNamesPlug()->hash();
}
示例10: childNames
IECore::ConstInternedStringVectorDataPtr ScenePlug::childNames( const ScenePath &scenePath ) const
{
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
tmpContext->set( scenePathContextName, scenePath );
Context::Scope scopedContext( tmpContext.get() );
return childNamesPlug()->getValue();
}
示例11: object
IECore::ConstObjectPtr ScenePlug::object( const ScenePath &scenePath ) const
{
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
tmpContext->set( scenePathContextName, scenePath );
Context::Scope scopedContext( tmpContext.get() );
return objectPlug()->getValue();
}
示例12: scopedContext
Imath::M44f ScenePlug::transform( const ScenePath &scenePath ) const
{
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
tmpContext->set( scenePathContextName, scenePath );
Context::Scope scopedContext( tmpContext.get() );
return transformPlug()->getValue();
}
示例13: scopedContext
Imath::Box3f SceneNode::unionOfTransformedChildBounds( const ScenePath &path, const ScenePlug *out, const IECore::InternedStringVectorData *childNamesData ) const
{
ConstInternedStringVectorDataPtr computedChildNames;
if( !childNamesData )
{
computedChildNames = out->childNames( path );
childNamesData = computedChildNames.get();
}
const vector<InternedString> &childNames = childNamesData->readable();
Box3f result;
if( childNames.size() )
{
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
Context::Scope scopedContext( tmpContext.get() );
ScenePath childPath( path );
childPath.push_back( InternedString() ); // room for the child name
for( vector<InternedString>::const_iterator it = childNames.begin(); it != childNames.end(); it++ )
{
childPath[path.size()] = *it;
tmpContext->set( ScenePlug::scenePathContextName, childPath );
Box3f childBound = out->boundPlug()->getValue();
childBound = transform( childBound, out->transformPlug()->getValue() );
result.extendBy( childBound );
}
}
return result;
}
示例14: hashOfTransformedChildBounds
IECore::MurmurHash SceneNode::hashOfTransformedChildBounds( const ScenePath &path, const ScenePlug *out, const IECore::InternedStringVectorData *childNamesData ) const
{
ConstInternedStringVectorDataPtr computedChildNames;
if( !childNamesData )
{
computedChildNames = out->childNames( path );
childNamesData = computedChildNames.get();
}
const vector<InternedString> &childNames = childNamesData->readable();
IECore::MurmurHash result;
if( childNames.size() )
{
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
Context::Scope scopedContext( tmpContext.get() );
ScenePath childPath( path );
childPath.push_back( InternedString() ); // room for the child name
for( vector<InternedString>::const_iterator it = childNames.begin(); it != childNames.end(); it++ )
{
childPath[path.size()] = *it;
tmpContext->set( ScenePlug::scenePathContextName, childPath );
out->boundPlug()->hash( result );
out->transformPlug()->hash( result );
}
}
else
{
result.append( typeId() );
result.append( "emptyBound" );
}
return result;
}
示例15: attributesHash
IECore::MurmurHash ScenePlug::attributesHash( const ScenePath &scenePath ) const
{
ContextPtr tmpContext = new Context( *Context::current() );
tmpContext->set( scenePathContextName, scenePath );
Context::Scope scopedContext( tmpContext );
return attributesPlug()->hash();
}