Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/orange/orangeinp/CsgTreeUtils.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file orange/orangeinp/CsgTreeUtils.hh
0006 //! \brief Free functions to apply to a CSG tree
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <vector>
0011 
0012 #include "orange/OrangeTypes.hh"
0013 
0014 #include "CsgTree.hh"
0015 #include "CsgTypes.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace orangeinp
0020 {
0021 
0022 //---------------------------------------------------------------------------//
0023 /*!
0024  * Result of a DeMorgan simplification.
0025  */
0026 struct SimplifiedCsgTree
0027 {
0028     //! The simplified tree
0029     CsgTree tree;
0030     //! Has the same size as the original tree, indexed by old node id, with
0031     //! the value pointing to the equivalent node in the simplified tree
0032     std::vector<NodeId> new_nodes;
0033 };
0034 
0035 //---------------------------------------------------------------------------//
0036 
0037 // Replace a node in the tree with a boolean constant
0038 std::vector<NodeId> replace_and_simplify(CsgTree* tree,
0039                                          orangeinp::NodeId n,
0040                                          orangeinp::Node replacement);
0041 
0042 // Simplify the tree by sweeping
0043 orangeinp::NodeId simplify_up(CsgTree* tree, orangeinp::NodeId start);
0044 
0045 // Simplify the tree iteratively
0046 void simplify(CsgTree* tree, orangeinp::NodeId start);
0047 
0048 // Replace ~&(xs...) with |(~xs...) and ~|(xs...) with &(~xs...)
0049 [[nodiscard]] SimplifiedCsgTree transform_negated_joins(CsgTree const& tree);
0050 
0051 // Transform a CSG node into a string expression
0052 [[nodiscard]] std::string
0053 build_infix_string(CsgTree const& tree, orangeinp::NodeId n);
0054 
0055 // Get the set of unsimplified surfaces in a tree
0056 [[nodiscard]] std::vector<LocalSurfaceId> calc_surfaces(CsgTree const& tree);
0057 
0058 //---------------------------------------------------------------------------//
0059 }  // namespace orangeinp
0060 }  // namespace celeritas