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