Example #1
0
IECore::ConstInternedStringVectorDataPtr Isolate::computeChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	ContextPtr tmpContext = filterContext( context );
	Context::Scope scopedContext( tmpContext.get() );

	if( mayPruneChildren( path, filterPlug()->getValue() ) )
	{
		// we may need to delete one or more of our children
		ConstInternedStringVectorDataPtr inputChildNamesData = inPlug()->childNamesPlug()->getValue();
		const vector<InternedString> &inputChildNames = inputChildNamesData->readable();

		InternedStringVectorDataPtr outputChildNamesData = new InternedStringVectorData;
		vector<InternedString> &outputChildNames = outputChildNamesData->writable();

		ScenePath childPath = path;
		childPath.push_back( InternedString() ); // for the child name
		for( vector<InternedString>::const_iterator it = inputChildNames.begin(), eIt = inputChildNames.end(); it != eIt; it++ )
		{
			childPath[path.size()] = *it;
			tmpContext->set( ScenePlug::scenePathContextName, childPath );
			if( filterPlug()->getValue() != Filter::NoMatch )
			{
				outputChildNames.push_back( *it );
			}
		}

		return outputChildNamesData;
	}
	else
	{
		// pass through
		return inPlug()->childNamesPlug()->getValue();
	}
}
Example #2
0
void Prune::hashChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	FilterPlug::SceneScope sceneScope( context, inPlug() );
	const Filter::Result m = (Filter::Result)filterPlug()->getValue();

	if( m & Filter::ExactMatch )
	{
		h = inPlug()->childNamesPlug()->defaultValue()->Object::hash();
	}
	else if( m & Filter::DescendantMatch )
	{
		// we might be computing new childnames for this level.
		FilteredSceneProcessor::hashChildNames( path, context, parent, h );

		ConstInternedStringVectorDataPtr inputChildNamesData = inPlug()->childNamesPlug()->getValue();
		const vector<InternedString> &inputChildNames = inputChildNamesData->readable();

		ScenePath childPath = path;
		childPath.push_back( InternedString() ); // for the child name
		for( vector<InternedString>::const_iterator it = inputChildNames.begin(), eIt = inputChildNames.end(); it != eIt; ++it )
		{
			childPath[path.size()] = *it;
			sceneScope.set( ScenePlug::scenePathContextName, childPath );
			filterPlug()->hash( h );
		}
	}
	else
	{
		// pass through
		h = inPlug()->childNamesPlug()->hash();
	}
}
Example #3
0
void Group::hashBound( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 0 ) // "/"
	{
		SceneProcessor::hashBound( path, context, parent, h );
		for( vector<ScenePlugPtr>::const_iterator it = m_inPlugs.inputs().begin(), eIt = m_inPlugs.inputs().end(); it!=eIt; it++ )
		{
			(*it)->boundPlug()->hash( h );
		}
		transformPlug()->hash( h );
	}
	else if( path.size() == 1 ) // "/group"
	{
		SceneProcessor::hashBound( path, context, parent, h );
		ContextPtr tmpContext = new Context( *Context::current() );
		tmpContext->set( ScenePlug::scenePathContextName, ScenePath() );
		Context::Scope scopedContext( tmpContext );
		for( vector<ScenePlugPtr>::const_iterator it = m_inPlugs.inputs().begin(), eIt = m_inPlugs.inputs().end(); it!=eIt; it++ )
		{
			(*it)->boundPlug()->hash( h );
		}
	}
	else // "/group/..."
	{
		// pass through
		ScenePlug *sourcePlug = 0;
		ScenePath source = sourcePath( path, namePlug()->getValue(), &sourcePlug );
		h = sourcePlug->boundHash( source );
	}
}
Example #4
0
void Group::hashBound( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 0 ) // "/"
	{
		SceneProcessor::hashBound( path, context, parent, h );
		for( ScenePlugIterator it( inPlugs() ); it != it.end(); ++it )
		{
			(*it)->boundPlug()->hash( h );
		}
		transformPlug()->hash( h );
	}
	else if( path.size() == 1 ) // "/group"
	{
		SceneProcessor::hashBound( path, context, parent, h );
		ContextPtr tmpContext = new Context( *context, Context::Borrowed );
		tmpContext->set( ScenePlug::scenePathContextName, ScenePath() );
		Context::Scope scopedContext( tmpContext.get() );
		for( ScenePlugIterator it( inPlugs() ); it != it.end(); ++it )
		{
			(*it)->boundPlug()->hash( h );
		}
	}
	else // "/group/..."
	{
		// pass through
		const ScenePlug *sourcePlug = 0;
		ScenePath source = sourcePath( path, namePlug()->getValue(), &sourcePlug );
		h = sourcePlug->boundHash( source );
	}
}
Example #5
0
Imath::Box3f Group::computeBound( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	std::string groupName = namePlug()->getValue();

	if( path.size() <= 1 )
	{
		// either / or /groupName
		Box3f combinedBound;
		for( ScenePlugIterator it( inPlugs() ); it != it.end(); ++it )
		{
			// we don't need to transform these bounds, because the SceneNode
			// guarantees that the transform for root nodes is always identity.
			Box3f bound = (*it)->bound( ScenePath() );
			combinedBound.extendBy( bound );
		}
		if( path.size() == 0 )
		{
			combinedBound = transform( combinedBound, transformPlug()->matrix() );
		}
		return combinedBound;
	}
	else
	{
		const ScenePlug *sourcePlug = 0;
		ScenePath source = sourcePath( path, groupName, &sourcePlug );
		return sourcePlug->bound( source );
	}
}
Example #6
0
void Grid::hashAttributes( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 1 )
	{
		SceneNode::hashAttributes( path, context, parent, h );
		return;
	}
	else if( path.size() == 2 )
	{
		SceneNode::hashAttributes( path, context, parent, h );
		if( path.back() == g_gridLinesName )
		{
			gridPixelWidthPlug()->hash( h );
		}
		else if( path.back() == g_centerLinesName )
		{
			centerPixelWidthPlug()->hash( h );
		}
		else if( path.back() == g_borderLinesName )
		{
			borderPixelWidthPlug()->hash( h );
		}
		return;
	}
	h = outPlug()->attributesPlug()->defaultValue()->Object::hash();
}
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;
}
Example #8
0
void SubTree::hashChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	bool createRoot = false;
	const ScenePath source = sourcePath( path, createRoot );
	if( createRoot )
	{
		SceneProcessor::hashChildNames( path, context, parent, h );
		h.append( *(source.rbegin()) );
	}
	else
	{
		h = inPlug()->childNamesHash( source );
	}
}
Example #9
0
IECore::ConstInternedStringVectorDataPtr SubTree::computeChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	bool createRoot = false;
	const ScenePath source = sourcePath( path, createRoot );
	if( createRoot )
	{
		IECore::InternedStringVectorDataPtr result = new IECore::InternedStringVectorData;
		result->writable().push_back( *(source.rbegin()) );
		return result;
	}
	else
	{
		return inPlug()->childNames( source );
	}
}
Example #10
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;
}
Example #11
0
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;
}
Example #12
0
Imath::Box3f Instancer::computeBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const
{
	if( branchPath.size() <= 1 )
	{
		// "/" or "/name"
		Box3f result;
		ConstV3fVectorDataPtr p = sourcePoints( parentPath );
		if( p )
		{
			ScenePath branchChildPath( branchPath );
			if( branchChildPath.size() == 0 )
			{
				branchChildPath.push_back( namePlug()->getValue() );
			}

			BoundUnion unioner( this, branchChildPath, context, p.get() );
			parallel_reduce(
				blocked_range<size_t>( 0, p->readable().size() ),
				unioner
			);

			result = unioner.result();
		}

		return result;
	}
	else
	{
		InstanceScope instanceScope( context, branchPath );
		return instancePlug()->boundPlug()->getValue();
	}
}
Example #13
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;
}
Example #14
0
IECore::ConstInternedStringVectorDataPtr Instancer::computeBranchChildNames( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const
{
	if( branchPath.size() == 0 )
	{
		std::string name = namePlug()->getValue();
		if( !name.size() )
		{
			return outPlug()->childNamesPlug()->defaultValue();
		}
		ConstV3fVectorDataPtr p = sourcePoints( parentPath );
		if( !p || !p->readable().size() )
		{
			return outPlug()->childNamesPlug()->defaultValue();
		}
		
		InternedStringVectorDataPtr result = new InternedStringVectorData();
		for( size_t i=0; i<p->readable().size(); i++ )
		{
			result->writable().push_back( boost::lexical_cast<string>( i ) );
		}
		
		return result;
	}
	else
	{
		ContextPtr ic = instanceContext( context, branchPath );
		Context::Scope scopedContext( ic );
		return instancePlug()->childNamesPlug()->getValue();
	}
}
Example #15
0
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;
}
Example #16
0
void Instancer::hashBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	if( branchPath.size() <= 1 )
	{
		// "/" or "/name"

		BranchCreator::hashBranchBound( parentPath, branchPath, context, h );

		ConstV3fVectorDataPtr p = sourcePoints( parentPath );
		if( p )
		{
			p->hash( h );

			ScenePath branchChildPath( branchPath );
			if( branchChildPath.size() == 0 )
			{
				branchChildPath.push_back( namePlug()->getValue() );
			}

			BoundHash hasher( this, branchChildPath, context );
			parallel_deterministic_reduce(
				blocked_range<size_t>( 0, p->readable().size(), 100 ),
				hasher
			);

			h.append( hasher.result() );
		}
	}
	else
	{
		InstanceScope instanceScope( context, branchPath );
		h = instancePlug()->boundPlug()->hash();
	}
}
Example #17
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;
}
Example #18
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;
}
Example #19
0
void AlembicSource::hashChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	SceneNode::hashChildNames( path, context, parent, h );

	fileNamePlug()->hash( h );
	refreshCountPlug()->hash( h );

	h.append( &(path[0]), path.size() );
}
Example #20
0
Imath::M44f Group::computeTransform( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	std::string groupName = namePlug()->getValue();

	if( path.size() == 0 )
	{
		return Imath::M44f();
	}
	else if( path.size() == 1 )
	{
		return transformPlug()->matrix();
	}
	else
	{
		const ScenePlug *sourcePlug = 0;
		ScenePath source = sourcePath( path, groupName, &sourcePlug );
		return sourcePlug->transform( source );
	}
}
Example #21
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 );
	}
}
Example #22
0
void SetVisualiser::hashProcessedAttributes( const ScenePath &path, const Gaffer::Context *context, MurmurHash &h ) const
{
	ConstCompoundDataPtr outSetsData = outSetsPlug()->getValue();

	outSetsData->hash( h );
	includeInheritedPlug()->hash( h );

	// We also need to consider each of our candidate sets membership
	// definition (which we didn't need to when computing outSets).
	// outSetsData is map of names -> colors.
	ConstInternedStringVectorDataPtr setNames = outSetsData->member<InternedStringVectorData>( "names" );
	for( auto &setName : setNames->readable() )
	{
		h.append( inPlug()->setHash( setName ) );
	}

	h.append( path.data(), path.size() );
	stripeWidthPlug()->hash( h );
}
Example #23
0
void Group::hashTransform( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 0 ) // "/"
	{
		SceneProcessor::hashTransform( path, context, parent, h );
	}
	else if( path.size() == 1 ) // "/group"
	{
		SceneProcessor::hashTransform( path, context, parent, h );
		transformPlug()->hash( h );
	}
	else if( path.size() > 1 ) // "/group/..."
	{
		// pass through
		const ScenePlug *sourcePlug = 0;
		ScenePath source = sourcePath( path, namePlug()->getValue(), &sourcePlug );
		h = sourcePlug->transformHash( source );
	}
}
Example #24
0
IECore::ConstCompoundObjectPtr Prune::computeGlobals( const Gaffer::Context *context, const ScenePlug *parent ) const
{	
	ConstCompoundObjectPtr inputGlobals = inPlug()->globalsPlug()->getValue();
	const CompoundData *inputSets = inputGlobals->member<CompoundData>( "gaffer:sets" );
	if( !inputSets )
	{
		return inputGlobals;
	}

	CompoundObjectPtr outputGlobals = inputGlobals->copy();
	CompoundDataPtr outputSets = new CompoundData;
	outputGlobals->members()["gaffer:sets"] = outputSets;
	
	ContextPtr tmpContext = new Context( *Context::current() );
	Context::Scope scopedContext( tmpContext );
	ScenePath path;

	for( CompoundDataMap::const_iterator it = inputSets->readable().begin(), eIt = inputSets->readable().end(); it != eIt; ++it )
	{
		/// \todo This could be more efficient if PathMatcher exposed the internal nodes,
		/// and allowed sharing between matchers. Then we could do a really lightweight copy
		/// and just trim out the nodes we didn't want.
		const PathMatcher &inputSet = static_cast<const PathMatcherData *>( it->second.get() )->readable();
		PathMatcher &outputSet = outputSets->member<PathMatcherData>( it->first, /* throwExceptions = */ false, /* createIfMissing = */ true )->writable();
		
		vector<string> inputPaths;
		inputSet.paths( inputPaths );
		for( vector<string>::const_iterator pIt = inputPaths.begin(), peIt = inputPaths.end(); pIt != peIt; ++pIt )
		{
			path.clear();
			ScenePlug::stringToPath( *pIt, path );
			
			tmpContext->set( ScenePlug::scenePathContextName, path );
			if( !(filterPlug()->getValue() & ( Filter::ExactMatch | Filter::AncestorMatch ) ) )
			{
				outputSet.addPath( *pIt );
			}
		}
	}
	
	return outputGlobals;
}
Example #25
0
Imath::M44f Instancer::computeBranchTransform( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const
{
	if( branchPath.size() < 2 )
	{
		// "/" or "/name"
		return M44f();
	}
	else if( branchPath.size() == 2 )
	{
		// "/name/instanceNumber"
		int index = instanceIndex( branchPath );
		ConstV3fVectorDataPtr p = sourcePoints( parentPath );
		return instanceTransform( p.get(), index );
	}
	else
	{
		InstanceScope instanceScope( context, branchPath );
		return instancePlug()->transformPlug()->getValue();
	}
}
Example #26
0
void Instancer::hashBranchTransform( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	if( branchPath.size() < 2 )
	{
		// "/" or  "/name"
		BranchCreator::hashBranchTransform( parentPath, branchPath, context, h );
	}
	else if( branchPath.size() == 2 )
	{
		// "/name/instanceNumber"
		BranchCreator::hashBranchTransform( parentPath, branchPath, context, h );
		h.append( inPlug()->objectHash( parentPath ) );
		h.append( instanceIndex( branchPath ) );
	}
	else
	{
		InstanceScope instanceScope( context, branchPath );
		h = instancePlug()->transformPlug()->hash();
	}
}
Example #27
0
void Group::hashChildNames( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 0 ) // "/"
	{
		SceneProcessor::hashChildNames( path, context, parent, h );
		namePlug()->hash( h );
	}
	else if( path.size() == 1 ) // "/group"
	{
		SceneProcessor::hashChildNames( path, context, parent, h );
		mappingPlug()->hash( h );
	}
	else // "/group/..."
	{
		// pass through
		ScenePlug *sourcePlug = 0;
		ScenePath source = sourcePath( path, namePlug()->getValue(), &sourcePlug );
		h = sourcePlug->childNamesHash( source );
	}
}
Example #28
0
void Instancer::hashBranchChildNames( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	if( branchPath.size() == 0 )
	{
		// "/"
		BranchCreator::hashBranchChildNames( parentPath, branchPath, context, h );
		namePlug()->hash( h );
	}
	else if( branchPath.size() == 1 )
	{
		// "/name"
		BranchCreator::hashBranchChildNames( parentPath, branchPath, context, h );
		h.append( inPlug()->objectHash( parentPath ) );
	}
	else
	{
		// "/name/..."
		InstanceScope instanceScope( context, branchPath );
		h = instancePlug()->childNamesPlug()->hash();
	}
}
Example #29
0
void Seeds::hashBranchChildNames( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	if( branchPath.size() == 0 )
	{
		BranchCreator::hashBranchChildNames( parentPath, branchPath, context, h );
		namePlug()->hash( h );
	}
	else
	{
		h = outPlug()->childNamesPlug()->defaultValue()->Object::hash();
	}
}
Example #30
0
IECore::ConstInternedStringVectorDataPtr Instancer::computeBranchChildNames( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const
{
	if( branchPath.size() == 0 )
	{
		// "/"
		std::string name = namePlug()->getValue();
		if( name.empty() )
		{
			return outPlug()->childNamesPlug()->defaultValue();
		}
		InternedStringVectorDataPtr result = new InternedStringVectorData();
		result->writable().push_back( name );
		return result;
	}
	else if( branchPath.size() == 1 )
	{
		ConstV3fVectorDataPtr p = sourcePoints( parentPath );
		if( !p || !p->readable().size() )
		{
			return outPlug()->childNamesPlug()->defaultValue();
		}

		const size_t s = p->readable().size();
		InternedStringVectorDataPtr resultData = new InternedStringVectorData();
		vector<InternedString> &result = resultData->writable();
		result.resize( s );

		for( size_t i = 0; i < s ; ++i )
		{
			result[i] = InternedString( i );
		}

		return resultData;
	}
	else
	{
		InstanceScope instanceScope( context, branchPath );
		return instancePlug()->childNamesPlug()->getValue();
	}
}