mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: relocate some friend operations to be global ones
This commit is contained in:
@ -71,7 +71,7 @@ Enum Foam::NamedEnum<Enum, nEnum>::read(Istream& is) const
|
||||
<< sortedToc() << exit(FatalIOError);
|
||||
}
|
||||
|
||||
return Enum(*iter);
|
||||
return Enum(iter.object());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -50,11 +50,8 @@ namespace Foam
|
||||
class boundBox;
|
||||
template<class T> class tmp;
|
||||
|
||||
bool operator==(const boundBox&, const boundBox&);
|
||||
bool operator!=(const boundBox&, const boundBox&);
|
||||
|
||||
Istream& operator>>(Istream&, boundBox&);
|
||||
Ostream& operator<<(Ostream&, const boundBox&);
|
||||
Istream& operator>>(Istream& is, boundBox& bb);
|
||||
Ostream& operator<<(Ostream& os, const boundBox& bb);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -289,12 +286,6 @@ public:
|
||||
inline void operator+=(const boundBox& bb);
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
inline friend bool operator==(const boundBox& a, const boundBox& b);
|
||||
inline friend bool operator!=(const boundBox& a, const boundBox& b);
|
||||
|
||||
|
||||
// IOstream operator
|
||||
|
||||
friend Istream& operator>>(Istream& is, boundBox& bb);
|
||||
@ -306,6 +297,11 @@ public:
|
||||
template<>
|
||||
inline bool contiguous<boundBox>() {return contiguous<point>();}
|
||||
|
||||
// Global Operators
|
||||
|
||||
inline bool operator==(const boundBox& a, const boundBox& b);
|
||||
inline bool operator!=(const boundBox& a, const boundBox& b);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -268,11 +268,11 @@ inline void Foam::boundBox::operator+=(const boundBox& bb)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::operator==(const boundBox& a, const boundBox& b)
|
||||
{
|
||||
return (a.min_ == b.min_) && (a.max_ == b.max_);
|
||||
return (a.min() == b.min()) && (a.max() == b.max());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ inline Foam::label Foam::cell::nFaces() const
|
||||
|
||||
inline bool Foam::operator!=(const cell& a, const cell& b)
|
||||
{
|
||||
return (!(a == b));
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ Ostream& operator<<(Ostream& os, const cellModel& c);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellModel Declaration
|
||||
Class cellModel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellModel
|
||||
@ -122,13 +122,13 @@ public:
|
||||
inline label nFaces() const;
|
||||
|
||||
//- Return list of edges
|
||||
inline edgeList edges(const labelList& pointLabels) const;
|
||||
inline edgeList edges(const UList<label>& pointLabels) const;
|
||||
|
||||
//- Return a raw list of model faces
|
||||
inline const faceList& modelFaces() const;
|
||||
|
||||
//- Return list of faces
|
||||
inline faceList faces(const labelList& pointLabels) const;
|
||||
inline faceList faces(const UList<label>& pointLabels) const;
|
||||
|
||||
|
||||
//- Vector centroid
|
||||
|
||||
@ -21,45 +21,38 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
#include "cellModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const word& cellModel::name() const
|
||||
inline const Foam::word& Foam::cellModel::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
inline label cellModel::index() const
|
||||
inline Foam::label Foam::cellModel::index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
|
||||
inline label cellModel::nPoints() const
|
||||
inline Foam::label Foam::cellModel::nPoints() const
|
||||
{
|
||||
return nPoints_;
|
||||
}
|
||||
|
||||
|
||||
inline label cellModel::nEdges() const
|
||||
inline Foam::label Foam::cellModel::nEdges() const
|
||||
{
|
||||
return edges_.size();
|
||||
}
|
||||
|
||||
|
||||
inline label cellModel::nFaces() const
|
||||
inline Foam::label Foam::cellModel::nFaces() const
|
||||
{
|
||||
return faces_.size();
|
||||
}
|
||||
@ -67,7 +60,10 @@ inline label cellModel::nFaces() const
|
||||
|
||||
// Return the faces of a cellModel by untangling the geometry
|
||||
// supplied in terms of the face labels
|
||||
inline edgeList cellModel::edges(const labelList& pointLabels) const
|
||||
inline Foam::edgeList Foam::cellModel::edges
|
||||
(
|
||||
const UList<label>& pointLabels
|
||||
) const
|
||||
{
|
||||
edgeList e(edges_.size());
|
||||
|
||||
@ -86,7 +82,7 @@ inline edgeList cellModel::edges(const labelList& pointLabels) const
|
||||
}
|
||||
|
||||
|
||||
inline const faceList& cellModel::modelFaces() const
|
||||
inline const Foam::faceList& Foam::cellModel::modelFaces() const
|
||||
{
|
||||
return faces_;
|
||||
}
|
||||
@ -94,7 +90,10 @@ inline const faceList& cellModel::modelFaces() const
|
||||
|
||||
// Return the faces of a cellModel by untangling the geometry
|
||||
// supplied in terms of the face labels
|
||||
inline faceList cellModel::faces(const labelList& pointLabels) const
|
||||
inline Foam::faceList Foam::cellModel::faces
|
||||
(
|
||||
const UList<label>& pointLabels
|
||||
) const
|
||||
{
|
||||
faceList f(faces_.size());
|
||||
|
||||
@ -120,20 +119,16 @@ inline faceList cellModel::faces(const labelList& pointLabels) const
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// Equality operator: true => ptr to models are equal !
|
||||
inline bool operator==(const cellModel& m1, const cellModel& m2)
|
||||
inline bool Foam::operator==(const cellModel& m1, const cellModel& m2)
|
||||
{
|
||||
return (&m1 == &m2);
|
||||
}
|
||||
|
||||
// Inequality operator: true => ptr to models are not equal !
|
||||
inline bool operator!=(const cellModel& m1, const cellModel& m2)
|
||||
inline bool Foam::operator!=(const cellModel& m1, const cellModel& m2)
|
||||
{
|
||||
return (&m1 != &m2);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -34,7 +34,7 @@ Description
|
||||
Valid point labels are always non-negative (since they correspond to
|
||||
addressing within the mesh). The value '-1' is used to tag invalid
|
||||
point labels that correspond conceptually to open 'slots', which
|
||||
can be filled with the HashSet-like functionality.
|
||||
can be filled with a HashSet-like functionality.
|
||||
|
||||
SourceFiles
|
||||
edgeI.H
|
||||
@ -53,15 +53,8 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class edge;
|
||||
inline bool operator==(const edge& a, const edge& b);
|
||||
inline bool operator!=(const edge& a, const edge& b);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class edge Declaration
|
||||
Class edge Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class edge
|
||||
@ -266,18 +259,22 @@ public:
|
||||
//- Compare edges
|
||||
// Returns:
|
||||
// - 0: different
|
||||
// - +1: identical
|
||||
// - -1: same edge, but different orientation
|
||||
// - +1: identical values and order used
|
||||
// - -1: identical values, but in different order
|
||||
static inline int compare(const edge& a, const edge& b);
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
friend bool operator==(const edge& a, const edge& b);
|
||||
friend bool operator!=(const edge& a, const edge& b);
|
||||
};
|
||||
|
||||
|
||||
// Global Operators
|
||||
|
||||
//- Compare edges for equal content, ignoring orientation
|
||||
inline bool operator==(const edge& a, const edge& b);
|
||||
|
||||
//- Compare edges for non-equal content, ignoring orientation
|
||||
inline bool operator!=(const edge& a, const edge& b);
|
||||
|
||||
|
||||
//- Hash specialization for hashing edges - a commutative hash value.
|
||||
// Hash incrementally.
|
||||
template<>
|
||||
|
||||
@ -451,7 +451,7 @@ inline Foam::linePointRef Foam::edge::line(const UList<point>& pts) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::operator==(const edge& a, const edge& b)
|
||||
{
|
||||
|
||||
@ -65,8 +65,6 @@ class triFace;
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
class DynamicList;
|
||||
|
||||
inline bool operator==(const face& a, const face& b);
|
||||
inline bool operator!=(const face& a, const face& b);
|
||||
inline Istream& operator>>(Istream& is, face& f);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -382,12 +380,6 @@ public:
|
||||
static bool sameVertices(const face& a, const face& b);
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
friend bool operator==(const face& a, const face& b);
|
||||
friend bool operator!=(const face& a, const face& b);
|
||||
|
||||
|
||||
// Istream Operator
|
||||
|
||||
friend Istream& operator>>(Istream& is, face& f);
|
||||
@ -418,6 +410,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Global operators
|
||||
inline bool operator==(const face& a, const face& b);
|
||||
inline bool operator!=(const face& a, const face& b);
|
||||
|
||||
|
||||
// Global functions
|
||||
|
||||
//- Find the longest edge on a face. Face point labels index into pts.
|
||||
|
||||
@ -135,14 +135,14 @@ inline Foam::label Foam::face::nTriangles() const
|
||||
return size() - 2;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::operator==(const face& a, const face& b)
|
||||
{
|
||||
return face::compare(a,b) != 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::operator!=(const face& a, const face& b)
|
||||
{
|
||||
return face::compare(a,b) == 0;
|
||||
|
||||
@ -162,8 +162,7 @@ inline Foam::Ostream& Foam::operator<<(Ostream& os, const labelledTri& t)
|
||||
}
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("Ostream& operator<<(Ostream&, const labelledTri&)");
|
||||
|
||||
os.check(FUNCTION_NAME);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -229,13 +229,16 @@ public:
|
||||
// - -1: same face, but different orientation
|
||||
static inline int compare(const triFace& a, const triFace& b);
|
||||
|
||||
// Friend Operators
|
||||
|
||||
inline friend bool operator==(const triFace& a, const triFace& b);
|
||||
inline friend bool operator!=(const triFace& a, const triFace& b);
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
inline bool contiguous<triFace>() {return true;}
|
||||
|
||||
inline bool operator==(const triFace& a, const triFace& b);
|
||||
inline bool operator!=(const triFace& a, const triFace& b);
|
||||
|
||||
|
||||
//- Hash specialization for hashing triFace - a commutative hash value.
|
||||
// Hash incrementally.
|
||||
template<>
|
||||
@ -260,10 +263,6 @@ inline unsigned Hash<triFace>::operator()(const triFace& t) const
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
inline bool contiguous<triFace>() {return true;}
|
||||
|
||||
|
||||
//- Hash specialization to offset faces in ListListOps::combineOffset
|
||||
template<>
|
||||
class offsetOp<triFace>
|
||||
|
||||
@ -377,7 +377,7 @@ inline int Foam::triFace::edgeDirection(const edge& e) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::operator==(const triFace& a, const triFace& b)
|
||||
{
|
||||
|
||||
@ -84,31 +84,18 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Is there a hit
|
||||
bool hit() const
|
||||
inline bool hit() const
|
||||
{
|
||||
return hit_;
|
||||
}
|
||||
|
||||
//- Return hit object
|
||||
label hitObject() const
|
||||
inline label hitObject() const
|
||||
{
|
||||
return hitObject_;
|
||||
}
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
inline friend bool operator==(const objectHit& a, const objectHit& b)
|
||||
{
|
||||
return (a.hit_ == b.hit_) && (a.hitObject_ == b.hitObject_);
|
||||
}
|
||||
|
||||
inline friend bool operator!=(const objectHit& a, const objectHit& b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
// Ostream operator
|
||||
|
||||
inline friend Ostream& operator<<(Ostream& os, const objectHit& obj)
|
||||
@ -118,6 +105,20 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Global Operators
|
||||
|
||||
inline bool operator==(const objectHit& a, const objectHit& b)
|
||||
{
|
||||
return a.hit() == b.hit() && a.hitObject() == b.hitObject();
|
||||
}
|
||||
|
||||
|
||||
inline bool operator!=(const objectHit& a, const objectHit& b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -487,14 +487,14 @@ void Foam::plane::writeDict(Ostream& os) const
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::operator==(const plane& a, const plane& b)
|
||||
{
|
||||
return (a.point_ == b.point_ && a.normal_ == b.normal_);
|
||||
return (a.refPoint() == b.refPoint() && a.normal() == b.normal());
|
||||
}
|
||||
|
||||
|
||||
bool Foam::operator!=(const plane& a, const plane& b)
|
||||
{
|
||||
return !(a == b);
|
||||
|
||||
@ -49,8 +49,6 @@ namespace Foam
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class plane;
|
||||
bool operator==(const plane& a, const plane& b);
|
||||
bool operator!=(const plane& a, const plane& b);
|
||||
Ostream& operator<<(Ostream& os, const plane& pln);
|
||||
|
||||
|
||||
@ -193,7 +191,7 @@ public:
|
||||
|
||||
//- Return the cutting line between this plane and another.
|
||||
// Returned as direction vector and point line goes through.
|
||||
ray planeIntersect(const plane&) const;
|
||||
ray planeIntersect(const plane& plane2) const;
|
||||
|
||||
//- Return the cutting point between this plane and two other planes
|
||||
point planePlaneIntersect
|
||||
@ -217,12 +215,6 @@ public:
|
||||
void writeDict(Ostream& os) const;
|
||||
|
||||
|
||||
// friend Operators
|
||||
|
||||
friend bool operator==(const plane& a, const plane& b);
|
||||
friend bool operator!=(const plane& a, const plane& b);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
//- Write plane properties
|
||||
@ -231,6 +223,12 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Global Operators
|
||||
|
||||
bool operator==(const plane& a, const plane& b);
|
||||
bool operator!=(const plane& a, const plane& b);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -555,24 +555,6 @@ Foam::label Foam::treeBoundBox::distanceCmp
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::operator==(const treeBoundBox& a, const treeBoundBox& b)
|
||||
{
|
||||
return operator==
|
||||
(
|
||||
static_cast<const boundBox&>(a),
|
||||
static_cast<const boundBox&>(b)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::operator!=(const treeBoundBox& a, const treeBoundBox& b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const treeBoundBox& bb)
|
||||
|
||||
@ -77,10 +77,6 @@ class Random;
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class treeBoundBox;
|
||||
|
||||
bool operator==(const treeBoundBox& a, const treeBoundBox& b);
|
||||
bool operator!=(const treeBoundBox& a, const treeBoundBox& b);
|
||||
|
||||
Istream& operator>>(Istream& is, treeBoundBox& bb);
|
||||
Ostream& operator<<(Ostream& os, const treeBoundBox& bb);
|
||||
|
||||
@ -340,12 +336,6 @@ public:
|
||||
inline treeBoundBox extend(Random& rndGen, const scalar s) const;
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
friend bool operator==(const treeBoundBox& a, const treeBoundBox& b);
|
||||
friend bool operator!=(const treeBoundBox& a, const treeBoundBox& b);
|
||||
|
||||
|
||||
// IOstream operator
|
||||
|
||||
friend Istream& operator>>(Istream& is, treeBoundBox& bb);
|
||||
@ -358,6 +348,12 @@ template<>
|
||||
inline bool contiguous<treeBoundBox>() {return contiguous<boundBox>();}
|
||||
|
||||
|
||||
// Global Operators
|
||||
|
||||
inline bool operator==(const treeBoundBox& a, const treeBoundBox& b);
|
||||
inline bool operator!=(const treeBoundBox& a, const treeBoundBox& b);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -343,4 +343,17 @@ inline Foam::treeBoundBox Foam::treeBoundBox::extend
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::operator==(const treeBoundBox& a, const treeBoundBox& b)
|
||||
{
|
||||
return static_cast<const boundBox&>(a) == static_cast<const boundBox&>(b);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::operator!=(const treeBoundBox& a, const treeBoundBox& b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -70,9 +70,9 @@ public:
|
||||
}
|
||||
|
||||
//- Construct from FixedList
|
||||
inline Pair(const FixedList<Type, 2>& fl)
|
||||
inline Pair(const FixedList<Type, 2>& lst)
|
||||
:
|
||||
FixedList<Type, 2>(fl)
|
||||
FixedList<Type, 2>(lst)
|
||||
{}
|
||||
|
||||
//- Construct from Istream
|
||||
@ -134,18 +134,20 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Comparison
|
||||
|
||||
//- Compare Pairs
|
||||
// Returning:
|
||||
// Returns:
|
||||
// - 0: different
|
||||
// - +1: identical
|
||||
// - -1: same pair, but reversed order
|
||||
// - +1: identical values and order used
|
||||
// - -1: identical values, but in reversed order
|
||||
static inline int compare(const Pair<Type>& a, const Pair<Type>& b)
|
||||
{
|
||||
if (a == b)
|
||||
if (a[0] == b[0] && a[1] == b[1])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (a == reverse(b))
|
||||
else if (a[0] == b[1] && a[1] == b[0])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -157,6 +159,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Pair<Type> reverse(const Pair<Type>& p)
|
||||
{
|
||||
@ -167,14 +171,14 @@ Pair<Type> reverse(const Pair<Type>& p)
|
||||
template<class Type>
|
||||
bool operator==(const Pair<Type>& a, const Pair<Type>& b)
|
||||
{
|
||||
return (a.first() == b.first() && a.second() == b.second());
|
||||
return Pair<Type>::compare(a,b) != 0;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool operator!=(const Pair<Type>& a, const Pair<Type>& b)
|
||||
{
|
||||
return !(a == b);
|
||||
return Pair<Type>::compare(a,b) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user