本文整理汇总了C++中CompoundDataPtr类的典型用法代码示例。如果您正苦于以下问题:C++ CompoundDataPtr类的具体用法?C++ CompoundDataPtr怎么用?C++ CompoundDataPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CompoundDataPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: namePlug
IECore::ConstCompoundObjectPtr Set::computeProcessedGlobals( const Gaffer::Context *context, IECore::ConstCompoundObjectPtr inputGlobals ) const
{
std::string name = namePlug()->getValue();
if( !name.size() )
{
return inputGlobals;
}
IECore::CompoundObjectPtr result = new IECore::CompoundObject;
// Since we're not going to modify any existing members other than the sets,
// and our result becomes const on returning it, we can directly reference
// the input members in our result without copying. We have to be careful not
// to modify the input sets though.
result->members() = inputGlobals->members();
CompoundDataPtr sets = new CompoundData;
if( const CompoundData *inputSets = inputGlobals->member<CompoundData>( "gaffer:sets" ) )
{
sets->writable() = inputSets->readable();
}
result->members()["gaffer:sets"] = sets;
ConstObjectPtr set = pathMatcherPlug()->getValue();
// const cast is acceptable because we're just using it to place a const object into a
// container that will be treated as const everywhere immediately after return from this method.
sets->writable()[name] = const_cast<Data *>( static_cast<const Data *>( set.get() ) );
return result;
}
示例2: FileIndexedIO
void ObjectWriter::doWrite( const CompoundObject *operands )
{
IndexedIOPtr io = new FileIndexedIO( fileName(), IndexedIO::rootPath, IndexedIO::Exclusive | IndexedIO::Write);
/// \todo Establish why we only accept CompoundData / Data here when HeaderGenerator::header(), for example,
/// returns a CompoundObject
// write the header
CompoundDataPtr header = boost::static_pointer_cast<CompoundData>( m_headerParameter->getValue()->copy() );
header->writable()["typeName"] = new StringData( object()->typeName() );
if( const VisibleRenderable* visibleRenderable = runTimeCast<const VisibleRenderable>(object()) )
{
header->writable()["bound"] = new Box3fData( visibleRenderable->bound() );
}
CompoundObjectPtr genericHeader = HeaderGenerator::header();
for ( CompoundObject::ObjectMap::const_iterator it = genericHeader->members().begin(); it != genericHeader->members().end(); it++ )
{
assert( it->second );
if ( it->second->isInstanceOf( Data::staticTypeId() ) )
{
header->writable()[ it->first ] = boost::static_pointer_cast< Data >( it->second );
}
}
((ObjectPtr)header)->save( io, "header" );
// write the object
object()->save( io, "object" );
}
示例3: metadataGetter
static IECore::ConstCompoundDataPtr metadataGetter( const std::string &key, size_t &cost )
{
cost = 1;
if( !key.size() )
{
return NULL;
}
const char *searchPath = getenv( "OSL_SHADER_PATHS" );
OSLQuery query;
if( !query.open( key, searchPath ? searchPath : "" ) )
{
throw Exception( query.error() );
}
CompoundDataPtr metadata = new CompoundData;
metadata->writable()["shader"] = convertMetadata( query.metadata() );
CompoundDataPtr parameterMetadata = new CompoundData;
metadata->writable()["parameter"] = parameterMetadata;
for( size_t i = 0; i < query.nparams(); ++i )
{
const OSLQuery::Parameter *parameter = query.getparam( i );
if( parameter->metadata.size() )
{
parameterMetadata->writable()[parameter->name] = convertMetadata( parameter->metadata );
}
}
return metadata;
}
示例4: fnCamera
IECore::ObjectPtr FromMayaCameraConverter::doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const
{
MFnCamera fnCamera( dagPath );
// convert things that are required by the IECore::Renderer specification
CameraPtr result = new Camera;
result->setName( IECore::convert<std::string>( fnCamera.name() ) );
result->setTransform( new MatrixTransform( IECore::convert<Imath::M44f>( dagPath.inclusiveMatrix() ) ) );
V2i resolution;
if( operands->member<IntData>( "resolutionMode" )->readable()==RenderGlobals )
{
MCommonRenderSettingsData renderSettings;
MRenderUtil::getCommonRenderSettings( renderSettings );
resolution = Imath::V2i( renderSettings.width, renderSettings.height );
}
else
{
resolution = operands->member<V2iData>( "resolution" )->readable();
}
result->parameters()["resolution"] = new V2iData( resolution );
Imath::V2f clippingPlanes = Imath::V2f( fnCamera.nearClippingPlane(), fnCamera.farClippingPlane() );
result->parameters()["clippingPlanes"] = new V2fData( clippingPlanes );
Imath::Box2d frustum;
fnCamera.getRenderingFrustum( (float)resolution.x / (float)resolution.y, frustum.min.x, frustum.max.x, frustum.min.y, frustum.max.y );
if( fnCamera.isOrtho() )
{
// orthographic
result->parameters()["projection"] = new StringData( "orthographic" );
result->parameters()["screenWindow"] = new Box2fData( Box2f( frustum.min, frustum.max ) );
}
else
{
// perspective
result->parameters()["projection"] = new StringData( "perspective" );
// derive horizontal field of view from the viewing frustum
float fov = Math<double>::atan( frustum.max.x / clippingPlanes[0] ) * 2.0f;
fov = radiansToDegrees( fov );
result->parameters()["projection:fov"] = new FloatData( fov );
// scale the frustum so that it's -1,1 in x and that gives us the screen window
float frustumScale = 2.0f/(frustum.max.x - frustum.min.x);
Box2f screenWindow( V2f( -1, frustum.min.y * frustumScale ), V2f( 1, frustum.max.y * frustumScale ) );
result->parameters()["screenWindow"] = new Box2fData( screenWindow );
}
// and add on other bits and bobs from maya attributes as blind data
CompoundDataPtr maya = new CompoundData;
result->blindData()->writable()["maya"] = maya;
maya->writable()["aperture"] = new V2fData( Imath::V2f( fnCamera.horizontalFilmAperture(), fnCamera.verticalFilmAperture() ) );
return result;
}
示例5: InternedStringVectorData
IECore::CompoundDataPtr LinkedScene::linkAttributeData( const SceneInterface *scene )
{
std::string f = scene->fileName();
InternedStringVectorDataPtr r = new InternedStringVectorData();
scene->path( r->writable() );
CompoundDataPtr d = new CompoundData();
d->writable()[g_fileName] = new StringData(f);
d->writable()[g_root] = r;
return d;
}
示例6: metaData
IECore::CompoundDataPtr AlembicInput::metaData() const
{
const MetaData &md = m_data->object.getMetaData();
CompoundDataPtr resultData = new CompoundData;
CompoundDataMap &resultMap = resultData->writable();
for( MetaData::const_iterator it = md.begin(), eIt = md.end(); it!=eIt; it++ )
{
resultMap[it->first] = new StringData( it->second );
}
return resultData;
}
示例7: convertMetadata
static IECore::CompoundDataPtr convertMetadata( const std::vector<OSLQuery::Parameter> &metadata )
{
CompoundDataPtr result = new CompoundData;
for( std::vector<OSLQuery::Parameter>::const_iterator it = metadata.begin(), eIt = metadata.end(); it != eIt; ++it )
{
DataPtr data = convertMetadata( *it );
if( data )
{
result->writable()[it->name.c_str()] = data;
}
}
return result;
}
示例8: particleAttributes
ObjectPtr BGEOParticleReader::doOperation( const CompoundObject *operands )
{
vector<string> attributes;
particleAttributes( attributes );
size_t nParticles = numParticles();
PointsPrimitivePtr result = new PointsPrimitive( nParticles );
CompoundDataPtr attributeData = readAttributes( attributes );
if ( !attributeData )
{
throw Exception( ( format( "Failed to load \"%s\"." ) % fileName() ).str() );
}
bool haveNumPoints = false;
for( vector<string>::const_iterator it = attributes.begin(); it!=attributes.end(); it++ )
{
CompoundDataMap::const_iterator itData = attributeData->readable().find( *it );
if ( itData == attributeData->readable().end() )
{
msg( Msg::Warning, "ParticleReader::doOperation", format( "Attribute %s expected but not found." ) % *it );
continue;
}
DataPtr d = itData->second;
if ( testTypedData<TypeTraits::IsVectorTypedData>( d ) )
{
size_t s = despatchTypedData< TypedDataSize, TypeTraits::IsVectorTypedData >( d );
if( !haveNumPoints )
{
result->setNumPoints( s );
haveNumPoints = true;
}
if( s==result->getNumPoints() )
{
result->variables.insert( PrimitiveVariableMap::value_type( *it, PrimitiveVariable( PrimitiveVariable::Vertex, d ) ) );
}
else
{
msg( Msg::Warning, "ParticleReader::doOperation", format( "Ignoring attribute \"%s\" due to insufficient elements (expected %d but found %d)." ) % *it % result->getNumPoints() % s );
}
}
else if ( testTypedData<TypeTraits::IsSimpleTypedData>( d ) )
{
result->variables.insert( PrimitiveVariableMap::value_type( *it, PrimitiveVariable( PrimitiveVariable::Constant, d ) ) );
}
}
return result;
}
示例9: setsPlug
void SetVisualiser::compute( Gaffer::ValuePlug *output, const Gaffer::Context *context ) const
{
if( output == outSetsPlug() )
{
const StringAlgo::MatchPattern requestedSetsPattern = setsPlug()->getValue();
std::vector<InternedString> names;
std::vector<Color3f> colors;
if( !requestedSetsPattern.empty() )
{
const std::vector<Override> overrides = unpackOverrides( colorOverridesPlug() );
ConstInternedStringVectorDataPtr allSetNamesData = inPlug()->setNames();
// Sorting now makes everything easier, otherwise you have to
// sort parallel arrays later, which is a pain.
std::vector<InternedString> allNames = allSetNamesData->readable();
std::sort( allNames.begin(), allNames.end(), internedStringCompare );
for( auto &name : allNames )
{
// Gaffer has some internal sets that begin with the '__'
// prefix. These are usually Lights, Cameras, etc... We filter
// these out as they most of their objects don't even draw in
// the viewer in a meaningful way for visualising set Membership
if( boost::starts_with( name.string(), "__" ) )
{
continue;
}
if( StringAlgo::matchMultiple( name, requestedSetsPattern ) )
{
names.push_back( name );
colors.push_back( colorForSetName( name, overrides ) );
}
}
}
CompoundDataPtr data = new CompoundData();
data->writable()["names"] = new InternedStringVectorData( names );
data->writable()["colors"] = new Color3fVectorData( colors );
static_cast<AtomicCompoundDataPlug *>( output )->setValue( data );
}
else
{
SceneElementProcessor::compute( output, context );
}
}
示例10: shaderPlug
IECore::ConstObjectPtr OSLObject::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const Primitive *inputPrimitive = runTimeCast<const Primitive>( inputObject.get() );
if( !inputPrimitive )
{
return inputObject;
}
if( !inputPrimitive->variableData<V3fVectorData>( "P", PrimitiveVariable::Vertex ) )
{
return inputObject;
}
ConstOSLShaderPtr shader = runTimeCast<const OSLShader>( shaderPlug()->source<Plug>()->node() );
ConstShadingEnginePtr shadingEngine = shader ? shader->shadingEngine() : NULL;
if( !shadingEngine )
{
return inputObject;
}
CompoundDataPtr shadingPoints = new CompoundData;
for( PrimitiveVariableMap::const_iterator it = inputPrimitive->variables.begin(), eIt = inputPrimitive->variables.end(); it != eIt; ++it )
{
if( it->second.interpolation == PrimitiveVariable::Vertex )
{
// cast is ok - we're only using it to be able to reference the data from the shadingPoints,
// but nothing will modify the data itself.
shadingPoints->writable()[it->first] = boost::const_pointer_cast<Data>( it->second.data );
}
}
PrimitivePtr outputPrimitive = inputPrimitive->copy();
ShadingEngine::Transforms transforms;
transforms[ g_world ] = ShadingEngine::Transform( inPlug()->fullTransform( path ));
CompoundDataPtr shadedPoints = shadingEngine->shade( shadingPoints.get(), transforms );
for( CompoundDataMap::const_iterator it = shadedPoints->readable().begin(), eIt = shadedPoints->readable().end(); it != eIt; ++it )
{
if( it->first != "Ci" )
{
outputPrimitive->variables[it->first] = PrimitiveVariable( PrimitiveVariable::Vertex, it->second );
}
}
return outputPrimitive;
}
示例11: unameHeaderGenerator
static void unameHeaderGenerator( CompoundObjectPtr header )
{
struct utsname name;
if ( !uname( &name ) )
{
CompoundDataPtr compound = new CompoundData();
compound->writable()["systemName"] = new StringData( name.sysname );
compound->writable()["nodeName"] = new StringData( name.nodename );
compound->writable()["systemRelease"] = new StringData( name.release );
compound->writable()["systemVersion"] = new StringData( name.version );
compound->writable()["machineName"] = new StringData( name.machine );
header->members()["host"] = compound;
}
}
示例12: readAttributes
DataPtr BGEOParticleReader::readAttribute( const std::string &name )
{
std::vector< std::string > names;
names.push_back( name );
CompoundDataPtr result = readAttributes( names );
if (!result)
{
return 0;
}
CompoundDataMap::const_iterator it = result->readable().find( name );
if ( it == result->readable().end() )
{
return 0;
}
return it->second;
}
示例13: shaderPlug
IECore::ConstObjectPtr OSLObject::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const Primitive *inputPrimitive = runTimeCast<const Primitive>( inputObject.get() );
if( !inputPrimitive )
{
return inputObject;
}
if( !inputPrimitive->variableData<V3fVectorData>( "P", PrimitiveVariable::Vertex ) )
{
return inputObject;
}
OSLRenderer::ConstShadingEnginePtr shadingEngine = OSLImage::shadingEngine( shaderPlug() );
if( !shadingEngine )
{
return inputObject;
}
CompoundDataPtr shadingPoints = new CompoundData;
for( PrimitiveVariableMap::const_iterator it = inputPrimitive->variables.begin(), eIt = inputPrimitive->variables.end(); it != eIt; ++it )
{
if( it->second.interpolation == PrimitiveVariable::Vertex )
{
// cast is ok - we're only using it to be able to reference the data from the shadingPoints,
// but nothing will modify the data itself.
shadingPoints->writable()[it->first] = constPointerCast<Data>( it->second.data );
}
}
PrimitivePtr outputPrimitive = inputPrimitive->copy();
ConstCompoundDataPtr shadedPoints = shadingEngine->shade( shadingPoints );
const std::vector<Color3f> &ci = shadedPoints->member<Color3fVectorData>( "Ci" )->readable();
V3fVectorDataPtr p = new V3fVectorData;
p->writable().reserve( ci.size() );
std::copy( ci.begin(), ci.end(), back_inserter( p->writable() ) );
outputPrimitive->variables["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, p );
/// \todo Allow shaders to write arbitrary primitive variables.
return outputPrimitive;
}
示例14: setsCompute
IECore::ConstCompoundDataPtr GafferScene::sets( const ScenePlug *scene )
{
ConstInternedStringVectorDataPtr setNamesData = scene->setNamesPlug()->getValue();
std::vector<GafferScene::ConstPathMatcherDataPtr> setsVector;
setsVector.resize( setNamesData->readable().size(), NULL );
Sets setsCompute( scene, setNamesData->readable(), setsVector );
parallel_for( tbb::blocked_range<size_t>( 0, setsVector.size() ), setsCompute );
CompoundDataPtr result = new CompoundData;
for( size_t i = 0, e = setsVector.size(); i < e; ++i )
{
// The const_pointer_cast is ok because we're just using it to put the set into
// a container that will be const on return - we never modify the set itself.
result->writable()[setNamesData->readable()[i]] = boost::const_pointer_cast<GafferScene::PathMatcherData>( setsVector[i] );
}
return result;
}
示例15: metadataGetter
static IECore::ConstCompoundDataPtr metadataGetter( const std::string &key, size_t &cost )
{
cost = 1;
if( !key.size() )
{
return NULL;
}
const char *searchPath = getenv( "OSL_SHADER_PATHS" );
OSLQuery query;
if( !query.open( key, searchPath ? searchPath : "" ) )
{
throw Exception( query.geterror() );
}
CompoundDataPtr metadata = new CompoundData;
metadata->writable()["shader"] = convertMetadata( query.metadata() );
CompoundDataPtr parameterMetadata = new CompoundData;
metadata->writable()["parameter"] = parameterMetadata;
for( size_t i = 0; i < query.nparams(); ++i )
{
const OSLQuery::Parameter *parameter = query.getparam( i );
if( parameter->metadata.size() )
{
string nameWithoutSuffix;
const OSLQuery::Parameter *positionsParameter;
const OSLQuery::Parameter *valuesParameter;
const OSLQuery::Parameter *basisParameter;
// If this parameter is part of a spline, register the metadata onto the spline plug
if( findSplineParameters( query, parameter, nameWithoutSuffix, positionsParameter, valuesParameter, basisParameter ) )
{
// We merge metadata found on all the parameters that make up the plug, but in no particular order.
// If you specify conflicting metadata on the different parameters you may get inconsistent results.
CompoundData *prevData = parameterMetadata->member<CompoundData>( nameWithoutSuffix );
CompoundDataPtr data = convertMetadata( parameter->metadata );
if( prevData )
{
data->writable().insert( prevData->readable().begin(), prevData->readable().end() );
}
parameterMetadata->writable()[nameWithoutSuffix] = data;
}
else
{
parameterMetadata->writable()[parameter->name.c_str()] = convertMetadata( parameter->metadata );
}
}
}
return metadata;
}