Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <meshTools/octreeDataPoint.H>
00030 #include <meshTools/treeLeaf.H>
00031
00032
00033
00034 template<>
00035 Foam::label Foam::treeLeaf<Foam::octreeDataPoint>::find
00036 (
00037 const octreeDataPoint& shapes,
00038 const point& sample
00039 ) const
00040 {
00041 notImplemented
00042 (
00043 "Foam::treeLeaf<Foam::octreeDataPoint>::find("
00044 "const octreeDataPoint& shapes,"
00045 "const point& sample"
00046 );
00047
00048 return false;
00049 }
00050
00051
00052 template<>
00053 bool Foam::treeLeaf<Foam::octreeDataPoint>::findNearest
00054 (
00055 const octreeDataPoint& shapes,
00056 const point& sample,
00057 treeBoundBox& tightest,
00058 label& tightestI,
00059 scalar& tightestDist
00060 ) const
00061 {
00062
00063 const pointField& points = shapes.points();
00064 point& tMin = tightest.min();
00065 point& tMax = tightest.max();
00066
00067 scalar minDist2 = sqr(tightestDist);
00068
00069 label minIndex = -1;
00070 forAll(indices_, i)
00071 {
00072 label pointi = indices_[i];
00073 scalar dist = magSqr(points[pointi] - sample);
00074
00075 if (dist < minDist2)
00076 {
00077 minDist2 = dist;
00078 minIndex = pointi;
00079 }
00080 }
00081
00082 if (minIndex != -1)
00083 {
00084 tightestDist = sqrt(minDist2);
00085
00086
00087 tMin.x() = sample.x() - tightestDist;
00088 tMin.y() = sample.y() - tightestDist;
00089 tMin.z() = sample.z() - tightestDist;
00090
00091 tMax.x() = sample.x() + tightestDist;
00092 tMax.y() = sample.y() + tightestDist;
00093 tMax.z() = sample.z() + tightestDist;
00094
00095 tightestI = minIndex;
00096
00097 return true;
00098 }
00099 else
00100 {
00101
00102 return false;
00103 }
00104 }
00105
00106
00107