本文整理汇总了C++中ConstObjectPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ConstObjectPtr类的具体用法?C++ ConstObjectPtr怎么用?C++ ConstObjectPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstObjectPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doDetailConversion
ObjectPtr FromHoudiniCortexObjectConverter::doDetailConversion( const GU_Detail *geo, const CompoundObject *operands ) const
{
const GA_Primitive *prim = geo->getPrimitiveList().get( geo->getPrimitiveRange().begin().getOffset() );
if ( prim->getTypeId() != GU_CortexPrimitive::typeId() )
{
throw std::runtime_error( "FromHoudiniCortexObjectConverter: Geometry does not contain a single CortexObject primitive" );
}
ConstObjectPtr object = ((GU_CortexPrimitive *)prim)->getObject();
ObjectPtr result = filterAttribs( object, operands->member<StringData>( "attributeFilter" )->readable().c_str() );
if ( result )
{
return result;
}
if ( object )
{
if ( object->isInstanceOf( IECore::ParameterisedProcedural::staticTypeId() ) )
{
return IECore::constPointerCast<IECore::Object>( object );
}
return object->copy();
}
return 0;
}
示例2: filterAttribs
bool ToHoudiniCortexObjectConverter::doConversion( const Object *object, GU_Detail *geo ) const
{
ConstObjectPtr result = filterAttribs( object );
GA_Size numPrims = geo->getNumPrimitives();
CortexPrimitive::build( geo, result.get() );
GA_OffsetList offsets;
offsets.append( geo->primitiveOffset( numPrims ) );
GA_Range newPrims( geo->getPrimitiveMap(), offsets );
if ( nameParameter()->getTypedValue() != "" )
{
setName( geo, newPrims );
}
// backwards compatibility with older data
else if ( const BlindDataHolder *holder = IECore::runTimeCast<const BlindDataHolder>( object ) )
{
if ( const StringData *nameData = holder->blindData()->member<StringData>( "name" ) )
{
ToHoudiniStringVectorAttribConverter::convertString( "name", nameData->readable(), geo, newPrims );
}
}
return ( (GA_Size)geo->getNumPrimitives() > numPrims );
}
示例3: namePlug
IECore::ConstCompoundObjectPtr Set::computeProcessedGlobals( const Gaffer::Context *context, IECore::ConstCompoundObjectPtr inputGlobals ) const
{
std::string name = namePlug()->getValue();
if( !name.size() )
{
return inputGlobals;
}
IECore::CompoundObjectPtr result = new IECore::CompoundObject;
// Since we're not going to modify any existing members other than the sets,
// and our result becomes const on returning it, we can directly reference
// the input members in our result without copying. We have to be careful not
// to modify the input sets though.
result->members() = inputGlobals->members();
CompoundDataPtr sets = new CompoundData;
if( const CompoundData *inputSets = inputGlobals->member<CompoundData>( "gaffer:sets" ) )
{
sets->writable() = inputSets->readable();
}
result->members()["gaffer:sets"] = sets;
ConstObjectPtr set = pathMatcherPlug()->getValue();
// const cast is acceptable because we're just using it to place a const object into a
// container that will be treated as const everywhere immediately after return from this method.
sets->writable()[name] = const_cast<Data *>( static_cast<const Data *>( set.get() ) );
return result;
}
示例4: fnPluginData
ObjectPtr FromMayaObjectDataConverter::doConversion( const MObject &obj, ConstCompoundObjectPtr operands ) const
{
MStatus s;
MFnPluginData fnPluginData( obj, &s );
if ( !s )
{
return 0;
}
/// If we ever support more than one type of data, we can handle them here.
const ObjectData *objectData = dynamic_cast< const ObjectData * >( fnPluginData.data( &s ) );
if ( !objectData || !s )
{
return 0;
}
ConstObjectPtr object = objectData->getObject();
if ( !object )
{
return 0;
}
assert( object );
return object->copy();
}
示例5: namesPlug
IECore::ConstCompoundObjectPtr AttributeProcessor::computeProcessedAttributes( const ScenePath &path, const Gaffer::Context *context, IECore::ConstCompoundObjectPtr inputAttributes ) const
{
if( inputAttributes->members().empty() )
{
return inputAttributes;
}
const std::string names = namesPlug()->getValue();
const bool invert = invertNamesPlug()->getValue();
CompoundObjectPtr result = new CompoundObject;
for( CompoundObject::ObjectMap::const_iterator it = inputAttributes->members().begin(), eIt = inputAttributes->members().end(); it != eIt; ++it )
{
ConstObjectPtr attribute = it->second;
if( matchMultiple( it->first, names ) != invert )
{
attribute = processAttribute( path, context, it->first, attribute.get() );
}
if( attribute )
{
result->members().insert(
CompoundObject::ObjectMap::value_type(
it->first,
// cast is ok - result is const immediately on
// returning from this function, and attribute will
// therefore not be modified.
boost::const_pointer_cast<Object>( attribute )
)
);
}
}
return result;
}
示例6: outPlug
Imath::Box3f PointsType::computeProcessedBound( const ScenePath &path, const Gaffer::Context *context, const Imath::Box3f &inputBound ) const
{
ConstObjectPtr object = outPlug()->objectPlug()->getValue();
if( const Primitive *primitive = runTimeCast<const Primitive>( object.get() ) )
{
return primitive->bound();
}
return inputBound;
}
示例7: readObjectAtSample
ObjectPtr readObjectAtSample( SampledSceneInterface &m, size_t sampleIndex )
{
ConstObjectPtr o = m.readObjectAtSample(sampleIndex);
if ( o )
{
return o->copy();
}
return 0;
}
示例8: readAttributeAtSample
ObjectPtr readAttributeAtSample( SampledSceneInterface &m, const SceneInterface::Name &name, size_t sampleIndex )
{
ConstObjectPtr o = m.readAttributeAtSample(name,sampleIndex);
if ( o )
{
return o->copy();
}
return 0;
}
示例9: writeLocation
void SceneWriter::writeLocation( const GafferScene::ScenePlug *scene, const ScenePlug::ScenePath &scenePath, Context *context, IECore::SceneInterface *output, double time ) const
{
context->set( ScenePlug::scenePathContextName, scenePath );
ConstCompoundObjectPtr attributes = scene->attributesPlug()->getValue();
for( CompoundObject::ObjectMap::const_iterator it = attributes->members().begin(), eIt = attributes->members().end(); it != eIt; it++ )
{
output->writeAttribute( it->first, it->second.get(), time );
}
if( scenePath.empty() )
{
ConstCompoundObjectPtr globals = scene->globalsPlug()->getValue();
output->writeAttribute( "gaffer:globals", globals.get(), time );
}
ConstObjectPtr object = scene->objectPlug()->getValue();
if( object->typeId() != IECore::NullObjectTypeId && scenePath.size() > 0 )
{
output->writeObject( object.get(), time );
}
Imath::Box3f b = scene->boundPlug()->getValue();
output->writeBound( Imath::Box3d( Imath::V3f( b.min ), Imath::V3f( b.max ) ), time );
if( scenePath.size() )
{
Imath::M44f t = scene->transformPlug()->getValue();
Imath::M44d transform(
t[0][0], t[0][1], t[0][2], t[0][3],
t[1][0], t[1][1], t[1][2], t[1][3],
t[2][0], t[2][1], t[2][2], t[2][3],
t[3][0], t[3][1], t[3][2], t[3][3]
);
output->writeTransform( new IECore::M44dData( transform ), time );
}
ConstInternedStringVectorDataPtr childNames = scene->childNamesPlug()->getValue();
ScenePlug::ScenePath childScenePath = scenePath;
childScenePath.push_back( InternedString() );
for( vector<InternedString>::const_iterator it=childNames->readable().begin(); it!=childNames->readable().end(); it++ )
{
childScenePath[scenePath.size()] = *it;
SceneInterfacePtr outputChild = output->child( *it, SceneInterface::CreateIfMissing );
writeLocation( scene, childScenePath, context, outputChild.get(), time );
}
}
示例10: create
ToNukeGeometryConverterPtr ToNukeGeometryConverter::create( ConstObjectPtr object )
{
const TypesToFnsMap *m = typesToFns();
TypesToFnsMap::const_iterator it = m->find( Types( object->typeId() ) );
if( it!=m->end() )
{
return it->second( object );
}
return 0;
}
示例11: create
ToMayaObjectConverterPtr ToMayaObjectConverter::create( ConstObjectPtr object, MFn::Type resultType )
{
const TypesToFnsMap *m = typesToFns();
TypesToFnsMap::const_iterator it = m->find( Types( object->typeId(), resultType ) );
if( it!=m->end() )
{
return it->second( object );
}
return 0;
}
示例12: namesPlug
IECore::ConstCompoundObjectPtr AttributeProcessor::computeProcessedAttributes( const ScenePath &path, const Gaffer::Context *context, IECore::ConstCompoundObjectPtr inputAttributes ) const
{
if( inputAttributes->members().empty() )
{
return inputAttributes;
}
/// \todo See todos about name matching in PrimitiveVariableProcessor.
typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
std::string namesValue = namesPlug()->getValue();
Tokenizer names( namesValue, boost::char_separator<char>( " " ) );
bool invert = invertNamesPlug()->getValue();
CompoundObjectPtr result = new CompoundObject;
IECore::PrimitiveVariableMap::iterator next;
for( CompoundObject::ObjectMap::const_iterator it = inputAttributes->members().begin(), eIt = inputAttributes->members().end(); it != eIt; ++it )
{
ConstObjectPtr attribute = it->second;
bool found = std::find( names.begin(), names.end(), it->first.string() ) != names.end();
if( found != invert )
{
attribute = processAttribute( path, context, it->first, attribute.get() );
}
if( attribute )
{
result->members().insert(
CompoundObject::ObjectMap::value_type(
it->first,
// cast is ok - result is const immediately on
// returning from this function, and attribute will
// therefore not be modified.
constPointerCast<Object>( attribute )
)
);
}
}
return result;
}
示例13: fileLoad
GA_Detail::IOStatus GEO_CobIOTranslator::fileLoad( GEO_Detail *geo, UT_IStream &is, int ate_magic )
{
((UT_IFStream&)is).close();
ConstObjectPtr object = 0;
try
{
ReaderPtr reader = Reader::create( is.getLabel() );
if ( !reader )
{
return false;
}
object = reader->read();
}
catch ( IECore::Exception e )
{
return false;
}
if ( !object )
{
return false;
}
ToHoudiniGeometryConverterPtr converter = ToHoudiniGeometryConverter::create( object.get() );
if ( !converter )
{
return false;
}
GU_DetailHandle handle;
handle.allocateAndSet( (GU_Detail*)geo, false );
return converter->convert( handle );
}
示例14: UTgetInterrupt
void SOP_SceneCacheSource::loadObjects( const IECore::SceneInterface *scene, Imath::M44d transform, double time, Space space, Parameters ¶ms, size_t rootSize )
{
UT_Interrupt *progress = UTgetInterrupt();
progress->setLongOpText( ( "Loading " + scene->name().string() ).c_str() );
if ( progress->opInterrupt() )
{
return;
}
if ( scene->hasObject() && UT_String( scene->name() ).multiMatch( params.shapeFilter ) && tagged( scene, params.tagFilter ) )
{
std::string name = relativePath( scene, rootSize );
Imath::M44d currentTransform;
if ( space == Local )
{
currentTransform = scene->readTransformAsMatrix( time );
}
else if ( space != Object )
{
currentTransform = transform;
}
ConstObjectPtr object = 0;
if ( params.geometryType == BoundingBox )
{
Imath::Box3d bound = scene->readBound( time );
object = MeshPrimitive::createBox( Imath::Box3f( bound.min, bound.max ) );
params.hasAnimatedTopology = false;
params.hasAnimatedPrimVars = true;
params.animatedPrimVars.clear();
params.animatedPrimVars.push_back( "P" );
}
else if ( params.geometryType == PointCloud )
{
std::vector<Imath::V3f> point( 1, scene->readBound( time ).center() );
PointsPrimitivePtr points = new PointsPrimitive( new V3fVectorData( point ) );
std::vector<Imath::V3f> basis1( 1, Imath::V3f( currentTransform[0][0], currentTransform[0][1], currentTransform[0][2] ) );
std::vector<Imath::V3f> basis2( 1, Imath::V3f( currentTransform[1][0], currentTransform[1][1], currentTransform[1][2] ) );
std::vector<Imath::V3f> basis3( 1, Imath::V3f( currentTransform[2][0], currentTransform[2][1], currentTransform[2][2] ) );
points->variables["basis1"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis1 ) );
points->variables["basis2"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis2 ) );
points->variables["basis3"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis3 ) );
params.hasAnimatedTopology = false;
params.hasAnimatedPrimVars = true;
params.animatedPrimVars.clear();
params.animatedPrimVars.push_back( "P" );
params.animatedPrimVars.push_back( "basis1" );
params.animatedPrimVars.push_back( "basis2" );
params.animatedPrimVars.push_back( "basis3" );
object = points;
}
else
{
object = scene->readObject( time );
params.hasAnimatedTopology = scene->hasAttribute( SceneCache::animatedObjectTopologyAttribute );
params.hasAnimatedPrimVars = scene->hasAttribute( SceneCache::animatedObjectPrimVarsAttribute );
if ( params.hasAnimatedPrimVars )
{
const ConstObjectPtr animatedPrimVarObj = scene->readAttribute( SceneCache::animatedObjectPrimVarsAttribute, 0 );
const InternedStringVectorData *animatedPrimVarData = IECore::runTimeCast<const InternedStringVectorData>( animatedPrimVarObj.get() );
if ( animatedPrimVarData )
{
const std::vector<InternedString> &values = animatedPrimVarData->readable();
params.animatedPrimVars.clear();
params.animatedPrimVars.resize( values.size() );
std::copy( values.begin(), values.end(), params.animatedPrimVars.begin() );
}
}
}
// modify the object if necessary
object = modifyObject( object.get(), params );
// transform the object unless its an identity
if ( currentTransform != Imath::M44d() )
{
object = transformObject( object.get(), currentTransform, params );
}
// convert the object to Houdini
if ( !convertObject( object.get(), name, scene, params ) )
{
std::string fullName;
SceneInterface::Path path;
scene->path( path );
SceneInterface::pathToString( path, fullName );
addWarning( SOP_MESSAGE, ( "Could not convert " + fullName + " to Houdini" ).c_str() );
}
}
if ( evalInt( pObjectOnly.getToken(), 0, 0 ) )
{
return;
}
//.........这里部分代码省略.........
示例15: scopedContext
void SceneProcedural::render( RendererPtr renderer ) const
{
Context::Scope scopedContext( m_context );
/// \todo See above.
try
{
// get all the attributes, and early out if we're not visibile
ConstCompoundObjectPtr attributes = m_scenePlug->attributesPlug()->getValue();
const BoolData *visibilityData = attributes->member<BoolData>( "gaffer:visibility" );
if( visibilityData && !visibilityData->readable() )
{
return;
}
// if we are visible then make an attribute block to contain everything, set the name
// and get on with generating things.
AttributeBlock attributeBlock( renderer );
std::string name = "";
for( ScenePlug::ScenePath::const_iterator it = m_scenePath.begin(), eIt = m_scenePath.end(); it != eIt; it++ )
{
name += "/" + it->string();
}
renderer->setAttribute( "name", new StringData( name ) );
// transform
std::set<float> transformTimes;
motionTimes( ( m_options.transformBlur && m_attributes.transformBlur ) ? m_attributes.transformBlurSegments : 0, transformTimes );
{
ContextPtr timeContext = new Context( *m_context );
Context::Scope scopedTimeContext( timeContext );
MotionBlock motionBlock( renderer, transformTimes, transformTimes.size() > 1 );
for( std::set<float>::const_iterator it = transformTimes.begin(), eIt = transformTimes.end(); it != eIt; it++ )
{
timeContext->setFrame( *it );
renderer->concatTransform( m_scenePlug->transformPlug()->getValue() );
}
}
// attributes
for( CompoundObject::ObjectMap::const_iterator it = attributes->members().begin(), eIt = attributes->members().end(); it != eIt; it++ )
{
if( const StateRenderable *s = runTimeCast<const StateRenderable>( it->second.get() ) )
{
s->render( renderer );
}
else if( const ObjectVector *o = runTimeCast<const ObjectVector>( it->second.get() ) )
{
for( ObjectVector::MemberContainer::const_iterator it = o->members().begin(), eIt = o->members().end(); it != eIt; it++ )
{
const StateRenderable *s = runTimeCast<const StateRenderable>( it->get() );
if( s )
{
s->render( renderer );
}
}
}
else if( const Data *d = runTimeCast<const Data>( it->second.get() ) )
{
renderer->setAttribute( it->first, d );
}
}
// object
std::set<float> deformationTimes;
motionTimes( ( m_options.deformationBlur && m_attributes.deformationBlur ) ? m_attributes.deformationBlurSegments : 0, deformationTimes );
{
ContextPtr timeContext = new Context( *m_context );
Context::Scope scopedTimeContext( timeContext );
unsigned timeIndex = 0;
for( std::set<float>::const_iterator it = deformationTimes.begin(), eIt = deformationTimes.end(); it != eIt; it++, timeIndex++ )
{
timeContext->setFrame( *it );
ConstObjectPtr object = m_scenePlug->objectPlug()->getValue();
if( const Primitive *primitive = runTimeCast<const Primitive>( object.get() ) )
{
if( deformationTimes.size() > 1 && timeIndex == 0 )
{
renderer->motionBegin( deformationTimes );
}
primitive->render( renderer );
if( deformationTimes.size() > 1 && timeIndex == deformationTimes.size() - 1 )
{
renderer->motionEnd();
}
}
else if( const Camera *camera = runTimeCast<const Camera>( object.get() ) )
{
//.........这里部分代码省略.........