Exemplo n.º 1
0
SceneNode::ScenePath SubTree::sourcePath( const ScenePath &outputPath, bool &createRoot ) const
{
	typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
	/// \todo We should introduce a plug type which stores its values as a ScenePath directly.
	string rootAsString = rootPlug()->getValue();
	Tokenizer rootTokenizer( rootAsString, boost::char_separator<char>( "/" ) );
	ScenePath result;
	for( Tokenizer::const_iterator it = rootTokenizer.begin(), eIt = rootTokenizer.end(); it != eIt; it++ )
	{
		result.push_back( *it );
	}

	createRoot = false;
	if( result.size() && includeRootPlug()->getValue() )
	{
		if( outputPath.size() )
		{
			result.insert( result.end(), outputPath.begin() + 1, outputPath.end() );
		}
		else
		{
			createRoot = true;
		}
	}
	else
	{
		result.insert( result.end(), outputPath.begin(), outputPath.end() );
	}

	return result;
}
Exemplo n.º 2
0
void Instancer::InstanceScope::update( const ScenePath &branchPath, int instanceId )
{
	assert( branchPath.size() >= 2 );
	ScenePath instancePath;
	instancePath.insert( instancePath.end(), branchPath.begin() + 2, branchPath.end() );
	set( ScenePlug::scenePathContextName, instancePath );
	set( idContextName, instanceId );
}
Exemplo n.º 3
0
IECore::ConstCompoundObjectPtr CompoundObjectSource::entryForPath( const ScenePath &path ) const
{
	ConstCompoundObjectPtr result = inObject();

	for( ScenePath::const_iterator it=path.begin(); it!=path.end(); it++ )
	{
		result = result->member<CompoundObject>( "children", true /* throw exceptions */ );
		result = result->member<CompoundObject>( *it, true /* throw exceptions */ );
	}

	return result;
}
Exemplo n.º 4
0
Filter::Result BranchCreator::parentAndBranchPaths( const IECore::CompoundData *mapping, const ScenePath &path, ScenePath &parentPath, ScenePath &branchPath ) const
{
	if( !mapping->readable().size() )
	{
		return Filter::NoMatch;
	}
	
	const ScenePath &parent = mapping->member<InternedStringVectorData>( "__BranchCreatorParent" )->readable();

	ScenePath::const_iterator parentIterator, parentIteratorEnd, pathIterator, pathIteratorEnd;
	
	for(
		parentIterator = parent.begin(), parentIteratorEnd = parent.end(),
		pathIterator = path.begin(), pathIteratorEnd = path.end();	
		parentIterator != parentIteratorEnd && pathIterator != pathIteratorEnd;
		parentIterator++, pathIterator++
	)
	{
		if( *parentIterator != *pathIterator )
		{
			return Filter::NoMatch;
		}
	}
	
	if( pathIterator == pathIteratorEnd )
	{
		// path is ancestor of parent, or parent itself
		parentPath = parent;
		return parentIterator == parentIteratorEnd ? Filter::ExactMatch : Filter::DescendantMatch;
	}
	
	// path is descendant of parent
	
	const InternedStringData *branchName = mapping->member<InternedStringData>( *pathIterator );
	if( !branchName )
	{
		// descendant comes from the input, rather than being part of the generated branch
		return Filter::NoMatch;
	}
	
	// somewhere on the new branch

	parentPath = parent;
	branchPath.push_back( branchName->readable() );
	branchPath.insert( branchPath.end(), ++pathIterator, pathIteratorEnd );
	
	return Filter::AncestorMatch;
}
Exemplo n.º 5
0
IECore::ConstCompoundObjectPtr CompoundObjectSource::entryForPath( const ScenePath &path ) const
{
	ConstCompoundObjectPtr result = runTimeCast<const CompoundObject>( inPlug()->getValue() );
	if( !result )
	{
		throw Exception( "Input value is not a CompoundObject" );
	}

	for( ScenePath::const_iterator it=path.begin(); it!=path.end(); it++ )
	{
		result = result->member<CompoundObject>( "children", true /* throw exceptions */ );
		result = result->member<CompoundObject>( *it, true /* throw exceptions */ );
	}

	return result;
}
Exemplo n.º 6
0
IECoreAlembic::AlembicInputPtr AlembicSource::inputForPath( const ScenePath &path ) const
{
	const std::string fileName = fileNamePlug()->getValue();
	if( !fileName.size() )
	{
		return NULL;
	}
	
	AlembicInputPtr result = Detail::alembicInputCache()->get( fileName );
	for( ScenePath::const_iterator it = path.begin(), eIt = path.end(); it != eIt; it++ )
	{	
		result = result->child( it->value() );
	}
	
	return result;
}
Exemplo n.º 7
0
Gaffer::ContextPtr Instancer::instanceContext( const Gaffer::Context *parentContext, const ScenePath &branchPath ) const
{
	if( branchPath.size() == 0 )
	{
		return 0;
	}
	
	ContextPtr result = new Context( *parentContext );

	InternedStringVectorDataPtr instancePath = new InternedStringVectorData;
	instancePath->writable().insert( instancePath->writable().end(), branchPath.begin() + 1, branchPath.end() );
	result->set( ScenePlug::scenePathContextName, instancePath.get() );
	
	result->set( "instancer:id", instanceIndex( branchPath ) );
	
	return result;
}
Exemplo n.º 8
0
SceneNode::ScenePath Group::sourcePath( const ScenePath &outputPath, const std::string &groupName, const ScenePlug **source ) const
{
	const InternedString mappedChildName = outputPath[1];

	ConstCompoundObjectPtr mapping = boost::static_pointer_cast<const CompoundObject>( mappingPlug()->getValue() );
	const CompoundObject *entry = mapping->member<CompoundObject>( mappedChildName );
	if( !entry )
	{
		throw Exception( boost::str( boost::format( "Unable to find mapping for output path" ) ) );
	}

	*source = inPlugs()->getChild<ScenePlug>( entry->member<IntData>( "i" )->readable() );

	ScenePath result;
	result.reserve( outputPath.size() - 1 );
	result.push_back( entry->member<InternedStringData>( "n" )->readable() );
	result.insert( result.end(), outputPath.begin() + 2, outputPath.end() );
	return result;
}
Exemplo n.º 9
0
void BranchCreator::hashBranchChildNames( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	const InternedStringVectorData *fullPathData = context->get<InternedStringVectorData>( ScenePlug::scenePathContextName, NULL );
	if( fullPathData )
	{
		// In the common case, the full path is in the context already (and we just decomposed it
		// into parentPath and branchPath for the convenience of derived classes).
		SceneProcessor::hashChildNames( fullPathData->readable(), context, inPlug(), h );
	}
	else
	{
		// In the rare case that we're being called from from our own globals computation
		// via hashMapping(), the full path isn't in the context, so we need to
		// construct it ourselves.
		ScenePath fullPath( parentPath );
		fullPath.insert( fullPath.end(), branchPath.begin(), branchPath.end() );
		SceneProcessor::hashChildNames( fullPath, context, inPlug(), h );
	}
}
Exemplo n.º 10
0
void Duplicate::sourcePath( const ScenePath &branchPath, ScenePath &source ) const
{
	assert( branchPath.size() );
	ScenePlug::stringToPath( targetPlug()->getValue(), source );
	copy( ++branchPath.begin(), branchPath.end(), back_inserter( source ) );
}