diff --git a/libsrc/core/array.hpp b/libsrc/core/array.hpp index e1aabdc1..36ae9fb9 100644 --- a/libsrc/core/array.hpp +++ b/libsrc/core/array.hpp @@ -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 & a2) { diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 32402d43..e6865d50 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -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; } diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index fcb78f0c..dc297506 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -97,19 +97,22 @@ namespace netgen -#define MULTIPOINTGEOMINFO_MAX 100 class MultiPointGeomInfo { - int cnt; - PointGeomInfo mgi[MULTIPOINTGEOMINFO_MAX]; + ArrayMem 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; };