| 59 | } |
| 60 | |
| 61 | IECore::RunTimeTypedPtr ToGLPointsConverter::doConversion( IECore::ConstObjectPtr src, IECore::ConstCompoundObjectPtr operands ) const |
| 62 | { |
| 63 | IECoreScene::PointsPrimitive::ConstPtr pointsPrim = boost::static_pointer_cast<const IECoreScene::PointsPrimitive>( src ); // safe because the parameter validated it for us |
| 64 | |
| 65 | IECore::V3fVectorData::ConstPtr points = pointsPrim->variableData<IECore::V3fVectorData>( "P", IECoreScene::PrimitiveVariable::Vertex ); |
| 66 | if( !points ) |
| 67 | { |
| 68 | throw IECore::Exception( "Must specify primitive variable \"P\", of type V3fVectorData and interpolation type Vertex." ); |
| 69 | } |
| 70 | |
| 71 | // get type |
| 72 | PointsPrimitive::Type type = PointsPrimitive::Disk; |
| 73 | IECore::ConstStringDataPtr t = pointsPrim->variableData<IECore::StringData>( "type", IECoreScene::PrimitiveVariable::Constant ); |
| 74 | if ( !t ) |
| 75 | { |
| 76 | t = pointsPrim->variableData<IECore::StringData>( "type", IECoreScene::PrimitiveVariable::Uniform ); |
| 77 | } |
| 78 | if( t ) |
| 79 | { |
| 80 | if( t->readable()=="particle" || t->readable()=="disk" || t->readable()=="blobby" ) |
| 81 | { |
| 82 | type = PointsPrimitive::Disk; |
| 83 | } |
| 84 | else if( t->readable()=="sphere" ) |
| 85 | { |
| 86 | type = PointsPrimitive::Sphere; |
| 87 | } |
| 88 | else if( t->readable()=="patch" ) |
| 89 | { |
| 90 | type = PointsPrimitive::Quad; |
| 91 | } |
| 92 | else if( t->readable()=="gl:point" ) |
| 93 | { |
| 94 | type = PointsPrimitive::Point; |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | IECore::msg( IECore::Msg::Warning, "ToGLPointsConverter::doConversion", boost::format( "Unknown type \"%s\" - reverting to particle type." ) % t->readable() ); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | PointsPrimitive::Ptr result = new PointsPrimitive( type ); |
| 103 | |
| 104 | for ( IECoreScene::PrimitiveVariableMap::const_iterator pIt = pointsPrim->variables.begin(); pIt != pointsPrim->variables.end(); ++pIt ) |
| 105 | { |
| 106 | if( pIt->first == "type" ) |
| 107 | { |
| 108 | continue; |
| 109 | } |
| 110 | |
| 111 | if ( pIt->second.data ) |
| 112 | { |
| 113 | result->addPrimitiveVariable( pIt->first, pIt->second ); |
| 114 | } |
| 115 | else |
| 116 | { |
| 117 | IECore::msg( IECore::Msg::Warning, "ToGLPointsConverter", boost::format( "No data given for primvar \"%s\"" ) % pIt->first ); |
| 118 | } |
nothing calls this directly
no test coverage detected