当前位置: 首页>>代码示例>>C++>>正文


C++ GA_Range::getEntries方法代码示例

本文整理汇总了C++中GA_Range::getEntries方法的典型用法代码示例。如果您正苦于以下问题:C++ GA_Range::getEntries方法的具体用法?C++ GA_Range::getEntries怎么用?C++ GA_Range::getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GA_Range的用法示例。


在下文中一共展示了GA_Range::getEntries方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:Alwnikrotikz,项目名称:cortex-vfx,代码行数:47,代码来源:ToHoudiniPolygonsConverter.cpp

示例2: 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;
}
开发者ID:richardmonette,项目名称:cortex,代码行数:63,代码来源:ToHoudiniCurvesConverter.cpp

示例3: cookMySop


//.........这里部分代码省略.........
			{
				continue;
			}
			
			ToHoudiniAttribConverterPtr converter = ToHoudiniAttribConverter::create( data );
			if ( !converter )
 			{
 				continue;
 			}
			
			// strip the prefix/suffix from the GA_Attribute name
			std::string attrName = aIt->first.value();
			size_t prefixLength = attributePrefix.length();
			if ( prefixLength && ( search( attrName.begin(), attrName.begin()+prefixLength, attributePrefix.begin(), attributePrefix.end() ) == attrName.begin() ) )
			{
				attrName.erase( attrName.begin(), attrName.begin() + prefixLength );
			}
			
			size_t suffixLength = attributeSuffix.length();
			if ( suffixLength && ( search( attrName.end() - suffixLength, attrName.end(), attributeSuffix.begin(), attributeSuffix.end() ) == ( attrName.end() - suffixLength ) ) )
			{
				attrName.erase( attrName.end() - suffixLength, attrName.end() );
			}
			
			if ( attrName == "P" )
			{
				const V3fVectorData *positions = IECore::runTimeCast<const V3fVectorData>( data );
				if ( !positions )
				{
					continue;
				}
				
				size_t index = 0;
				size_t entries = pointRange.getEntries();
				const std::vector<Imath::V3f> &pos = positions->readable();
				
				// Attempting to account for the vertex difference between an IECore::CurvesPrimitive and Houdini curves.
				// As Houdini implicitly triples the endpoints of a curve, a cache generated from a single CurvesPrimitive
				// will have exactly four extra vertices. In this case, we adjust the cache by ignoring the first two and
				// last two V3fs. In all other cases, we report a warning and don't apply the cache to these points.
				if ( pos.size() - 4 == entries )
				{
					index = 2;
				}
				else if ( pos.size() != entries )
				{
					addWarning( SOP_ATTRIBUTE_INVALID, ( boost::format( "Geometry/Cache mismatch: %s contains %d points, while cache expects %d values for P." ) % group->getName().toStdString() % entries % pos.size() ).str().c_str() );
					continue;
				}
				
				/// \todo: try multi-threading this with a GA_SplittableRange
				for ( GA_Iterator it=pointRange.begin(); !it.atEnd(); ++it, ++index )
				{
					gdp->setPos3( it.getOffset(), IECore::convert<UT_Vector3>( pos[index] ) );
				}

			}
			else if ( groupingMode == PrimitiveGroup )
			{
				GA_Range currentRange;
				unsigned size = despatchTypedData<TypedDataSize, TypeTraits::IsVectorTypedData, DespatchTypedDataIgnoreError>( data );
				
				// check for existing attributes
				if ( gdp->findPrimitiveAttribute( attrName.c_str() ).isValid() && size == primRange.getEntries() )
				{
					currentRange = primRange;
开发者ID:Alwnikrotikz,项目名称:cortex-vfx,代码行数:67,代码来源:SOP_InterpolatedCacheReader.cpp

示例4: transferAttribValues


//.........这里部分代码省略.........
					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";
				}
			}
		}
	}
	
 	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++ )
	{
		UT_String varName( it->first );
		if ( !varName.multiMatch( attribFilter ) )
		{
			continue;
		}
		
		PrimitiveVariable primVar = processPrimitiveVariable( primitive, it->second );
		ToHoudiniAttribConverterPtr converter = ToHoudiniAttribConverter::create( primVar.data );
		if ( !converter )
		{
			continue;
		}
		
		PrimitiveVariable::Interpolation interpolation = primVar.interpolation;
		
		if ( converter->isInstanceOf( (IECore::TypeId)ToHoudiniStringVectorAttribConverterTypeId ) )
		{
			PrimitiveVariableMap::const_iterator indices = stringsToIndices.find( it->first );
			if ( indices != stringsToIndices.end() )
			{
				ToHoudiniStringVectorAttribConverter *stringVectorConverter = IECore::runTimeCast<ToHoudiniStringVectorAttribConverter>( converter );
				PrimitiveVariable indicesPrimVar = processPrimitiveVariable( primitive, indices->second );
				stringVectorConverter->indicesParameter()->setValidatedValue( indicesPrimVar.data );
				interpolation = indices->second.interpolation;
			}
		}
		
		const std::string name = ( convertStandardAttributes ) ? processPrimitiveVariableName( it->first ) : it->first;
		
		if ( interpolation == detailInterpolation )
 		{
			// add detail attribs
			converter->convert( name, geo );
	 	}
		else if ( interpolation == pointInterpolation )
		{
			// add point attribs
			if ( name == "P" )
			{
				// special case for P
				transferP( runTimeCast<const V3fVectorData>( primVar.data ), geo, points );
			}
			else
			{
 				converter->convert( name, geo, points );
			}
		}
		else if ( interpolation == primitiveInterpolation )
		{
			// add primitive attribs
			converter->convert( name, geo, prims );
		}
		else if ( interpolation == vertexInterpolation )
		{
			// add vertex attribs
			converter->convert( name, geo, vertRange );
		}
	}
	
	// add the name attribute based on blindData
	const StringData *nameData = primitive->blindData()->member<StringData>( "name" );
	if ( nameData )
	{
		if ( prims.isValid() )
		{
			StringVectorDataPtr nameVectorData = new StringVectorData();
			nameVectorData->writable().push_back( nameData->readable() );
			std::vector<int> indexValues( prims.getEntries(), 0 );
			IntVectorDataPtr indexData = new IntVectorData( indexValues );
			ToHoudiniStringVectorAttribConverterPtr converter = new ToHoudiniStringVectorAttribConverter( nameVectorData );
			converter->indicesParameter()->setValidatedValue( indexData );
			converter->convert( "name", geo, prims );
		}
	}
}
开发者ID:Alwnikrotikz,项目名称:cortex-vfx,代码行数:101,代码来源:ToHoudiniGeometryConverter.cpp

示例5: detailLock

void
GusdRefiner::refineDetail(
    const GU_ConstDetailHandle& detail,
    const GT_RefineParms&      refineParms )
{
    m_refineParms = refineParms;

    GU_DetailHandleAutoReadLock detailLock( detail );

    GA_ROHandleS partitionAttr;
    if( !m_pathAttrName.empty() ) {
        partitionAttr = 
            detailLock->findStringTuple( 
                            GA_ATTRIB_PRIMITIVE, 
                            m_pathAttrName.c_str() );
    }

    std::vector<GA_Range> partitions;
    GA_Range primRange = detailLock->getPrimitiveRange();
    if(!partitionAttr.isValid() || primRange.getEntries() == 0) {
        partitions.push_back(primRange);
    }
    else {

        typedef UT_Map<GA_StringIndexType, GA_OffsetList> PrimPartitionMap;

        PrimPartitionMap partitionMap;
        for(GA_Iterator offsetIt(primRange); !offsetIt.atEnd(); ++offsetIt) {
            GA_StringIndexType idx = partitionAttr.getIndex(offsetIt.getOffset());
            partitionMap[idx].append(offsetIt.getOffset());
        }

        partitions.reserve(partitionMap.size());
        for(PrimPartitionMap::const_iterator mapIt=partitionMap.begin();
                mapIt != partitionMap.end(); ++mapIt) {
            partitions.push_back(GA_Range(detailLock->getPrimitiveMap(),
                                          mapIt->second));
        }
    }
    
    // Refine each geometry partition to prims that can be written to USD. 
    // The results are accumulated in buffer in the refiner.
    for(vector<GA_Range>::const_iterator rangeIt=partitions.begin();
            rangeIt != partitions.end(); ++rangeIt) {

        const GA_Range& range = *rangeIt;

        // Before we refine we need to decide if we want to coalesce packed
        // fragments. We will coalesce unless we are writing transform
        // overlays and the fragment has a name.

        GU_DetailHandleAutoReadLock detailLock( detail );

        bool overlayTransforms = false;
        GA_AttributeOwner order[] = { GA_ATTRIB_PRIMITIVE, GA_ATTRIB_DETAIL };
        const GA_Attribute *overTransformsAttr = 
            detailLock->findAttribute( GUSD_OVERTRANSFORMS_ATTR, order, 2 );
        if( overTransformsAttr ) {
            GA_ROHandleI h( overTransformsAttr );
            if( overTransformsAttr->getOwner() == GA_ATTRIB_DETAIL ) {
                overlayTransforms = h.get( GA_Offset(0) );
            }
            else {
                // assume all prims in the range have the same usdovertransforms
                // attribute value
                overlayTransforms = h.get( range.begin().getOffset() );
            }
        }
        if( overlayTransforms ) {
            // prims must be named to overlay transforms
            const GA_Attribute *primPathAttr = 
                detailLock->findPrimitiveAttribute( GUSD_PRIMPATH_ATTR );
            if( !primPathAttr ) {
                overlayTransforms = false;
            }
        }
        
        GT_RefineParms newRefineParms( refineParms );
        newRefineParms.setCoalesceFragments( m_refinePackedPrims && !overlayTransforms );

        GT_PrimitiveHandle detailPrim
                = GT_GEODetail::makeDetail( detail, &range);
        if(detailPrim) {
            detailPrim->refine(*this, &newRefineParms );
        }
    }
}
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:87,代码来源:refiner.cpp


注:本文中的GA_Range::getEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。