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 147 of file CSGRegion.C.

148 {
149  return CSGRegion(region_a, region_b, "INTERSECTION");
150 }

◆ 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 147 of file CSGRegion.C.

148 {
149  return CSGRegion(region_a, region_b, "INTERSECTION");
150 }

◆ 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 133 of file CSGRegion.C.

134 {
135  return CSGRegion(surf, CSGSurface::Halfspace::POSITIVE);
136 }

◆ operator-()

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

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

Definition at line 140 of file CSGRegion.C.

141 {
142  return CSGRegion(surf, CSGSurface::Halfspace::NEGATIVE);
143 }

◆ 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 154 of file CSGRegion.C.

155 {
156  return CSGRegion(region_a, region_b, "UNION");
157 }

◆ operator~()

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

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

Definition at line 161 of file CSGRegion.C.

162 {
163  return CSGRegion(region, "COMPLEMENT");
164 }

◆ 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 94 of file CSGRegion.C.

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

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