1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "searchablePlane.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "SortableList.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(searchablePlane, 0);
36 addToRunTimeSelectionTable(searchableSurface, searchablePlane, dict);
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 Foam::pointIndexHit Foam::searchablePlane::findLine
49 pointIndexHit info(true, vector::zero, 0);
51 linePointRef l(start, end);
53 scalar t = lineIntersect(l);
62 info.setPoint(start+t*l.vec());
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 Foam::searchablePlane::searchablePlane
74 const point& basePoint,
78 searchableSurface(io),
79 plane(basePoint, normal)
83 Foam::searchablePlane::searchablePlane
86 const dictionary& dict
89 searchableSurface(io),
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
96 Foam::searchablePlane::~searchablePlane()
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 const Foam::wordList& Foam::searchablePlane::regions() const
104 if (regions_.empty())
107 regions_[0] = "region0";
113 void Foam::searchablePlane::findNearest
115 const pointField& samples,
116 const scalarField& nearestDistSqr,
117 List<pointIndexHit>& info
120 info.setSize(samples.size());
124 info[i].setPoint(nearestPoint(samples[i]));
126 if (magSqr(samples[i]-info[i].rawPoint()) > nearestDistSqr[i])
128 info[i].setIndex(-1);
140 void Foam::searchablePlane::findLine
142 const pointField& start,
143 const pointField& end,
144 List<pointIndexHit>& info
147 info.setSize(start.size());
151 info[i] = findLine(start[i], end[i]);
156 void Foam::searchablePlane::findLineAny
158 const pointField& start,
159 const pointField& end,
160 List<pointIndexHit>& info
163 findLine(start, end, info);
167 void Foam::searchablePlane::findLineAll
169 const pointField& start,
170 const pointField& end,
171 List<List<pointIndexHit> >& info
174 List<pointIndexHit> nearestInfo;
175 findLine(start, end, nearestInfo);
177 info.setSize(start.size());
180 if (nearestInfo[pointI].hit())
182 info[pointI].setSize(1);
183 info[pointI][0] = nearestInfo[pointI];
187 info[pointI].clear();
193 void Foam::searchablePlane::getRegion
195 const List<pointIndexHit>& info,
199 region.setSize(info.size());
204 void Foam::searchablePlane::getNormal
206 const List<pointIndexHit>& info,
210 n.setSize(info.size());
215 void Foam::searchablePlane::getVolumeType
217 const pointField& points,
218 List<volumeType>& volType
223 "searchableCollection::getVolumeType(const pointField&"
224 ", List<volumeType>&) const"
225 ) << "Volume type not supported for plane."
230 // ************************************************************************* //