本文整理汇总了C++中iecore::ConstObjectPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstObjectPtr::get方法的具体用法?C++ ConstObjectPtr::get怎么用?C++ ConstObjectPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iecore::ConstObjectPtr
的用法示例。
在下文中一共展示了ConstObjectPtr::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeProcessedObject
IECore::ConstObjectPtr PointsType::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const PointsPrimitive *inputPoints = runTimeCast<const PointsPrimitive>( inputObject.get() );
if( !inputPoints )
{
return inputObject;
}
const std::string type = typePlug()->getValue();
if( type == "" )
{
return inputObject;
}
if( const StringData *existingType = inputPoints->variableData<StringData>( "type" ) )
{
if( existingType->readable() == type )
{
return inputObject;
}
}
PointsPrimitivePtr result = inputPoints->copy();
result->variables["type"] = PrimitiveVariable( PrimitiveVariable::Constant, new StringData( type ) );
return result;
}
示例2: computeProcessedObject
IECore::ConstObjectPtr PointsGridToPoints::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const VDBObject *vdbObject = runTimeCast<const VDBObject>( inputObject.get() );
if( !vdbObject )
{
return inputObject;
}
openvdb::GridBase::ConstPtr grid = vdbObject->findGrid( gridPlug()->getValue() );
if ( !grid )
{
return inputObject;
}
std::string names = namesPlug()->getValue();
bool invert = invertNamesPlug()->getValue();
auto primitiveVariableFilter = [names, invert](const std::string& primitiveVariableName) -> bool
{
if (primitiveVariableName == "P")
{
return false;
}
return StringAlgo::matchMultiple( primitiveVariableName, names ) != invert;
};
IECoreScene::PointsPrimitivePtr points = createPointsPrimitive( grid, primitiveVariableFilter );
if ( !points )
{
return inputObject;
}
return points;
}
示例3: sourcePlug
Imath::Box3f ObjectSource::computeBound( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
IECore::ConstObjectPtr object = sourcePlug()->getValue();
Imath::Box3f result = bound( object.get() );
if( path.size() == 0 )
{
result = Imath::transform( result, transformPlug()->matrix() );
}
return result;
}
示例4: computeProcessedObject
IECore::ConstObjectPtr OSLObject::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const Primitive *inputPrimitive = runTimeCast<const Primitive>( inputObject.get() );
if( !inputPrimitive )
{
return inputObject;
}
if( !inputPrimitive->variableData<V3fVectorData>( "P", PrimitiveVariable::Vertex ) )
{
return inputObject;
}
ConstOSLShaderPtr shader = runTimeCast<const OSLShader>( shaderPlug()->source<Plug>()->node() );
ConstShadingEnginePtr shadingEngine = shader ? shader->shadingEngine() : NULL;
if( !shadingEngine )
{
return inputObject;
}
CompoundDataPtr shadingPoints = new CompoundData;
for( PrimitiveVariableMap::const_iterator it = inputPrimitive->variables.begin(), eIt = inputPrimitive->variables.end(); it != eIt; ++it )
{
if( it->second.interpolation == PrimitiveVariable::Vertex )
{
// cast is ok - we're only using it to be able to reference the data from the shadingPoints,
// but nothing will modify the data itself.
shadingPoints->writable()[it->first] = boost::const_pointer_cast<Data>( it->second.data );
}
}
PrimitivePtr outputPrimitive = inputPrimitive->copy();
ShadingEngine::Transforms transforms;
transforms[ g_world ] = ShadingEngine::Transform( inPlug()->fullTransform( path ));
CompoundDataPtr shadedPoints = shadingEngine->shade( shadingPoints.get(), transforms );
for( CompoundDataMap::const_iterator it = shadedPoints->readable().begin(), eIt = shadedPoints->readable().end(); it != eIt; ++it )
{
if( it->first != "Ci" )
{
outputPrimitive->variables[it->first] = PrimitiveVariable( PrimitiveVariable::Vertex, it->second );
}
}
return outputPrimitive;
}
示例5: computeProcessedObject
IECore::ConstObjectPtr MapOffset::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
// early out if it's not a primitive
const Primitive *inputPrimitive = runTimeCast<const Primitive>( inputObject.get() );
if( !inputPrimitive )
{
return inputObject;
}
// early out if the s/t names haven't been provided.
std::string sName = sNamePlug()->getValue();
std::string tName = tNamePlug()->getValue();
if( sName == "" || tName == "" )
{
return inputObject;
}
// do the work
PrimitivePtr result = inputPrimitive->copy();
V2f offset = offsetPlug()->getValue();
const int udim = udimPlug()->getValue();
offset.x += (udim - 1001) % 10;
offset.y += (udim - 1001) / 10;
if( FloatVectorDataPtr sData = result->variableData<FloatVectorData>( sName ) )
{
for( vector<float>::iterator it = sData->writable().begin(), eIt = sData->writable().end(); it != eIt; ++it )
{
*it += offset.x;
}
}
if( FloatVectorDataPtr tData = result->variableData<FloatVectorData>( tName ) )
{
for( vector<float>::iterator it = tData->writable().begin(), eIt = tData->writable().end(); it != eIt; ++it )
{
*it += offset.y;
}
}
return result;
}
示例6: getValue
std::string StringPlug::getValue() const
{
IECore::ConstObjectPtr o = getObjectValue();
const IECore::StringData *s = IECore::runTimeCast<const IECore::StringData>( o.get() );
if( !s )
{
throw IECore::Exception( "StringPlug::getObjectValue() didn't return StringData - is the hash being computed correctly?" );
}
bool performSubstitution =
direction()==Plug::In &&
inCompute() &&
Plug::getFlags( Plug::PerformsSubstitutions ) &&
Context::hasSubstitutions( s->readable() );
return performSubstitution ? Context::current()->substitute( s->readable() ) : s->readable();
}
示例7: computeProcessedObject
IECore::ConstObjectPtr LevelSetToMesh::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const VDBObject *vdbObject = runTimeCast<const VDBObject>( inputObject.get() );
if( !vdbObject )
{
return inputObject;
}
openvdb::GridBase::ConstPtr grid = vdbObject->findGrid( gridPlug()->getValue() );
if (!grid)
{
return inputObject;
}
return volumeToMesh( grid, isoValuePlug()->getValue(), adaptivityPlug()->getValue() );
}
示例8: computeProcessedObject
IECore::ConstObjectPtr OSLObject::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const Primitive *inputPrimitive = runTimeCast<const Primitive>( inputObject.get() );
if( !inputPrimitive )
{
return inputObject;
}
if( !inputPrimitive->variableData<V3fVectorData>( "P", PrimitiveVariable::Vertex ) )
{
return inputObject;
}
OSLRenderer::ConstShadingEnginePtr shadingEngine = OSLImage::shadingEngine( shaderPlug() );
if( !shadingEngine )
{
return inputObject;
}
CompoundDataPtr shadingPoints = new CompoundData;
for( PrimitiveVariableMap::const_iterator it = inputPrimitive->variables.begin(), eIt = inputPrimitive->variables.end(); it != eIt; ++it )
{
if( it->second.interpolation == PrimitiveVariable::Vertex )
{
// cast is ok - we're only using it to be able to reference the data from the shadingPoints,
// but nothing will modify the data itself.
shadingPoints->writable()[it->first] = constPointerCast<Data>( it->second.data );
}
}
PrimitivePtr outputPrimitive = inputPrimitive->copy();
ConstCompoundDataPtr shadedPoints = shadingEngine->shade( shadingPoints );
const std::vector<Color3f> &ci = shadedPoints->member<Color3fVectorData>( "Ci" )->readable();
V3fVectorDataPtr p = new V3fVectorData;
p->writable().reserve( ci.size() );
std::copy( ci.begin(), ci.end(), back_inserter( p->writable() ) );
outputPrimitive->variables["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, p );
/// \todo Allow shaders to write arbitrary primitive variables.
return outputPrimitive;
}
示例9: computeProcessedObject
IECore::ConstObjectPtr MeshDistortion::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const MeshPrimitive *mesh = runTimeCast<const MeshPrimitive>( inputObject.get() );
if( !mesh )
{
return inputObject;
}
const std::string position = positionPlug()->getValue();
const std::string referencePosition = referencePositionPlug()->getValue();
const std::string uvSet = uvSetPlug()->getValue();
if( position.empty() || referencePosition.empty() || uvSet.empty() )
{
return inputObject;
}
const std::string distortion = distortionPlug()->getValue();
const std::string uvDistortion = uvDistortionPlug()->getValue();
if( distortion.empty() && uvDistortion.empty() )
{
return inputObject;
}
auto distortions = MeshAlgo::calculateDistortion(
mesh,
uvSet,
referencePosition,
position
);
MeshPrimitivePtr result = mesh->copy();
if( !distortion.empty() )
{
result->variables[distortion] = distortions.first;
}
if( !uvDistortion.empty() )
{
result->variables[uvDistortion] = distortions.second;
}
return result;
}
示例10: computeProcessedObject
IECore::ConstObjectPtr OSLObject::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const Primitive *inputPrimitive = runTimeCast<const Primitive>( inputObject.get() );
if( !inputPrimitive )
{
return inputObject;
}
const OSLShader *shader = runTimeCast<const OSLShader>( shaderPlug()->source()->node() );
ConstShadingEnginePtr shadingEngine = shader ? shader->shadingEngine() : nullptr;
if( !shadingEngine )
{
return inputObject;
}
PrimitiveVariable::Interpolation interpolation = static_cast<PrimitiveVariable::Interpolation>( interpolationPlug()->getValue() );
IECoreScene::ConstPrimitivePtr resampledObject = IECore::runTimeCast<const IECoreScene::Primitive>( resampledInPlug()->objectPlug()->getValue() );
CompoundDataPtr shadingPoints = prepareShadingPoints( resampledObject.get(), shadingEngine.get() );
PrimitivePtr outputPrimitive = inputPrimitive->copy();
ShadingEngine::Transforms transforms;
transforms[ g_world ] = ShadingEngine::Transform( inPlug()->fullTransform( path ));
CompoundDataPtr shadedPoints = shadingEngine->shade( shadingPoints.get(), transforms );
for( CompoundDataMap::const_iterator it = shadedPoints->readable().begin(), eIt = shadedPoints->readable().end(); it != eIt; ++it )
{
// Ignore the output color closure as the debug closures are used to define what is 'exported' from the shader
if( it->first != "Ci" )
{
outputPrimitive->variables[it->first] = PrimitiveVariable( interpolation, it->second );
}
}
return outputPrimitive;
}
示例11: doConversion
IECore::RunTimeTypedPtr ToGLStateConverter::doConversion( IECore::ConstObjectPtr src, IECore::ConstCompoundObjectPtr operands ) const
{
const CompoundObject *co = runTimeCast<const CompoundObject>( src.get() );
if( !co )
{
throw Exception( "Expected a CompoundObject" );
}
const AttributeToStateMap &m = attributeToStateMap();
const StatePtr result = new State( false );
for( CompoundObject::ObjectMap::const_iterator it = co->members().begin(), eIt = co->members().end(); it != eIt; ++it )
{
AttributeToStateMap::const_iterator mIt = m.find( it->first );
if( mIt != m.end() )
{
StateComponentPtr s = mIt->second( it->second.get() );
result->add( s );
}
}
return result;
}
示例12: computeProcessedObject
IECore::ConstObjectPtr MeshTangents::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const MeshPrimitive *mesh = runTimeCast<const MeshPrimitive>( inputObject.get() );
if( !mesh )
{
return inputObject;
}
std::string uvSet = uvSetPlug()->getValue();
std::string position = positionPlug()->getValue();
bool ortho = orthogonalPlug()->getValue();
std::string uTangent = uTangentPlug()->getValue();
std::string vTangent = vTangentPlug()->getValue();
std::pair<PrimitiveVariable, PrimitiveVariable> tangentPrimvars = MeshAlgo::calculateTangents( mesh, uvSet, ortho, position);
MeshPrimitivePtr meshWithTangents = runTimeCast<MeshPrimitive>( mesh->copy() );
meshWithTangents->variables[uTangent] = tangentPrimvars.first;
meshWithTangents->variables[vTangent] = tangentPrimvars.second;
return meshWithTangents;
}
示例13: hash
IECore::MurmurHash StringPlug::hash() const
{
bool performSubstitution = direction()==Plug::In && !getInput<ValuePlug>() && Plug::getFlags( Plug::PerformsSubstitutions );
if( performSubstitution )
{
IECore::ConstObjectPtr o = getObjectValue();
const IECore::StringData *s = IECore::runTimeCast<const IECore::StringData>( o.get() );
if( !s )
{
throw IECore::Exception( "StringPlug::getObjectValue() didn't return StringData - is the hash being computed correctly?" );
}
if( Context::hasSubstitutions( s->readable() ) )
{
IECore::MurmurHash result;
result.append( Context::current()->substitute( s->readable() ) );
return result;
}
}
// no substitutions
return ValuePlug::hash();
}
示例14: computeProcessedObject
IECore::ConstObjectPtr DeleteCurves::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
const CurvesPrimitive *curves = runTimeCast<const CurvesPrimitive>( inputObject.get() );
if( !curves )
{
return inputObject;
}
std::string deletePrimVarName = curvesPlug()->getValue();
if( boost::trim_copy( deletePrimVarName ).empty() )
{
return inputObject;
}
PrimitiveVariableMap::const_iterator it = curves->variables.find( deletePrimVarName );
if (it == curves->variables.end())
{
throw InvalidArgumentException( boost::str( boost::format( "DeleteCurves : No primitive variable \"%s\" found" ) % deletePrimVarName ) );
}
return CurvesAlgo::deleteCurves(curves, it->second);
}
示例15: if
Imath::Box3f ObjectSource::computeBound( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
Imath::Box3f result;
IECore::ConstObjectPtr object = sourcePlug()->getValue();
if( const IECore::VisibleRenderable *renderable = IECore::runTimeCast<const IECore::VisibleRenderable>( object.get() ) )
{
result = renderable->bound();
}
else if( object->isInstanceOf( IECore::Camera::staticTypeId() ) )
{
result = Imath::Box3f( Imath::V3f( -0.5, -0.5, 0 ), Imath::V3f( 0.5, 0.5, 2.0 ) );
}
else if( object->isInstanceOf( IECore::CoordinateSystem::staticTypeId() ) )
{
result = Imath::Box3f( Imath::V3f( 0 ), Imath::V3f( 1 ) );
}
else
{
result = Imath::Box3f( Imath::V3f( -0.5 ), Imath::V3f( 0.5 ) );
}
if( path.size() == 0 )
{
result = Imath::transform( result, transformPlug()->matrix() );
}
return result;
}