Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:35:33

0001 #ifndef VECGEOM_SURFACE_LOGICHELPER_H_
0002 #define VECGEOM_SURFACE_LOGICHELPER_H_
0003 
0004 #include <VecGeom/surfaces/Model.h>
0005 #include <VecGeom/volumes/BooleanVolume.h>
0006 #include <VecGeom/management/Logger.h>
0007 
0008 namespace vgbrep {
0009 
0010 using LogicExpressionCPU = std::vector<logic_int>;
0011 
0012 namespace logichelper {
0013 
0014 bool string_to_logic(std::string s, LogicExpressionCPU &logic);
0015 char logic_to_char(logic_int item);
0016 void print_item(logic_int item);
0017 void print_logic(LogicExpressionCPU const &logic, int istart = 0, int iend = -1, bool jumps = true);
0018 void print_logic(LogicExpression const &logic, int istart = 0, int iend = -1, bool jumps = true);
0019 void remove_range(LogicExpressionCPU &logic, size_t istart, size_t iend);
0020 void remove_parentheses(LogicExpressionCPU &logic, size_t start, size_t end);
0021 void insert_jumps(LogicExpressionCPU &logic);
0022 bool is_negated(int isurf, LogicExpressionCPU &logic);
0023 size_t find_matching_parenthesis(LogicExpressionCPU &logic, size_t start);
0024 
0025 /// @brief Logic expression decomposed in a vector of operands (also logic expressions) connected by and/or operators
0026 struct LogicExpressionConstruct {
0027   bool fNegated{false};                            /// is negated logic
0028   bool fHasScope{false};                           /// has a scope
0029   int fComplexity{0};                              /// expression complexity
0030   LogicExpressionCPU fLogic;                       /// Logic expression
0031   LogicExpressionCPU fOperators;                   /// Vector of operators
0032   std::vector<LogicExpressionConstruct> fOperands; /// Vector of operands
0033 
0034   LogicExpressionConstruct(LogicExpressionCPU const &logic);
0035   LogicExpressionConstruct &operator&=(LogicExpressionConstruct const &other);
0036   LogicExpressionConstruct &operator|=(LogicExpressionConstruct const &other);
0037 
0038   void Concatenate(LogicExpressionConstruct const &other, logic_int op_concat);
0039   void PushNegation(bool neg = false);
0040   bool RemoveScope(logic_int logic_op);
0041   void RemoveChildrenScopes(bool top = false);
0042   void Print() const;
0043   void GivePrecedenceToAnd();
0044   void SwapByComplexity();
0045   void GetLogicExpression(LogicExpressionCPU &logic) const;
0046   int GetNumOperands() const;
0047   void Simplify(LogicExpressionCPU &logic);
0048 };
0049 
0050 int max_operand(LogicExpressionCPU const &logic);
0051 void substitute_logic(LogicExpressionCPU const &logic, LogicExpressionCPU &substutute_logic, const bool *values);
0052 bool evaluate_logic(LogicExpressionCPU const &logic, const bool *values, int &num_eval);
0053 
0054 } // namespace logichelper
0055 } // namespace vgbrep
0056 #endif