Fix some memory leaks
detangle some /interesting/ use of pointer/reference usage
This commit is contained in:
parent
79ea7c6819
commit
661f840843
5 changed files with 16 additions and 21 deletions
|
@ -63,6 +63,7 @@ Edge::~Edge()
|
||||||
e2->qnext = NULL;
|
e2->qnext = NULL;
|
||||||
e3->qnext = NULL;
|
e3->qnext = NULL;
|
||||||
|
|
||||||
|
//FIXME: who deletes the edges allocated in ctor? (Torsten Dreyer 01/2019)
|
||||||
//delete e1;
|
//delete e1;
|
||||||
//delete e2;
|
//delete e2;
|
||||||
//delete e3;
|
//delete e3;
|
||||||
|
|
|
@ -15,8 +15,8 @@ private:
|
||||||
|
|
||||||
Edge(Edge *prev);
|
Edge(Edge *prev);
|
||||||
|
|
||||||
protected:
|
//protected:
|
||||||
Vec2 *data;
|
Vec2 data;
|
||||||
Edge *next;
|
Edge *next;
|
||||||
|
|
||||||
Triangle *lface;
|
Triangle *lface;
|
||||||
|
@ -47,16 +47,16 @@ public:
|
||||||
Edge *Rprev() const { return Sym()->Onext(); }
|
Edge *Rprev() const { return Sym()->Onext(); }
|
||||||
|
|
||||||
|
|
||||||
Vec2& Org() const { return *data; }
|
const Vec2& Org() const { return data; }
|
||||||
Vec2& Dest() const { return *Sym()->data; }
|
const Vec2& Dest() const { return Sym()->data; }
|
||||||
|
|
||||||
Triangle *Lface() const { return lface; }
|
Triangle *Lface() const { return lface; }
|
||||||
void set_Lface(Triangle *t) { lface = t; }
|
void set_Lface(Triangle *t) { lface = t; }
|
||||||
|
|
||||||
void EndPoints(Vec2& org, Vec2& dest)
|
void EndPoints(const Vec2& org, const Vec2& dest)
|
||||||
{
|
{
|
||||||
data = &org;
|
data = org;
|
||||||
Sym()->data = &dest;
|
Sym()->data = dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -28,7 +28,7 @@ Subdivision::~Subdivision()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Edge *Subdivision::makeEdge(Vec2& org, Vec2& dest)
|
Edge *Subdivision::makeEdge(const Vec2& org, const Vec2& dest)
|
||||||
{
|
{
|
||||||
Edge *e = new Edge();
|
Edge *e = new Edge();
|
||||||
edges.push_back(e);
|
edges.push_back(e);
|
||||||
|
@ -54,31 +54,26 @@ Edge *Subdivision::makeEdge()
|
||||||
void Subdivision::initMesh(const Vec2& A,const Vec2& B,
|
void Subdivision::initMesh(const Vec2& A,const Vec2& B,
|
||||||
const Vec2& C,const Vec2& D)
|
const Vec2& C,const Vec2& D)
|
||||||
{
|
{
|
||||||
Vec2& a = A.clone();
|
|
||||||
Vec2& b = B.clone();
|
|
||||||
Vec2& c = C.clone();
|
|
||||||
Vec2& d = D.clone();
|
|
||||||
|
|
||||||
Edge *ea = makeEdge();
|
Edge *ea = makeEdge();
|
||||||
ea->EndPoints(a, b);
|
ea->EndPoints(A, B);
|
||||||
|
|
||||||
Edge *eb = makeEdge();
|
Edge *eb = makeEdge();
|
||||||
splice(ea->Sym(), eb);
|
splice(ea->Sym(), eb);
|
||||||
eb->EndPoints(b, c);
|
eb->EndPoints(B, C);
|
||||||
|
|
||||||
Edge *ec = makeEdge();
|
Edge *ec = makeEdge();
|
||||||
splice(eb->Sym(), ec);
|
splice(eb->Sym(), ec);
|
||||||
ec->EndPoints(c, d);
|
ec->EndPoints(C, D);
|
||||||
|
|
||||||
Edge *ed = makeEdge();
|
Edge *ed = makeEdge();
|
||||||
splice(ec->Sym(), ed);
|
splice(ec->Sym(), ed);
|
||||||
ed->EndPoints(d, a);
|
ed->EndPoints(D, A);
|
||||||
splice(ed->Sym(), ea);
|
splice(ed->Sym(), ea);
|
||||||
|
|
||||||
Edge *diag = makeEdge();
|
Edge *diag = makeEdge();
|
||||||
splice(ed->Sym(),diag);
|
splice(ed->Sym(),diag);
|
||||||
splice(eb->Sym(),diag->Sym());
|
splice(eb->Sym(),diag->Sym());
|
||||||
diag->EndPoints(a,c);
|
diag->EndPoints(A,C);
|
||||||
|
|
||||||
startingEdge = ea;
|
startingEdge = ea;
|
||||||
|
|
||||||
|
@ -334,7 +329,7 @@ Edge *Subdivision::spoke(Vec2& x, Edge *e)
|
||||||
// x lies within the Lface of e
|
// x lies within the Lface of e
|
||||||
}
|
}
|
||||||
|
|
||||||
Edge *base = makeEdge(e->Org(), x.clone());
|
Edge *base = makeEdge(e->Org(), x );
|
||||||
|
|
||||||
splice(base, e);
|
splice(base, e);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ protected:
|
||||||
~Subdivision();
|
~Subdivision();
|
||||||
|
|
||||||
Edge *makeEdge();
|
Edge *makeEdge();
|
||||||
Edge *makeEdge(Vec2& org, Vec2& dest);
|
Edge *makeEdge(const Vec2& org, const Vec2& dest);
|
||||||
|
|
||||||
virtual Triangle *allocFace(Edge *e);
|
virtual Triangle *allocFace(Edge *e);
|
||||||
Triangle& makeFace(Edge *e);
|
Triangle& makeFace(Edge *e);
|
||||||
|
|
|
@ -16,7 +16,6 @@ public:
|
||||||
Vec2(real x=0, real y=0) { elt[0]=x; elt[1]=y; }
|
Vec2(real x=0, real y=0) { elt[0]=x; elt[1]=y; }
|
||||||
Vec2(const Vec2& v) { copy(v); }
|
Vec2(const Vec2& v) { copy(v); }
|
||||||
Vec2(const real *v) { elt[0]=v[0]; elt[1]=v[1]; }
|
Vec2(const real *v) { elt[0]=v[0]; elt[1]=v[1]; }
|
||||||
Vec2& clone() const { return *(new Vec2(elt[0], elt[1])); }
|
|
||||||
|
|
||||||
// Access methods
|
// Access methods
|
||||||
real& operator()(int i) { return elt[i]; }
|
real& operator()(int i) { return elt[i]; }
|
||||||
|
|
Loading…
Reference in a new issue