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::treeDataPrimitivePatch 00026 00027 Description 00028 Encapsulation of data needed to search on PrimitivePatches 00029 00030 SourceFiles 00031 treeDataPrimitivePatch.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef treeDataPrimitivePatch_H 00036 #define treeDataPrimitivePatch_H 00037 00038 #include <OpenFOAM/PrimitivePatch_.H> 00039 //#include "indexedOctree.H" 00040 #include <meshTools/treeBoundBoxList.H> 00041 00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00043 00044 namespace Foam 00045 { 00046 00047 // Forward declaration of classes 00048 template<class Type> class indexedOctree; 00049 00050 00051 /*---------------------------------------------------------------------------*\ 00052 Class treeDataPrimitivePatchName Declaration 00053 \*---------------------------------------------------------------------------*/ 00054 00055 TemplateName(treeDataPrimitivePatch); 00056 00057 00058 /*---------------------------------------------------------------------------*\ 00059 Class treeDataPrimitivePatch Declaration 00060 \*---------------------------------------------------------------------------*/ 00061 00062 template 00063 < 00064 class Face, 00065 template<class> class FaceList, 00066 class PointField, 00067 class PointType=point 00068 > 00069 class treeDataPrimitivePatch 00070 : 00071 public treeDataPrimitivePatchName 00072 { 00073 // Static data 00074 00075 //- tolerance on linear dimensions 00076 static scalar tolSqr; 00077 00078 // Private data 00079 00080 //- Underlying geometry 00081 const PrimitivePatch<Face, FaceList, PointField, PointType>& patch_; 00082 00083 //- Whether to precalculate and store face bounding box 00084 const bool cacheBb_; 00085 00086 //- face bounding boxes (valid only if cacheBb_) 00087 treeBoundBoxList bbs_; 00088 00089 00090 // Private Member Functions 00091 00092 //- Calculate face bounding box 00093 static treeBoundBox calcBb(const pointField&, const face&); 00094 00095 //- Initialise all member data 00096 void update(); 00097 00098 public: 00099 00100 // Constructors 00101 00102 //- Construct from patch. 00103 treeDataPrimitivePatch 00104 ( 00105 const bool cacheBb, 00106 const PrimitivePatch<Face, FaceList, PointField, PointType>& 00107 ); 00108 00109 00110 // Member Functions 00111 00112 // Access 00113 00114 label size() const 00115 { 00116 return patch_.size(); 00117 } 00118 00119 //- Get representative point cloud for all shapes inside 00120 // (one point per shape) 00121 pointField points() const; 00122 00123 00124 // Search 00125 00126 //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. 00127 // Only makes sense for closed surfaces. 00128 label getVolumeType 00129 ( 00130 const indexedOctree 00131 < 00132 treeDataPrimitivePatch 00133 < 00134 Face, 00135 FaceList, 00136 PointField, 00137 PointType 00138 > 00139 >&, 00140 const point& 00141 ) const; 00142 00143 //- Does (bb of) shape at index overlap bb 00144 bool overlaps 00145 ( 00146 const label index, 00147 const treeBoundBox& sampleBb 00148 ) const; 00149 00150 //- Calculates nearest (to sample) point in shape. 00151 // Returns actual point and distance (squared) 00152 void findNearest 00153 ( 00154 const labelList& indices, 00155 const point& sample, 00156 00157 scalar& nearestDistSqr, 00158 label& nearestIndex, 00159 point& nearestPoint 00160 ) const; 00161 00162 //- Calculates nearest (to line) point in shape. 00163 // Returns point and distance (squared) 00164 void findNearest 00165 ( 00166 const labelList& indices, 00167 const linePointRef& ln, 00168 00169 treeBoundBox& tightest, 00170 label& minIndex, 00171 point& linePoint, 00172 point& nearestPoint 00173 ) const 00174 { 00175 notImplemented 00176 ( 00177 "treeDataPrimitivePatch::findNearest" 00178 "(const labelList&, const linePointRef&, ..)" 00179 ); 00180 } 00181 00182 //- Calculate intersection of shape with ray. Sets result 00183 // accordingly 00184 bool intersects 00185 ( 00186 const label index, 00187 const point& start, 00188 const point& end, 00189 point& result 00190 ) const; 00191 00192 }; 00193 00194 00195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00196 00197 } // End namespace Foam 00198 00199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00200 00201 #ifdef NoRepository 00202 # include "treeDataPrimitivePatch.C" 00203 #endif 00204 00205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00206 00207 #endif 00208 00209 // ************************************************************************* //