searchablePlane.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 #include "searchablePlane.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "SortableList.H"
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036 defineTypeNameAndDebug(searchablePlane, 0);
00037 addToRunTimeSelectionTable(searchableSurface, searchablePlane, dict);
00038
00039 }
00040
00041
00042
00043
00044 Foam::pointIndexHit Foam::searchablePlane::findLine
00045 (
00046 const point& start,
00047 const point& end
00048 ) const
00049 {
00050 pointIndexHit info(true, vector::zero, 0);
00051
00052 linePointRef l(start, end);
00053
00054 scalar t = lineIntersect(l);
00055
00056 if (t < 0 || t > 1)
00057 {
00058 info.setMiss();
00059 info.setIndex(-1);
00060 }
00061 else
00062 {
00063 info.setPoint(start+t*l.vec());
00064 }
00065
00066 return info;
00067 }
00068
00069
00070
00071
00072 Foam::searchablePlane::searchablePlane
00073 (
00074 const IOobject& io,
00075 const point& basePoint,
00076 const vector& normal
00077 )
00078 :
00079 searchableSurface(io),
00080 plane(basePoint, normal)
00081 {}
00082
00083
00084 Foam::searchablePlane::searchablePlane
00085 (
00086 const IOobject& io,
00087 const dictionary& dict
00088 )
00089 :
00090 searchableSurface(io),
00091 plane(dict)
00092 {}
00093
00094
00095
00096
00097 Foam::searchablePlane::~searchablePlane()
00098 {}
00099
00100
00101
00102
00103 const Foam::wordList& Foam::searchablePlane::regions() const
00104 {
00105 if (regions_.empty())
00106 {
00107 regions_.setSize(1);
00108 regions_[0] = "region0";
00109 }
00110 return regions_;
00111 }
00112
00113
00114 void Foam::searchablePlane::findNearest
00115 (
00116 const pointField& samples,
00117 const scalarField& nearestDistSqr,
00118 List<pointIndexHit>& info
00119 ) const
00120 {
00121 info.setSize(samples.size());
00122
00123 forAll(samples, i)
00124 {
00125 info[i].setPoint(nearestPoint(samples[i]));
00126
00127 if (magSqr(samples[i]-info[i].rawPoint()) > nearestDistSqr[i])
00128 {
00129 info[i].setIndex(-1);
00130 info[i].setMiss();
00131 }
00132 else
00133 {
00134 info[i].setIndex(0);
00135 info[i].setHit();
00136 }
00137 }
00138 }
00139
00140
00141 void Foam::searchablePlane::findLine
00142 (
00143 const pointField& start,
00144 const pointField& end,
00145 List<pointIndexHit>& info
00146 ) const
00147 {
00148 info.setSize(start.size());
00149
00150 forAll(start, i)
00151 {
00152 info[i] = findLine(start[i], end[i]);
00153 }
00154 }
00155
00156
00157 void Foam::searchablePlane::findLineAny
00158 (
00159 const pointField& start,
00160 const pointField& end,
00161 List<pointIndexHit>& info
00162 ) const
00163 {
00164 findLine(start, end, info);
00165 }
00166
00167
00168 void Foam::searchablePlane::findLineAll
00169 (
00170 const pointField& start,
00171 const pointField& end,
00172 List<List<pointIndexHit> >& info
00173 ) const
00174 {
00175 List<pointIndexHit> nearestInfo;
00176 findLine(start, end, nearestInfo);
00177
00178 info.setSize(start.size());
00179 forAll(info, pointI)
00180 {
00181 if (nearestInfo[pointI].hit())
00182 {
00183 info[pointI].setSize(1);
00184 info[pointI][0] = nearestInfo[pointI];
00185 }
00186 else
00187 {
00188 info[pointI].clear();
00189 }
00190 }
00191 }
00192
00193
00194 void Foam::searchablePlane::getRegion
00195 (
00196 const List<pointIndexHit>& info,
00197 labelList& region
00198 ) const
00199 {
00200 region.setSize(info.size());
00201 region = 0;
00202 }
00203
00204
00205 void Foam::searchablePlane::getNormal
00206 (
00207 const List<pointIndexHit>& info,
00208 vectorField& n
00209 ) const
00210 {
00211 n.setSize(info.size());
00212 n = normal();
00213 }
00214
00215
00216 void Foam::searchablePlane::getVolumeType
00217 (
00218 const pointField& points,
00219 List<volumeType>& volType
00220 ) const
00221 {
00222 FatalErrorIn
00223 (
00224 "searchableCollection::getVolumeType(const pointField&"
00225 ", List<volumeType>&) const"
00226 ) << "Volume type not supported for plane."
00227 << exit(FatalError);
00228 }
00229
00230
00231
Copyright © 2000-2009 OpenCFD Ltd