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::treeDataEdge 00026 00027 Description 00028 Holds data for octree to work on an edges subset. 00029 00030 SourceFiles 00031 treeDataEdge.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef treeDataEdge_H 00036 #define treeDataEdge_H 00037 00038 #include <meshTools/treeBoundBoxList.H> 00039 #include <OpenFOAM/linePointRef.H> 00040 00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00042 00043 namespace Foam 00044 { 00045 00046 // Forward declaration of classes 00047 template<class Type> class indexedOctree; 00048 00049 /*---------------------------------------------------------------------------*\ 00050 Class treeDataEdge Declaration 00051 \*---------------------------------------------------------------------------*/ 00052 00053 class treeDataEdge 00054 { 00055 // Static data 00056 00057 //- tolerance on linear dimensions 00058 static scalar tol; 00059 00060 00061 // Private data 00062 00063 //- Reference to edgeList 00064 const edgeList& edges_; 00065 00066 //- Reference to points 00067 const pointField& points_; 00068 00069 //- labels of edges 00070 const labelList edgeLabels_; 00071 00072 //- Whether to precalculate and store face bounding box 00073 const bool cacheBb_; 00074 00075 //- bbs for all above edges (valid only if cacheBb_) 00076 treeBoundBoxList bbs_; 00077 00078 00079 // Private Member Functions 00080 00081 //- Calculate edge bounding box 00082 treeBoundBox calcBb(const label edgeI) const; 00083 00084 public: 00085 00086 // Declare name of the class and its debug switch 00087 ClassName("treeDataEdge"); 00088 00089 00090 // Constructors 00091 00092 //- Construct from selected edges. !Holds references to edges and points 00093 treeDataEdge 00094 ( 00095 const bool cacheBb, 00096 const edgeList& edges, 00097 const pointField& points, 00098 const labelList& edgeLabels 00099 ); 00100 00101 00102 // Member Functions 00103 00104 // Access 00105 00106 label size() const 00107 { 00108 return edgeLabels_.size(); 00109 } 00110 00111 //- Get representative point cloud for all shapes inside 00112 // (one point per shape) 00113 pointField points() const; 00114 00115 00116 // Search 00117 00118 //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. 00119 // Only makes sense for closed surfaces. 00120 label getVolumeType 00121 ( 00122 const indexedOctree<treeDataEdge>&, 00123 const point& 00124 ) const; 00125 00126 //- Does (bb of) shape at index overlap bb 00127 bool overlaps 00128 ( 00129 const label index, 00130 const treeBoundBox& sampleBb 00131 ) const; 00132 00133 //- Calculates nearest (to sample) point in shape. 00134 // Returns actual point and distance (squared) 00135 void findNearest 00136 ( 00137 const labelList& indices, 00138 const point& sample, 00139 00140 scalar& nearestDistSqr, 00141 label& nearestIndex, 00142 point& nearestPoint 00143 ) const; 00144 00145 //- Calculates nearest (to line) point in shape. 00146 // Returns point and distance (squared) 00147 void findNearest 00148 ( 00149 const labelList& indices, 00150 const linePointRef& ln, 00151 00152 treeBoundBox& tightest, 00153 label& minIndex, 00154 point& linePoint, 00155 point& nearestPoint 00156 ) const; 00157 00158 //- Calculate intersection of shape with ray. Sets result 00159 // accordingly 00160 bool intersects 00161 ( 00162 const label index, 00163 const point& start, 00164 const point& end, 00165 point& result 00166 ) const 00167 { 00168 notImplemented 00169 ( 00170 "treeDataEdge::intersects(const label, const point&," 00171 "const point&, point&)" 00172 ); 00173 return false; 00174 } 00175 00176 }; 00177 00178 00179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00180 00181 } // End namespace Foam 00182 00183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00184 00185 00186 #endif 00187 00188 // ************************ vim: set sw=4 sts=4 et: ************************ //