From 2a6cbeb7cb77f12653cf56ca16b8041a08212e81 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 9 Oct 2020 11:21:39 +0200 Subject: [PATCH] ENH: update and document point/object hit methods - add point() as unchecked getter method. - add hitPoint(.., label) convenience method for common combination of setHit() + setIndex(label) + setPoint(..) GIT: remove unused headers, typedefs (point2DHit.H pointHitSort.H) --- .../primitiveShapes/objectHit/PointHit.H | 166 ++++++++-------- .../primitiveShapes/objectHit/PointIndexHit.H | 180 ++++++++++++------ .../primitiveShapes/objectHit/objectHit.H | 58 ++++-- .../primitiveShapes/objectHit/point2DHit.H | 50 ----- .../primitiveShapes/objectHit/pointHit.H | 1 + .../primitiveShapes/objectHit/pointHitSort.H | 117 ------------ .../primitiveShapes/objectHit/pointIndexHit.H | 3 +- .../surfaceLocation/surfaceLocation.C | 31 +-- .../surfaceLocation/surfaceLocation.H | 41 ++-- 9 files changed, 282 insertions(+), 365 deletions(-) delete mode 100644 src/OpenFOAM/meshes/primitiveShapes/objectHit/point2DHit.H delete mode 100644 src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHitSort.H diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H index 0e93965a81f..eda6232aa6f 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,8 +28,8 @@ Class Foam::PointHit Description - This class describes the interaction of a face and a point. It - carries the info of a successful hit and (if successful), returns + Describes the interaction of a face and a point. + It carries the info of a successful hit and (if successful) the interaction point. \*---------------------------------------------------------------------------*/ @@ -37,6 +38,7 @@ Description #define PointHit_H #include "bool.H" +#include "point.H" #include "token.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,51 +46,55 @@ Description namespace Foam { -// Forward declaration of classes - -class Ostream; - - -// Forward declaration of friend functions and operators - -template<class Point> class PointHit; - -template<class Point> -inline Ostream& operator<<(Ostream&, const PointHit<Point>&); - - /*---------------------------------------------------------------------------*\ Class PointHit Declaration \*---------------------------------------------------------------------------*/ -template<class Point> +template<class PointType> class PointHit { - // Private data - - //- Hit success - bool hit_; + // Private Data //- Point of hit; for miss holds best estimate outside the object - Point hitPoint_; + PointType point_; //- Distance to hit point scalar distance_; + //- Hit success + bool hit_; + //- Eligible miss bool eligibleMiss_; public: + // Public Typedefs + + //- The point type + typedef PointType point_type; + + // Constructors - //- Construct null + //- Default construct. A zero point with a large distance, + //- no hit, no eligible misses PointHit() : + point_(Zero), + distance_(GREAT), hit_(false), - hitPoint_(Zero), + eligibleMiss_(false) + {} + + //- Construct from point with a large distance, + //- no hit, no eligible misses + explicit PointHit(const point_type& p) + : + point_(p), distance_(GREAT), + hit_(false), eligibleMiss_(false) {} @@ -96,123 +102,129 @@ public: PointHit ( const bool hit, - const Point& p, + const point_type& p, const scalar dist, - const bool eligibleMiss + const bool eligibleMiss = false ) : - hit_(hit), - hitPoint_(p), + point_(p), distance_(dist), + hit_(hit), eligibleMiss_(eligibleMiss) {} - //- Construct from point. Hit and distance set later - PointHit(const Point& p) - : - hit_(false), - hitPoint_(p), - distance_(GREAT), - eligibleMiss_(false) - {} - // Member Functions - // Access + // Access //- Is there a hit - bool hit() const + bool hit() const noexcept { return hit_; } - //- Return hit point - const Point& hitPoint() const + //- Is this an eligible miss + bool eligibleMiss() const noexcept { - if (!hit_) - { - FatalErrorInFunction - << "requested a hit point for a miss" - << abort(FatalError); - } + return eligibleMiss_; + } - return hitPoint_; + //- Return the point, no checks + const point_type& point() const noexcept + { + return point_; } //- Return distance to hit - scalar distance() const + scalar distance() const noexcept { return distance_; } - //- Return miss point - const Point& missPoint() const + //- Return the hit point. Fatal if not hit. + const point_type& hitPoint() const { - if (hit_) + if (!hit_) { FatalErrorInFunction - << "requested a miss point for a hit" + << "Requested a hit point, but it was not hit" << abort(FatalError); } - return hitPoint_; + return point_; } - //- Return point with no checking - const Point& rawPoint() const + //- Return the miss point. Fatal if hit. + const point_type& missPoint() const { - return hitPoint_; + if (hit_) + { + FatalErrorInFunction + << "Requested a miss point, but it was hit" + << abort(FatalError); + } + + return point_; } - //- Is this an eligible miss - bool eligibleMiss() const + //- The point, no checks + // \deprecated(2020-10) use point() + const point_type& rawPoint() const noexcept { - return eligibleMiss_; + return point_; } - // Edit - void setHit() + // Edit + + //- Set the hit status \em on + void setHit() noexcept { hit_ = true; eligibleMiss_ = false; } - void setMiss(const bool eligible) + //- Set the hit status \em off and set the eligible miss status + void setMiss(const bool eligible) noexcept { hit_ = false; eligibleMiss_ = eligible; } - void setPoint(const Point& p) + //- Set the point + void setPoint(const point_type& p) { - hitPoint_ = p; + point_ = p; } - void setDistance(const scalar d) + //- Set the distance + void setDistance(const scalar d) noexcept { distance_ = d; } - // Ostream operator + // Member Operators - friend Ostream& operator<< <Point> - ( - Ostream& os, - const PointHit<Point>& b - ); + //- Distance comparision operator, for sorting + template<class AnyPointType> + bool operator<(const PointHit<AnyPointType>& rhs) const noexcept + { + return distance_ < rhs.distance_; + } }; -template<class Point> -inline Ostream& operator<<(Ostream& os, const PointHit<Point>& b) +// Ostream Operator + +template<class PointType> +inline Ostream& operator<<(Ostream& os, const PointHit<PointType>& pHit) { - os << b.hit() << token::SPACE - << b.rawPoint() << token::SPACE - << b.distance() << token::SPACE - << b.eligibleMiss(); + os << pHit.hit() << token::SPACE + << pHit.point() << token::SPACE + << pHit.distance() << token::SPACE + << pHit.eligibleMiss(); return os; } diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointIndexHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointIndexHit.H index 5a6b47abade..5cc86d3e61a 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointIndexHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointIndexHit.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,20 +49,29 @@ SourceFiles namespace Foam { +// Forward Declarations +template<class PointType> class PointIndexHit; + +template<class PointType> +inline Istream& operator>>(Istream& is, PointIndexHit<PointType>& pHit); + +template<class PointType> +inline Ostream& operator<<(Ostream& os, const PointIndexHit<PointType>& pHit); + /*---------------------------------------------------------------------------*\ Class PointIndexHit Declaration \*---------------------------------------------------------------------------*/ -template<class Point> +template<class PointType> class PointIndexHit { - // Private data + // Private Data //- Hit success bool hit_; //- Point of hit; invalid for misses - Point hitPoint_; + PointType point_; //- Label of face hit label index_; @@ -69,34 +79,45 @@ class PointIndexHit public: + // Public Typedefs + + //- The point type + typedef PointType point_type; + + // Constructors - //- Construct from components - PointIndexHit(const bool success, const Point& p, const label index) + //- Default construct. A zero point, with no hit and index = -1 + PointIndexHit() : - hit_(success), - hitPoint_(p), - index_(index) + hit_(false), + point_(Zero), + index_(-1) {} - //- Construct from point. Hit and distance set later - PointIndexHit(const Point& p) + //- Construct from a point, with no hit and index = -1 + explicit PointIndexHit(const point_type& p) : hit_(false), - hitPoint_(p), + point_(p), index_(-1) {} - //- Construct null - PointIndexHit() + //- Construct from components + PointIndexHit + ( + const bool success, + const point_type& p, + const label index + ) : - hit_(false), - hitPoint_(Zero), - index_(-1) + hit_(success), + point_(p), + index_(index) {} //- Construct from Istream - PointIndexHit(Istream& is) + explicit PointIndexHit(Istream& is) { is >> *this; } @@ -104,106 +125,142 @@ public: // Member Functions - //- Is there a hit - bool hit() const + // Access + + //- Is there a hit? + bool hit() const noexcept { return hit_; } - //- Return index - label index() const + //- Return the hit index + label index() const noexcept { return index_; } - //- Return hit point - const Point& hitPoint() const + //- Return point, no checks + const point_type& point() const noexcept + { + return point_; + } + + //- Access the point, no checks + point_type& point() noexcept + { + return point_; + } + + //- Return hit point. Fatal if not hit. + const point_type& hitPoint() const { if (!hit_) { FatalErrorInFunction - << "requested a hit point for a miss" + << "Requested a hit point, but it was not hit" << abort(FatalError); } - - return hitPoint_; + return point_; } - //- Return miss point - const Point& missPoint() const + //- Return miss point. Fatal if hit. + const point_type& missPoint() const { if (hit_) { FatalErrorInFunction - << "requested a miss point for a hit" + << "Requested a miss point, but it was hit" << abort(FatalError); } - - return hitPoint_; + return point_; } - //- Return point with no checking - const Point& rawPoint() const + //- The point, no checks. Same as point() + const point_type& rawPoint() const noexcept { - return hitPoint_; + return point_; } - Point& rawPoint() + //- The point, no checks. Same as point() + point_type& rawPoint() noexcept { - return hitPoint_; + return point_; } - void setHit() + + // Edit + + //- Set the hit status \em on + void setHit() noexcept { hit_ = true; } - void setMiss() + //- Set the hit status \em off + void setMiss() noexcept { hit_ = false; } - void setPoint(const Point& p) + //- Set the point + void setPoint(const point_type& p) { - hitPoint_ = p; + point_ = p; } - void setIndex(const label index) + //- Set the index + void setIndex(const label index) noexcept { index_ = index; } - bool operator==(const PointIndexHit& rhs) const + //- Set the point as \em hit and the hit-index + void hitPoint(const point_type& p, const label index) { - return - hit_ == rhs.hit() - && hitPoint_ == rhs.rawPoint() - && index_ == rhs.index(); + point_ = p; + hit_ = true; + index_ = index; } - bool operator!=(const PointIndexHit& rhs) const + + // Write + + void write(Ostream& os) { - return !operator==(rhs); + os << (hit_ ? "hit:" : "miss:") + << point_ << " index:" << index_; } - void write(Ostream& os) + + // Member Operators + + //- Test for equality of all components + bool operator==(const PointIndexHit& rhs) const { - if (hit()) - { - os << "hit:" << hitPoint() << " index:" << index(); - } - else - { - os << "miss:" << missPoint() << " index:" << index(); - } + return + ( + hit_ == rhs.hit_ + && index_ == rhs.index_ + && point_ == rhs.point_ + ); + } + + //- Test for inequality of components + bool operator!=(const PointIndexHit& rhs) const + { + return !(*this == rhs); } - friend Ostream& operator<< (Ostream& os, const PointIndexHit& pHit) + + // IO Operators + + friend Ostream& operator<<(Ostream& os, const PointIndexHit& pHit) { if (os.format() == IOstream::ASCII) { - os << pHit.hit_ << token::SPACE << pHit.hitPoint_ - << token::SPACE << pHit.index_; + os << pHit.hit_ << token::SPACE + << pHit.point_ << token::SPACE + << pHit.index_; } else { @@ -223,7 +280,7 @@ public: { if (is.format() == IOstream::ASCII) { - return is >> pHit.hit_ >> pHit.hitPoint_ >> pHit.index_; + return is >> pHit.hit_ >> pHit.point_ >> pHit.index_; } else { @@ -241,7 +298,6 @@ public: is.check(FUNCTION_NAME); return is; } - }; diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H index 8b665e4bab7..e4217a08852 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +29,7 @@ Class Description This class describes a combination of target object index and success flag. + Behaves somewhat like std::optional \*---------------------------------------------------------------------------*/ @@ -49,72 +50,87 @@ namespace Foam class objectHit { - // Private data + // Private Data //- Hit success bool hit_; - //- Object of hit - label hitObject_; + //- The hit object index + label index_; public: // Constructors - //- Construct null - objectHit() + //- Default construct. Nothing hit and object = -1 + constexpr objectHit() noexcept : hit_(false), - hitObject_(-1) + index_(-1) {} //- Construct from components - objectHit(const bool success, const label obj) + objectHit(const bool success, const label index) noexcept : hit_(success), - hitObject_(obj) + index_(index) {} //- Construct from Istream - objectHit(Istream& is) + explicit objectHit(Istream& is) : hit_(readBool(is)), - hitObject_(readLabel(is)) + index_(readLabel(is)) {} // Member Functions - // Access + // Access - //- Is there a hit - inline bool hit() const + //- Is there a hit? + bool hit() const noexcept { return hit_; } - //- Return hit object - inline label hitObject() const + //- Return the hit object index + label index() const noexcept { - return hitObject_; + return index_; } + //- Identical to index() + label hitObject() const noexcept + { + return index_; + } + + + // Edit - // Edit + //- Reset to default construct state + void reset() noexcept + { + hit_ = false; + index_ = -1; + } - void setHit() + //- Set the hit status \em on + void setHit() noexcept { hit_ = true; } - void setMiss() + //- Set the hit status \em off + void setMiss() noexcept { hit_ = false; } - // Ostream operator + // Ostream Operator inline friend Ostream& operator<<(Ostream& os, const objectHit& obj) { diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/point2DHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/point2DHit.H deleted file mode 100644 index 9d083cdcfb5..00000000000 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/point2DHit.H +++ /dev/null @@ -1,50 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Typedef - Foam::point2DHit - -Description - -\*---------------------------------------------------------------------------*/ - -#ifndef point2DHit_H -#define point2DHit_H - -#include "point2D.H" -#include "PointHit.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef PointHit<point2D> point2DHit; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHit.H index 97473f58615..2abae313e7b 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHit.H @@ -27,6 +27,7 @@ Typedef Foam::pointHit Description + A PointIndexHit for 3D points. \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHitSort.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHitSort.H deleted file mode 100644 index a01c2a972b0..00000000000 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHitSort.H +++ /dev/null @@ -1,117 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::pointHitSort - -Description - Container for sorting intersections - -SourceFiles - -\*---------------------------------------------------------------------------*/ - -#ifndef pointHitSort_H -#define pointHitSort_H - -#include "pointHit.H" -#include "label.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declaration of classes - -/*---------------------------------------------------------------------------*\ - Class pointHitSort Declaration -\*---------------------------------------------------------------------------*/ - -class pointHitSort -{ - // Private data - - //- intersection - pointHit inter_; - - //- Original index - label index_; - -public: - - // Constructors - - //- Construct null - pointHitSort() - : - inter_(false, Zero, GREAT, false), - index_(-1) - {} - - //- Construct from intersection, index - pointHitSort(const pointHit& inter, const label index) - : - inter_(inter), - index_(index) - {} - - - // Member Functions - - const pointHit& inter() const - { - return inter_; - } - - label index() const - { - return index_; - } - - // Member Operators - - bool operator==(const pointHitSort& rhs) const - { - return inter_.distance() == rhs.inter().distance(); - } - - bool operator<(const pointHitSort& rhs) const - { - return inter_.distance() < rhs.inter().distance(); - } - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHit.H index fb42bb8837b..08a9a28e05e 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHit.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,7 @@ Typedef Foam::pointIndexHit Description + A PointIndexHit for 3D points. \*---------------------------------------------------------------------------*/ diff --git a/src/meshTools/triSurface/surfaceLocation/surfaceLocation.C b/src/meshTools/triSurface/surfaceLocation/surfaceLocation.C index cda9933fda8..a8eb28fb104 100644 --- a/src/meshTools/triSurface/surfaceLocation/surfaceLocation.C +++ b/src/meshTools/triSurface/surfaceLocation/surfaceLocation.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,16 +49,18 @@ Foam::vector Foam::surfaceLocation::normal(const triSurface& s) const } else { + // Average edge normal vector edgeNormal(Zero); - forAll(eFaces, i) + for (const label facei : eFaces) { - edgeNormal += n[eFaces[i]]; + edgeNormal += n[facei]; } + return edgeNormal/(mag(edgeNormal) + VSMALL); } } - else + else // triPointRef::POINT { return s.pointNormals()[index()]; } @@ -78,7 +81,7 @@ void Foam::surfaceLocation::write(Ostream& os, const triSurface& s) const os << "edgecoords:" << e.line(s.localPoints()); } - else + else // triPointRef::POINT { os << "pointcoord:" << s.localPoints()[index()]; } @@ -90,6 +93,7 @@ Foam::Istream& Foam::operator>>(Istream& is, surfaceLocation& sl) label elType; is >> static_cast<pointIndexHit&>(sl) >> elType >> sl.triangle_; + sl.elementType_ = triPointRef::proxType(elType); return is; } @@ -112,25 +116,24 @@ Foam::Ostream& Foam::operator<< { const surfaceLocation& sl = ip.t_; + os << "coord:" << sl.point(); + if (sl.elementType() == triPointRef::NONE) { - os << "coord:" << sl.rawPoint() - << " inside triangle:" << sl.index() - << " excludeTriangle:" << sl.triangle(); + os << " inside triangle:"; } else if (sl.elementType() == triPointRef::EDGE) { - os << "coord:" << sl.rawPoint() - << " on edge:" << sl.index() - << " excludeTriangle:" << sl.triangle(); + os << " on edge:"; } - else + else // triPointRef::POINT { - os << "coord:" << sl.rawPoint() - << " on point:" << sl.index() - << " excludeTriangle:" << sl.triangle(); + os << " on point:"; } + os << sl.index() + << " excludeTriangle:" << sl.triangle(); + if (sl.hit()) { os << " (hit)"; diff --git a/src/meshTools/triSurface/surfaceLocation/surfaceLocation.H b/src/meshTools/triSurface/surfaceLocation/surfaceLocation.H index 1009ed31c8f..8e97cff8d4f 100644 --- a/src/meshTools/triSurface/surfaceLocation/surfaceLocation.H +++ b/src/meshTools/triSurface/surfaceLocation/surfaceLocation.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,39 +57,34 @@ SourceFiles namespace Foam { -// Forward declaration of classes -class triSurface; - - -// Forward declaration of friend functions and operators - +// Forward Declarations class surfaceLocation; +class triSurface; Istream& operator>>(Istream&, surfaceLocation&); Ostream& operator<<(Ostream&, const surfaceLocation&); Ostream& operator<<(Ostream&, const InfoProxy<surfaceLocation>&); - /*---------------------------------------------------------------------------*\ - Class surfaceLocation Declaration + Class surfaceLocation Declaration \*---------------------------------------------------------------------------*/ class surfaceLocation : public pointIndexHit { - // Private data + // Private Data triPointRef::proxType elementType_; label triangle_; -public: +public: // Constructors - //- Construct null + //- Default construct surfaceLocation() : pointIndexHit(), @@ -99,18 +95,18 @@ public: //- Construct from components surfaceLocation ( - const pointIndexHit& pih, + const pointIndexHit& pHit, const triPointRef::proxType elementType, const label triangle ) : - pointIndexHit(pih), + pointIndexHit(pHit), elementType_(elementType), triangle_(triangle) {} //- Construct from Istream - surfaceLocation(Istream& is) + explicit surfaceLocation(Istream& is) : pointIndexHit(is), elementType_(triPointRef::proxType(readLabel(is))), @@ -120,22 +116,22 @@ public: // Member Functions - triPointRef::proxType& elementType() + triPointRef::proxType& elementType() noexcept { return elementType_; } - triPointRef::proxType elementType() const + triPointRef::proxType elementType() const noexcept { return elementType_; } - label& triangle() + label& triangle() noexcept { return triangle_; } - label triangle() const + label triangle() const noexcept { return triangle_; } @@ -143,14 +139,13 @@ public: //- Normal. Approximate for points. vector normal(const triSurface& s) const; - //- Return info proxy. - // Used to print token information to a stream + //- Return info proxy, to print information to a stream InfoProxy<surfaceLocation> info() const { return *this; } - //- Write info to os + //- Write info about selected face index to a stream void write(Ostream& os, const triSurface& s) const; @@ -162,8 +157,8 @@ public: friend Ostream& operator<< ( - Ostream&, - const InfoProxy<surfaceLocation>& + Ostream& os, + const InfoProxy<surfaceLocation>& ip ); }; -- GitLab