ObjectPtr FromHoudiniGroupConverter::doDetailConversion( const GU_Detail *geo, const CompoundObject *operands ) const
{
	GU_DetailHandle handle;
	handle.allocateAndSet( (GU_Detail*)geo, false );

	FromHoudiniGeometryConverterPtr converter = FromHoudiniGeometryConverter::create( handle );
	if ( !converter || converter->isInstanceOf( FromHoudiniGroupConverter::staticTypeId() ) )
	{
		/// \todo: if we're in PrimitiveGroup mode, but names exist, we return 0 when we should be returning a Group
		return 0;
	}
	
	// transfer the common parameter values
	CompoundParameter *parameters = converter->parameters();
	const CompoundParameter::ParameterMap &parameterMap = parameters->parameters();
	const CompoundObject::ObjectMap &values = operands->members();
	for ( CompoundObject::ObjectMap::const_iterator it = values.begin(); it != values.end(); ++it )
	{
		CompoundParameter::ParameterMap::const_iterator pIt = parameterMap.find( it->first );
		if ( pIt != parameterMap.end() && pIt->second->defaultValue()->typeId() == it->second->typeId() )
		{
			parameters->setParameterValue( it->first, it->second );
		}
	}
	
	return converter->convert();
}
Ejemplo n.º 2
0
static boost::python::list compoundParameterItems( const CompoundParameter &o )
{
	boost::python::list result;
	CompoundParameter::ParameterVector::const_iterator it;
	for( it = o.orderedParameters().begin(); it!=o.orderedParameters().end(); it++ )
	{
		result.append( boost::python::make_tuple( (*it)->name(), *it ) );
	}
	return result;
}
Ejemplo n.º 3
0
static boost::python::list compoundParameterValues( const CompoundParameter &o )
{
	boost::python::list result;
	CompoundParameter::ParameterVector::const_iterator it;
	for( it = o.orderedParameters().begin(); it!=o.orderedParameters().end(); it++ )
	{
		result.append( *it );
	}
	return result;
}
void ParameterisedHolderModificationCmd::restoreClassParameterStates( const IECore::CompoundData *classes, IECore::Parameter *parameter, const std::string &parentParameterPath )
{
	std::string parameterPath = parentParameterPath;
	if( parentParameterPath.size() )
	{
		parameterPath += ".";
	}
	parameterPath += parameter->name();
		
	if( parameter->isInstanceOf( "ClassParameter" ) )
	{				
		const CompoundData *c = classes->member<const CompoundData>( parameterPath );
		if( c )
		{
			ClassParameterHandler::setClass(
				parameter,
				c->member<const IECore::StringData>( "className" )->readable().c_str(),
				c->member<const IECore::IntData>( "classVersion" )->readable(),
				c->member<const IECore::StringData>( "searchPathEnvVar" )->readable().c_str()
			);
		}
	}
	else if( parameter->isInstanceOf( "ClassVectorParameter" ) )
	{		
		const CompoundData *c = classes->member<const CompoundData>( parameterPath );
		if( c )
		{
			IECore::ConstStringVectorDataPtr parameterNames = c->member<const IECore::StringVectorData>( "parameterNames" );
			IECore::ConstStringVectorDataPtr classNames = c->member<const IECore::StringVectorData>( "classNames" );
			IECore::ConstIntVectorDataPtr classVersions = c->member<const IECore::IntVectorData>( "classVersions" );
			MStringArray mParameterNames;
			MStringArray mClassNames;
			MIntArray mClassVersions;
			int numClasses = parameterNames->readable().size();
			for( int i=0; i<numClasses; i++ )
			{
				mParameterNames.append( parameterNames->readable()[i].c_str() );
				mClassNames.append( classNames->readable()[i].c_str() );
				mClassVersions.append( classVersions->readable()[i] );
			}
			ClassVectorParameterHandler::setClasses( parameter, mParameterNames, mClassNames, mClassVersions );
		}
	}
	
	if( parameter->isInstanceOf( IECore::CompoundParameter::staticTypeId() ) )
	{
		CompoundParameter *compoundParameter = static_cast<CompoundParameter *>( parameter );
		const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters();
		for( CompoundParameter::ParameterVector::const_iterator it = childParameters.begin(); it!=childParameters.end(); it++ )
		{
			restoreClassParameterStates( classes, it->get(), parameterPath );
		}
	}
}
void CompoundParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource )
{
	CompoundParameter *compoundParameter = static_cast<CompoundParameter *>( parameter );
	const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters();
	for( CompoundParameter::ParameterVector::const_iterator cIt=childParameters.begin(); cIt!=childParameters.end(); cIt++ )
	{
		ParameterHandlerPtr h = handler( cIt->get(), false );
		if( h )
		{
			h->setParameterValue( cIt->get(), valueSource );
		}
	}
}
void ParameterisedHolderModificationCmd::setNodeValue( IECore::Parameter *parameter ) const
{
	m_parameterisedHolder->setNodeValue( parameter );
	
	if( parameter->isInstanceOf( CompoundParameter::staticTypeId() ) )
	{
		// recurse to the children - this is the only reason this function
		// is necessary as ParameterisedHolder::setNodeValue() doesn't recurse.
		CompoundParameter *compoundParameter = static_cast<CompoundParameter *>( parameter );
		const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters();
		for( CompoundParameter::ParameterVector::const_iterator it = childParameters.begin(); it!=childParameters.end(); it++ )
		{
			setNodeValue( it->get() );
		}
	}
}
Ejemplo n.º 7
0
static ParameterPtr compoundParameterGetItem( CompoundParameter &o, const char *n )
{
	const CompoundParameter::ParameterMap &p = o.parameters();
	CompoundParameter::ParameterMap::const_iterator it = p.find( n );
	if( it!=p.end() )
	{
		return it->second;
	}

	throw Exception( std::string("Bad index: ") + n );
}
Ejemplo n.º 8
0
static boost::python::list parameterPath( CompoundParameter &o, ConstParameterPtr child )
{
	std::vector<std::string> p;
	o.parameterPath( child.get(), p );
	boost::python::list result;
	for( std::vector<std::string>::const_iterator it=p.begin(); it!=p.end(); it++ )
	{
		result.append( *it );
	}
	return result;
}
Ejemplo n.º 9
0
static void compoundParameterAddParameters( CompoundParameter &o, const boost::python::list &p )
{
	int listLen = boost::python::len(p);

	for( int i=0; i<listLen; i++ )
	{
		object m = p[i];
		Parameter &p = extract<Parameter &>( m );
		o.addParameter( &p );
	}
}
Ejemplo n.º 10
0
static bool compoundParameterContains( const CompoundParameter &o, const std::string &n )
{
	const CompoundParameter::ParameterMap &map = o.parameters();
	return map.find( n ) != map.end();
}
Ejemplo n.º 11
0
static unsigned int compoundParameterLen( const CompoundParameter &o )
{
	return o.parameters().size();
}