treeDataPoint.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 #include "treeDataPoint.H"
00030 #include "treeBoundBox.H"
00031 #include "indexedOctree.H"
00032 #include "polyMesh.H"
00033 #include "triangleFuncs.H"
00034
00035
00036
00037 defineTypeNameAndDebug(Foam::treeDataPoint, 0);
00038
00039
00040
00041
00042
00043 Foam::treeDataPoint::treeDataPoint(const pointField& points)
00044 :
00045 points_(points)
00046 {}
00047
00048
00049
00050
00051 Foam::pointField Foam::treeDataPoint::points() const
00052 {
00053 return points_;
00054 }
00055
00056
00057
00058
00059 Foam::label Foam::treeDataPoint::getVolumeType
00060 (
00061 const indexedOctree<treeDataPoint>& oc,
00062 const point& sample
00063 ) const
00064 {
00065 return indexedOctree<treeDataPoint>::UNKNOWN;
00066 }
00067
00068
00069
00070 bool Foam::treeDataPoint::overlaps
00071 (
00072 const label index,
00073 const treeBoundBox& cubeBb
00074 ) const
00075 {
00076 return cubeBb.contains(points_[index]);
00077 }
00078
00079
00080
00081
00082 void Foam::treeDataPoint::findNearest
00083 (
00084 const labelList& indices,
00085 const point& sample,
00086
00087 scalar& nearestDistSqr,
00088 label& minIndex,
00089 point& nearestPoint
00090 ) const
00091 {
00092 forAll(indices, i)
00093 {
00094 label index = indices[i];
00095
00096 const point& pt = points_[index];
00097
00098 scalar distSqr = magSqr(pt - sample);
00099
00100 if (distSqr < nearestDistSqr)
00101 {
00102 nearestDistSqr = distSqr;
00103 minIndex = index;
00104 nearestPoint = pt;
00105 }
00106 }
00107 }
00108
00109
00110
00111
00112 void Foam::treeDataPoint::findNearest
00113 (
00114 const labelList& indices,
00115 const linePointRef& ln,
00116
00117 treeBoundBox& tightest,
00118 label& minIndex,
00119 point& linePoint,
00120 point& nearestPoint
00121 ) const
00122 {
00123
00124 scalar nearestDistSqr = magSqr(linePoint - nearestPoint);
00125
00126 forAll(indices, i)
00127 {
00128 label index = indices[i];
00129
00130 const point& shapePt = points_[index];
00131
00132 if (tightest.contains(shapePt))
00133 {
00134
00135 pointHit pHit = ln.nearestDist(shapePt);
00136 scalar distSqr = sqr(pHit.distance());
00137
00138 if (distSqr < nearestDistSqr)
00139 {
00140 nearestDistSqr = distSqr;
00141 minIndex = index;
00142 linePoint = pHit.rawPoint();
00143 nearestPoint = shapePt;
00144
00145 {
00146 point& minPt = tightest.min();
00147 minPt = min(ln.start(), ln.end());
00148 minPt.x() -= pHit.distance();
00149 minPt.y() -= pHit.distance();
00150 minPt.z() -= pHit.distance();
00151 }
00152 {
00153 point& maxPt = tightest.max();
00154 maxPt = max(ln.start(), ln.end());
00155 maxPt.x() += pHit.distance();
00156 maxPt.y() += pHit.distance();
00157 maxPt.z() += pHit.distance();
00158 }
00159 }
00160 }
00161 }
00162 }
00163
00164
00165
Copyright © 2000-2009 OpenCFD Ltd