OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

triangleFuncs.H

Go 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-2009 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     Foam::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 // Forward declaration of classes
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 Member Functions
00075 
00076         //- Helper function for intersect. Sets pt to be anywhere on the edge
00077         //  between oppositeSidePt and thisSidePt depending on both signs.
00078         static void setIntersection
00079         (
00080             const point& oppositeSidePt,
00081             const scalar oppositeSign,
00082             const point& thisSidePt,
00083             const scalar thisSign,
00084             const scalar tol,
00085             point& pt
00086         );
00087 
00088         //- Helper function.
00089         static void selectPt
00090         (
00091             const bool select0,
00092             const point& p0,
00093             const point& p1,
00094             point& min
00095         );
00096 
00097 public:
00098 
00099     //- Intersect triangle with parallel edges aligned with axis i0.
00100     //  Returns true (and intersection in pInter) if any of them intersects
00101     //  triangle. Used in intersectBb.
00102     static bool intersectAxesBundle
00103     (
00104         const point& V0,
00105         const point& V10,
00106         const point& V20,
00107         const label i0,
00108         const pointField& origin,
00109         const scalar maxLength,
00110         point& pInter
00111     );
00112 
00113     //- Does triangle intersect bounding box.
00114     static bool intersectBb
00115     (
00116         const point& p0,
00117         const point& p1,
00118         const point& p2,
00119         const treeBoundBox& cubeBb
00120     );
00121 
00122     //- Does triangle intersect plane. Return bool and set intersection segment.
00123     static bool intersect
00124     (
00125         const point& va0,
00126         const point& va10,
00127         const point& va20,
00128 
00129         const point& basePoint,
00130         const vector& normal,
00131 
00132         point& pInter0,
00133         point& pInter1
00134     );
00135 
00136     //- Do triangles intersect. Return bool and set intersection segment.
00137     static bool intersect
00138     (
00139         const point& va0,
00140         const point& va10,
00141         const point& va20,
00142 
00143         const point& vb0,
00144         const point& vb10,
00145         const point& vb20,
00146 
00147         point& pInter0,
00148         point& pInter1
00149     );
00150 };
00151 
00152 
00153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00154 
00155 } // End namespace Foam
00156 
00157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00158 
00159 #endif
00160 
00161 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd