Commit 0d5283a6 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: added edge::valid() method

- simple check for unique and non-negative point labels
parent 0e8704de
......@@ -134,6 +134,9 @@ public:
// No special handling of negative point labels.
inline label maxVertex() const;
//- Return true if the vertices are unique and non-negative.
inline bool valid() const;
//- Return true if point label is found in edge.
// Always false for a negative label.
inline bool found(const label pointLabel) const;
......@@ -146,19 +149,19 @@ public:
// Negative point labels never connect.
inline bool connects(const edge& other) const;
//- Return vertex common with otherEdge or -1 on failure
//- Return vertex common with other edge or -1 on failure
// Negative point labels are never considered common between edges.
inline label commonVertex(const edge& other) const;
//- Given one vertex index, return the other one.
//- Given the point label for one vertex, return the other one.
// No special treatment for negative point labels.
inline label otherVertex(const label index) const;
inline label otherVertex(const label pointLabel) const;
// Editing
//- 'Collapse' edge by marking duplicate point labels as '-1',
// the lower vertex is retained.
//- the lower vertex is retained.
// Return the effective size after collapsing.
inline label collapse();
......@@ -114,6 +114,12 @@ inline Foam::label Foam::edge::maxVertex() const
inline bool Foam::edge::valid() const
return (first() != second() && first() >= 0 && second() >= 0);
inline bool Foam::edge::found(const label pointLabel) const
// -1: always false
......@@ -166,13 +172,13 @@ inline Foam::label Foam::edge::commonVertex(const edge& other) const
inline Foam::label Foam::edge::otherVertex(const label index) const
inline Foam::label Foam::edge::otherVertex(const label pointLabel) const
if (index == first())
if (pointLabel == first())
return second();
if (index == second())
if (pointLabel == second())
return first();
Supports Markdown
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