Skip to content

Refactor logic builder and related utilities#2238

Open
sethrj wants to merge 24 commits intoceleritas-project:developfrom
sethrj:logic-builder-refactor
Open

Refactor logic builder and related utilities#2238
sethrj wants to merge 24 commits intoceleritas-project:developfrom
sethrj:logic-builder-refactor

Conversation

@sethrj
Copy link
Member

@sethrj sethrj commented Feb 6, 2026

This is in advance of some fixes for the infix/postfix builder/converter, which is somewhat confusing because of the hardcoded posfix construction (but with simplification) despite the hardcoded infix tracking.

  • Add bzone stream
  • Add additional debug/warning statements to UnitProto construction
  • Add proto constructor test
  • Replace constexpr function with inline consexpr value
  • Remove duplicate function declaration
  • Extend string parsing and remove lend
  • Refactor CsgLogicUtils to use immutable policy factory
  • Move policy out of loop
  • Add dynamic policy
  • Convert more token vectors to string
  • Remove ScaleUtils and improve conversion explanation
  • Split build-logic utils into header and cc
  • Split logic conversion and IO utilities
  • Add single place for building "nowhere" logic expression
  • Remove now-unnecessary logic from scalars
  • Use vectors not spans
  • Assume that input in infix format will always satisfy demorgan's law

sethrj added 17 commits February 6, 2026 07:14
Split the builder pattern into two parts:
- Policy classes: Immutable factories that can be passed by const reference
- Visitor classes: Mutable workers that hold references to the logic vector

This makes the code clearer by separating configuration (policy) from
execution (visitor). The policy's operator() creates a visitor with the
necessary references, and build_logic coordinates the process.

Benefits:
- Policies are now truly immutable and can be reused
- No more confusing move semantics or rvalue references
- Clear separation between factory and worker
- Maintains the same CRTP pattern for postfix/infix variants

Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
@sethrj sethrj requested a review from esseivaju February 6, 2026 12:16
@sethrj sethrj requested a review from elliottbiondo as a code owner February 6, 2026 12:16
@sethrj sethrj added minor Refactoring or minor internal changes/fixes orange Work on ORANGE geometry engine labels Feb 6, 2026
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Test summary

 5 893 files   9 431 suites   18m 39s ⏱️
 2 145 tests  2 117 ✅  28 💤 0 ❌
32 234 runs  32 076 ✅ 158 💤 0 ❌

Results for commit f736bf5.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.83%. Comparing base (43e05ae) to head (f736bf5).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/orange/orangeinp/detail/BuildLogic.cc 92.94% 6 Missing ⚠️
src/orange/orangeinp/UnitProto.cc 76.47% 1 Missing and 3 partials ⚠️
src/orange/detail/ConvertLogic.cc 91.89% 2 Missing and 1 partial ⚠️
src/orange/detail/LogicIO.cc 98.24% 1 Missing ⚠️
src/orange/orangeinp/detail/BuildLogic.hh 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2238      +/-   ##
===========================================
+ Coverage    86.81%   86.83%   +0.01%     
===========================================
  Files         1330     1330              
  Lines        42019    42048      +29     
  Branches     12950    12959       +9     
===========================================
+ Hits         36480    36511      +31     
+ Misses        4335     4334       -1     
+ Partials      1204     1203       -1     
Files with missing lines Coverage Δ
src/orange/OrangeData.hh 97.08% <ø> (-0.07%) ⬇️
src/orange/OrangeInputIO.json.cc 69.68% <100.00%> (ø)
src/orange/OrangeParams.cc 87.85% <100.00%> (-0.12%) ⬇️
src/orange/OrangeParamsOutput.cc 100.00% <ø> (ø)
src/orange/OrangeTypes.hh 83.33% <ø> (ø)
src/orange/detail/UnitInserter.cc 84.41% <100.00%> (ø)
src/orange/orangeinp/UnitProto.hh 83.33% <100.00%> (-0.67%) ⬇️
src/orange/univ/SimpleUnitTracker.hh 95.45% <ø> (ø)
src/orange/detail/LogicIO.cc 98.24% <98.24%> (ø)
src/orange/orangeinp/detail/BuildLogic.hh 85.71% <85.71%> (ø)
... and 3 more

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

// Calculate the maximum stack depth of the volume definition
int depth = calc_depth(input_logic);
// TODO: is this valid for infix??
int depth = calc_depth(make_span(v.logic));
Copy link
Member Author

Choose a reason for hiding this comment

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

@esseivaju I think this is only needed for postfix runtime?

// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file orange/orangeinp/ScaleUtils.cc
//! \file orange/detail/LogicIO.hh
Copy link
Member Author

Choose a reason for hiding this comment

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

Ignore the faulty git rename detection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Refactoring or minor internal changes/fixes orange Work on ORANGE geometry engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant