From 579e5d387418655847769e95701bc552e5bbb096 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 20 Aug 2019 17:59:36 +0200 Subject: [PATCH] Remove BitArrayChar --- libsrc/general/bitarray.cpp | 47 --------------------- libsrc/general/bitarray.hpp | 80 ------------------------------------ libsrc/meshing/adfront3.cpp | 8 ++-- libsrc/meshing/delaunay.cpp | 12 +++--- libsrc/meshing/meshclass.cpp | 16 ++++---- libsrc/meshing/meshtool.cpp | 8 ++-- 6 files changed, 22 insertions(+), 149 deletions(-) diff --git a/libsrc/general/bitarray.cpp b/libsrc/general/bitarray.cpp index 1c36e5fc..af2dae2a 100644 --- a/libsrc/general/bitarray.cpp +++ b/libsrc/general/bitarray.cpp @@ -82,51 +82,4 @@ namespace netgen } - - - - - - - - - - template - void BitArrayChar :: Set () - { - data = 1; - } - - template - void BitArrayChar :: Clear () - { - data = 0; - } - - - template - void BitArrayChar :: Invert () - { - for (int i = BASE; i < data.Size()+BASE; i++) - data[i] = 1 - data[i]; - } - - template - void BitArrayChar :: And (const BitArrayChar & ba2) - { - for (int i = BASE; i < data.Size()+BASE; i++) - data[i] &= ba2.data[i]; - } - - - template - void BitArrayChar :: Or (const BitArrayChar & ba2) - { - for (int i = BASE; i < data.Size()+BASE; i++) - data[i] |= ba2.data[i]; - } - - - template class BitArrayChar<0>; - template class BitArrayChar<1>; } diff --git a/libsrc/general/bitarray.hpp b/libsrc/general/bitarray.hpp index 3f1f7060..95dc5fad 100644 --- a/libsrc/general/bitarray.hpp +++ b/libsrc/general/bitarray.hpp @@ -142,86 +142,6 @@ int BitArray :: Test (INDEX i) const */ - - - - - -/** - data type BitArrayChar - - BitArray is an array of Boolean information. By Set and Clear - the whole array or one bit can be set or reset, respectively. - Test returns the state of the occurring bit. - No range checking is done. -*/ -template -class BitArrayChar -{ - /// - NgArray data; - -public: - /// - BitArrayChar () - { ; } - /// - BitArrayChar (int asize) - : data(asize) - { ; } - /// - ~BitArrayChar () - { ; } - - /// - void SetSize (int asize) - { data.SetSize(asize); } - - /// - inline int Size () const - { return data.Size(); } - - /// - void Set (); - /// - inline void Set (int i) - { data[i] = 1; } - /// - void Clear (); - /// - inline void Clear (int i) - { data[i] = 0; } - /// - inline int Test (int i) const - { return data[i]; } - /// - void Invert (); - /// - void And (const BitArrayChar & ba2); - /// - void Or (const BitArrayChar & ba2); -private: - /// copy bitarray is not supported - BitArrayChar & operator= (BitArrayChar &) { return *this; } - /// copy bitarray is not supported - BitArrayChar (const BitArrayChar &) { ; } -}; - - - - -template -inline ostream & operator<< (ostream & s, const BitArrayChar & a) -{ - for (int i = BASE; i < a.Size()+BASE; i++) - { - s << a.Test(i); - if ( (i-BASE) % 40 == 39) s << "\n"; - } - if (a.Size() % 40 != 0) s << "\n"; - return s; -} - } #endif diff --git a/libsrc/meshing/adfront3.cpp b/libsrc/meshing/adfront3.cpp index a46d14b0..31e1248a 100644 --- a/libsrc/meshing/adfront3.cpp +++ b/libsrc/meshing/adfront3.cpp @@ -349,18 +349,18 @@ void AdFront3 :: RebuildInternalTables () - BitArrayChar usecl(np); - usecl.Clear(); + Array usecl(np); + usecl = false; for (int i = 1; i <= faces.Size(); i++) { - usecl.Set (points[faces.Get(i).Face().PNum(1)].cluster); + usecl[points[faces.Get(i).Face().PNum(1)].cluster] = true; faces.Elem(i).cluster = points[faces.Get(i).Face().PNum(1)].cluster; } int cntcl = 0; for (int i = PointIndex::BASE; i < np+PointIndex::BASE; i++) - if (usecl.Test(i)) + if (usecl[i]) cntcl++; NgArray clvol (np); diff --git a/libsrc/meshing/delaunay.cpp b/libsrc/meshing/delaunay.cpp index 9516f28f..082246d1 100644 --- a/libsrc/meshing/delaunay.cpp +++ b/libsrc/meshing/delaunay.cpp @@ -561,19 +561,19 @@ namespace netgen startel[3] = mesh.AddPoint (cp4); // flag points to use for Delaunay: - BitArrayChar usep(np); - usep.Clear(); + Array usep(np); + usep = false; for (auto & face : adfront->Faces()) for (PointIndex pi : face.Face().PNums()) - usep.Set (pi); + usep[pi] = true; for (size_t i = oldnp + PointIndex::BASE; i < np + PointIndex::BASE; i++) - usep.Set (i); + usep[i] = true; for (PointIndex pi : mesh.LockedPoints()) - usep.Set (pi); + usep[pi] = true; NgArray freelist; @@ -649,7 +649,7 @@ namespace netgen PointIndex newpi = mixed[pi]; - if (!usep.Test(newpi)) + if (!usep[newpi]) continue; cntp++; diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 0e5545dc..5734bbab 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -3260,7 +3260,7 @@ namespace netgen NgArray op2np(GetNP()); NgArray hpoints; - BitArrayChar pused(GetNP()); + Array pused(GetNP()); /* (*testout) << "volels: " << endl; @@ -3300,37 +3300,37 @@ namespace netgen if(segments[i].edgenr < 0) segments.DeleteElement(i--); - pused.Clear(); + pused = false; for (int i = 0; i < volelements.Size(); i++) { const Element & el = volelements[i]; for (int j = 0; j < el.GetNP(); j++) - pused.Set (el[j]); + pused[el[j]] = true; } for (int i = 0; i < surfelements.Size(); i++) { const Element2d & el = surfelements[i]; for (int j = 0; j < el.GetNP(); j++) - pused.Set (el[j]); + pused[el[j]] = true; } for (int i = 0; i < segments.Size(); i++) { const Segment & seg = segments[i]; for (int j = 0; j < seg.GetNP(); j++) - pused.Set (seg[j]); + pused[seg[j]] = true; } for (int i = 0; i < openelements.Size(); i++) { const Element2d & el = openelements[i]; for (int j = 0; j < el.GetNP(); j++) - pused.Set(el[j]); + pused[el[j]] = true; } for (int i = 0; i < lockedpoints.Size(); i++) - pused.Set (lockedpoints[i]); + pused[lockedpoints[i]] = true; /* @@ -3352,7 +3352,7 @@ namespace netgen // for (PointIndex pi = points.Begin(); pi < points.End(); pi++) for (PointIndex pi : points.Range()) - if (pused.Test(pi)) + if (pused[pi]) { npi++; op2np[pi] = npi; diff --git a/libsrc/meshing/meshtool.cpp b/libsrc/meshing/meshtool.cpp index 74d5283a..3368cf66 100644 --- a/libsrc/meshing/meshtool.cpp +++ b/libsrc/meshing/meshtool.cpp @@ -964,7 +964,7 @@ namespace netgen mesh.FindOpenElements(domainnr); int np = mesh.GetNP(); - BitArrayChar ppoints(np); + Array ppoints(np); // int ndom = mesh.GetNDomains(); @@ -972,7 +972,7 @@ namespace netgen // for (k = 1; k <= ndom; k++) k = domainnr; { - ppoints.Clear(); + ppoints = false; for (i = 1; i <= mesh.GetNOpenElements(); i++) { @@ -980,7 +980,7 @@ namespace netgen if (sel.GetIndex() == k) { for (j = 1; j <= sel.GetNP(); j++) - ppoints.Set (sel.PNum(j)); + ppoints[sel.PNum(j)] = true; } } @@ -991,7 +991,7 @@ namespace netgen { int todel = 0; for (j = 0; j < el.GetNP(); j++) - if (ppoints.Test (el[j])) + if (ppoints[el[j]]) todel = 1; if (el.GetNP() != 4)