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; }
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 ); }
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; }
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; }