diff --git a/src/orange/CMakeLists.txt b/src/orange/CMakeLists.txt index 7bd46d75b8..73d8c504f9 100644 --- a/src/orange/CMakeLists.txt +++ b/src/orange/CMakeLists.txt @@ -25,7 +25,8 @@ list(APPEND SOURCES detail/BIHBuilder.cc detail/BIHPartitioner.cc detail/DepthCalculator.cc - detail/LogicUtils.cc + detail/ConvertLogic.cc + detail/LogicIO.cc detail/OrangeInputIOImpl.json.cc detail/RectArrayInserter.cc detail/SurfacesRecordBuilder.cc @@ -50,11 +51,11 @@ list(APPEND SOURCES orangeinp/Shape.cc orangeinp/Solid.cc orangeinp/StackedExtrudedPolygon.cc - orangeinp/ScaleUtils.cc orangeinp/Transformed.cc orangeinp/Truncated.cc orangeinp/UnitProto.cc orangeinp/detail/BoundingZone.cc + orangeinp/detail/BuildLogic.cc orangeinp/detail/BuildIntersectRegion.cc orangeinp/detail/CsgUnitBuilder.cc orangeinp/detail/DeMorganSimplifier.cc diff --git a/src/orange/OrangeData.hh b/src/orange/OrangeData.hh index 4e01f1d7ae..a477bb4e11 100644 --- a/src/orange/OrangeData.hh +++ b/src/orange/OrangeData.hh @@ -38,10 +38,7 @@ inline constexpr UnivId orange_global_univ{0}; inline constexpr UnivLevelId orange_global_univ_level{0}; //! Logic notation used for boolean expressions -CELER_FUNCTION inline constexpr auto orange_tracking_logic() -{ - return LogicNotation::infix; -} +inline constexpr auto orange_tracking_logic{LogicNotation::infix}; //---------------------------------------------------------------------------// /*! @@ -64,9 +61,6 @@ struct OrangeParamsScalars // Soft comparison and dynamic "bumping" values Tolerance<> tol; - // Logic expression notation - LogicNotation logic{}; - // Raw pointers to externally owned memory for debug output OrangeParams const* host_geo_params{nullptr}; VolumeParams const* host_volume_params{nullptr}; diff --git a/src/orange/OrangeInputIO.json.cc b/src/orange/OrangeInputIO.json.cc index 162248a2e4..798fee7a13 100644 --- a/src/orange/OrangeInputIO.json.cc +++ b/src/orange/OrangeInputIO.json.cc @@ -29,7 +29,7 @@ #include "OrangeTypes.hh" #include "OrangeTypesIO.json.hh" // IWYU pragma: keep -#include "detail/LogicUtils.hh" +#include "detail/LogicIO.hh" #include "detail/OrangeInputIOImpl.json.hh" namespace celeritas @@ -133,7 +133,7 @@ void from_json(nlohmann::json const& j, VolumeInput& value) { // Background volumes should be "nowhere" explicitly using "inside" // logic - value.logic = {logic::ltrue, logic::lnot}; + value.logic = detail::make_nowhere_expr(LogicNotation::postfix); value.bbox = {}; } else diff --git a/src/orange/OrangeParams.cc b/src/orange/OrangeParams.cc index 734ee70cc2..cc1449c16c 100644 --- a/src/orange/OrangeParams.cc +++ b/src/orange/OrangeParams.cc @@ -24,7 +24,6 @@ #include "geocel/BoundingBox.hh" #include "geocel/GeantGeoParams.hh" #include "geocel/VolumeParams.hh" -#include "orange/detail/LogicUtils.hh" #include "OrangeData.hh" // IWYU pragma: associated #include "OrangeInput.hh" @@ -33,6 +32,7 @@ #include "g4org/Converter.hh" #include "univ/detail/LogicStack.hh" +#include "detail/ConvertLogic.hh" #include "detail/DepthCalculator.hh" #include "detail/RectArrayInserter.hh" #include "detail/UnitInserter.hh" @@ -180,6 +180,10 @@ OrangeParams::OrangeParams(OrangeInput&& input, SPConstVolumes&& volumes) << (celeritas::device() ? " and copying to GPU" : ""); ScopedTimeLog scoped_time; + // First, preprocess the input logic expressions to match the tracker + detail::convert_logic(input, orange_tracking_logic); + CELER_ASSERT(input.logic == orange_tracking_logic); + // Save global bounding box bbox_ = [&input] { auto& global = input.universes[orange_global_univ.unchecked_get()]; @@ -191,14 +195,11 @@ OrangeParams::OrangeParams(OrangeInput&& input, SPConstVolumes&& volumes) // Create host data for construction, setting tolerances first HostVal host_data; host_data.scalars.tol = input.tol; - host_data.scalars.logic = input.logic; host_data.scalars.num_univ_levels = detail::DepthCalculator{input.universes}(); host_data.scalars.num_vol_levels = volumes_ ? volumes_->num_volume_levels() : 0; - detail::convert_logic(input, orange_tracking_logic()); - // Insert all universes { std::vector