![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 triangleFuncs 00027 00028 Description 00029 Various triangle functions. 00030 00031 SourceFiles 00032 triangleFuncs.C 00033 00034 \*---------------------------------------------------------------------------*/ 00035 00036 #ifndef triangleFuncs_H 00037 #define triangleFuncs_H 00038 00039 #include "point.H" 00040 #include "label.H" 00041 #include "scalar.H" 00042 #include "pointField.H" 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 // Class forward declarations 00050 class treeBoundBox; 00051 00052 /*---------------------------------------------------------------------------*\ 00053 Class triangleFuncs Declaration 00054 \*---------------------------------------------------------------------------*/ 00055 00056 class triangleFuncs 00057 { 00058 00059 public: 00060 00061 // Public data types 00062 00063 //- Enumeration defining nearness classification 00064 enum proxType 00065 { 00066 NONE, 00067 POINT, 00068 EDGE 00069 }; 00070 00071 00072 private: 00073 00074 // Private data 00075 00076 //- Not VSMALL - but smaller than SMALL 00077 static const scalar NVSMALL; 00078 00079 // Private Member Functions 00080 00081 //- Helper function for intersect. Sets pt to be anywhere on the edge 00082 // between oppositeSidePt and thisSidePt depending on both signs. 00083 static void setIntersection 00084 ( 00085 const point& oppositeSidePt, 00086 const scalar oppositeSign, 00087 const point& thisSidePt, 00088 const scalar thisSign, 00089 const scalar tol, 00090 point& pt 00091 ); 00092 00093 //- Helper function. 00094 static void selectPt 00095 ( 00096 const bool select0, 00097 const point& p0, 00098 const point& p1, 00099 point& min 00100 ); 00101 00102 public: 00103 00104 //- Intersect triangle with parallel edges aligned with axis i0. 00105 // Returns true (and intersection in pInter) if any of them intersects 00106 // triangle. Used in intersectBb. 00107 static bool intersectAxesBundle 00108 ( 00109 const point& V0, 00110 const point& V10, 00111 const point& V20, 00112 const label i0, 00113 const pointField& origin, 00114 const scalar maxLength, 00115 point& pInter 00116 ); 00117 00118 //- Does triangle intersect bounding box. 00119 static bool intersectBb 00120 ( 00121 const point& p0, 00122 const point& p1, 00123 const point& p2, 00124 const treeBoundBox& cubeBb 00125 ); 00126 00127 //- Does triangle intersect plane. Return bool and set intersection segment. 00128 static bool intersect 00129 ( 00130 const point& va0, 00131 const point& va10, 00132 const point& va20, 00133 00134 const point& basePoint, 00135 const vector& normal, 00136 00137 point& pInter0, 00138 point& pInter1 00139 ); 00140 00141 //- Do triangles intersect. Return bool and set intersection segment. 00142 static bool intersect 00143 ( 00144 const point& va0, 00145 const point& va10, 00146 const point& va20, 00147 00148 const point& vb0, 00149 const point& vb10, 00150 const point& vb20, 00151 00152 point& pInter0, 00153 point& pInter1 00154 ); 00155 00156 00157 //- Classify point on triangle plane w.r.t. triangle edges. 00158 // - inside/outside (returned) 00159 // - near point (0, 1, 2) 00160 // - near edge (0, 1, 2). Note: edges are counted from starting vertex 00161 // so e.g. edge 2 is from f[2] to f[0] 00162 static bool classify 00163 ( 00164 const point& baseVertex, 00165 const vector& E0, 00166 const vector& E1, 00167 const vector& n, 00168 const point& pInter, 00169 const scalar tol, 00170 label& nearType, 00171 label& nearLabel 00172 ); 00173 00174 }; 00175 00176 00177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00178 00179 } // End namespace Foam 00180 00181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00182 00183 #endif 00184 00185 // ************************************************************************* //