Merge branch 'remove_pointgeominfo_limit' into 'master'

Remove limit of max 100 PointGeomInfos, add move assignment to ArrayMem

See merge request jschoeberl/netgen!174
This commit is contained in:
Matthias Hochsteger 2019-07-11 13:21:47 +00:00
commit 39e4e2bc12
3 changed files with 33 additions and 17 deletions

View File

@ -1110,6 +1110,25 @@ namespace ngcore
return *this;
}
ArrayMem & operator= (ArrayMem && a2)
{
if (a2.mem_to_delete)
{
ngcore::Swap (mem_to_delete, a2.mem_to_delete);
ngcore::Swap (data, a2.data);
ngcore::Swap (allocsize, a2.allocsize);
ngcore::Swap (size, a2.size);
}
else
{
allocsize = S;
for (size_t i = 0; i < S; i++)
mem[i] = std::move(a2.mem[i]);
}
return *this;
}
/// array copy
ArrayMem & operator= (const FlatArray<T> & a2)
{

View File

@ -7,18 +7,12 @@ namespace netgen
int MultiPointGeomInfo ::
AddPointGeomInfo (const PointGeomInfo & gi)
{
for (int k = 0; k < cnt; k++)
if (mgi[k].trignum == gi.trignum)
for (auto & pgi : mgi)
if (pgi.trignum == gi.trignum)
return 0;
if (cnt < MULTIPOINTGEOMINFO_MAX)
{
mgi[cnt] = gi;
cnt++;
return 0;
}
throw NgException ("Please report error: MPGI Size too small\n");
mgi.Append(gi);
return 0;
}

View File

@ -97,19 +97,22 @@ namespace netgen
#define MULTIPOINTGEOMINFO_MAX 100
class MultiPointGeomInfo
{
int cnt;
PointGeomInfo mgi[MULTIPOINTGEOMINFO_MAX];
ArrayMem<PointGeomInfo, 100> mgi;
public:
MultiPointGeomInfo () { cnt = 0; }
int AddPointGeomInfo (const PointGeomInfo & gi);
void Init () { cnt = 0; }
void DeleteAll () { cnt = 0; }
void Init () { mgi.SetSize(0); }
void DeleteAll () { mgi.SetSize(0); }
int GetNPGI () const { return cnt; }
int GetNPGI () const { return mgi.Size(); }
const PointGeomInfo & GetPGI (int i) const { return mgi[i-1]; }
MultiPointGeomInfo () = default;
MultiPointGeomInfo (const MultiPointGeomInfo&) = default;
MultiPointGeomInfo (MultiPointGeomInfo &&) = default;
MultiPointGeomInfo & operator= (const MultiPointGeomInfo&) = default;
MultiPointGeomInfo & operator= (MultiPointGeomInfo&&) = default;
};