Merge branch 'master' of mapserver.flightgear.org:/home/martin/git/terragear-cs
This commit is contained in:
commit
304287ee8f
8 changed files with 74 additions and 12 deletions
|
@ -48,7 +48,10 @@ TGArray::TGArray( void ):
|
||||||
fitted_in(NULL)
|
fitted_in(NULL)
|
||||||
{
|
{
|
||||||
// cout << "class TGArray CONstructor called." << endl;
|
// 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];
|
// out_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +61,9 @@ TGArray::TGArray( const string &file ):
|
||||||
fitted_in(NULL)
|
fitted_in(NULL)
|
||||||
{
|
{
|
||||||
// cout << "class TGArray CONstructor called." << endl;
|
// 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];
|
// out_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
|
||||||
|
|
||||||
TGArray::open(file);
|
TGArray::open(file);
|
||||||
|
@ -101,6 +106,8 @@ bool
|
||||||
TGArray::close() {
|
TGArray::close() {
|
||||||
// the sg_gzifstream doesn't seem to have a close()
|
// the sg_gzifstream doesn't seem to have a close()
|
||||||
|
|
||||||
|
array_in->close();
|
||||||
|
fitted_in->close();
|
||||||
delete array_in;
|
delete array_in;
|
||||||
delete fitted_in;
|
delete fitted_in;
|
||||||
|
|
||||||
|
@ -754,6 +761,8 @@ void TGArray::outputmesh_output_nodes( const string& fg_root, SGBucket& p )
|
||||||
|
|
||||||
TGArray::~TGArray( void ) {
|
TGArray::~TGArray( void ) {
|
||||||
// printf("class TGArray DEstructor called.\n");
|
// printf("class TGArray DEstructor called.\n");
|
||||||
|
for (int i = 0; i < ARRAY_SIZE_1; i++)
|
||||||
|
delete [] in_data[i];
|
||||||
delete [] in_data;
|
delete [] in_data;
|
||||||
// delete [] out_data;
|
// delete [] out_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ private:
|
||||||
double col_step, row_step;
|
double col_step, row_step;
|
||||||
|
|
||||||
// pointers to the actual grid data allocated here
|
// pointers to the actual grid data allocated here
|
||||||
int (*in_data)[ARRAY_SIZE_1];
|
int **in_data;
|
||||||
// float (*out_data)[ARRAY_SIZE_1];
|
// float (*out_data)[ARRAY_SIZE_1];
|
||||||
|
|
||||||
// output nodes
|
// output nodes
|
||||||
|
|
|
@ -65,6 +65,12 @@ GreedySubdivision::GreedySubdivision(Map *map)
|
||||||
count = 4;
|
count = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GreedySubdivision::~GreedySubdivision()
|
||||||
|
{
|
||||||
|
delete heap;
|
||||||
|
is_used.free();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +78,7 @@ GreedySubdivision::GreedySubdivision(Map *map)
|
||||||
Triangle *GreedySubdivision::allocFace(Edge *e)
|
Triangle *GreedySubdivision::allocFace(Edge *e)
|
||||||
{
|
{
|
||||||
Triangle *t = new TrackedTriangle(e);
|
Triangle *t = new TrackedTriangle(e);
|
||||||
|
triangles.push_back(t);
|
||||||
|
|
||||||
heap->insert(t, -1.0);
|
heap->insert(t, -1.0);
|
||||||
|
|
||||||
|
@ -248,7 +255,6 @@ int GreedySubdivision::greedyInsert()
|
||||||
T.getCandidate(&sx, &sy);
|
T.getCandidate(&sx, &sy);
|
||||||
|
|
||||||
select(sx, sy, &T);
|
select(sx, sy, &T);
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GreedySubdivision(Map *map);
|
GreedySubdivision(Map *map);
|
||||||
|
~GreedySubdivision();
|
||||||
|
|
||||||
array2<char> is_used;
|
array2<char> is_used;
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ Edge::~Edge()
|
||||||
e2->qnext = NULL;
|
e2->qnext = NULL;
|
||||||
e3->qnext = NULL;
|
e3->qnext = NULL;
|
||||||
|
|
||||||
delete e1;
|
//delete e1;
|
||||||
delete e2;
|
//delete e2;
|
||||||
delete e3;
|
//delete e3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,45 @@ using std::endl;
|
||||||
|
|
||||||
namespace Terra {
|
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 *Subdivision::makeEdge(Vec2& org, Vec2& dest)
|
||||||
{
|
{
|
||||||
Edge *e = 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());
|
||||||
e->EndPoints(org, dest);
|
e->EndPoints(org, dest);
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Edge *Subdivision::makeEdge()
|
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,
|
void Subdivision::initMesh(const Vec2& A,const Vec2& B,
|
||||||
|
@ -67,7 +96,8 @@ void Subdivision::deleteEdge(Edge *e)
|
||||||
splice(e, e->Oprev());
|
splice(e, e->Oprev());
|
||||||
splice(e->Sym(), e->Sym()->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)
|
Edge *Subdivision::connect(Edge *a, Edge *b)
|
||||||
|
@ -386,7 +416,9 @@ Edge *Subdivision::insert(Vec2& x, Triangle *tri)
|
||||||
|
|
||||||
Triangle *Subdivision::allocFace(Edge *e)
|
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)
|
Triangle& Subdivision::makeFace(Edge *e)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "Quadedge.h"
|
#include "Quadedge.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Terra {
|
namespace Terra {
|
||||||
|
|
||||||
|
@ -38,15 +39,26 @@ public:
|
||||||
typedef void (*edge_callback)(Edge *, void *);
|
typedef void (*edge_callback)(Edge *, void *);
|
||||||
typedef void (*face_callback)(Triangle&, 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 {
|
class Subdivision {
|
||||||
private:
|
private:
|
||||||
Edge *startingEdge;
|
Edge *startingEdge;
|
||||||
Triangle *first_face;
|
Triangle *first_face;
|
||||||
|
|
||||||
|
EdgeVec edges;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
TriangleVec triangles;
|
||||||
void initMesh(const Vec2&, const Vec2&, const Vec2&, const Vec2&);
|
void initMesh(const Vec2&, const Vec2&, const Vec2&, const Vec2&);
|
||||||
Subdivision() { }
|
Subdivision();
|
||||||
|
~Subdivision();
|
||||||
|
|
||||||
Edge *makeEdge();
|
Edge *makeEdge();
|
||||||
Edge *makeEdge(Vec2& org, Vec2& dest);
|
Edge *makeEdge(Vec2& org, Vec2& dest);
|
||||||
|
|
|
@ -203,6 +203,8 @@ void fit_file(const std::string& path) {
|
||||||
gzprintf(fp,"%+03.8f %+02.8f %0.2f\n",vx,vy,vz);
|
gzprintf(fp,"%+03.8f %+02.8f %0.2f\n",vx,vy,vz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete mesh;
|
||||||
|
delete DEM;
|
||||||
|
|
||||||
gzclose(fp);
|
gzclose(fp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue