Example #1
0
void MayaScene::readTags( NameList &tags, int filter ) const
{
	tags.clear();

	if ( m_isRoot )
	{
		return;
	}

	if( m_dagPath.length() == 0 )
	{
		throw Exception( "MayaScene::attributeNames: Dag path no longer exists!" );
	}
	
	std::set<Name> uniqueTags;
	std::vector<CustomTagReader> &tagReaders = customTagReaders();
	for ( std::vector<CustomTagReader>::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it )
	{
		NameList values;
		it->m_read( m_dagPath, values, filter );
		uniqueTags.insert( values.begin(), values.end() );
	}

	tags.insert( tags.end(), uniqueTags.begin(), uniqueTags.end() );
}
Example #2
0
void LinkedScene::readTags( NameList &tags, int filter ) const
{
	if ( filter!=SceneInterface::LocalTag && !m_readOnly )
	{
		throw Exception( "readTags with filter != LocalTag is only supported when reading the scene file!" );
	}

	if ( m_linkedScene )
	{
		m_linkedScene->readTags( tags, filter );

		/// Only queries ancestor tags and local tags (if at the link location) from the main scene.
		int mainFilter = filter & ( SceneInterface::AncestorTag | ( m_atLink ? SceneInterface::LocalTag : 0 ) );
		if ( !m_atLink && (filter & SceneInterface::AncestorTag) )
		{
			/// child locations inside the link consider all the local tags at the link location as ancestor tags as well.
			mainFilter |= SceneInterface::LocalTag;
		}
		if ( mainFilter )
		{
			NameList mainTags;
			m_mainScene->readTags( mainTags, mainFilter );
			tags.insert( tags.end(), mainTags.begin(), mainTags.end() );
		}
	}
	else
	{
		m_mainScene->readTags( tags, filter );
	}
}
Example #3
0
void LiveScene::readTags( NameList &tags, int filter ) const
{
	tags.clear();

	if ( m_isRoot )
	{
		return;
	}

	if( m_dagPath.length() == 0 )
	{
		throw Exception( "IECoreMaya::LiveScene::attributeNames: Dag path no longer exists!" );
	}
	
	std::set<Name> uniqueTags;

	// read tags from ieTags attribute:
	MStatus st;
	MFnDependencyNode fnNode( m_dagPath.node() );
	MPlug tagsPlug = fnNode.findPlug( "ieTags", false, &st );
	if( st )
	{
		std::string tagsStr( tagsPlug.asString().asChar() );
		boost::tokenizer<boost::char_separator<char> > t( tagsStr, boost::char_separator<char>( " " ) );
		for (
			boost::tokenizer<boost::char_separator<char> >::iterator it = t.begin();
			it != t.end();
			++it
		)
		{
			uniqueTags.insert( Name( *it ) );
		}
	}

	// read tags from custom readers:
	std::vector<CustomTagReader> &tagReaders = customTagReaders();
	for ( std::vector<CustomTagReader>::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it )
	{
		NameList values;
		it->m_read( m_dagPath, values, filter );
		uniqueTags.insert( values.begin(), values.end() );
	}

	tags.insert( tags.end(), uniqueTags.begin(), uniqueTags.end() );
}
Example #4
0
void HoudiniScene::readTags( NameList &tags, bool includeChildren ) const
{
	tags.clear();
	
	const OP_Node *node = retrieveNode();
	if ( !node )
	{
		return;
	}
	
	// add user supplied tags if we're not inside a SOP
	if ( !m_contentIndex && node->hasParm( pTags.getToken() ) )
	{
		UT_String parmTagStr;
		node->evalString( parmTagStr, pTags.getToken(), 0, 0 );
		if ( !parmTagStr.equal( UT_String::getEmptyString() ) )
		{
			UT_WorkArgs tokens;
			parmTagStr.tokenize( tokens, " " );
			for ( int i = 0; i < tokens.getArgc(); ++i )
			{
				tags.push_back( tokens[i] );
			}
		}
	}
	
	// add tags from the registered tag readers
	std::vector<CustomTagReader> &tagReaders = customTagReaders();
	for ( std::vector<CustomTagReader>::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it )
	{
		NameList values;
		it->m_read( node, values, includeChildren );
		tags.insert( tags.end(), values.begin(), values.end() );
	}
	
	// add tags based on primitive groups
	OBJ_Node *contentNode = retrieveNode( true )->castToOBJNode();
	if ( contentNode && contentNode->getObjectType() == OBJ_GEOMETRY && m_splitter )
	{
		GU_DetailHandle newHandle = m_splitter->split( contentPathValue() );
		if ( !newHandle.isNull() )
		{
			GU_DetailHandleAutoReadLock readHandle( newHandle );
			if ( const GU_Detail *geo = readHandle.getGdp() )
			{
				GA_Range prims = geo->getPrimitiveRange();
				for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
				{
					GA_PrimitiveGroup *group = static_cast<GA_PrimitiveGroup*>( it.group() );
					if ( group->getInternal() || group->isEmpty() )
					{
						continue;
					}
					
					const UT_String &groupName = group->getName();
					if ( groupName.startsWith( tagGroupPrefix ) && group->containsAny( prims ) )
					{
						UT_String tag;
						groupName.substr( tag, tagGroupPrefix.length() );
						tag.substitute( "_", ":" );
						tags.push_back( tag.buffer() );
					}
				}
			}
		}
	}
}