00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::triangleFuncs 00026 00027 Description 00028 Various triangle functions. 00029 00030 SourceFiles 00031 triangleFuncs.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef triangleFuncs_H 00036 #define triangleFuncs_H 00037 00038 #include <OpenFOAM/point.H> 00039 #include <OpenFOAM/label.H> 00040 #include <OpenFOAM/scalar.H> 00041 #include <OpenFOAM/pointField.H> 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 // Forward declaration of classes 00049 class treeBoundBox; 00050 00051 /*---------------------------------------------------------------------------*\ 00052 Class triangleFuncs Declaration 00053 \*---------------------------------------------------------------------------*/ 00054 00055 class triangleFuncs 00056 { 00057 00058 public: 00059 00060 // Public data types 00061 00062 //- Enumeration defining nearness classification 00063 enum proxType 00064 { 00065 NONE, 00066 POINT, 00067 EDGE 00068 }; 00069 00070 00071 private: 00072 00073 // Private Member Functions 00074 00075 //- Helper function for intersect. Sets pt to be anywhere on the edge 00076 // between oppositeSidePt and thisSidePt depending on both signs. 00077 static void setIntersection 00078 ( 00079 const point& oppositeSidePt, 00080 const scalar oppositeSign, 00081 const point& thisSidePt, 00082 const scalar thisSign, 00083 const scalar tol, 00084 point& pt 00085 ); 00086 00087 //- Helper function. 00088 static void selectPt 00089 ( 00090 const bool select0, 00091 const point& p0, 00092 const point& p1, 00093 point& min 00094 ); 00095 00096 public: 00097 00098 //- Intersect triangle with parallel edges aligned with axis i0. 00099 // Returns true (and intersection in pInter) if any of them intersects 00100 // triangle. Used in intersectBb. 00101 static bool intersectAxesBundle 00102 ( 00103 const point& V0, 00104 const point& V10, 00105 const point& V20, 00106 const label i0, 00107 const pointField& origin, 00108 const scalar maxLength, 00109 point& pInter 00110 ); 00111 00112 //- Does triangle intersect bounding box. 00113 static bool intersectBb 00114 ( 00115 const point& p0, 00116 const point& p1, 00117 const point& p2, 00118 const treeBoundBox& cubeBb 00119 ); 00120 00121 //- Does triangle intersect plane. Return bool and set intersection segment. 00122 static bool intersect 00123 ( 00124 const point& va0, 00125 const point& va10, 00126 const point& va20, 00127 00128 const point& basePoint, 00129 const vector& normal, 00130 00131 point& pInter0, 00132 point& pInter1 00133 ); 00134 00135 //- Do triangles intersect. Return bool and set intersection segment. 00136 static bool intersect 00137 ( 00138 const point& va0, 00139 const point& va10, 00140 const point& va20, 00141 00142 const point& vb0, 00143 const point& vb10, 00144 const point& vb20, 00145 00146 point& pInter0, 00147 point& pInter1 00148 ); 00149 }; 00150 00151 00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00153 00154 } // End namespace Foam 00155 00156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00157 00158 #endif 00159 00160 // ************************ vim: set sw=4 sts=4 et: ************************ //