Skip to content

Conversation

@weiliangjin2021
Copy link
Collaborator

@weiliangjin2021 weiliangjin2021 commented Oct 30, 2025

Greptile Overview

Updated On: 2025-10-30 23:56:51 UTC

Greptile Summary

This PR increases the default angle_threshold in CornerFinderSpec from 0.1π to 0.25π (π/4) to reduce false positive corner detection when processing STL files.

Key changes:

  • Updated CORNER_ANGLE_THRESOLD constant from 0.1 * np.pi to 0.25 * np.pi in tidy3d/components/grid/corner_finder.py:18
  • Updated all JSON schemas (Simulation, EMESimulation, ModeSimulation, TerminalComponentModeler) to reflect the new default value
  • Added breaking change entry in CHANGELOG.md noting that angle_threshold in CornerFinderSpec now defaults to pi/4
  • Properly categorized this as a breaking change affecting the microwave and smatrix plugins

Technical context:
The angle threshold determines when a vertex qualifies as a corner. A vertex is considered a corner if the angle spanned by its two edges is larger than π minus the threshold value. The previous threshold of 0.1π (18°) was too sensitive, causing false positives when detecting corners in STL files. The new threshold of 0.25π (45°) is more conservative and will only detect vertices as corners when the angle deviation from straight is more pronounced.

Confidence Score: 5/5

  • This PR is safe to merge with no significant concerns
  • The change is straightforward and well-implemented. It updates a single constant and ensures all related schema files are synchronized. The change is properly documented as a breaking change in the CHANGELOG. All modifications are consistent across files, and the new default value (pi/4) is reasonable for corner detection in geometric processing.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
tidy3d/components/grid/corner_finder.py 5/5 Changed default angle threshold constant from 0.1π to 0.25π (line 18) to reduce false positive corner detection
CHANGELOG.md 4/5 Added breaking change entry for angle_threshold default change to pi/4, moved from wrong section

Sequence Diagram

sequenceDiagram
    participant User
    participant CornerFinderSpec
    participant LayerRefinementSpec
    participant GridSpec
    participant Simulation
    
    User->>CornerFinderSpec: Create with default angle_threshold
    Note over CornerFinderSpec: angle_threshold = 0.25π (NEW)<br/>previously 0.1π
    
    User->>LayerRefinementSpec: Configure with corner_finder
    LayerRefinementSpec->>CornerFinderSpec: Use corner detection
    
    User->>Simulation: Create with layer_refinement_specs
    Simulation->>GridSpec: Generate grid with layer specs
    GridSpec->>LayerRefinementSpec: Apply layer refinement
    LayerRefinementSpec->>CornerFinderSpec: Find corners on 2D plane
    
    CornerFinderSpec->>CornerFinderSpec: _filter_collinear_vertices()
    Note over CornerFinderSpec: Filter vertices where<br/>angle <= π - angle_threshold<br/>(now π - 0.25π = 0.75π)
    
    CornerFinderSpec-->>LayerRefinementSpec: Return corner coordinates
    LayerRefinementSpec-->>GridSpec: Apply corner-based refinement
    GridSpec-->>Simulation: Generate refined grid
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

6 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

  • tidy3d/components/grid/corner_finder.py (100%)

Summary

  • Total: 1 line
  • Missing: 0 lines
  • Coverage: 100%

@weiliangjin2021 weiliangjin2021 force-pushed the weiliang/FXC-3874-corner-finder-angle branch from d5e8c35 to 5983f62 Compare October 31, 2025 16:54
@weiliangjin2021 weiliangjin2021 added this pull request to the merge queue Oct 31, 2025
Merged via the queue into develop with commit e8663e6 Oct 31, 2025
26 checks passed
@weiliangjin2021 weiliangjin2021 deleted the weiliang/FXC-3874-corner-finder-angle branch October 31, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants