FromHoudiniGeometryConverter::Convertability FromHoudiniCurvesConverter::canConvert( const GU_Detail *geo ) { const GA_PrimitiveList &primitives = geo->getPrimitiveList(); unsigned numPrims = geo->getNumPrimitives(); GA_Iterator firstPrim = geo->getPrimitiveRange().begin(); if ( !numPrims || !compatiblePrimitive( primitives.get( firstPrim.getOffset() )->getTypeId() ) ) { return Inapplicable; } const GEO_Curve *firstCurve = (const GEO_Curve*)primitives.get( firstPrim.getOffset() ); bool periodic = firstCurve->isClosed(); unsigned order = firstCurve->getOrder(); for ( GA_Iterator it=firstPrim; !it.atEnd(); ++it ) { const GA_Primitive *prim = primitives.get( it.getOffset() ); if ( !compatiblePrimitive( prim->getTypeId() ) ) { return Inapplicable; } const GEO_Curve *curve = (const GEO_Curve*)prim; if ( curve->getOrder() != order ) { return Inapplicable; } if ( curve->isClosed() != periodic ) { return Inapplicable; } } // is there a single named shape? GA_ROAttributeRef attrRef = geo->findPrimitiveAttribute( "name" ); if ( attrRef.isValid() && attrRef.isString() ) { const GA_Attribute *nameAttr = attrRef.getAttribute(); const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple(); GA_StringTableStatistics stats; tuple->getStatistics( nameAttr, stats ); if ( stats.getEntries() < 2 ) { return Ideal; } } return Suitable; }
FromHoudiniGeometryConverter::Convertability FromHoudiniPolygonsConverter::canConvert( const GU_Detail *geo ) { const GA_PrimitiveList &primitives = geo->getPrimitiveList(); GA_Offset start, end; for( GA_Iterator it( geo->getPrimitiveRange() ); it.blockAdvance( start, end ); ) { for( GA_Offset offset = start; offset < end; ++offset ) { const GA_Primitive *prim = primitives.get( offset ); if( prim->getTypeId() != GEO_PRIMPOLY ) { return Inapplicable; } } } if ( hasOnlyOpenPolygons( geo ) ) { return Suitable; } // is there a single named shape? GA_ROHandleS nameAttrib( geo, GA_ATTRIB_PRIMITIVE, GA_Names::name ); if( nameAttrib.isValid() ) { GA_StringTableStatistics stats; const GA_Attribute *nameAttr = nameAttrib.getAttribute(); const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple(); tuple->getStatistics( nameAttr, stats ); if ( stats.getEntries() < 2 ) { return Ideal; } } return Suitable; }
bool LiveScene::hasObject() const { OP_Node *node = retrieveNode( true ); if ( node->isManager() ) { return false; } OBJ_Node *objNode = node->castToOBJNode(); if ( !objNode ) { return false; } OBJ_OBJECT_TYPE type = objNode->getObjectType(); if ( type == OBJ_GEOMETRY ) { OP_Context context( adjustedDefaultTime() ); const GU_Detail *geo = objNode->getRenderGeometry( context, false ); if ( !geo ) { return false; } // multiple named shapes define children that contain each object /// \todo: similar attribute logic is repeated in several places. unify in a single function if possible GA_ROAttributeRef nameAttrRef = geo->findStringTuple( GA_ATTRIB_PRIMITIVE, "name" ); if ( !nameAttrRef.isValid() ) { return true; } const GA_Attribute *nameAttr = nameAttrRef.getAttribute(); const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple(); GA_StringTableStatistics stats; tuple->getStatistics( nameAttr, stats ); GA_Size numShapes = stats.getEntries(); if ( !numShapes ) { return true; } GA_Size numStrings = stats.getCapacity(); for ( GA_Size i=0; i < numStrings; ++i ) { GA_StringIndexType validatedIndex = tuple->validateTableHandle( nameAttr, i ); if ( validatedIndex < 0 ) { continue; } const char *currentName = tuple->getTableString( nameAttr, validatedIndex ); const char *match = matchPath( currentName ); if ( match && *match == *emptyString ) { // exact match return true; } } return false; } /// \todo: need to account for OBJ_CAMERA and OBJ_LIGHT return false; }