Skip to content

refactor: Material designator with less boilerplate#5221

Merged
paulgessinger merged 8 commits intoacts-project:mainfrom
paulgessinger:refactor/material-designator
Mar 12, 2026
Merged

refactor: Material designator with less boilerplate#5221
paulgessinger merged 8 commits intoacts-project:mainfrom
paulgessinger:refactor/material-designator

Conversation

@paulgessinger
Copy link
Copy Markdown
Member

@paulgessinger paulgessinger commented Mar 9, 2026

  1. Replace virtual dispatch with std::variantDesignatorBase polymorphism is replaced by a std::variant-based design.
  2. Unify ProtoDesignator – Single template for cylinder, cuboid, trapezoid, and diamond bounds.
  3. Use boost::core::demangle – Remove shellTypeName() and use boost::core::demangle for error messages.

Replace the double-dispatch pattern in MaterialDesignator.hpp with a
std::variant holding the concrete designator types. DesignatorBase,
NullDesignator, and the merged() virtual dispatch infrastructure are
removed entirely.

Each designator type becomes a standalone value type with plain apply(),
graphvizLabel(), and merged() methods. Merging, applying, and graphviz
output are handled by free functions operating on the variant via
std::visit, with std::monostate as the identity (null) state.

MaterialDesignatorBlueprintNodeImpl now stores a Designator value
instead of a unique_ptr<DesignatorBase>, removing the heap allocation
for the null state and the runtime polymorphism overhead.
…/diamond support

Merge CylinderProtoDesignator and CuboidProtoDesignator into a single
ProtoDesignator<FaceEnum, ShellType> template, mirroring the existing
ISurfaceMaterialDesignator pattern. Axis validation and duplicate-face
detection are separated into validateAxes() and validateDuplicate(),
with geometry-specific logic guarded by if constexpr.

Extend ISurfaceMaterialDesignator::shellTypeName() with cases for
TrapezoidPortalShell and DiamondPortalShell, add the corresponding
type aliases, and include both in the Designator variant so that the
existing merge/apply/graphvizLabel free functions cover them for free.
@paulgessinger paulgessinger requested a review from dimitra97 March 9, 2026 12:35
@github-actions github-actions bot added this to the next milestone Mar 9, 2026
@github-actions github-actions bot added the Component - Core Affects the Core module label Mar 9, 2026
@paulgessinger paulgessinger changed the title Refactor/material designator refactor: Material designator with less boilerplate Mar 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

📊: Physics performance monitoring for 1a594d3

Full contents

physmon summary

Avoid static local in portalShellShapeName by moving the regex to an
anonymous namespace. Keeps single construction while satisfying
static-analysis tools.
dimitra97
dimitra97 previously approved these changes Mar 10, 2026
Copy link
Copy Markdown
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

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

there are a couple more sonarcloud comments that can be considered

- Add default case to Face switch for exhaustive handling (SonarCloud S131)
- Use explicit template lambdas in std::visit over Designator
- Move portalShell regex to file scope, mark validateAxes const
- Use if-init in portalShellShapeName
@acts-policybot acts-policybot bot dismissed dimitra97’s stale review March 11, 2026 08:23

Invalidated by push of 69500fe

@sonarqubecloud
Copy link
Copy Markdown

@paulgessinger paulgessinger merged commit 6fd3e31 into acts-project:main Mar 12, 2026
42 of 43 checks passed
@paulgessinger paulgessinger deleted the refactor/material-designator branch March 12, 2026 20:09
@andiwand andiwand modified the milestones: next, v46.0.0 Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component - Core Affects the Core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants