Skip to content

Commit

Permalink
patchkernel: allow to check if an adjacency was added to the given fa…
Browse files Browse the repository at this point in the history
…ce of a cell
  • Loading branch information
andrea-iob committed Jun 5, 2021
1 parent fa554a5 commit 3cf98cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/patchkernel/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,18 +630,27 @@ void Cell::setAdjacency(int face, int index, long adjacency)
/*!
Add an adjacency to the given face of the cell.
Before adding the adjacency a check is performed to avoid adding duplicate
adjacencies. The adjacency will not be added if the face already contains
it.
\param face is the face of the cell
\param adjacency is the index of the adjacency that will be added
\result Returns true if the adjacency has been added, false if the
adjacency has not been added because the face already contained it.
*/
void Cell::pushAdjacency(int face, long adjacency)
bool Cell::pushAdjacency(int face, long adjacency)
{
// Do not push an existing adjacency
if (findAdjacency(face, adjacency) >= 0) {
return;
return false;
}

// Add the adjacency
m_adjacencies.pushBackItem(face, adjacency);

// Done
return true;
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion src/patchkernel/cell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ friend bitpit::IBinaryStream& (::operator>>) (bitpit::IBinaryStream& buf, Cell&
void setAdjacencies(const std::vector<std::vector<long>> &adjacencies);
void setAdjacencies(FlatVector2D<long> &&adjacencies);
void setAdjacency(int face, int index, long adjacencies);
void pushAdjacency(int face, long adjacency);
bool pushAdjacency(int face, long adjacency);
void deleteAdjacency(int face, int i);
int getAdjacencyCount() const;
int getAdjacencyCount(int face) const;
Expand Down

0 comments on commit 3cf98cd

Please sign in to comment.