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::treeDataTriSurface 00026 00027 Description 00028 Encapsulates data for (indexedOc)tree searches on triSurface. 00029 00030 SourceFiles 00031 treeDataTriSurface.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef treeDataTriSurface_H 00036 #define treeDataTriSurface_H 00037 00038 #include <triSurface/triSurface.H> 00039 00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00041 00042 namespace Foam 00043 { 00044 00045 // Forward declaration of classes 00046 class treeBoundBox; 00047 class treeDataTriSurface; 00048 template<class Type> class indexedOctree; 00049 00050 /*---------------------------------------------------------------------------*\ 00051 Class treeDataTriSurface Declaration 00052 \*---------------------------------------------------------------------------*/ 00053 00054 class treeDataTriSurface 00055 { 00056 // Private data 00057 00058 const triSurface& surface_; 00059 00060 00061 // Private Member Functions 00062 00063 //- fast triangle nearest point calculation. Returns point in E0, E1 00064 // coordinate system: base + s*E0 + t*E1 00065 static scalar nearestCoords 00066 ( 00067 const point& base, 00068 const point& E0, 00069 const point& E1, 00070 const scalar a, 00071 const scalar b, 00072 const scalar c, 00073 const point& P, 00074 scalar& s, 00075 scalar& t 00076 ); 00077 00078 public: 00079 00080 // Declare name of the class and its debug switch 00081 ClassName("treeDataTriSurface"); 00082 00083 00084 // Constructors 00085 00086 //- Construct from triSurface. Holds reference. 00087 treeDataTriSurface(const triSurface&); 00088 00089 00090 // Member Functions 00091 00092 // Access 00093 00094 const triSurface& surface() const 00095 { 00096 return surface_; 00097 } 00098 00099 label size() const 00100 { 00101 return surface_.size(); 00102 } 00103 00104 //- Get representative point cloud for all shapes inside 00105 // (one point per shape) 00106 pointField points() const; 00107 00108 00109 // Search 00110 00111 //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. 00112 // Only makes sense for closed surfaces. 00113 label getVolumeType 00114 ( 00115 const indexedOctree<treeDataTriSurface>&, 00116 const point& 00117 ) const; 00118 00119 //- Does (bb of) shape at index overlap bb 00120 bool overlaps 00121 ( 00122 const label index, 00123 const treeBoundBox& sampleBb 00124 ) const; 00125 00126 //- Calculates nearest (to sample) point in shape. 00127 // Returns actual point and distance (squared) 00128 void findNearest 00129 ( 00130 const labelList& indices, 00131 const point& sample, 00132 00133 scalar& nearestDistSqr, 00134 label& nearestIndex, 00135 point& nearestPoint 00136 ) const; 00137 00138 //- Calculates nearest (to line) point in shape. 00139 // Returns point and distance (squared) 00140 void findNearest 00141 ( 00142 const labelList& indices, 00143 const linePointRef& ln, 00144 00145 treeBoundBox& tightest, 00146 label& minIndex, 00147 point& linePoint, 00148 point& nearestPoint 00149 ) const; 00150 00151 //- Calculate intersection of triangle with ray. Sets result 00152 // accordingly 00153 bool intersects 00154 ( 00155 const label index, 00156 const point& start, 00157 const point& end, 00158 point& result 00159 ) const; 00160 00161 }; 00162 00163 00164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00165 00166 } // End namespace Foam 00167 00168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00169 00170 00171 #endif 00172 00173 // ************************ vim: set sw=4 sts=4 et: ************************ //