Feature: Topology Cleanup Tools
As a retopology artist
I want to clean up mesh topology issues
So that I can achieve proper quad-based topology
Background:
Given the MCP server is running
And the Blender addon is connected
And a mesh object is active in the scene
# ============================================================================
# tris_to_quads - Convert Triangles to Quads
# ============================================================================
Scenario: Convert triangles to quads with default threshold
Given a mesh with triangle pairs that form quads
When I call tris_to_quads with object_name="Mesh"
Then triangles are merged into quads where possible
And the result includes converted count
And the result includes remaining_tris count
Scenario Outline: Convert triangles with different angle thresholds
Given a mesh with triangles at various angles
When I call tris_to_quads with angle_threshold=<angle>
Then triangles with shared edge angle < <angle> are merged
And triangles with angle >= <angle> remain
Examples:
| angle |
| 30 |
| 40 |
| 60 |
| 90 |
Scenario: No triangles to convert
Given a mesh with only quad faces
When I call tris_to_quads
Then converted count is 0
And remaining_tris is 0
And a message indicates mesh is already quad-only
# ============================================================================
# align_vertex_to_loop - Align Vertex Position to Edge Loop
# ============================================================================
Scenario: Align vertex Y coordinate to edge loop
Given a vertex that is misaligned from its edge loop
When I call align_vertex_to_loop with vertex_index=5, axis="Y", target_coord=-0.138
Then the vertex Y coordinate is set to -0.138
And X and Z coordinates remain unchanged
And the new_position is returned
Scenario Outline: Align vertex on different axes
When I call align_vertex_to_loop with axis="<axis>" and target_coord=<coord>
Then the vertex <axis> coordinate matches <coord>
Examples:
| axis | coord |
| X | 0.5 |
| Y | -0.138 |
| Z | 1.0 |
Scenario: Align multiple vertices
Given multiple vertices selected
When I call align_vertex_to_loop with vertex_index=None (all selected)
Then all selected vertices are aligned to the target coordinate
Scenario: Invalid vertex index
When I call align_vertex_to_loop with vertex_index=999999
Then I receive an error message
And the error indicates vertex index out of range
# ============================================================================
# dissolve_edge_loop - Remove Edge Loop Without N-gons
# ============================================================================
Scenario: Dissolve non-form-defining edge loop
Given a mesh with redundant edge loops
When I call dissolve_edge_loop with object_name="Mesh" and loop_edges=[10, 11, 12, 13]
Then the edge loop is removed
And surrounding faces are merged cleanly
And no n-gons are created
And removed_edges count is returned
Scenario: Dissolve would create n-gon
Given an edge loop that bounds an n-gon if dissolved
When I call dissolve_edge_loop
Then I receive a warning
And the operation is prevented
And the error explains n-gon would result
Scenario: Dissolve boundary edge loop
Given an edge loop on mesh boundary
When I call dissolve_edge_loop on boundary edges
Then boundary edges cannot be dissolved
And an appropriate error is returned
# ============================================================================
# reduce_vertex_valence - Reduce High-Valence Vertices
# ============================================================================
Scenario: Reduce valence-6 vertex to valence-4
Given a vertex with valence 6 (star pattern)
When I call reduce_vertex_valence with vertex_index=42 and target_valence=4
Then the vertex is restructured to have 4 edges
And surrounding topology is adjusted
And no n-gons are created
Scenario: Cannot reduce below valence 3
When I call reduce_vertex_valence with target_valence=2
Then I receive an error message
And the error indicates minimum valence is 3
# ============================================================================
# Error Handling
# ============================================================================
Scenario: Cleanup on non-mesh object
Given a curve object is active
When I call tris_to_quads
Then I receive an error message
And the error indicates object must be a mesh
Scenario: Cleanup with no active object
Given no object is selected
When I call dissolve_edge_loop
Then I receive an error message
And the error indicates no active mesh object