Commit 9cb6338c authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

STYLE: declare edge::operator[]

- already available from the FixedList inheritance, but provide
  explicitly in edge to allow future adjustment of the inheritance
  (#1205)
parent 041be829
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
......@@ -168,7 +168,7 @@ public:
inline label collapse();
// Hash-like functions
// Hash-like Functions
//- Return the number of unique, valid (non -1) point labels.
// Similar to a HashTable::size().
......@@ -233,7 +233,7 @@ public:
inline label erase(const labelUList& list);
// Geometric functions
// Geometric Functions
//- Return centre point (centroid) of the edge.
// No special handling of negative point labels.
......@@ -266,6 +266,15 @@ public:
static inline int compare(const edge& a, const edge& b);
// Member Operators
//- Return edge element. Index should be limited to 0/1.
inline label& operator[](const label i);
//- Return constant edge element. Index should be limited to 0/1.
inline const label& operator[](const label i) const;
// Hashing
//- The (commutative) hash-value for edge
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
......@@ -457,6 +457,34 @@ inline Foam::linePointRef Foam::edge::line(const UList<point>& pts) const
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline Foam::label& Foam::edge::operator[](const label i)
{
#ifdef FULLDEBUG
if (i < 0 || i > 1)
{
FatalErrorInFunction
<< "Index " << i << " out of range [0,1]" << abort(FatalError);
}
#endif
return (i ? second() : first());
}
inline const Foam::label& Foam::edge::operator[](const label i) const
{
#ifdef FULLDEBUG
if (i < 0 || i > 1)
{
FatalErrorInFunction
<< "Index " << i << " out of range [0,1]" << abort(FatalError);
}
#endif
return (i ? second() : first());
}
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
inline bool Foam::operator==(const edge& a, const edge& b)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment