| 322 | } |
| 323 | |
| 324 | void MeshPrimitive::setCreases( const IECore::IntVectorData *lengths, const IECore::IntVectorData *ids, const IECore::FloatVectorData *sharpnesses ) |
| 325 | { |
| 326 | size_t expectedIds = 0; |
| 327 | for( auto length : lengths->readable() ) |
| 328 | { |
| 329 | if( length < 2 ) |
| 330 | { |
| 331 | throw Exception( boost::str( |
| 332 | boost::format( |
| 333 | "Bad creases : length (%1%) is less than 2" |
| 334 | ) % length |
| 335 | ) ); |
| 336 | } |
| 337 | expectedIds += length; |
| 338 | } |
| 339 | |
| 340 | if( ids->readable().size() != expectedIds ) |
| 341 | { |
| 342 | throw Exception( boost::str( |
| 343 | boost::format( |
| 344 | "Bad creases : expected %1% ids but given %2%" |
| 345 | ) % expectedIds % ids->readable().size() |
| 346 | ) ); |
| 347 | } |
| 348 | |
| 349 | for( auto id : ids->readable() ) |
| 350 | { |
| 351 | if( id < 0 || (size_t)id >= m_numVertices ) |
| 352 | { |
| 353 | throw Exception( boost::str( |
| 354 | boost::format( |
| 355 | "Bad creases : id (%1%) is out of expected range (0-%2%)" |
| 356 | ) % id % (m_numVertices - 1) |
| 357 | ) ); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | if( sharpnesses->readable().size() != lengths->readable().size() ) |
| 362 | { |
| 363 | throw Exception( boost::str( |
| 364 | boost::format( |
| 365 | "Bad creases : number of sharpnesses (%1%) does not match number of lengths (%2%)" |
| 366 | ) % sharpnesses->readable().size() % lengths->readable().size() |
| 367 | ) ); |
| 368 | } |
| 369 | |
| 370 | m_creaseLengths = lengths->copy(); |
| 371 | m_creaseIds = ids->copy(); |
| 372 | m_creaseSharpnesses = sharpnesses->copy(); |
| 373 | } |
| 374 | |
| 375 | const IECore::IntVectorData *MeshPrimitive::creaseLengths() const |
| 376 | { |