| 368 | } // namespace |
| 369 | |
| 370 | MeshPrimitivePtr IECoreScene::MeshAlgo::merge( const std::vector<const MeshPrimitive *> &meshes, const Canceller *canceller ) |
| 371 | { |
| 372 | if( meshes.empty() ) |
| 373 | { |
| 374 | throw IECore::InvalidArgumentException( "IECoreScene::MeshAlgo::merge : No Mesh Primitives were provided." ); |
| 375 | } |
| 376 | |
| 377 | /// \todo: This scales poorly with increasing numbers of meshes. |
| 378 | /// Rather than allocating enough memory for everything and filling |
| 379 | /// it once, we're re-allocating and re-copying from the start for |
| 380 | /// each mesh. Improve the algorithm. |
| 381 | MeshPrimitivePtr result = meshes[0]->copy(); |
| 382 | auto it = meshes.begin() + 1; |
| 383 | for( ; it != meshes.end(); ++it ) |
| 384 | { |
| 385 | Canceller::check( canceller ); |
| 386 | ::merge( result.get(), *it, canceller ); |
| 387 | } |
| 388 | |
| 389 | return result; |
| 390 | } |