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