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

CSGPlane creates an internal representation of a Constructive Solid Geometry (CSG) plane, represented in the form aX + bY + cZ = d. More...

#include <CSGPlane.h>

Inheritance diagram for CSG::CSGPlane:
[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

 CSGPlane (const std::string &name, const Point &p1, const Point &p2, const Point &p3)
 Construct a new CSGPlane surface from three non co-linear points. More...
 
 CSGPlane (const std::string &name, const Real a, const Real b, const Real c, const Real d)
 Construct a new CSGPlane surface from coefficients (a, b, c, d) for the equation of a plane: aX + bY + cZ = d. More...
 
virtual ~CSGPlane ()=default
 Destructor. More...
 
virtual std::unordered_map< std::string, RealgetCoeffs () const override
 get coefficients (a, b, c, d) of the Plane aX + bY + cZ = d More...
 
virtual Real evaluateSurfaceEquationAtPoint (const Point &p) const override
 given a point, determine its evaluation based on the equation of the plane More...
 
const std::string & getSurfaceType () const
 Get the Surface Type. 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 coeffsFromPoints (const Point &p1, const Point &p2, const Point &p3)
 
void setName (const std::string &name)
 
 FRIEND_TEST (CSGSurfaceTest, testSetName)
 Friends for unit testing. More...
 

Protected Attributes

Real _a
 Value of a in equation of plane. More...
 
Real _b
 Value of b in equation of plane. More...
 
Real _c
 Value of c in equation of plane. More...
 
Real _d
 Value of d in equation of plane. More...
 
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...
 

Detailed Description

CSGPlane creates an internal representation of a Constructive Solid Geometry (CSG) plane, represented in the form aX + bY + cZ = d.

Definition at line 23 of file CSGPlane.h.

Member Enumeration Documentation

◆ Halfspace

enum CSG::CSGSurface::Halfspace
stronginherited

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

◆ CSGPlane() [1/2]

CSG::CSGPlane::CSGPlane ( const std::string &  name,
const Point &  p1,
const Point &  p2,
const Point &  p3 
)

Construct a new CSGPlane surface from three non co-linear points.

Parameters
nameunique name of plane
p1point 1
p2point 2
p3point 3

Definition at line 15 of file CSGPlane.C.

16  : CSGSurface(name, MooseUtils::prettyCppType<CSGPlane>())
17 {
18  coeffsFromPoints(p1, p2, p3);
19 }
CSGSurface(const std::string &name)
Default constructor.
void coeffsFromPoints(const Point &p1, const Point &p2, const Point &p3)
Definition: CSGPlane.C:34

◆ CSGPlane() [2/2]

CSG::CSGPlane::CSGPlane ( const std::string &  name,
const Real  a,
const Real  b,
const Real  c,
const Real  d 
)

Construct a new CSGPlane surface from coefficients (a, b, c, d) for the equation of a plane: aX + bY + cZ = d.

Parameters
nameunique name of plane
acoefficient a
bcoefficient b
ccoefficient c
dcoefficient d

Definition at line 21 of file CSGPlane.C.

22  : CSGSurface(name, MooseUtils::prettyCppType<CSGPlane>()), _a(a), _b(b), _c(c), _d(d)
23 {
24 }
Real _a
Value of a in equation of plane.
Definition: CSGPlane.h:74
Real _b
Value of b in equation of plane.
Definition: CSGPlane.h:77
Real _d
Value of d in equation of plane.
Definition: CSGPlane.h:83
CSGSurface(const std::string &name)
Default constructor.
Real _c
Value of c in equation of plane.
Definition: CSGPlane.h:80

◆ ~CSGPlane()

virtual CSG::CSGPlane::~CSGPlane ( )
virtualdefault

Destructor.

Member Function Documentation

◆ coeffsFromPoints()

void CSG::CSGPlane::coeffsFromPoints ( const Point &  p1,
const Point &  p2,
const Point &  p3 
)
protected

Definition at line 34 of file CSGPlane.C.

Referenced by CSGPlane().

35 {
36  // Use three points on plane to solve for the plane equation in form aX + bY +cZ = d,
37  // where we are solving for a, b, c, and d.
38  RealVectorValue v1 = p2 - p1;
39  RealVectorValue v2 = p3 - p1;
40  RealVectorValue cross = v2.cross(v1);
41 
42  // Check that provided points aren't collinear
43  if (MooseUtils::absoluteFuzzyEqual(cross.norm(), 0))
44  mooseError("Provided points to define a CSGPlane are collinear");
45 
46  _a = cross(0);
47  _b = cross(1);
48  _c = cross(2);
49  _d = cross * (RealVectorValue)p1;
50 }
auto norm() const -> decltype(std::norm(Real()))
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
Definition: MooseUtils.h:382
Real _a
Value of a in equation of plane.
Definition: CSGPlane.h:74
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
Real _b
Value of b in equation of plane.
Definition: CSGPlane.h:77
Real _d
Value of d in equation of plane.
Definition: CSGPlane.h:83
Real _c
Value of c in equation of plane.
Definition: CSGPlane.h:80

◆ evaluateSurfaceEquationAtPoint()

Real CSG::CSGPlane::evaluateSurfaceEquationAtPoint ( const Point &  p) const
overridevirtual

given a point, determine its evaluation based on the equation of the plane

Parameters
ppoint
Returns
evaluation of point based on surface equation

Implements CSG::CSGSurface.

Definition at line 53 of file CSGPlane.C.

54 {
55  // Compute dot product of <a, b, c> and p to determine if p lies
56  // in the positive or negative halfspace of the plane
57  const Real dot_prod = _a * p(0) + _b * p(1) + _c * p(2);
58 
59  return dot_prod - _d;
60 }
Real _a
Value of a in equation of plane.
Definition: CSGPlane.h:74
Real _b
Value of b in equation of plane.
Definition: CSGPlane.h:77
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real _d
Value of d in equation of plane.
Definition: CSGPlane.h:83
Real _c
Value of c in equation of plane.
Definition: CSGPlane.h:80

◆ FRIEND_TEST()

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

Friends for unit testing.

◆ getCoeffs()

std::unordered_map< std::string, Real > CSG::CSGPlane::getCoeffs ( ) const
overridevirtual

get coefficients (a, b, c, d) of the Plane aX + bY + cZ = d

Returns
std::unordered_map<std::string, Real> map of coefficients (a, b, c, and d) and their values

Implements CSG::CSGSurface.

Definition at line 27 of file CSGPlane.C.

28 {
29  std::unordered_map<std::string, Real> coeffs = {{"a", _a}, {"b", _b}, {"c", _c}, {"d", _d}};
30  return coeffs;
31 }
Real _a
Value of a in equation of plane.
Definition: CSGPlane.h:74
Real _b
Value of b in equation of plane.
Definition: CSGPlane.h:77
Real _d
Value of d in equation of plane.
Definition: CSGPlane.h:83
Real _c
Value of c in equation of plane.
Definition: CSGPlane.h:80

◆ getHalfspaceFromPoint()

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

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
inlineinherited

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(), CSG::CSGSurface::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
inlineinherited

Get the Surface Type.

Returns
type of surface

Definition at line 61 of file CSGSurface.h.

Referenced by CSG::CSGSurface::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
inherited

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
inherited

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)
inlineprotectedinherited

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

Member Data Documentation

◆ _a

Real CSG::CSGPlane::_a
protected

Value of a in equation of plane.

Definition at line 74 of file CSGPlane.h.

Referenced by coeffsFromPoints(), evaluateSurfaceEquationAtPoint(), and getCoeffs().

◆ _b

Real CSG::CSGPlane::_b
protected

Value of b in equation of plane.

Definition at line 77 of file CSGPlane.h.

Referenced by coeffsFromPoints(), evaluateSurfaceEquationAtPoint(), and getCoeffs().

◆ _c

Real CSG::CSGPlane::_c
protected

Value of c in equation of plane.

Definition at line 80 of file CSGPlane.h.

Referenced by coeffsFromPoints(), evaluateSurfaceEquationAtPoint(), and getCoeffs().

◆ _d

Real CSG::CSGPlane::_d
protected

Value of d in equation of plane.

Definition at line 83 of file CSGPlane.h.

Referenced by coeffsFromPoints(), evaluateSurfaceEquationAtPoint(), and getCoeffs().

◆ _name

std::string CSG::CSGSurface::_name
protectedinherited

Name of surface.

Definition at line 109 of file CSGSurface.h.

Referenced by CSG::CSGSurface::getHalfspaceFromPoint(), CSG::CSGSurface::getName(), and CSG::CSGSurface::setName().

◆ _surface_type

const std::string CSG::CSGSurface::_surface_type
protectedinherited

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 CSG::CSGSurface::getSurfaceType().


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