当前位置: 首页>>代码示例>>C++>>正文


C++ ConstFloatVectorDataPtr::get方法代码示例

本文整理汇总了C++中ConstFloatVectorDataPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstFloatVectorDataPtr::get方法的具体用法?C++ ConstFloatVectorDataPtr::get怎么用?C++ ConstFloatVectorDataPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConstFloatVectorDataPtr的用法示例。


在下文中一共展示了ConstFloatVectorDataPtr::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadShaderParameters

void RenderManShader::loadShaderParameters( const IECore::Shader *shader, Gaffer::CompoundPlug *parametersPlug, bool keepExistingValues )
{
	const CompoundData *typeHints = shader->blindData()->member<CompoundData>( "ri:parameterTypeHints", true );

	const StringVectorData *orderedParameterNamesData = shader->blindData()->member<StringVectorData>( "ri:orderedParameterNames", true );
	const vector<string> &orderedParameterNames = orderedParameterNamesData->readable();

	const StringVectorData *outputParameterNamesData = shader->blindData()->member<StringVectorData>( "ri:outputParameterNames", true );
	const vector<string> &outputParameterNames = outputParameterNamesData->readable();

	const CompoundData *annotations = shader->blindData()->member<CompoundData>( "ri:annotations", true );

	// if we're not preserving existing values then remove all existing parameter plugs - the various
	// plug creators above know that if a plug exists then they should preserve its values.

	if( !keepExistingValues )
	{
		for( int i = parametersPlug->children().size() - 1; i >= 0; --i )
		{
			parametersPlug->removeChild( parametersPlug->getChild<GraphComponent>( i ) );
		}
	}

	// make sure we have a plug to represent each parameter, reusing plugs wherever possible.

	set<string> validPlugNames;
	for( vector<string>::const_iterator it = orderedParameterNames.begin(), eIt = orderedParameterNames.end(); it != eIt; it++ )
	{
		if( std::find( outputParameterNames.begin(), outputParameterNames.end(), *it ) != outputParameterNames.end() )
		{
			continue;
		}

		// splines are represented by two parameters matched by a naming convention, and we map
		// those two parameters to a single SplinePlug.

		const bool endsWithValues = ends_with( *it, "Values" );
		const bool endsWithPositions = ends_with( *it, "Positions" );
		if( endsWithPositions || endsWithValues )
		{
			string plugName( *it, 0, it->size() - ( endsWithValues ? 6 : 9 ) );
			if( validPlugNames.find( plugName ) != validPlugNames.end() )
			{
				continue;
			}

			// must use a smart pointers here because we may assign the data the parser creates (and which we therefore own)
			ConstFloatVectorDataPtr positions = shader->parametersData()->member<FloatVectorData>( plugName + "Positions" );
			ConstDataPtr values = shader->parametersData()->member<Data>( plugName + "Values" );

			if( positions && values )
			{
				const StringData *defaultValuesAnnotation = annotations->member<StringData>( plugName + "Values.defaultValue" );
				const StringData *defaultPositionsAnnotation = annotations->member<StringData>( plugName + "Positions.defaultValue" );

				if( defaultValuesAnnotation )
				{
					DataPtr parsedValues;
					if( values->isInstanceOf( Color3fVectorData::staticTypeId() ) )
					{
						parsedValues = parseColors( defaultValuesAnnotation->readable() );
					}
					else
					{
						parsedValues = parseFloats( defaultValuesAnnotation->readable() );
					}

					if( parsedValues )
					{
						values = parsedValues;
					}
					else
					{
						msg(
							Msg::Warning, "RenderManShader::loadShaderParameters",
							boost::format( "Unable to parse default value \"%s\" for parameter \"%s\"" ) % defaultValuesAnnotation->readable() % ( plugName + "Values" )
						);
					}
				}

				if( defaultPositionsAnnotation )
				{
					FloatVectorDataPtr parsedPositions = parseFloats( defaultPositionsAnnotation->readable() );
					if( parsedPositions )
					{
						positions = parsedPositions;
					}
					else
					{
						msg(
							Msg::Warning, "RenderManShader::loadShaderParameters",
							boost::format( "Unable to parse default value \"%s\" for parameter \"%s\"" ) % defaultPositionsAnnotation->readable() % ( plugName + "Positions" )
						);
					}
				}

				switch( values->typeId() )
				{
					case FloatVectorDataTypeId  :
						loadSplineParameter<SplineffPlug>( parametersPlug, plugName, positions.get(), values.get() );
//.........这里部分代码省略.........
开发者ID:cwmartin,项目名称:gaffer,代码行数:101,代码来源:RenderManShader.cpp


注:本文中的ConstFloatVectorDataPtr::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。