https://mooseframework.inl.gov
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CSG::CSGSurface Class Referenceabstract

CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface, represented as some polynomial in x, y, and z. More...

#include <CSGSurface.h>

Inheritance diagram for CSG::CSGSurface:
[legend]

Public Types

enum  Halfspace { Halfspace::POSITIVE, Halfspace::NEGATIVE }
 Enum for the sign of the half-space being represented by a point and surface. More...
 

Public Member Functions

 CSGSurface (const std::string &name)
 Default constructor. More...
 
 CSGSurface (const std::string &name, const std::string &surf_type)
 Construct a new CSGSurface. More...
 
virtual ~CSGSurface ()=default
 Destructor. More...
 
const std::string & getSurfaceType () const
 Get the Surface Type. More...
 
virtual std::unordered_map< std::string, RealgetCoeffs () const =0
 Get the coefficients that define the surface. More...
 
virtual Real evaluateSurfaceEquationAtPoint (const Point &p) const =0
 given a point, determine its evaluation based on the surface equation. More...
 
CSGSurface::Halfspace getHalfspaceFromPoint (const Point &p) const
 given a point, determine if it is in the positive or negative half-space for the surface More...
 
const std::string & getName () const
 Get the name of surface. More...
 
bool operator== (const CSGSurface &other) const
 Operator overload for checking if two CSGSurface objects are equal. More...
 
bool operator!= (const CSGSurface &other) const
 Operator overload for checking if two CSGSurface objects are not equal. More...
 

Protected Member Functions

void setName (const std::string &name)
 
 FRIEND_TEST (CSGSurfaceTest, testSetName)
 Friends for unit testing. More...
 

Protected Attributes

std::string _name
 Name of surface. More...
 
const std::string _surface_type
 Type of surface that is being represented string is taken directly from the surface class name. More...
 

Friends

class CSGSurfaceList
 

Detailed Description

CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface, represented as some polynomial in x, y, and z.

Definition at line 26 of file CSGSurface.h.

Member Enumeration Documentation

◆ Halfspace

Enum for the sign of the half-space being represented by a point and surface.

Enumerator
POSITIVE 
NEGATIVE 

Definition at line 30 of file CSGSurface.h.

31  {
32  POSITIVE,
33  NEGATIVE
34  };

Constructor & Destructor Documentation

◆ CSGSurface() [1/2]

CSG::CSGSurface::CSGSurface ( const std::string &  name)

Default constructor.

Parameters
nameunique name of surface

◆ CSGSurface() [2/2]

CSG::CSGSurface::CSGSurface ( const std::string &  name,
const std::string &  surf_type 
)

Construct a new CSGSurface.

Parameters
nameunique name of surface
surf_typesurface type

Definition at line 15 of file CSGSurface.C.

16  : _name(name), _surface_type(surf_type)
17 {
18 }
const std::string _surface_type
Type of surface that is being represented string is taken directly from the surface class name...
Definition: CSGSurface.h:113
std::string _name
Name of surface.
Definition: CSGSurface.h:109

◆ ~CSGSurface()

virtual CSG::CSGSurface::~CSGSurface ( )
virtualdefault

Destructor.

Member Function Documentation

◆ evaluateSurfaceEquationAtPoint()

virtual Real CSG::CSGSurface::evaluateSurfaceEquationAtPoint ( const Point &  p) const
pure virtual

given a point, determine its evaluation based on the surface equation.

A positive value indicates a point that lies in the positive half-space with regards to the surface, a negative value indicates a point that lies in the negative side of the surface, and a value of 0 indicates that the point lies on the surface.

Parameters
ppoint
Returns
evaluation of point based on surface equation

Implemented in CSG::CSGPlane, CSG::CSGSphere, CSG::CSGXCylinder, CSG::CSGYCylinder, and CSG::CSGZCylinder.

Referenced by getHalfspaceFromPoint().

◆ FRIEND_TEST()

CSG::CSGSurface::FRIEND_TEST ( CSGSurfaceTest  ,
testSetName   
)
protected

Friends for unit testing.

◆ getCoeffs()

virtual std::unordered_map<std::string, Real> CSG::CSGSurface::getCoeffs ( ) const
pure virtual

Get the coefficients that define the surface.

Returns
map of coefficients and their values

Implemented in CSG::CSGPlane, CSG::CSGSphere, CSG::CSGXCylinder, CSG::CSGYCylinder, and CSG::CSGZCylinder.

Referenced by operator==().

◆ getHalfspaceFromPoint()

CSGSurface::Halfspace CSG::CSGSurface::getHalfspaceFromPoint ( const Point &  p) const

given a point, determine if it is in the positive or negative half-space for the surface

Parameters
ppoint
Returns
sign of the half-space

Definition at line 21 of file CSGSurface.C.

22 {
23  auto eval = evaluateSurfaceEquationAtPoint(p);
25  return Halfspace::POSITIVE;
26  else if (MooseUtils::absoluteFuzzyLessThan(eval, 0))
27  return Halfspace::NEGATIVE;
28  else
29  mooseError("Point ",
30  p,
31  " used to determine halfspace evaluation lies on the surface ",
32  _name,
33  ", leading to an ambiguously defined halfspace.");
34 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
virtual Real evaluateSurfaceEquationAtPoint(const Point &p) const =0
given a point, determine its evaluation based on the surface equation.
bool absoluteFuzzyLessThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than another variable within an absolute tolerance...
Definition: MooseUtils.h:477
std::string _name
Name of surface.
Definition: CSGSurface.h:109
bool absoluteFuzzyGreaterThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than another variable within an absolute tolerance...
Definition: MooseUtils.h:430

◆ getName()

const std::string& CSG::CSGSurface::getName ( ) const
inline

Get the name of surface.

Returns
std::string name of surface

Definition at line 95 of file CSGSurface.h.

Referenced by CSG::CSGSurfaceList::addSurface(), CSG::CSGRegion::CSGRegion(), operator==(), and CSG::CSGSurfaceList::renameSurface().

95 { return _name; }
std::string _name
Name of surface.
Definition: CSGSurface.h:109

◆ getSurfaceType()

const std::string& CSG::CSGSurface::getSurfaceType ( ) const
inline

Get the Surface Type.

Returns
type of surface

Definition at line 61 of file CSGSurface.h.

Referenced by operator==().

61 { return _surface_type; }
const std::string _surface_type
Type of surface that is being represented string is taken directly from the surface class name...
Definition: CSGSurface.h:113

◆ operator!=()

bool CSG::CSGSurface::operator!= ( const CSGSurface other) const

Operator overload for checking if two CSGSurface objects are not equal.

Definition at line 45 of file CSGSurface.C.

46 {
47  return !(*this == other);
48 }

◆ operator==()

bool CSG::CSGSurface::operator== ( const CSGSurface other) const

Operator overload for checking if two CSGSurface objects are equal.

Definition at line 37 of file CSGSurface.C.

38 {
39  return (this->getName() == other.getName()) &&
40  (this->getSurfaceType() == other.getSurfaceType()) &&
41  (this->getCoeffs() == other.getCoeffs());
42 }
const std::string & getName() const
Get the name of surface.
Definition: CSGSurface.h:95
virtual std::unordered_map< std::string, Real > getCoeffs() const =0
Get the coefficients that define the surface.
const std::string & getSurfaceType() const
Get the Surface Type.
Definition: CSGSurface.h:61

◆ setName()

void CSG::CSGSurface::setName ( const std::string &  name)
inlineprotected

Definition at line 106 of file CSGSurface.h.

106 { _name = name; }
std::string name(const ElemQuality q)
std::string _name
Name of surface.
Definition: CSGSurface.h:109

Friends And Related Function Documentation

◆ CSGSurfaceList

friend class CSGSurfaceList
friend

Definition at line 116 of file CSGSurface.h.

Member Data Documentation

◆ _name

std::string CSG::CSGSurface::_name
protected

Name of surface.

Definition at line 109 of file CSGSurface.h.

Referenced by getHalfspaceFromPoint(), getName(), and setName().

◆ _surface_type

const std::string CSG::CSGSurface::_surface_type
protected

Type of surface that is being represented string is taken directly from the surface class name.

Definition at line 113 of file CSGSurface.h.

Referenced by getSurfaceType().


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