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 : // calculate the equivalent coeffients (aX + bY + cZ = d) from 3 points on a plane 71 : void coeffsFromPoints(const Point & p1, const Point & p2, const Point & p3); 72 : 73 : /// Value of a in equation of plane 74 : Real _a; 75 : 76 : /// Value of b in equation of plane 77 : Real _b; 78 : 79 : /// Value of c in equation of plane 80 : Real _c; 81 : 82 : /// Value of d in equation of plane 83 : Real _d; 84 : }; 85 : } // namespace CSG