Celeritas 0.7.0-dev.149+develop.91f427834
Loading...
Searching...
No Matches
Typedefs | Functions
CsgTreeUtils.hh File Reference

Free functions to apply to a CSG tree. More...

#include <vector>
#include "orange/OrangeTypes.hh"
#include "CsgTree.hh"
#include "CsgTypes.hh"
This graph shows which files directly or indirectly include this file:

Typedefs

using celeritas::orangeinp::TransformedTree = std::pair< CsgTree, std::vector< NodeId > >
 Transformed CSG tree and mapping from the old one.
 

Functions

std::vector< NodeIdceleritas::orangeinp::replace_and_simplify (CsgTree *tree, NodeId repl_key, Node repl_value)
 Replace the given node ID with the replacement node.
 
NodeId celeritas::orangeinp::simplify_up (CsgTree *tree, NodeId start)
 Simplify all nodes in the tree starting with this one.
 
void celeritas::orangeinp::simplify (CsgTree *tree, NodeId start)
 Iteratively simplify all nodes in the tree.
 
TransformedTree celeritas::orangeinp::transform_negated_joins (CsgTree const &tree)
 Simplify negated joins using De Morgan's law.
 
std::string celeritas::orangeinp::build_infix_string (CsgTree const &tree, NodeId n)
 Convert a node to an infix string expression.
 
std::vector< LocalSurfaceIdceleritas::orangeinp::calc_surfaces (CsgTree const &tree)
 Construct the sorted set of all surfaces that are part of the tree.
 

Detailed Description

Free functions to apply to a CSG tree.

Typedef Documentation

◆ TransformedTree

using celeritas::orangeinp::TransformedTree = typedef std::pair<CsgTree, std::vector<NodeId> >

Transformed CSG tree and mapping from the old one.

The new_nodes member has the same size as the original tree, and is a map from {old node ID} -> {equivalent simplified node ID}.

Function Documentation

◆ calc_surfaces()

std::vector< LocalSurfaceId > celeritas::orangeinp::calc_surfaces ( CsgTree const tree)

Construct the sorted set of all surfaces that are part of the tree.

This list removes surfaces that have been eliminated by logical replacement. Thanks to the CSG tree's deduplication, each surface should appear in the tree at most once.

◆ replace_and_simplify()

std::vector< NodeId > celeritas::orangeinp::replace_and_simplify ( CsgTree tree,
NodeId  repl_key,
Node  repl_value 
)

Replace the given node ID with the replacement node.

This recurses through daughters of "Joined" to simplify their originating surfaces if possible.

  • "negated": non-constant daughter node is replaced with ~b
  • "replaced": non-constant daughter node is replaced with b
  • "joined": for (false, or): all daughters are "false" for (true, and): all daughters are "true"
  • surface: "true"
  • constant: check for contradiction

This operation is at worst O((number of nodes) * (depth of graph)).

◆ simplify()

void celeritas::orangeinp::simplify ( CsgTree tree,
NodeId  start 
)

Iteratively simplify all nodes in the tree.

The input 'start' node should be the minimum node from a replace_down operation. In the worst case, it should take as many sweeps as the depth of the tree.

◆ simplify_up()

orangeinp::NodeId celeritas::orangeinp::simplify_up ( CsgTree tree,
NodeId  start 
)

Simplify all nodes in the tree starting with this one.

Returns
Lowest ID of any simplified node

◆ transform_negated_joins()

TransformedTree celeritas::orangeinp::transform_negated_joins ( CsgTree const tree)

Simplify negated joins using De Morgan's law.

This is required if the tree's logic expression is used with InfixEvaluator as negated joins are not supported.