octreeDataPointTreeLeaf.C
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
00030 #include "octreeDataPoint.H"
00031 #include "treeLeaf.H"
00032
00033
00034
00035 template<>
00036 Foam::label Foam::treeLeaf<Foam::octreeDataPoint>::find
00037 (
00038 const octreeDataPoint& shapes,
00039 const point& sample
00040 ) const
00041 {
00042 notImplemented
00043 (
00044 "Foam::treeLeaf<Foam::octreeDataPoint>::find("
00045 "const octreeDataPoint& shapes,"
00046 "const point& sample"
00047 );
00048
00049 return false;
00050 }
00051
00052
00053 template<>
00054 bool Foam::treeLeaf<Foam::octreeDataPoint>::findNearest
00055 (
00056 const octreeDataPoint& shapes,
00057 const point& sample,
00058 treeBoundBox& tightest,
00059 label& tightestI,
00060 scalar& tightestDist
00061 ) const
00062 {
00063
00064 const pointField& points = shapes.points();
00065 point& tMin = tightest.min();
00066 point& tMax = tightest.max();
00067
00068 scalar minDist2 = sqr(tightestDist);
00069
00070 label minIndex = -1;
00071 forAll(indices_, i)
00072 {
00073 label pointi = indices_[i];
00074 scalar dist = magSqr(points[pointi] - sample);
00075
00076 if (dist < minDist2)
00077 {
00078 minDist2 = dist;
00079 minIndex = pointi;
00080 }
00081 }
00082
00083 if (minIndex != -1)
00084 {
00085 tightestDist = sqrt(minDist2);
00086
00087
00088 tMin.x() = sample.x() - tightestDist;
00089 tMin.y() = sample.y() - tightestDist;
00090 tMin.z() = sample.z() - tightestDist;
00091
00092 tMax.x() = sample.x() + tightestDist;
00093 tMax.y() = sample.y() + tightestDist;
00094 tMax.z() = sample.z() + tightestDist;
00095
00096 tightestI = minIndex;
00097
00098 return true;
00099 }
00100 else
00101 {
00102
00103 return false;
00104 }
00105 }
00106
00107
00108
Copyright © 2000-2009 OpenCFD Ltd