MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / cloneRegion

Function cloneRegion

source/MRMesh/MRObjectMesh.cpp:405–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405std::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

Callers 1

cloneSelectedPartMethod · 0.50

Calls 11

cloneRegionMethod · 0.80
setBackColorMethod · 0.80
setMeshMethod · 0.80
copyTextureAndColorsMethod · 0.80
ViewportMaskClass · 0.70
emptyMethod · 0.45
setFrontColorMethod · 0.45
copyColorsMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected