|
|
|
plane.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 plane 00027 00028 Description 00029 Geometric class that creates a 2D plane and can return the intersection 00030 point between a line and the plane. 00031 00032 SourceFiles 00033 plane.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef plane_H 00038 #define plane_H 00039 00040 #include "point.H" 00041 #include "scalarList.H" 00042 #include "dictionary.H" 00043 #include "line.H" 00044 00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00046 00047 namespace Foam 00048 { 00049 00050 /*---------------------------------------------------------------------------*\ 00051 Class plane Declaration 00052 \*---------------------------------------------------------------------------*/ 00053 00054 class plane 00055 { 00056 public: 00057 00058 class ray 00059 { 00060 point refPoint_; 00061 00062 vector dir_; 00063 00064 public: 00065 00066 ray(const point& refPoint, const vector& dir) 00067 : 00068 refPoint_(refPoint), 00069 dir_(dir) 00070 {} 00071 00072 const point& refPoint() const 00073 { 00074 return refPoint_; 00075 } 00076 00077 const vector& dir() const 00078 { 00079 return dir_; 00080 } 00081 }; 00082 00083 00084 private: 00085 00086 // Private data 00087 00088 //- Plane normal 00089 vector unitVector_; 00090 00091 //- Base point 00092 point basePoint_; 00093 00094 00095 // Private Member Functions 00096 00097 //- Calculates basePoint and normal vector given plane coefficients 00098 void calcPntAndVec(const scalarList& C); 00099 00100 //- Calculates basePoint and normal vector given three points 00101 //- Normal vector determined using right hand rule 00102 void calcPntAndVec 00103 ( 00104 const point& point1, 00105 const point& point2, 00106 const point& point3 00107 ); 00108 00109 00110 public: 00111 00112 // Constructors 00113 00114 //- Construct from normal vector through the origin 00115 plane(const vector& normalVector); 00116 00117 //- Construct from normal vector and point in plane 00118 plane(const point& basePoint, const vector& normalVector); 00119 00120 //- Construct from three points in plane 00121 plane(const point& point1, const point& point2, const point& point3); 00122 00123 //- Construct from coefficients for the 00124 // plane equation: ax + by + cz + d = 0 00125 plane(const scalarList& C); 00126 00127 //- Construct from dictionary 00128 plane(const dictionary& planeDict); 00129 00130 //- Construct from Istream. Assumes the base + normal notation. 00131 plane(Istream& is); 00132 00133 00134 // Member Functions 00135 00136 //- Return plane normal 00137 const vector& normal() const; 00138 00139 //- Return or return plane base point 00140 const point& refPoint() const; 00141 00142 //- Return coefficients for the 00143 // plane equation: ax + by + cz + d = 0 00144 scalarList planeCoeffs() const; 00145 00146 //- Return nearest point in the plane for the given point 00147 point nearestPoint(const point& p) const; 00148 00149 //- Return distance from the given point to the plane 00150 scalar distance(const point& p) const; 00151 00152 //- Return cut coefficient for plane and line defined by 00153 // origin and direction 00154 scalar normalIntersect(const point& pnt0, const vector& dir) const; 00155 00156 //- Return cut coefficient for plane and ray 00157 scalar normalIntersect(const ray& r) const 00158 { 00159 return normalIntersect(r.refPoint(), r.dir()); 00160 } 00161 00162 //- Return the cutting point between the plane and 00163 // a line passing through the supplied points 00164 template<class Point, class PointRef> 00165 scalar lineIntersect(const line<Point, PointRef>& l) const 00166 { 00167 return normalIntersect(l.start(), l.vec()); 00168 } 00169 00170 //- Return the cutting line between this plane and another. 00171 // Returned as direction vector and point line goes through. 00172 ray planeIntersect(const plane&) const; 00173 00174 //- Return the cutting point between this plane and two other planes 00175 point planePlaneIntersect(const plane&, const plane&) const; 00176 00177 00178 // friend Operators 00179 00180 friend bool operator==(const plane&, const plane&); 00181 friend bool operator!=(const plane&, const plane&); 00182 00183 00184 // IOstream Operators 00185 00186 //- Write plane properties 00187 friend Ostream& operator<<(Ostream&, const plane&); 00188 }; 00189 00190 00191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00192 00193 } // End namespace Foam 00194 00195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00196 00197 #endif 00198 00199 // ************************************************************************* // |