本文整理汇总了C++中GA_Range::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ GA_Range::isEmpty方法的具体用法?C++ GA_Range::isEmpty怎么用?C++ GA_Range::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GA_Range
的用法示例。
在下文中一共展示了GA_Range::isEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertObject
bool SOP_SceneCacheSource::convertObject( IECore::Object *object, const std::string &name, const std::string &attributeFilter, bool hasAnimatedTopology, bool hasAnimatedPrimVars, const std::vector<InternedString> &animatedPrimVars )
{
VisibleRenderable *renderable = IECore::runTimeCast<VisibleRenderable>( object );
if ( !renderable )
{
return false;
}
ToHoudiniGeometryConverterPtr converter = ToHoudiniGeometryConverter::create( renderable );
if ( !converter )
{
return false;
}
// attempt to optimize the conversion by re-using animated primitive variables
const Primitive *primitive = IECore::runTimeCast<Primitive>( renderable );
GA_ROAttributeRef nameAttrRef = gdp->findStringTuple( GA_ATTRIB_PRIMITIVE, "name" );
GA_Range primRange = gdp->getRangeByValue( nameAttrRef, name.c_str() );
if ( primitive && !hasAnimatedTopology && hasAnimatedPrimVars )
{
if ( nameAttrRef.isValid() && !primRange.isEmpty() )
{
// this means constant topology and primitive variables, even though multiple samples were written
if ( animatedPrimVars.empty() )
{
return true;
}
GA_Range pointRange( *gdp, primRange, GA_ATTRIB_POINT, GA_Range::primitiveref(), false );
std::string animatedPrimVarStr = "";
for ( std::vector<InternedString>::const_iterator it = animatedPrimVars.begin(); it != animatedPrimVars.end(); ++it )
{
animatedPrimVarStr += it->string() + " ";
}
converter->attributeFilterParameter()->setTypedValue( animatedPrimVarStr );
converter->transferAttribs( gdp, pointRange, primRange );
return true;
}
}
else
{
gdp->destroyPrimitives( primRange, true );
}
// fallback to full conversion
converter->attributeFilterParameter()->setTypedValue( attributeFilter );
if ( converter->convert( myGdpHandle ) )
{
return true;
}
return false;
}
示例2: holdObject
void SOP_SceneCacheSource::holdObject( IECore::Object *object, const std::string &name, bool hasAnimatedTopology, bool hasAnimatedPrimVars, const std::vector<InternedString> &animatedPrimVars )
{
// attempt to optimize the conversion by re-using animated primitive variables
const Primitive *primitive = IECore::runTimeCast<Primitive>( object );
GA_ROAttributeRef nameAttrRef = gdp->findStringTuple( GA_ATTRIB_PRIMITIVE, "name" );
GA_Range primRange = gdp->getRangeByValue( nameAttrRef, name.c_str() );
if ( primitive && !hasAnimatedTopology && hasAnimatedPrimVars && nameAttrRef.isValid() && !primRange.isEmpty() )
{
// this means constant topology and primitive variables, even though multiple samples were written
if ( animatedPrimVars.empty() )
{
return;
}
GA_Primitive *hPrim = gdp->getPrimitiveList().get( primRange.begin().getOffset() );
if ( hPrim->getTypeId() == GU_CortexPrimitive::typeId() )
{
/// \todo: can we just update the prim vars?
((GU_CortexPrimitive *)hPrim)->setObject( primitive );
GA_Range pointRange( *gdp, primRange, GA_ATTRIB_POINT, GA_Range::primitiveref(), false );
gdp->setPos3( pointRange.begin().getOffset(), IECore::convert<UT_Vector3>( primitive->bound().center() ) );
return;
}
}
else
{
gdp->destroyPrimitives( primRange, true );
}
size_t numPrims = gdp->getNumPrimitives();
GU_CortexPrimitive::build( gdp, object );
GA_Offset primOffset = gdp->primitiveOffset( numPrims );
GA_OffsetList offsets;
offsets.append( primOffset );
GA_Range newPrims( gdp->getPrimitiveMap(), offsets );
ToHoudiniStringVectorAttribConverter::convertString( "name", name, gdp, newPrims );
}