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

This commit is contained in:
Matthias Hochsteger 2019-07-11 13:21:47 +00:00
parent b16dd0c777
commit ea9fab8c77
3 changed files with 33 additions and 17 deletions

View File

@ -1110,6 +1110,25 @@ namespace ngcore
return *this; 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 /// array copy
ArrayMem & operator= (const FlatArray<T> & a2) ArrayMem & operator= (const FlatArray<T> & a2)
{ {

View File

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

View File

@ -97,19 +97,22 @@ namespace netgen
#define MULTIPOINTGEOMINFO_MAX 100
class MultiPointGeomInfo class MultiPointGeomInfo
{ {
int cnt; ArrayMem<PointGeomInfo, 100> mgi;
PointGeomInfo mgi[MULTIPOINTGEOMINFO_MAX];
public: public:
MultiPointGeomInfo () { cnt = 0; }
int AddPointGeomInfo (const PointGeomInfo & gi); int AddPointGeomInfo (const PointGeomInfo & gi);
void Init () { cnt = 0; } void Init () { mgi.SetSize(0); }
void DeleteAll () { cnt = 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]; } 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;
}; };