modernize ComputeNVertices

This commit is contained in:
Joachim Schöberl 2019-03-30 14:02:38 +01:00
parent 784fad9806
commit f6a290e44f
2 changed files with 9 additions and 24 deletions

View File

@ -5817,34 +5817,17 @@ namespace netgen
void Mesh :: ComputeNVertices ()
{
int i, j, nv;
int ne = GetNE();
// int nse = GetNSE();
numvertices = 0;
for (i = 1; i <= ne; i++)
{
const Element & el = VolumeElement(i);
nv = el.GetNV();
for (j = 0; j < nv; j++)
if (el[j] > numvertices)
numvertices = el[j];
}
/*
for (i = 1; i <= nse; i++)
{
const Element2d & el = SurfaceElement(i);
nv = el.GetNV();
for (j = 1; j <= nv; j++)
if (el.PNum(j) > numvertices)
numvertices = el.PNum(j);
}
*/
for (auto & el : SurfaceElements())
for (const Element & el : VolumeElements())
for (PointIndex v : el.Vertices())
if (v > numvertices) numvertices = v;
for (const Element2d & el : SurfaceElements())
for (PointIndex v : el.Vertices())
if (v > numvertices) numvertices = v;
numvertices += 1- PointIndex::BASE;
numvertices += 1-PointIndex::BASE;
}
int Mesh :: GetNV () const

View File

@ -751,6 +751,8 @@ namespace netgen
FlatArray<const PointIndex> PNums () const
{ return FlatArray<const PointIndex> (np, &pnum[0]); }
FlatArray<const PointIndex> Vertices() const { return { GetNV(), &pnum[0] }; }
///
PointIndex & PNum (int i) { return pnum[i-1]; }
///