33 Foam::plane::specificationNames_
34 {
"planeEquation",
"embeddedPoints",
"pointAndNormal"};
39 void Foam::plane::calcPntAndVec
49 const scalar magNormal =
mag(normal_);
62 if (magNormal >
mag(d)*vSmall)
64 point_ = - d/magNormal*normal_;
73 void Foam::plane::calcPntAndVec
80 normal_ =
normalised((point1 - point2) ^ (point2 - point3));
82 point_ = (point1 + point2 + point3)/3;
110 calcPntAndVec(a,
b,
c, d);
121 calcPntAndVec(point1, point2, point3);
132 if (
dict.found(
"planeType"))
134 spec = specificationNames_.
read(
dict.lookup(
"planeType"));
139 const bool havePlaneEquation =
140 dict.found(
"a") ||
dict.found(
"b") ||
142 const bool haveEmbeddedPoints =
143 dict.found(
"point1") ||
144 dict.found(
"point2") ||
145 dict.found(
"point3");
146 const bool havePointAndNormal =
147 dict.found(
"point") ||
dict.found(
"basePoint")
148 ||
dict.found(
"normal") ||
dict.found(
"normalVector");
149 const bool haveSingleSpec =
150 havePlaneEquation + haveEmbeddedPoints + havePointAndNormal == 1;
152 if (!haveSingleSpec)
dict.lookup(
"planeType");
155 havePlaneEquation ? specification::planeEquation
156 : haveEmbeddedPoints ? specification::embeddedPoints
157 : specification::pointAndNormal;
158 allowSubDict =
false;
164 :
dict.optionalSubDict(specificationNames_[spec] +
"Dict");
168 case specification::planeEquation:
174 calcPntAndVec(a,
b,
c, d);
177 case specification::embeddedPoints:
182 calcPntAndVec(point1, point2, point3);
185 case specification::pointAndNormal:
190 {
"point",
"basePoint"},
198 {
"normal",
"normalVector"},
209 <<
"Plane normal has zero length"
216 <<
"Plane is too far from the origin"
235 scalar magX =
mag(normal_.x());
236 scalar magY =
mag(normal_.y());
237 scalar magZ =
mag(normal_.z());
244 C[1] = normal_.y()/normal_.x();
245 C[2] = normal_.z()/normal_.x();
249 C[0] = normal_.x()/normal_.z();
250 C[1] = normal_.y()/normal_.z();
258 C[0] = normal_.x()/normal_.y();
260 C[2] = normal_.z()/normal_.y();
264 C[0] = normal_.x()/normal_.z();
265 C[1] = normal_.y()/normal_.z();
270 C[3] = -
C[0] * point_.x()
281 const point& refPt = refPoint();
286 const scalar perturbX = refPt.
x() + 1
e-3;
287 const scalar perturbY = refPt.
y() + 1
e-3;
288 const scalar perturbZ = refPt.
z() + 1
e-3;
347 return p - normal_*signedDistance(
p);
353 return mag(signedDistance(
p));
359 return (
p - point_) & normal_;
369 const scalar num = (point_ - pnt0) & normal_;
370 const scalar den = dir & normal_;
372 return mag(den) >
mag(num)*vSmall ? num/den : vGreat;
383 const vector& n1 = normal();
386 const point& p1 = refPoint();
396 scalar magX =
mag(dir.
x());
397 scalar magY =
mag(dir.
y());
398 scalar magZ =
mag(dir.
z());
436 pt[i1] = (n2[i2]*n1p1 - n1[i2]*n2p2) / (n1[i1]*n2[i2] - n2[i1]*n1[i2]);
437 pt[i2] = (n2[i1]*n1p1 - n1[i1]*n2p2) / (n1[i2]*n2[i1] - n1[i1]*n2[i2]);
455 coeffs1[0],coeffs1[1],coeffs1[2],
456 coeffs2[0],coeffs2[1],coeffs2[2],
457 coeffs3[0],coeffs3[1],coeffs3[2]
460 vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
462 return (
inv(a) & (-
b));
468 const vector mirroredPtDir =
p - nearestPoint(
p);
470 if ((normal() & mirroredPtDir) > 0)
472 return p - 2.0*distance(
p)*normal();
476 return p + 2.0*distance(
p)*normal();
483 writeEntry(os,
"planeType",
"pointAndNormal");
484 os <<
indent <<
"pointAndNormalDict" <<
nl
496 if (a.point_ ==
b.point_ && a.normal_ ==
b.normal_)
Graphite solid properties.
A 1D vector of objects of type <T> with a fixed size <Size>.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Initialise the NamedEnum HashTable from the static list of names.
Enum read(Istream &) const
Read a word from Istream and return the corresponding.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
A direction and a reference point.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
const point & refPoint() const
Return the plane base point.
point mirror(const point &p) const
Mirror the supplied point in the plane. Return the mirrored point.
FixedList< scalar, 4 > planeCoeffs() const
Return coefficients for the plane equation, ax + by + cz + d = 0.
scalar normalIntersect(const point &pnt0, const vector &dir) const
Return cut coefficient for plane and line defined by.
plane(const vector &normalVector)
Construct from normal vector through the origin.
scalar distance(const point &p) const
Return distance from the given point to the plane.
const vector & normal() const
Return the plane normal.
point aPoint() const
Return a point on the plane.
void writeDict(Ostream &) const
Write to dictionary.
point nearestPoint(const point &p) const
Return nearest point in the plane for the given point.
ray planeIntersect(const plane &) const
Return the cutting line between this plane and another.
point planePlaneIntersect(const plane &, const plane &) const
Return the cutting point between this plane and two other planes.
scalar signedDistance(const point &p) const
Return signed distance from the given point to the plane.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
const dimensionedScalar c
Speed of light in a vacuum.
static const coefficient C("C", dimTemperature, 234.5)
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool operator!=(const particle &, const particle &)
const dimensionSet & dimless
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet & dimLength
Ostream & incrIndent(Ostream &os)
Increment the indent level.
vector point
Point is a vector.
Vector< scalar > vector
A scalar version of the templated Vector.
void inv(pointPatchField< tensor > &, const pointPatchField< tensor > &)
dimensionSet normalised(const dimensionSet &)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
Ostream & indent(Ostream &os)
Indent stream.
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)