本文整理汇总了C++中GA_Range::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ GA_Range::isValid方法的具体用法?C++ GA_Range::isValid怎么用?C++ GA_Range::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GA_Range
的用法示例。
在下文中一共展示了GA_Range::isValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doConversion
bool ToHoudiniPointsConverter::doConversion( const VisibleRenderable *renderable, GU_Detail *geo ) const
{
const PointsPrimitive *points = static_cast<const PointsPrimitive *>( renderable );
if ( !points )
{
return false;
}
const IECore::V3fVectorData *positions = points->variableData<V3fVectorData>( "P" );
if ( !positions )
{
// accept "position" so we can convert the results of the PDCParticleReader without having to rename things
/// \todo: Consider making the ParticleReader create a P if it doesn't exist for Cortex 6.
positions = points->variableData<V3fVectorData>( "position" );
}
GA_Range newPoints = appendPoints( geo, points->getNumPoints() );
if ( !newPoints.isValid() || newPoints.empty() )
{
return false;
}
transferAttribs( geo, newPoints, GA_Range() );
return true;
}
示例2: setName
void ToHoudiniGeometryConverter::setName( GU_Detail *geo, const GA_Range &prims ) const
{
// add the name attribute based on the parameter
const std::string &name = nameParameter()->getTypedValue();
if ( name != "" && prims.isValid() )
{
ToHoudiniStringVectorAttribConverter::convertString( "name", name, geo, prims );
}
}
示例3: doConversion
bool ToHoudiniPolygonsConverter::doConversion( const VisibleRenderable *renderable, GU_Detail *geo ) const
{
const MeshPrimitive *mesh = static_cast<const MeshPrimitive *>( renderable );
if ( !mesh )
{
return false;
}
GA_Range newPoints = appendPoints( geo, mesh->variableSize( PrimitiveVariable::Vertex ) );
if ( !newPoints.isValid() || newPoints.empty() )
{
return false;
}
GA_OffsetList pointOffsets;
pointOffsets.reserve( newPoints.getEntries() );
for ( GA_Iterator it=newPoints.begin(); !it.atEnd(); ++it )
{
pointOffsets.append( it.getOffset() );
}
const std::vector<int> &vertexIds = mesh->vertexIds()->readable();
const std::vector<int> &verticesPerFace = mesh->verticesPerFace()->readable();
GA_OffsetList offsets;
offsets.reserve( verticesPerFace.size() );
size_t vertCount = 0;
size_t numPrims = geo->getNumPrimitives();
for ( size_t f=0; f < verticesPerFace.size(); f++ )
{
GU_PrimPoly *poly = GU_PrimPoly::build( geo, 0, GU_POLY_CLOSED, 0 );
offsets.append( geo->primitiveOffset( numPrims + f ) );
for ( size_t v=0; v < (size_t)verticesPerFace[f]; v++ )
{
poly->appendVertex( pointOffsets.get( vertexIds[ vertCount + verticesPerFace[f] - 1 - v ] ) );
}
vertCount += verticesPerFace[f];
}
GA_Range newPrims( geo->getPrimitiveMap(), offsets );
transferAttribs( geo, newPoints, newPrims );
return true;
}
示例4: doConversion
bool ToHoudiniCurvesConverter::doConversion( const VisibleRenderable *renderable, GU_Detail *geo ) const
{
const CurvesPrimitive *curves = static_cast<const CurvesPrimitive *>( renderable );
if ( !curves )
{
return false;
}
bool periodic = curves->periodic();
bool duplicatedEnds = !periodic && ( curves->basis() == CubicBasisf::bSpline() );
size_t numPoints = curves->variableSize( PrimitiveVariable::Vertex );
if ( duplicatedEnds )
{
numPoints -= 4 * curves->numCurves();
}
GA_Range newPoints = appendPoints( geo, numPoints );
if ( !newPoints.isValid() || newPoints.empty() )
{
return false;
}
GA_OffsetList pointOffsets;
pointOffsets.reserve( newPoints.getEntries() );
for ( GA_Iterator it=newPoints.begin(); !it.atEnd(); ++it )
{
pointOffsets.append( it.getOffset() );
}
const std::vector<int> &verticesPerCurve = curves->verticesPerCurve()->readable();
int order = ( curves->basis() == CubicBasisf::bSpline() ) ? 4 : 2;
bool interpEnds = !(periodic && ( curves->basis() == CubicBasisf::bSpline() ));
GA_OffsetList offsets;
offsets.reserve( verticesPerCurve.size() );
size_t vertCount = 0;
size_t numPrims = geo->getNumPrimitives();
for ( size_t c=0; c < verticesPerCurve.size(); c++ )
{
size_t numVerts = duplicatedEnds ? verticesPerCurve[c] - 4 : verticesPerCurve[c];
GU_PrimNURBCurve *curve = GU_PrimNURBCurve::build( geo, numVerts, order, periodic, interpEnds, false );
if ( !curve )
{
return false;
}
offsets.append( geo->primitiveOffset( numPrims + c ) );
for ( size_t v=0; v < numVerts; v++ )
{
curve->setVertexPoint( v, pointOffsets.get( vertCount + v ) );
}
vertCount += numVerts;
}
GA_Range newPrims( geo->getPrimitiveMap(), offsets );
transferAttribs( geo, newPoints, newPrims );
return true;
}
示例5: transferAttribValues
void ToHoudiniGeometryConverter::transferAttribValues(
const Primitive *primitive, GU_Detail *geo,
const GA_Range &points, const GA_Range &prims,
PrimitiveVariable::Interpolation vertexInterpolation,
PrimitiveVariable::Interpolation primitiveInterpolation,
PrimitiveVariable::Interpolation pointInterpolation,
PrimitiveVariable::Interpolation detailInterpolation
) const
{
GA_OffsetList offsets;
if ( prims.isValid() )
{
const GA_PrimitiveList &primitives = geo->getPrimitiveList();
for ( GA_Iterator it=prims.begin(); !it.atEnd(); ++it )
{
const GA_Primitive *prim = primitives.get( it.getOffset() );
size_t numPrimVerts = prim->getVertexCount();
for ( size_t v=0; v < numPrimVerts; v++ )
{
if ( prim->getTypeId() == GEO_PRIMPOLY )
{
offsets.append( prim->getVertexOffset( numPrimVerts - 1 - v ) );
}
else
{
offsets.append( prim->getVertexOffset( v ) );
}
}
}
}
GA_Range vertRange( geo->getVertexMap(), offsets );
UT_String filter( attributeFilterParameter()->getTypedValue() );
// match all the string variables to each associated indices variable
/// \todo: replace all this logic with IECore::IndexedData once it exists...
PrimitiveVariableMap stringsToIndices;
for ( PrimitiveVariableMap::const_iterator it=primitive->variables.begin() ; it != primitive->variables.end(); it++ )
{
if ( !primitive->isPrimitiveVariableValid( it->second ) )
{
IECore::msg( IECore::MessageHandler::Warning, "ToHoudiniGeometryConverter", "PrimitiveVariable " + it->first + " is invalid. Ignoring." );
filter += UT_String( " ^" + it->first );
continue;
}
ToHoudiniAttribConverterPtr converter = ToHoudiniAttribConverter::create( it->second.data.get() );
if ( !converter )
{
continue;
}
if ( it->second.data->isInstanceOf( StringVectorDataTypeId ) )
{
std::string indicesVariableName = it->first + "Indices";
PrimitiveVariableMap::const_iterator indices = primitive->variables.find( indicesVariableName );
if ( indices != primitive->variables.end() && indices->second.data->isInstanceOf( IntVectorDataTypeId ) && primitive->isPrimitiveVariableValid( indices->second ) )
{
stringsToIndices[it->first] = indices->second;
filter += UT_String( " ^" + indicesVariableName );
}
}
}
bool convertStandardAttributes = m_convertStandardAttributesParameter->getTypedValue();
if ( convertStandardAttributes && UT_String( "s" ).multiMatch( filter ) && UT_String( "t" ).multiMatch( filter ) )
{
// convert s and t to uv
PrimitiveVariableMap::const_iterator sPrimVar = primitive->variables.find( "s" );
PrimitiveVariableMap::const_iterator tPrimVar = primitive->variables.find( "t" );
if ( sPrimVar != primitive->variables.end() && tPrimVar != primitive->variables.end() )
{
if ( sPrimVar->second.interpolation == tPrimVar->second.interpolation )
{
const FloatVectorData *sData = runTimeCast<const FloatVectorData>( sPrimVar->second.data.get() );
const FloatVectorData *tData = runTimeCast<const FloatVectorData>( tPrimVar->second.data.get() );
if ( sData && tData )
{
const std::vector<float> &s = sData->readable();
const std::vector<float> &t = tData->readable();
std::vector<Imath::V3f> uvw;
uvw.reserve( s.size() );
for ( size_t i=0; i < s.size(); ++i )
{
uvw.push_back( Imath::V3f( s[i], 1 - t[i], 0 ) );
}
GA_Range range = vertRange;
if ( sPrimVar->second.interpolation == pointInterpolation )
{
range = points;
}
ToHoudiniAttribConverterPtr converter = ToHoudiniAttribConverter::create( new V3fVectorData( uvw ) );
converter->convert( "uv", geo, range );
filter += " ^s ^t";
}
}
//.........这里部分代码省略.........
示例6: transferAttribValues
void ToHoudiniGeometryConverter::transferAttribValues(
const Primitive *primitive, GU_Detail *geo,
const GA_Range &points, const GA_Range &prims,
PrimitiveVariable::Interpolation vertexInterpolation,
PrimitiveVariable::Interpolation primitiveInterpolation,
PrimitiveVariable::Interpolation pointInterpolation,
PrimitiveVariable::Interpolation detailInterpolation
) const
{
GA_OffsetList offsets;
if ( prims.isValid() )
{
const GA_PrimitiveList &primitives = geo->getPrimitiveList();
for ( GA_Iterator it=prims.begin(); !it.atEnd(); ++it )
{
const GA_Primitive *prim = primitives.get( it.getOffset() );
size_t numPrimVerts = prim->getVertexCount();
for ( size_t v=0; v < numPrimVerts; v++ )
{
if ( prim->getTypeId() == GEO_PRIMPOLY )
{
offsets.append( prim->getVertexOffset( numPrimVerts - 1 - v ) );
}
else
{
offsets.append( prim->getVertexOffset( v ) );
}
}
}
}
GA_Range vertRange( geo->getVertexMap(), offsets );
UT_String filter( attributeFilterParameter()->getTypedValue() );
bool convertStandardAttributes = m_convertStandardAttributesParameter->getTypedValue();
// process all primvars with UV interpretation
for ( const auto &it : primitive->variables)
{
if ( !UT_String( it.first ).multiMatch( filter ) )
{
continue;
}
if (const V2fVectorData *uvData = runTimeCast<const V2fVectorData> ( it.second.data.get() ) )
{
if ( uvData->getInterpretation() != GeometricData::UV )
{
continue;
}
PrimitiveVariable::IndexedView<Imath::V2f> uvIndexedView ( it.second );
// Houdini prefers a V3f uvw rather than V2f uv,
// though they advise setting the 3rd component to 0.
std::vector<Imath::V3f> uvw;
uvw.reserve( uvIndexedView.size() );
for ( size_t i=0; i < uvIndexedView.size(); ++i )
{
uvw.emplace_back( uvIndexedView[i][0], uvIndexedView[i][1], 0 );
}
GA_Range range = vertRange;
if ( it.second.interpolation == pointInterpolation )
{
range = points;
}
V3fVectorData::Ptr uvwData = new V3fVectorData( uvw );
uvwData->setInterpretation( GeometricData::UV );
ToHoudiniAttribConverterPtr converter = ToHoudiniAttribConverter::create( uvwData.get() );
converter->convert( it.first, geo, range );
filter += " ^" + it.first;
}
}
UT_StringMMPattern attribFilter;
attribFilter.compile( filter );
// add the primitive variables to the various GEO_AttribDicts based on interpolation type
for ( PrimitiveVariableMap::const_iterator it=primitive->variables.begin() ; it != primitive->variables.end(); it++ )
{
if( !primitive->isPrimitiveVariableValid( it->second ) )
{
IECore::msg( IECore::MessageHandler::Warning, "ToHoudiniGeometryConverter", "PrimitiveVariable " + it->first + " is invalid. Ignoring." );
continue;
}
UT_String varName( it->first );
if ( !varName.multiMatch( attribFilter ) )
{
continue;
}
PrimitiveVariable primVar = processPrimitiveVariable( primitive, it->second );
//.........这里部分代码省略.........