| 867 | } |
| 868 | |
| 869 | IECore::ConstCompoundDataPtr collapseRampParametersInternal( const IECore::ConstCompoundDataPtr ¶metersData, const std::string &shaderName ) |
| 870 | { |
| 871 | |
| 872 | auto [ positionsSuffix, floatValuesSuffix, colorValuesSuffix, basisSuffix, countSuffix ] = lookupRampParameterSuffixes( shaderName ); |
| 873 | |
| 874 | const CompoundDataMap ¶meters( parametersData->readable() ); |
| 875 | CompoundDataPtr newParametersData; |
| 876 | CompoundDataMap *newParameters = nullptr; |
| 877 | |
| 878 | for( const auto &maybeBasis : parameters ) |
| 879 | { |
| 880 | if( !boost::ends_with( maybeBasis.first.string(), *basisSuffix ) ) |
| 881 | { |
| 882 | continue; |
| 883 | } |
| 884 | const StringData *basis = runTimeCast<const StringData>( maybeBasis.second.get() ); |
| 885 | if( !basis ) |
| 886 | { |
| 887 | continue; |
| 888 | } |
| 889 | |
| 890 | |
| 891 | std::string prefix = maybeBasis.first.string().substr( 0, maybeBasis.first.string().size() - basisSuffix->size() ); |
| 892 | const IECore::InternedString positionsName = prefix + *positionsSuffix; |
| 893 | const FloatVectorData *floatPositions = parametersData->member<const FloatVectorData>( positionsName ); |
| 894 | if( !floatPositions ) |
| 895 | { |
| 896 | continue; |
| 897 | } |
| 898 | |
| 899 | IECore::InternedString countName; |
| 900 | const IntData *countData = nullptr; |
| 901 | |
| 902 | if( countSuffix ) |
| 903 | { |
| 904 | countName = prefix + *countSuffix; |
| 905 | countData = parametersData->member<const IntData>( countName ); |
| 906 | |
| 907 | if( !countData ) |
| 908 | { |
| 909 | IECore::msg( |
| 910 | Msg::Error, "ShaderNetworkAlgo", |
| 911 | "Using spline format that expects count parameter, but no int count parameter found matching \"" + countName.string() + "\"" |
| 912 | ); |
| 913 | } |
| 914 | else |
| 915 | { |
| 916 | if( (int)floatPositions->readable().size() != countData->readable() ) |
| 917 | { |
| 918 | IECore::msg( |
| 919 | Msg::Error, "ShaderNetworkAlgo", |
| 920 | "Spline count \"" + countName.string() + "\" does not match length of data: " + std::to_string( countData->readable() ) + " != " + std::to_string( floatPositions->readable().size() ) + "\"" |
| 921 | ); |
| 922 | } |
| 923 | } |
| 924 | } |
| 925 | |
| 926 | IECore::InternedString valuesName = prefix + *floatValuesSuffix; |
no test coverage detected