Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #pragma once 11 : 12 : #include "CSGSurface.h" 13 : 14 : #include "libmesh/point.h" 15 : 16 : namespace CSG 17 : { 18 : 19 : /** 20 : * CSGPlane creates an internal representation of a Constructive Solid Geometry (CSG) 21 : * plane, represented in the form aX + bY + cZ = d 22 : */ 23 : class CSGPlane : public CSGSurface 24 : { 25 : public: 26 : /** 27 : * @brief Construct a new CSGPlane surface from three non co-linear points 28 : * 29 : * @param name unique name of plane 30 : * @param p1 point 1 31 : * @param p2 point 2 32 : * @param p3 point 3 33 : */ 34 : CSGPlane(const std::string & name, const Point & p1, const Point & p2, const Point & p3); 35 : 36 : /** 37 : * @brief Construct a new CSGPlane surface from coefficients (a, b, c, d) for the 38 : * equation of a plane: aX + bY + cZ = d 39 : * 40 : * @param name unique name of plane 41 : * @param a coefficient a 42 : * @param b coefficient b 43 : * @param c coefficient c 44 : * @param d coefficient d 45 : */ 46 : CSGPlane(const std::string & name, const Real a, const Real b, const Real c, const Real d); 47 : 48 : /** 49 : * Destructor 50 : */ 51 270 : virtual ~CSGPlane() = default; 52 : 53 : /** 54 : * @brief get coefficients (a, b, c, d) of the Plane aX + bY + cZ = d 55 : * 56 : * @return std::unordered_map<std::string, Real> map of coefficients (a, b, c, and d) and their 57 : * values 58 : */ 59 : virtual std::unordered_map<std::string, Real> getCoeffs() const override; 60 : 61 : /** 62 : * @brief given a point, determine its evaluation based on the equation of the plane 63 : * 64 : * @param p point 65 : * @return evaluation of point based on surface equation 66 : */ 67 : virtual Real evaluateSurfaceEquationAtPoint(const Point & p) const override; 68 : 69 : protected: 70 : /** 71 : * @brief create clone of CSGPlane object 72 : * 73 : * @return std::unordered_map<CSGSurface> unique_ptr to cloned plane 74 : */ 75 0 : virtual std::unique_ptr<CSGSurface> clone() const override 76 : { 77 0 : return std::make_unique<CSGPlane>(_name, _a, _b, _c, _d); 78 : } 79 : 80 : // calculate the equivalent coeffients (aX + bY + cZ = d) from 3 points on a plane 81 : void coeffsFromPoints(const Point & p1, const Point & p2, const Point & p3); 82 : 83 : /// Normalize plane coefficients so that a^2 + b^2 + c^2 = 1 84 : void normalizePlaneCoefficients(); 85 : 86 : /// Value of a in equation of plane 87 : Real _a; 88 : 89 : /// Value of b in equation of plane 90 : Real _b; 91 : 92 : /// Value of c in equation of plane 93 : Real _c; 94 : 95 : /// Value of d in equation of plane 96 : Real _d; 97 : }; 98 : } // namespace CSG