本文整理汇总了C++中iecore::ConstObjectPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ConstObjectPtr类的具体用法?C++ ConstObjectPtr怎么用?C++ ConstObjectPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstObjectPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: getClipboardContents
static IECore::ObjectPtr getClipboardContents( ApplicationRoot &a )
{
IECore::ConstObjectPtr o = a.getClipboardContents();
if( o )
{
return o->copy();
}
return 0;
}
示例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:
void VectorTypedParameterHandler<ParameterType>::setParameterValue()
{
IECore::ConstObjectPtr o = m_plug->getValue();
if( o )
{
m_parameter->setValue( o->copy() );
}
else
{
m_parameter->setValue( m_parameter->defaultValue()->copy() );
}
}
示例5: setObjectValue
void ValuePlug::setObjectValue( IECore::ConstObjectPtr value )
{
bool haveInput = getInput<Plug>();
if( direction()==In && !haveInput )
{
// input plug with no input connection. there can only ever be a single value,
// which we store directly on the plug. when setting this we need to take care
// of undo, and also of triggering the plugValueSet signal and propagating the
// plugDirtiedSignal.
if( getFlags( ReadOnly ) )
{
// We don't allow static values to be set on read only plugs, so we throw.
// Note that it is perfectly acceptable to call setValue() on a read only
// plug during a computation because the result is not written onto the
// plug itself, so we don't make the check in the case that we call
// receiveResult() below. This allows plugs which have inputs to be made
// read only after having their input set.
throw IECore::Exception( boost::str( boost::format( "Cannot set value for read only plug \"%s\"" ) % fullName() ) );
}
if( value->isNotEqualTo( m_staticValue.get() ) )
{
Action::enact( new SetValueAction( this, value ) );
}
return;
}
// An input plug with an input connection or an output plug. We must be currently in a computation
// triggered by getObjectValue() for a setObjectValue() call to be valid (receiveResult will check this).
// We never trigger plugValueSet or plugDirtiedSignals during computation.
ComputeProcess::receiveResult( this, value );
}
示例6: 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;
}
示例7: 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;
}
示例8: 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();
}
示例9: 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();
}
示例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;
}
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;
}
示例11: getValue
Format FormatPlug::getValue( const IECore::MurmurHash *precomputedHash ) const
{
IECore::ConstObjectPtr o = getObjectValue( precomputedHash );
const GafferImage::FormatData *d = IECore::runTimeCast<const GafferImage::FormatData>( o.get() );
if( !d )
{
throw IECore::Exception( "FormatPlug::getObjectValue() didn't return FormatData - is the hash being computed correctly?" );
}
Format result = d->readable();
if( result.getDisplayWindow().isEmpty() && inCompute() )
{
return Context::current()->get<Format>( Format::defaultFormatContextName, Format() );
}
return result;
}
示例12: 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;
}
示例13: 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() );
}
示例14: 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;
}
示例15: 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;
}