| 403 | } |
| 404 | |
| 405 | std::shared_ptr<MR::ObjectMesh> cloneRegion( const std::shared_ptr<ObjectMesh>& objMesh, const FaceBitSet& region, bool copyTexture /*= true */ ) |
| 406 | { |
| 407 | VertMapOrHashMap vertMap; |
| 408 | FaceMapOrHashMap faceMap; |
| 409 | PartMapping partMapping; |
| 410 | if ( !objMesh->getVertsColorMap().empty() || !objMesh->getUVCoords().empty() ) |
| 411 | partMapping.tgt2srcVerts = &vertMap; |
| 412 | if ( !objMesh->getFacesColorMap().empty() || !objMesh->getTexturePerFace().empty() ) |
| 413 | partMapping.tgt2srcFaces = &faceMap; |
| 414 | std::shared_ptr<Mesh> newMesh = std::make_shared<Mesh>( objMesh->mesh()->cloneRegion( region, false, partMapping ) ); |
| 415 | std::shared_ptr<ObjectMesh> newObj = std::make_shared<ObjectMesh>(); |
| 416 | newObj->setFrontColor( objMesh->getFrontColor( true ), true ); |
| 417 | newObj->setFrontColor( objMesh->getFrontColor( false ), false ); |
| 418 | newObj->setBackColor( objMesh->getBackColor() ); |
| 419 | newObj->setMesh( newMesh ); |
| 420 | newObj->setAllVisualizeProperties( objMesh->getAllVisualizeProperties() ); |
| 421 | if ( copyTexture ) |
| 422 | { |
| 423 | newObj->copyTextureAndColors( *objMesh, *vertMap.getMap(), *faceMap.getMap() ); |
| 424 | } |
| 425 | else |
| 426 | { |
| 427 | newObj->copyColors( *objMesh, *vertMap.getMap(), *faceMap.getMap() ); |
| 428 | newObj->setVisualizePropertyMask( MeshVisualizePropertyType::Texture, ViewportMask( 0 ) ); |
| 429 | } |
| 430 | newObj->setName( objMesh->name() + "_part" ); |
| 431 | return newObj; |
| 432 | } |
| 433 | |
| 434 | } //namespace MR |
no test coverage detected