Celeritas  0.5.0-56+6b053cd
Public Member Functions | Static Public Member Functions | List of all members
celeritas::orangeinp::CsgTree Class Reference

DAG of constructed CSG nodes within a universe. More...

#include <CsgTree.hh>

Public Types

Type aliases
using Node = orangeinp::Node
 
using NodeId = orangeinp::NodeId
 
using size_type = NodeId::size_type
 
using Insertion = std::pair< NodeId, bool >
 
using Simplification = std::optional< Node >
 
using VecNodeId = std::vector< NodeId >
 

Public Member Functions

 CsgTree ()
 Insert true and 'negated true', and define equivalence operations.
 
Insertion insert (Node &&n)
 Add a node of type T and return the new ID. More...
 
Insertion insert (LocalSurfaceId s)
 Add a surface.
 
NodeId::size_type size () const
 Number of nodes.
 
Node const & operator[] (NodeId node_id) const
 Get a node by ID.
 
Node exchange (NodeId node_id, Node &&n)
 Replace a node with a simplified version or constant. More...
 
Simplification simplify (NodeId)
 Perform a simplification of a node in-place. More...
 
void insert_volume (NodeId)
 Insert a new volume which root is the node id.
 
VecNodeId const & volumes () const
 List of volumes defined in this tree.
 

Static Public Member Functions

static constexpr NodeId true_node_id ()
 Special ID of a node that's always 'true'.
 
static constexpr NodeId false_node_id ()
 Special ID of a node that's always 'false'.
 

Detailed Description

DAG of constructed CSG nodes within a universe.

Inserting a new node performs one local simplification for "join" types (removing duplicates, replacing zero- and one- entry special cases); and all nodes are inserted into a deduplicated map of nodes that may be further simplified later (see CsgAlgorithms).

The tree is a topologically sorted graph where the leaves are the lower node indices. The intent is for higher nodes to be simplified to boolean values, e.g., by representing that all points in space are inside a cylinder by replacing a Joined node with True . To facilitate this while preserving node indices, True and False nodes are automatically inserted as the first two node IDs. Because False is represented as "not true" during evaluation, it actually stores Negated{true_node_id()} and the deduplication table maps False to false_node_id() .

Note
The node classes use aggregate initialization so cannot be created directly as Node variant classes using std::in_place_type .

Member Function Documentation

◆ exchange()

auto celeritas::orangeinp::CsgTree::exchange ( NodeId  node_id,
Node &&  n 
)

Replace a node with a simplified version or constant.

Simplify the node first

◆ insert()

auto celeritas::orangeinp::CsgTree::insert ( Node &&  n)

Add a node of type T and return the new ID.

This performs a single level of simplification.

◆ simplify()

auto celeritas::orangeinp::CsgTree::simplify ( NodeId  node_id)

Perform a simplification of a node in-place.

Returns
Simplified node

The documentation for this class was generated from the following files: