| 109 | |
| 110 | template<typename T> |
| 111 | PointsPrimitivePtr deletePoints( const PointsPrimitive *pointsPrimitive, IECoreScene::PrimitiveVariable::IndexedView<T>& deleteFlagView, bool invert, const Canceller *canceller ) |
| 112 | { |
| 113 | PointsPrimitivePtr outPointsPrimitive = new PointsPrimitive( 0 ); |
| 114 | |
| 115 | IECoreScene::PrimitiveVariableAlgos::DeleteFlaggedUniformFunctor<T> vertexFunctor( deleteFlagView, invert ); |
| 116 | |
| 117 | for( PrimitiveVariableMap::const_iterator it = pointsPrimitive->variables.begin(), e = pointsPrimitive->variables.end(); it != e; ++it ) |
| 118 | { |
| 119 | Canceller::check( canceller ); |
| 120 | switch( it->second.interpolation ) |
| 121 | { |
| 122 | case PrimitiveVariable::Vertex: |
| 123 | case PrimitiveVariable::Varying: |
| 124 | case PrimitiveVariable::FaceVarying: |
| 125 | { |
| 126 | if( !pointsPrimitive->isPrimitiveVariableValid( it->second ) ) |
| 127 | { |
| 128 | throw InvalidArgumentException( |
| 129 | boost::str ( boost::format( "PointsAlgo::deletePoints cannot process invalid primitive variable \"%s\"" ) % it->first ) ); |
| 130 | } |
| 131 | const IECore::Data *inputData = it->second.data.get(); |
| 132 | vertexFunctor.setIndices( it->second.indices.get() ); |
| 133 | IECoreScene::PrimitiveVariableAlgos::IndexedData indexedData = dispatch( inputData, vertexFunctor ); |
| 134 | outPointsPrimitive->variables[it->first] = PrimitiveVariable( it->second.interpolation, indexedData.data, indexedData.indices ); |
| 135 | break; |
| 136 | } |
| 137 | case PrimitiveVariable::Uniform: |
| 138 | case PrimitiveVariable::Constant: |
| 139 | case PrimitiveVariable::Invalid: |
| 140 | { |
| 141 | outPointsPrimitive->variables[it->first] = it->second; |
| 142 | break; |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | V3fVectorDataPtr positionData = outPointsPrimitive->variableData<V3fVectorData>( "P" ); |
| 148 | if( positionData ) |
| 149 | { |
| 150 | outPointsPrimitive->setNumPoints( positionData->readable().size() ); |
| 151 | } |
| 152 | |
| 153 | return outPointsPrimitive; |
| 154 | } |
| 155 | |
| 156 | struct CollectDataFn |
| 157 | { |
no test coverage detected