Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 3 : 4 : // This library is free software; you can redistribute it and/or 5 : // modify it under the terms of the GNU Lesser General Public 6 : // License as published by the Free Software Foundation; either 7 : // version 2.1 of the License, or (at your option) any later version. 8 : 9 : // This library is distributed in the hope that it will be useful, 10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 : // Lesser General Public License for more details. 13 : 14 : // You should have received a copy of the GNU Lesser General Public 15 : // License along with this library; if not, write to the Free Software 16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 : 18 : 19 : 20 : #ifndef LIBMESH_PLANE_H 21 : #define LIBMESH_PLANE_H 22 : 23 : // Local includes 24 : #include "libmesh/surface.h" 25 : 26 : namespace libMesh 27 : { 28 : 29 : /** 30 : * This class defines a plane. 31 : * 32 : * \author Benjamin S. Kirk 33 : * \date 2002 34 : * \brief A geometric object representing a planar surface. 35 : */ 36 0 : class Plane : public Surface 37 : { 38 : public: 39 : 40 : /** 41 : * Dummy Constructor. 42 : */ 43 : Plane (); 44 : 45 : /** 46 : * Constructs a plane containing point p with normal n. 47 : */ 48 : Plane (const Point & p, const Point & n); 49 : 50 : /** 51 : * Constructs a plane containing the three points. The 52 : * normal is determined in a counter-clockwise sense. See 53 : * the create_from_three_points method for more details. 54 : */ 55 : Plane (const Point & p0, const Point & p1, const Point & p2); 56 : 57 : /** 58 : * Copy-constructor. 59 : */ 60 : Plane (const Plane & other_plane); 61 : 62 : /** 63 : * Destructor. Does nothing at the moment. 64 : */ 65 : ~Plane (); 66 : 67 : /** 68 : * Defines a plane containing point p with normal n. 69 : */ 70 : void create_from_point_normal (const Point & p, const Point & n); 71 : 72 : /** 73 : * Defines a plane intersecting the three points 74 : * p0, p1, and p2. The normal is constructed in a 75 : * counter-clockwise sense, i.e. (p1-p0)x(p2-p0); 76 : */ 77 : void create_from_three_points (const Point & p0, 78 : const Point & p1, 79 : const Point & p2 ); 80 : 81 : /** 82 : * Creates an XY plane located at z=zpos. 83 : */ 84 : void xy_plane (const Real zpos=0.); 85 : 86 : /** 87 : * Creates an XZ plane located at y=ypos. 88 : */ 89 : void xz_plane (const Real ypos=0.); 90 : 91 : /** 92 : * Creates an YZ plane located at x=xpos. 93 : */ 94 : void yz_plane (const Real xpos=0.); 95 : 96 : /** 97 : * \returns \p true if the point p is above the surface, 98 : * false otherwise. 99 : */ 100 : virtual bool above_surface (const Point & p) const override; 101 : 102 : /** 103 : * \returns \p true if the point p is below the surface, 104 : * false otherwise. 105 : */ 106 : virtual bool below_surface (const Point & p) const override; 107 : 108 : /** 109 : * \returns \p true if the point p is on the surface, 110 : * false otherwise. 111 : * 112 : * \note The definition of "on the surface" really means "very close" 113 : * to account for roundoff error. 114 : */ 115 : virtual bool on_surface (const Point & p) const override; 116 : 117 : /** 118 : * \returns The closest point on the surface to point p. 119 : */ 120 : virtual Point closest_point (const Point & p) const override; 121 : 122 : /** 123 : * \returns A unit vector normal to the surface at 124 : * point p. 125 : */ 126 : virtual Point unit_normal (const Point & p) const override; 127 : 128 : /** 129 : * \returns A point on the plane useful 130 : * for determining position. 131 : */ 132 : const Point & get_planar_point() const; 133 : 134 : 135 : private: 136 : /** 137 : * \returns The normal for the plane. 138 : */ 139 0 : const Point & normal () const { return _normal; } 140 : 141 : /** 142 : * The plane is defined by a point and a normal. 143 : */ 144 : Point _point; 145 : Point _normal; 146 : }; 147 : 148 : } // namespace libMesh 149 : 150 : #endif // LIBMESH_PLANE_H