1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "searchablePlane.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "SortableList.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(searchablePlane, 0);
37 addToRunTimeSelectionTable(searchableSurface, searchablePlane, dict);
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 Foam::pointIndexHit Foam::searchablePlane::findLine
50 pointIndexHit info(true, vector::zero, 0);
52 linePointRef l(start, end);
54 scalar t = lineIntersect(l);
63 info.setPoint(start+t*l.vec());
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
72 Foam::searchablePlane::searchablePlane
75 const point& basePoint,
79 searchableSurface(io),
80 plane(basePoint, normal)
84 Foam::searchablePlane::searchablePlane
87 const dictionary& dict
90 searchableSurface(io),
95 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
97 Foam::searchablePlane::~searchablePlane()
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 const Foam::wordList& Foam::searchablePlane::regions() const
105 if (regions_.empty())
108 regions_[0] = "region0";
114 void Foam::searchablePlane::findNearest
116 const pointField& samples,
117 const scalarField& nearestDistSqr,
118 List<pointIndexHit>& info
121 info.setSize(samples.size());
125 info[i].setPoint(nearestPoint(samples[i]));
127 if (magSqr(samples[i]-info[i].rawPoint()) > nearestDistSqr[i])
129 info[i].setIndex(-1);
141 void Foam::searchablePlane::findLine
143 const pointField& start,
144 const pointField& end,
145 List<pointIndexHit>& info
148 info.setSize(start.size());
152 info[i] = findLine(start[i], end[i]);
157 void Foam::searchablePlane::findLineAny
159 const pointField& start,
160 const pointField& end,
161 List<pointIndexHit>& info
164 findLine(start, end, info);
168 void Foam::searchablePlane::findLineAll
170 const pointField& start,
171 const pointField& end,
172 List<List<pointIndexHit> >& info
175 List<pointIndexHit> nearestInfo;
176 findLine(start, end, nearestInfo);
178 info.setSize(start.size());
181 if (nearestInfo[pointI].hit())
183 info[pointI].setSize(1);
184 info[pointI][0] = nearestInfo[pointI];
188 info[pointI].clear();
194 void Foam::searchablePlane::getRegion
196 const List<pointIndexHit>& info,
200 region.setSize(info.size());
205 void Foam::searchablePlane::getNormal
207 const List<pointIndexHit>& info,
211 n.setSize(info.size());
216 void Foam::searchablePlane::getVolumeType
218 const pointField& points,
219 List<volumeType>& volType
224 "searchableCollection::getVolumeType(const pointField&"
225 ", List<volumeType>&) const"
226 ) << "Volume type not supported for plane."
231 // ************************************************************************* //