Array::Append does not return size anymore ( will be changed to last )

This commit is contained in:
Joachim Schöberl 2016-12-11 18:22:07 +01:00
parent bdbc415589
commit 59dc0b6c6a
18 changed files with 45 additions and 30 deletions

View File

@ -648,7 +648,8 @@ namespace netgen
int CSGeometry :: SetTopLevelObject (Solid * sol, Surface * surf) int CSGeometry :: SetTopLevelObject (Solid * sol, Surface * surf)
{ {
return toplevelobjects.Append (new TopLevelObject (sol, surf)) - 1; toplevelobjects.Append (new TopLevelObject (sol, surf));
return toplevelobjects.Size()-1;
} }
TopLevelObject * CSGeometry :: TopLevelObject * CSGeometry ::

View File

@ -1158,7 +1158,8 @@ namespace netgen
//seg.surfnr2 = s2_rep; //seg.surfnr2 = s2_rep;
seg.surfnr1 = s1; seg.surfnr1 = s1;
seg.surfnr2 = s2; seg.surfnr2 = s2;
hi = refedges.Append (seg); refedges.Append (seg);
hi = refedges.Size();
refedgesinv.Append (edgeinv); refedgesinv.Append (edgeinv);
edges_priority.Append((pre_ok[k-1]) ? 1 : 0); edges_priority.Append((pre_ok[k-1]) ? 1 : 0);
} }

View File

@ -499,7 +499,8 @@ int Polyhedra :: AddPoint (const Point<3> & p)
else else
poly_bbox.Add(p); poly_bbox.Add(p);
return points.Append (p); points.Append (p);
return points.Size();
} }
int Polyhedra :: AddFace (int pi1, int pi2, int pi3, int inputnum) int Polyhedra :: AddFace (int pi1, int pi2, int pi3, int inputnum)

View File

@ -2027,7 +2027,8 @@ namespace netgen
if (spi == -1) if (spi == -1)
{ {
spi = specpoints.Append (SpecialPoint()) - 1; specpoints.Append (SpecialPoint());
spi = specpoints.Size()-1;
specpoint2point.Append (i); specpoint2point.Append (i);
specpoints.Last().unconditional = 0; specpoints.Last().unconditional = 0;
searchtree.Insert (apoints[i], spi); searchtree.Insert (apoints[i], spi);

View File

@ -416,7 +416,7 @@ namespace netgen
const Point3d & p = mesh->Point(i); const Point3d & p = mesh->Point(i);
glRasterPos3d (p.X(), p.Y(), p.Z()); glRasterPos3d (p.X(), p.Y(), p.Z());
sprintf (buf, "%d", i); sprintf (buf, "%d", int(i));
// glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
MyOpenGLText (buf); MyOpenGLText (buf);
} }

View File

@ -293,13 +293,13 @@ namespace netgen
/// Add element at end of array. reallocation if necessary. /// Add element at end of array. reallocation if necessary.
int Append (const T & el) void Append (const T & el)
{ {
if (size == allocsize) if (size == allocsize)
ReSize (size+1); ReSize (size+1);
data[size] = el; data[size] = el;
size++; size++;
return size; // return size;
} }
template <typename T2, int B2> template <typename T2, int B2>

View File

@ -202,7 +202,8 @@ namespace netgen
fa.p1 = i3.I1(); fa.p1 = i3.I1();
fa.p2 = i3.I2(); fa.p2 = i3.I2();
fa.p3 = i3.I3(); fa.p3 = i3.I3();
facei = faces.Append (fa); faces.Append (fa);
facei = faces.Size();
faceindex.Set (i3, facei); faceindex.Set (i3, facei);
} }
@ -241,7 +242,8 @@ namespace netgen
EDGE ed; EDGE ed;
ed.p1 = i2.I1(); ed.p1 = i2.I1();
ed.p2 = i2.I2(); ed.p2 = i2.I2();
edgei = edges.Append (ed); edges.Append (ed);
edgei = edges.Size();
edgeindex.Set (i2, edgei); edgeindex.Set (i2, edgei);
} }

View File

@ -88,7 +88,8 @@ namespace netgen
} }
else else
{ {
pi = points.Append (FrontPoint2 (p, globind, mgi, pointonsurface)) - 1; points.Append (FrontPoint2 (p, globind, mgi, pointonsurface));
pi = points.Size()-1;
} }
if (mgi) if (mgi)
@ -128,7 +129,8 @@ namespace netgen
} }
else else
{ {
li = lines.Append(FrontLine (INDEX_2(pi1, pi2))) - 1; lines.Append(FrontLine (INDEX_2(pi1, pi2)));
li = lines.Size()-1;
} }
@ -332,7 +334,8 @@ namespace netgen
{ {
pindex.Append (pi); pindex.Append (pi);
invpindex[pi] = pindex.Size(); invpindex[pi] = pindex.Size();
loclines[i][j] = locpoints.Append (points[pi].P()); locpoints.Append (points[pi].P());
loclines[i][j] = locpoints.Size();
} }
else else
loclines[i][j] = invpindex[pi]; loclines[i][j] = invpindex[pi];
@ -349,7 +352,8 @@ namespace netgen
// Dist2 (points.Get(i).P(), p0) <= xh2 && // Dist2 (points.Get(i).P(), p0) <= xh2 &&
invpindex[i] <= 0) invpindex[i] <= 0)
{ {
invpindex[i] = locpoints.Append (points[i].P()); locpoints.Append (points[i].P());
invpindex[i] = locpoints.Size();
pindex.Append(i); pindex.Append(i);
} }
} }

View File

@ -159,8 +159,9 @@ INDEX AdFront3 :: AddFace (const MiniElement2d & aface)
for (i = 1; i <= aface.GetNP(); i++) for (i = 1; i <= aface.GetNP(); i++)
points[aface.PNum(i)].DecFrontNr (minfn+1); points[aface.PNum(i)].DecFrontNr (minfn+1);
int nfn = faces.Append(FrontFace (aface)); faces.Append(FrontFace (aface));
int nfn = faces.Size();
faces.Elem(nfn).cluster = cluster; faces.Elem(nfn).cluster = cluster;
if (hashon && hashcreated) if (hashon && hashcreated)

View File

@ -577,10 +577,10 @@ namespace netgen
/// ///
int AddFaceDescriptor(const FaceDescriptor& fd) int AddFaceDescriptor(const FaceDescriptor& fd)
{ return facedecoding.Append(fd); } { facedecoding.Append(fd); return facedecoding.Size(); }
int AddEdgeDescriptor(const EdgeDescriptor & fd) int AddEdgeDescriptor(const EdgeDescriptor & fd)
{ return edgedecoding.Append(fd) - 1; } { edgedecoding.Append(fd); return edgedecoding.Size() - 1; }
/// ///
DLL_HEADER void SetMaterial (int domnr, const string & mat); DLL_HEADER void SetMaterial (int domnr, const string & mat);

View File

@ -593,8 +593,9 @@ namespace netgen
Point2d np = rule->GetPoint(i); Point2d np = rule->GetPoint(i);
np.X() += newu (2 * (i-oldnp) - 2); np.X() += newu (2 * (i-oldnp) - 2);
np.Y() += newu (2 * (i-oldnp) - 1); np.Y() += newu (2 * (i-oldnp) - 1);
pmap.Elem(i) = lpoints.Append (np); lpoints.Append (np);
pmap.Elem(i) = lpoints.Size();
} }
} }

View File

@ -870,8 +870,8 @@ int Meshing3 :: ApplyRules
np.X() += newu (3 * (i-oldnp) - 3); np.X() += newu (3 * (i-oldnp) - 3);
np.Y() += newu (3 * (i-oldnp) - 2); np.Y() += newu (3 * (i-oldnp) - 2);
np.Z() += newu (3 * (i-oldnp) - 1); np.Z() += newu (3 * (i-oldnp) - 1);
lpoints.Append (np);
pmap.Elem(i) = lpoints.Append (np)-1+PointIndex::BASE; pmap.Elem(i) = lpoints.Size()-1+PointIndex::BASE;
} }
// Set new Faces: // Set new Faces:

View File

@ -455,7 +455,8 @@ int STLGeometry :: AddEdge(int ap1, int ap2)
STLEdge e(ap1,ap2); STLEdge e(ap1,ap2);
e.SetLeftTrig(GetLeftTrig(ap1,ap2)); e.SetLeftTrig(GetLeftTrig(ap1,ap2));
e.SetRightTrig(GetRightTrig(ap1,ap2)); e.SetRightTrig(GetRightTrig(ap1,ap2));
return edges.Append(e); edges.Append(e);
return edges.Size();
} }
void STLGeometry :: STLDoctorConfirmEdge() void STLGeometry :: STLDoctorConfirmEdge()

View File

@ -302,11 +302,11 @@ namespace netgen
DLL_HEADER int GetNodeOfSelTrig() const; DLL_HEADER int GetNodeOfSelTrig() const;
int AddNormal(const Vec3d& n) {return normals.Append(n);} int AddNormal(const Vec3d& n) { normals.Append(n); return normals.Size(); }
const Vec3d & GetNormal(int nr) const {return normals.Get(nr);} const Vec3d & GetNormal(int nr) const {return normals.Get(nr);}
void SetNormal(int nr, const Vec3d& n) {normals.Elem(nr) = n;} void SetNormal(int nr, const Vec3d& n) {normals.Elem(nr) = n;}
int AddEdge(const STLEdge& v) {return edges.Append(v);} int AddEdge(const STLEdge& v) { edges.Append(v); return edges.Size(); }
int AddEdge(int p1, int p2); int AddEdge(int p1, int p2);
STLEdge GetEdge(int nr) {return edges.Get(nr);} STLEdge GetEdge(int nr) {return edges.Get(nr);}
@ -434,7 +434,7 @@ namespace netgen
int ProjectOnWholeSurface (Point<3> & p3d) const; int ProjectOnWholeSurface (Point<3> & p3d) const;
int GetNLines() const {return lines.Size();} int GetNLines() const {return lines.Size();}
int AddLine(STLLine* line) {return lines.Append(line);} int AddLine(STLLine* line) { lines.Append(line); return lines.Size(); }
STLLine* GetLine(int nr) const {return lines.Get(nr);} STLLine* GetLine(int nr) const {return lines.Get(nr);}
int GetLineP(int lnr, int pnr) const {return lines.Get(lnr)->PNum(pnr);} int GetLineP(int lnr, int pnr) const {return lines.Get(lnr)->PNum(pnr);}
int GetLineNP(int nr) const {return lines.Get(nr)->NP();} int GetLineNP(int nr) const {return lines.Get(nr)->NP();}

View File

@ -19,7 +19,8 @@ int AddPointIfNotExists(Array<Point3d>& ap, const Point3d& p, double eps)
for (int i = 1; i <= ap.Size(); i++) for (int i = 1; i <= ap.Size(); i++)
if (Dist2(ap.Get(i),p) <= eps2 ) if (Dist2(ap.Get(i),p) <= eps2 )
return i; return i;
return ap.Append(p); ap.Append(p);
return ap.Size();
} }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -592,7 +592,8 @@ void STLTopology :: FindNeighbourTrigs()
} }
else else
{ {
enr = topedges.Append (STLTopEdge (pi1, pi2, i, 0)); topedges.Append (STLTopEdge (pi1, pi2, i, 0));
enr = topedges.Size();
ht_topedges->Set (i2, enr); ht_topedges->Set (i2, enr);
trig.EdgeNum(j) = enr; trig.EdgeNum(j) = enr;
} }

View File

@ -293,7 +293,7 @@ public:
int GetNP() const { return points.Size(); } int GetNP() const { return points.Size(); }
int AddPoint(const Point<3> & p) { return points.Append(p); } int AddPoint(const Point<3> & p) { points.Append(p); return points.Size(); }
const Point<3> & GetPoint(int nr) const { return points.Get(nr); } const Point<3> & GetPoint(int nr) const { return points.Get(nr); }
int GetPointNum (const Point<3> & p); int GetPointNum (const Point<3> & p);
void SetPoint(int nr, const Point<3> & p) { points.Elem(nr) = p; } void SetPoint(int nr, const Point<3> & p) { points.Elem(nr) = p; }

View File

@ -4216,8 +4216,8 @@ namespace netgen
Point<3> p2 = locgrid[teti[pi2]]; Point<3> p2 = locgrid[teti[pi2]];
cppt.lami = p2 + edgelam[ednr] * (p1-p2); cppt.lami = p2 + edgelam[ednr] * (p1-p2);
pts.Append (cppt);
pnr = pts.Append (cppt)-1; pnr = pts.Size()-1;
edges.Set (pair, pnr); edges.Set (pair, pnr);
} }