Skip to content

computeTopologyMetrics and computeBoundaryMetrics for a mesh part - #7635

Merged
Fedr merged 12 commits into
masterfrom
mesh-part-topology-metrics
Dec 3, 2026
Merged

Fedr merged 12 commits into
masterfrom
mesh-part-topology-metrics

Conversation

@Fedr

@Fedr Fedr commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

New MRTopologyMetrics.h:

  • computeTopologyMetrics( const MeshPart& ), an analog of ObjectMeshHolder::numHandles() for a mesh part, where all not-region faces are considered missing. It returns MeshPartTopologyMetrics:
    • numFaces, numUndirectedEdges, numBdEdges, numVerts, numMultiHoleVerts (manifold vertices with more than one hole around)
    • numHoles: region boundary loops traced with Turn::Rightmost, i.e. the holes as they would be filled; for whole mesh equal to MeshTopology::findNumHoles()
    • numComponents (connected via vertices), eulerCharacteristic = numVerts - numUndirectedEdges + numFaces
    • numHandles = numComponents - ( eulerCharacteristic + numHoles ) / 2: the total genus after filling every hole with a disk
  • computeBoundaryMetrics( topology, region ): parallel computation of numBdEdges, multiHoleVerts, numHoles
  • computeNumComponents( meshPart, bd ): components connected via vertices, as getNumComponents( PerVertex ) but via edge components united only in bd.multiHoleVerts
  • inline computeNumHandles( numComponents, eulerCharacteristic, numHoles )

ObjectMeshHolder now caches computeBoundaryMetrics instead of findNumHoles() (same numHoles() values) and returns it from new public boundaryMetrics(), caches numHandles() and computes it via computeNumHandles; numComponents() (via edges) and the components via vertices for numHandles() come from one computeNumComponents call.

ObjectMesh on a 4M-triangle torus, master vs PR, min of 3 interleaved runs x 12 calls with cleared caches:

call mesh master PR
numHoles() 1000 holes 7.08 ms 6.79 ms
numHoles() 2000 holes, 1000 multi-hole vertices 7.15 ms 6.71 ms
numComponents() + numHandles() + numHoles() 1000 holes 24.66 ms 25.02 ms
numComponents() + numHandles() + numHoles() 2000 holes, 1000 multi-hole vertices 24.54 ms 25.96 ms

numComponents() alone takes 19 ms instead of 11 ms, since it computes boundary metrics first; all its callers (scene info, info lines, MCP stats) request numHoles() as well, which is then cached.

Unit tests: whole torus, torus with holes (null region vs all valid faces), torus without one triangle, torus with cut tube, two cube triangles sharing only a vertex, empty region; torus with 551 holes, many passing common vertices: computeBoundaryMetrics, findNumHoles and ObjectMesh::numHoles() agree.

🤖 Generated with Claude Code

Fedr and others added 5 commits November 29, 2026 23:35
Returns MeshPartTopologyMetrics with the number of handles, holes, components and other counts,
where all not-region faces are considered missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mics

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Grantim Grantim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to reuse it ObjectMesh metrics caches and/or Mesh caches? Should we be able to request only subset of all metrics?

…ObjectMeshHolder

Holes are traced with Turn::Rightmost, so for whole mesh their number equals MeshTopology::findNumHoles();
components are counted via vertices only if some vertex has several fans of region faces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fedr Fedr changed the title MeshComponents::computeTopologyMetrics for a mesh part computeTopologyMetrics and computeBoundaryMetrics for a mesh part Dec 3, 2026
Fedr and others added 4 commits December 3, 2026 17:12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tices

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
computeBoundaryMetrics visits only set bits when tracing loops and has a whole-mesh path for boundary edges;
ObjectMeshHolder gets both component counts from one union-find structure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread source/MRMesh/MRTopologyMetrics.h Resolved
Comment thread source/MRMesh/MRObjectMeshHolder.h Resolved
…s less

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread source/MRMesh/MRTopologyMetrics.h Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fedr
Fedr merged commit 7845028 into master Dec 3, 2026
64 checks passed
@Fedr
Fedr deleted the mesh-part-topology-metrics branch December 3, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants