1
0
Fork 0

Merge branch 'master' of mapserver.flightgear.org:/home/martin/git/terragear-cs

This commit is contained in:
Martin Spott 2011-09-02 11:30:19 +02:00
commit 304287ee8f
8 changed files with 74 additions and 12 deletions

View file

@ -48,7 +48,10 @@ TGArray::TGArray( void ):
fitted_in(NULL)
{
// cout << "class TGArray CONstructor called." << endl;
in_data = new int[ARRAY_SIZE_1][ARRAY_SIZE_1];
//in_data = new int[ARRAY_SIZE_1][ARRAY_SIZE_1];
in_data = new int*[ARRAY_SIZE_1];
for (int i = 0; i < ARRAY_SIZE_1; i++)
in_data[i] = new int[ARRAY_SIZE_1];
// out_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
}
@ -58,7 +61,9 @@ TGArray::TGArray( const string &file ):
fitted_in(NULL)
{
// cout << "class TGArray CONstructor called." << endl;
in_data = new int[ARRAY_SIZE_1][ARRAY_SIZE_1];
in_data = new int* [ARRAY_SIZE_1];
for (int i = 0; i < ARRAY_SIZE_1; i++)
in_data[i] = new int[ARRAY_SIZE_1];
// out_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
TGArray::open(file);
@ -101,6 +106,8 @@ bool
TGArray::close() {
// the sg_gzifstream doesn't seem to have a close()
array_in->close();
fitted_in->close();
delete array_in;
delete fitted_in;
@ -754,6 +761,8 @@ void TGArray::outputmesh_output_nodes( const string& fg_root, SGBucket& p )
TGArray::~TGArray( void ) {
// printf("class TGArray DEstructor called.\n");
for (int i = 0; i < ARRAY_SIZE_1; i++)
delete [] in_data[i];
delete [] in_data;
// delete [] out_data;
}

View file

@ -63,7 +63,7 @@ private:
double col_step, row_step;
// pointers to the actual grid data allocated here
int (*in_data)[ARRAY_SIZE_1];
int **in_data;
// float (*out_data)[ARRAY_SIZE_1];
// output nodes

View file

@ -65,6 +65,12 @@ GreedySubdivision::GreedySubdivision(Map *map)
count = 4;
}
GreedySubdivision::~GreedySubdivision()
{
delete heap;
is_used.free();
}
@ -72,6 +78,7 @@ GreedySubdivision::GreedySubdivision(Map *map)
Triangle *GreedySubdivision::allocFace(Edge *e)
{
Triangle *t = new TrackedTriangle(e);
triangles.push_back(t);
heap->insert(t, -1.0);
@ -248,7 +255,6 @@ int GreedySubdivision::greedyInsert()
T.getCandidate(&sx, &sy);
select(sx, sy, &T);
return True;
}

View file

@ -68,6 +68,7 @@ protected:
public:
GreedySubdivision(Map *map);
~GreedySubdivision();
array2<char> is_used;

View file

@ -63,9 +63,9 @@ Edge::~Edge()
e2->qnext = NULL;
e3->qnext = NULL;
delete e1;
delete e2;
delete e3;
//delete e1;
//delete e2;
//delete e3;
}
}

View file

@ -10,16 +10,45 @@ using std::endl;
namespace Terra {
Subdivision::Subdivision()
{
startingEdge = 0;
first_face = 0;
}
Subdivision::~Subdivision()
{
//delete [] startingEdge;
//delete [] first_face;
for (TriangleVecIterator tri= triangles.begin(); tri != triangles.end(); tri++) {
delete (*tri);
}
for (EdgeVecIterator e = edges.begin(); e != edges.end(); e++) {
delete (*e);
}
}
Edge *Subdivision::makeEdge(Vec2& org, Vec2& dest)
{
Edge *e = new Edge();
edges.push_back(e);
edges.push_back(e->Rot());
edges.push_back(e->Rot()->Rot());
edges.push_back(e->Rot()->Rot()->Rot());
e->EndPoints(org, dest);
return e;
}
Edge *Subdivision::makeEdge()
{
return new Edge();
Edge *e = new Edge();
edges.push_back(e);
edges.push_back(e->Rot());
edges.push_back(e->Rot()->Rot());
edges.push_back(e->Rot()->Rot()->Rot());
return e;
}
void Subdivision::initMesh(const Vec2& A,const Vec2& B,
@ -67,7 +96,8 @@ void Subdivision::deleteEdge(Edge *e)
splice(e, e->Oprev());
splice(e->Sym(), e->Sym()->Oprev());
delete e;
// Note that the Subdivision destructor takes care of the physical deletion now.
//delete e;
}
Edge *Subdivision::connect(Edge *a, Edge *b)
@ -386,7 +416,9 @@ Edge *Subdivision::insert(Vec2& x, Triangle *tri)
Triangle *Subdivision::allocFace(Edge *e)
{
return new Triangle(e);
Triangle *t = new Triangle(e);
triangles.push_back(t);
return t;
}
Triangle& Subdivision::makeFace(Edge *e)

View file

@ -4,6 +4,7 @@
#include "Quadedge.h"
#include <iostream>
#include <vector>
namespace Terra {
@ -38,15 +39,26 @@ public:
typedef void (*edge_callback)(Edge *, void *);
typedef void (*face_callback)(Triangle&, void *);
typedef std::vector<Triangle*> TriangleVec;
typedef std::vector<Triangle*>::iterator TriangleVecIterator;
typedef std::vector<Edge*> EdgeVec;
typedef std::vector<Edge*>::iterator EdgeVecIterator;
class Subdivision {
private:
Edge *startingEdge;
Triangle *first_face;
EdgeVec edges;
protected:
TriangleVec triangles;
void initMesh(const Vec2&, const Vec2&, const Vec2&, const Vec2&);
Subdivision() { }
Subdivision();
~Subdivision();
Edge *makeEdge();
Edge *makeEdge(Vec2& org, Vec2& dest);

View file

@ -203,6 +203,8 @@ void fit_file(const std::string& path) {
gzprintf(fp,"%+03.8f %+02.8f %0.2f\n",vx,vy,vz);
}
}
delete mesh;
delete DEM;
gzclose(fp);
}