MCPcopy Create free account
hub / github.com/ImageEngine/cortex / doConversion

Method doConversion

src/IECoreGL/ToGLPointsConverter.cpp:61–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61IECore::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 }

Callers

nothing calls this directly

Calls 4

readableMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
addPrimitiveVariableMethod · 0.45

Tested by

no test coverage detected