https://mooseframework.inl.gov
Classes | Functions
CSG Namespace Reference

Classes

class  CSGBase
 CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model. More...
 
class  CSGCell
 CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell, which represents a region of space filled by a material or void. More...
 
class  CSGCellList
 CSGCellList creates a container for CSGCell objects to pass to CSGBase object. More...
 
class  CSGPlane
 CSGPlane creates an internal representation of a Constructive Solid Geometry (CSG) plane, represented in the form aX + bY + cZ = d. More...
 
class  CSGRegion
 CSGRegions creates an internal representation of a CSG region, which can refer to an intersection, union, complement, or half-space. More...
 
class  CSGSphere
 CSGSphere creates an internal representation of a Constructive Solid Geometry (CSG) sphere, represented in the form (x - x0)^2 + (y - y0)^2 + (z - z0)^2 = r^2. More...
 
class  CSGSurface
 CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface, represented as some polynomial in x, y, and z. More...
 
class  CSGSurfaceList
 CSGSurfaceList is a container for storing CSGSurface objects in the CSGBase object. More...
 
class  CSGUniverse
 CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe, which represents a collection of cells that can be defined repeatedly within a separate container of cells. More...
 
class  CSGUniverseList
 CSGUniverseList creates a container for CSGUniverse objects to pass to CSGBase. More...
 
class  CSGXCylinder
 CSGXCylinder creates an internal representation of a Constructive Solid Geometry (CSG) x-axis aligned cylinder, represented in the following form (y - y0)^2 + (z - z0)^2 = r^2. More...
 
class  CSGYCylinder
 CSGYCylinder creates an internal representation of a Constructive Solid Geometry (CSG) y-axis aligned cylinder, represented in the following form (x - x0)^2 + (z - z0)^2 = r^2. More...
 
class  CSGZCylinder
 CSGZCylinder creates an internal representation of a Constructive Solid Geometry (CSG) z-axis aligned cylinder, represented in the following form (x - x0)^2 + (y - y0)^2 = r^2. More...
 

Functions

const std::string stripRegionString (std::string region_str, std::string op)
 strip the leading and trailing parentheses from the string if only the specified operator is present in the string More...
 
const CSGRegion operator+ (const CSGSurface &surf)
 Operation overloads for operation based region construction. More...
 
const CSGRegion operator- (const CSGSurface &surf)
 Overload for creating a region from the negative half-space (-) of a surface. More...
 
const CSGRegion operator & (const CSGRegion &region_a, const CSGRegion &region_b)
 Overload for creating a region from the the intersection (&) of two regions. More...
 
const CSGRegion operator| (const CSGRegion &region_a, const CSGRegion &region_b)
 Overload for creating a region from the union (|) of two regions. More...
 
const CSGRegion operator~ (const CSGRegion &region)
 Overload for creating a region from the complement (~) of another region. More...
 
const CSGRegion operator & (const CSGRegion &region_a, const CSGRegion &region_b)
 Overload for creating a region from the the intersection (&) of two regions. More...
 

Function Documentation

◆ operator &() [1/2]

const CSGRegion CSG::operator& ( const CSGRegion region_a,
const CSGRegion region_b 
)

Overload for creating a region from the the intersection (&) of two regions.

Definition at line 144 of file CSGRegion.C.

145 {
146  return CSGRegion(region_a, region_b, "INTERSECTION");
147 }

◆ operator &() [2/2]

const CSGRegion CSG::operator& ( const CSGRegion region_a,
const CSGRegion region_b 
)

Overload for creating a region from the the intersection (&) of two regions.

Definition at line 144 of file CSGRegion.C.

145 {
146  return CSGRegion(region_a, region_b, "INTERSECTION");
147 }

◆ operator+()

const CSGRegion CSG::operator+ ( const CSGSurface surf)

Operation overloads for operation based region construction.

Overload for creating a region from the positive half-space (+) of a surface

Definition at line 130 of file CSGRegion.C.

131 {
132  return CSGRegion(surf, CSGSurface::Halfspace::POSITIVE);
133 }

◆ operator-()

const CSGRegion CSG::operator- ( const CSGSurface surf)

Overload for creating a region from the negative half-space (-) of a surface.

Definition at line 137 of file CSGRegion.C.

138 {
139  return CSGRegion(surf, CSGSurface::Halfspace::NEGATIVE);
140 }

◆ operator|()

const CSGRegion CSG::operator| ( const CSGRegion region_a,
const CSGRegion region_b 
)

Overload for creating a region from the union (|) of two regions.

Definition at line 151 of file CSGRegion.C.

152 {
153  return CSGRegion(region_a, region_b, "UNION");
154 }

◆ operator~()

const CSGRegion CSG::operator~ ( const CSGRegion region)

Overload for creating a region from the complement (~) of another region.

Definition at line 158 of file CSGRegion.C.

159 {
160  return CSGRegion(region, "COMPLEMENT");
161 }

◆ stripRegionString()

const std::string CSG::stripRegionString ( std::string  region_str,
std::string  op 
)

strip the leading and trailing parentheses from the string if only the specified operator is present in the string

Parameters
region_strregion string representation to simplify
opoperator to consider
Returns
region string with () removed if applicable

Definition at line 91 of file CSGRegion.C.

Referenced by CSG::CSGRegion::CSGRegion().

92 {
93  // add expected spacing around operator if not provided
94  if (op == "|")
95  op = " | ";
96  if (op == "&")
97  op = " & ";
98 
99  std::vector<std::string> ops_list = {" | ", " & ", "~"};
100  if (op.compare(" | ") && op.compare(" & "))
101  { // compare() returns non zero if strings are not equal
102  mooseError(
103  "Region string can only be simplified based on intersection (&) and union (|) operations.");
104  }
105 
106  // find if there are any operators in string already that are not the op of interest
107  // if not, then remove parentheses:
108  bool remove_par = true; // assume parentheses can be removed unless otherwise
109  for (auto opi : ops_list)
110  if (opi != op)
111  // only look for strings that are not of the current op type
112  if (region_str.find(opi) != std::string::npos)
113  {
114  remove_par = false;
115  break;
116  }
117 
118  if (remove_par)
119  region_str.erase(std::remove_if(region_str.begin(),
120  region_str.end(),
121  [](char c) { return c == '(' || c == ')'; }),
122  region_str.end());
123  return region_str;
124 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323