Mesh: [skip ci] add method to get all facet indices from given point indices

This commit is contained in:
wmayer
2020-02-04 22:18:02 +01:00
parent 6b387a511c
commit 98fe02e739
2 changed files with 28 additions and 1 deletions

View File

@@ -745,13 +745,38 @@ std::vector<unsigned long> MeshKernel::GetFacetPoints(const std::vector<unsigned
points.push_back(p0);
points.push_back(p1);
points.push_back(p2);
}
}
std::sort(points.begin(), points.end());
points.erase(std::unique(points.begin(), points.end()), points.end());
return points;
}
std::vector<unsigned long> MeshKernel::GetPointFacets(const std::vector<unsigned long>& points) const
{
_aclPointArray.ResetFlag(MeshPoint::TMP0);
_aclFacetArray.ResetFlag(MeshFacet::TMP0);
for (std::vector<unsigned long>::const_iterator pI = points.begin(); pI != points.end(); ++pI)
_aclPointArray[*pI].SetFlag(MeshPoint::TMP0);
// mark facets if at least one corner point is marked
for (MeshFacetArray::_TConstIterator pF = _aclFacetArray.begin(); pF != _aclFacetArray.end(); ++pF) {
const MeshPoint &rclP0 = _aclPointArray[pF->_aulPoints[0]];
const MeshPoint &rclP1 = _aclPointArray[pF->_aulPoints[1]];
const MeshPoint &rclP2 = _aclPointArray[pF->_aulPoints[2]];
if (rclP0.IsFlag(MeshPoint::TMP0) ||
rclP1.IsFlag(MeshPoint::TMP0) ||
rclP2.IsFlag(MeshPoint::TMP0)) {
pF->SetFlag(MeshFacet::TMP0);
}
}
std::vector<unsigned long> facets;
MeshAlgorithm(*this).GetFacetsFlag(facets, MeshFacet::TMP0);
return facets;
}
std::vector<unsigned long> MeshKernel::HasFacets (const MeshPointIterator &rclIter) const
{
unsigned long i, ulPtInd = rclIter.Position();

View File

@@ -125,6 +125,8 @@ public:
unsigned long &rclP1, unsigned long &rclP2) const;
/** Returns the point indices of the given facet indices. */
std::vector<unsigned long> GetFacetPoints(const std::vector<unsigned long>&) const;
/** Returns the facet indices that share the given point indices. */
std::vector<unsigned long> GetPointFacets(const std::vector<unsigned long>&) const;
/** Returns the indices of the neighbour facets of the given facet index. */
inline void GetFacetNeighbours (unsigned long ulIndex, unsigned long &rulNIdx0,
unsigned long &rulNIdx1, unsigned long &rulNIdx2) const;