49int main(
int argc,
char *argv[])
53 "Find nearest face and vertex."
54 " Uses a zero origin unless otherwise specified"
57 argList::noParallel();
58 argList::addArgument(
"input",
"The input surface file");
59 argList::addOption(
"x",
"X",
"The point x-coordinate (if non-zero)");
60 argList::addOption(
"y",
"Y",
"The point y-coordinate (if non-zero)");
61 argList::addOption(
"z",
"Z",
"The point y-coordinate (if non-zero)");
71 Info<<
"Looking for nearest face/vertex to " << samplePt <<
endl;
81 const pointField& localPoints = surf1.localPoints();
84 scalar minDist = GREAT;
86 forAll(localPoints, pointi)
88 const scalar dist =
mag(localPoints[pointi] - samplePt);
96 Info<<
"Nearest vertex:" <<
nl
97 <<
" index : " << minIndex <<
" (in localPoints)" <<
nl
98 <<
" index : " << surf1.meshPoints()[minIndex]
99 <<
" (in points)" <<
nl
100 <<
" coordinates: " << localPoints[minIndex] <<
nl
116 const scalar dist =
mag(centre - samplePt);
124 const face&
f = surf1[minIndex];
126 Info<<
"Face with nearest centre:" <<
nl
127 <<
" index : " << minIndex <<
nl
128 <<
" centre : " <<
f.centre(
points) <<
nl
129 <<
" face : " <<
f <<
nl
130 <<
" vertex coords:" <<
endl;
141 if (minIndex >= surfZones[zonei].start())
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const Vector< Cmpt > & centre(const Foam::UList< Vector< Cmpt > > &) const
Return *this (used for point which is a typedef to Vector<scalar>.
Extract command arguments and options from the supplied argc and argv parameters.
T get(const label index) const
Get a value from the argument at index.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
A surface zone on a MeshedSurface.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.