memory cleanup

This commit is contained in:
zzzzrrr 2010-04-25 12:40:54 -04:00
parent bab616f9ea
commit d6dd5da27c
10 changed files with 120 additions and 109 deletions

View File

@ -1,4 +1,4 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
@ -40,7 +40,6 @@
namespace p2t { namespace p2t {
struct Node;
struct Edge; struct Edge;
struct Point { struct Point {
@ -50,7 +49,7 @@ struct Point {
/// Default constructor does nothing (for performance). /// Default constructor does nothing (for performance).
Point() Point()
{ {
x = 0.0; x = 0.0;
y = 0.0; y = 0.0;
} }
@ -63,43 +62,43 @@ struct Point {
/// Set this point to all zeros. /// Set this point to all zeros.
void set_zero() void set_zero()
{ {
x = 0.0f; x = 0.0f;
y = 0.0f; y = 0.0f;
} }
/// Set this point to some specified coordinates. /// Set this point to some specified coordinates.
void set(double x_, double y_) void set(double x_, double y_)
{ {
x = x_; x = x_;
y = y_; y = y_;
} }
/// Negate this point. /// Negate this point.
Point operator -() const Point operator -() const
{ {
Point v; Point v;
v.set(-x, -y); v.set(-x, -y);
return v; return v;
} }
/// Add a point to this point. /// Add a point to this point.
void operator +=(const Point& v) void operator +=(const Point& v)
{ {
x += v.x; x += v.x;
y += v.y; y += v.y;
} }
/// Subtract a point from this point. /// Subtract a point from this point.
void operator -=(const Point& v) void operator -=(const Point& v)
{ {
x -= v.x; x -= v.x;
y -= v.y; y -= v.y;
} }
/// Multiply this point by a scalar. /// Multiply this point by a scalar.
void operator *=(double a) void operator *=(double a)
{ {
x *= a; x *= a;
y *= a; y *= a;
} }

View File

@ -1,4 +1,4 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
@ -42,7 +42,7 @@ AdvancingFront::AdvancingFront(Node& head, Node& tail)
Node* AdvancingFront::LocateNode(const double& x) Node* AdvancingFront::LocateNode(const double& x)
{ {
Node* node = search_node_; Node* node = search_node_;
if (x < node->value) { if (x < node->value) {
while ((node = node->prev) != NULL) { while ((node = node->prev) != NULL) {
if (x >= node->value) { if (x >= node->value) {
@ -72,7 +72,7 @@ Node* AdvancingFront::LocatePoint(const Point* point)
const double px = point->x; const double px = point->x;
Node* node = FindSearchNode(px); Node* node = FindSearchNode(px);
const double nx = node->point->x; const double nx = node->point->x;
if (px == nx) { if (px == nx) {
if (point != node->point) { if (point != node->point) {
// We might have two nodes with same x value for a short time // We might have two nodes with same x value for a short time
@ -102,9 +102,6 @@ Node* AdvancingFront::LocatePoint(const Point* point)
AdvancingFront::~AdvancingFront() AdvancingFront::~AdvancingFront()
{ {
delete head_;
delete search_node_;
delete tail_;
} }
} }

View File

@ -1,4 +1,4 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
@ -28,7 +28,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef ADVANCED_FRONT_H #ifndef ADVANCED_FRONT_H
#define ADVANCED_FRONT_H #define ADVANCED_FRONT_H

View File

@ -1,4 +1,4 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
@ -88,7 +88,6 @@ Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
// x value than node due to how we fetch nodes from the front // x value than node due to how we fetch nodes from the front
if (point.x <= node.point->x + EPSILON) { if (point.x <= node.point->x + EPSILON) {
Fill(tcx, node); Fill(tcx, node);
delete &node;
} }
//tcx.AddNode(new_node); //tcx.AddNode(new_node);
@ -172,12 +171,12 @@ Node& Sweep::NewFrontTriangle(SweepContext& tcx, Point& point, Node& node)
Node* new_node = new Node(point); Node* new_node = new Node(point);
nodes_.push_back(new_node); nodes_.push_back(new_node);
new_node->next = node.next; new_node->next = node.next;
new_node->prev = &node; new_node->prev = &node;
node.next->prev = new_node; node.next->prev = new_node;
node.next = new_node; node.next = new_node;
if (!Legalize(tcx, *triangle)) { if (!Legalize(tcx, *triangle)) {
tcx.MapTriangleToNodes(*triangle); tcx.MapTriangleToNodes(*triangle);
} }
@ -203,13 +202,13 @@ void Sweep::Fill(SweepContext& tcx, Node& node)
// Update the advancing front // Update the advancing front
node.prev->next = node.next; node.prev->next = node.next;
node.next->prev = node.prev; node.next->prev = node.prev;
// If it was legalized the triangle has already been mapped // If it was legalized the triangle has already been mapped
if (!Legalize(tcx, *triangle)) { if (!Legalize(tcx, *triangle)) {
tcx.MapTriangleToNodes(*triangle); tcx.MapTriangleToNodes(*triangle);
} }
} }
/** /**
@ -220,7 +219,8 @@ void Sweep::Fill(SweepContext& tcx, Node& node)
* @param n * @param n
*/ */
void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n) void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
{ {
// Fill right holes // Fill right holes
Node* node = n.next; Node* node = n.next;
@ -228,9 +228,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
double angle = HoleAngle(*node); double angle = HoleAngle(*node);
if (angle > M_PI_2 || angle < -M_PI_2) break; if (angle > M_PI_2 || angle < -M_PI_2) break;
Fill(tcx, *node); Fill(tcx, *node);
Node *temp = node;
node = node->next; node = node->next;
delete temp;
} }
// Fill left holes // Fill left holes
@ -240,9 +238,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
double angle = HoleAngle(*node); double angle = HoleAngle(*node);
if (angle > M_PI_2 || angle < -M_PI_2) break; if (angle > M_PI_2 || angle < -M_PI_2) break;
Fill(tcx, *node); Fill(tcx, *node);
Node *temp = node;
node = node->prev; node = node->prev;
delete temp;
} }
// Fill right basins // Fill right basins
@ -528,23 +524,19 @@ void Sweep::FillBasinReq(SweepContext& tcx, Node* node)
return; return;
} }
Fill(tcx, *node); Fill(tcx, *node);
Node *temp = node;
if (node->prev == tcx.basin.left_node && node->next == tcx.basin.right_node) { if (node->prev == tcx.basin.left_node && node->next == tcx.basin.right_node) {
delete node;
return; return;
} else if (node->prev == tcx.basin.left_node) { } else if (node->prev == tcx.basin.left_node) {
Orientation o = Orient2d(*node->point, *node->next->point, *node->next->next->point); Orientation o = Orient2d(*node->point, *node->next->point, *node->next->next->point);
if (o == CW) { if (o == CW) {
delete node;
return; return;
} }
node = node->next; node = node->next;
} else if (node->next == tcx.basin.right_node) { } else if (node->next == tcx.basin.right_node) {
Orientation o = Orient2d(*node->point, *node->prev->point, *node->prev->prev->point); Orientation o = Orient2d(*node->point, *node->prev->point, *node->prev->prev->point);
if (o == CCW) { if (o == CCW) {
delete node;
return; return;
} }
node = node->prev; node = node->prev;
@ -557,7 +549,6 @@ void Sweep::FillBasinReq(SweepContext& tcx, Node* node)
} }
} }
delete temp;
FillBasinReq(tcx, node); FillBasinReq(tcx, node);
} }
@ -628,8 +619,8 @@ void Sweep::FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
// Next is convex // Next is convex
} }
} }
} }
} }
void Sweep::FillRightConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node) void Sweep::FillRightConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
@ -708,9 +699,9 @@ void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
} else{ } else{
// Next is convex // Next is convex
} }
} }
} }
} }
void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p) void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p)
@ -765,7 +756,7 @@ Triangle& Sweep::NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangl
// t is not crossing edge after flip // t is not crossing edge after flip
int edge_index = t.EdgeIndex(&p, &op); int edge_index = t.EdgeIndex(&p, &op);
t.delaunay_edge[edge_index] = true; t.delaunay_edge[edge_index] = true;
Legalize(tcx, t); Legalize(tcx, t);
t.ClearDelunayEdges(); t.ClearDelunayEdges();
@ -814,6 +805,15 @@ void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle&
Point& newP = NextFlipPoint(ep, eq, ot, op); Point& newP = NextFlipPoint(ep, eq, ot, op);
FlipScanEdgeEvent(tcx, ep, eq, flip_triangle, ot, newP); FlipScanEdgeEvent(tcx, ep, eq, flip_triangle, ot, newP);
} }
}
Sweep::~Sweep() {
// Clean up memory
for(int i = 0; i < nodes_.size(); i++) {
delete nodes_[i];
}
} }
} }

View File

@ -1,4 +1,4 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
@ -35,7 +35,7 @@
* *
* "FlipScan" Constrained Edge Algorithm invented by Thomas Åhlén, thahlen@gmail.com * "FlipScan" Constrained Edge Algorithm invented by Thomas Åhlén, thahlen@gmail.com
*/ */
#ifndef SWEEP_H #ifndef SWEEP_H
#define SWEEP_H #define SWEEP_H
@ -53,6 +53,7 @@ class Sweep {
public: public:
void Triangulate(SweepContext& tcx); void Triangulate(SweepContext& tcx);
~Sweep();
private: private:

View File

@ -1,4 +1,4 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
@ -91,7 +91,7 @@ void SweepContext::InitTriangulation()
// Sort points along y-axis // Sort points along y-axis
std::sort(points_.begin(), points_.end(), cmp); std::sort(points_.begin(), points_.end(), cmp);
} }
void SweepContext::InitEdges(std::vector<Point*> polyline) void SweepContext::InitEdges(std::vector<Point*> polyline)
@ -121,28 +121,23 @@ Node& SweepContext::LocateNode(Point& point)
void SweepContext::CreateAdvancingFront(std::vector<Node*> nodes) void SweepContext::CreateAdvancingFront(std::vector<Node*> nodes)
{ {
Node *head, *middle, *tail;
// Initial triangle // Initial triangle
Triangle* triangle = new Triangle(*points_[0], *tail_, *head_); Triangle* triangle = new Triangle(*points_[0], *tail_, *head_);
map_.push_back(triangle); map_.push_back(triangle);
head = new Node(*triangle->GetPoint(1), *triangle); af_head_ = new Node(*triangle->GetPoint(1), *triangle);
middle = new Node(*triangle->GetPoint(0), *triangle); af_middle_ = new Node(*triangle->GetPoint(0), *triangle);
tail = new Node(*triangle->GetPoint(2)); af_tail_ = new Node(*triangle->GetPoint(2));
front_ = new AdvancingFront(*head, *tail); front_ = new AdvancingFront(*af_head_, *af_tail_);
// Memory management :)
nodes.push_back(head);
nodes.push_back(middle);
nodes.push_back(tail);
// TODO: More intuitive if head is middles next and not previous? // TODO: More intuitive if head is middles next and not previous?
// so swap head and tail // so swap head and tail
head->next = middle; af_head_->next = af_middle_;
middle->next = tail; af_middle_->next = af_tail_;
middle->prev = head; af_middle_->prev = af_head_;
tail->prev = middle; af_tail_->prev = af_middle_;
} }
void SweepContext::RemoveNode(Node* node) void SweepContext::RemoveNode(Node* node)
@ -180,9 +175,27 @@ void SweepContext::MeshClean(Triangle& triangle)
SweepContext::~SweepContext() SweepContext::~SweepContext()
{ {
delete head_;
delete tail_; // Clean up memory
delete front_;
delete head_;
delete tail_;
delete front_;
delete af_head_;
delete af_middle_;
delete af_tail_;
typedef std::list<Triangle*> type_list;
for(type_list::iterator iter = map_.begin(); iter != map_.end(); ++iter) {
Triangle* ptr = *iter;
delete ptr;
}
for(int i = 0; i < edge_list.size(); i++) {
delete edge_list[i];
}
} }
} }

View File

@ -1,4 +1,4 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
@ -28,7 +28,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef SWEEP_CONTEXT_H #ifndef SWEEP_CONTEXT_H
#define SWEEP_CONTEXT_H #define SWEEP_CONTEXT_H
@ -91,7 +91,8 @@ AdvancingFront* front();
void MeshClean(Triangle& triangle); void MeshClean(Triangle& triangle);
std::vector<Triangle*> GetTriangles(); std::vector<Triangle*> GetTriangles();
std::list<Triangle*> GetMap(); std::list<Triangle*> GetMap();
std::vector<Edge*> edge_list; std::vector<Edge*> edge_list;
struct Basin { struct Basin {
@ -133,7 +134,6 @@ friend class Sweep;
std::vector<Triangle*> triangles_; std::vector<Triangle*> triangles_;
std::list<Triangle*> map_; std::list<Triangle*> map_;
std::vector<Point*> points_; std::vector<Point*> points_;
// Advancing front // Advancing front
@ -143,7 +143,7 @@ Point* head_;
// tail point used with advancing front // tail point used with advancing front
Point* tail_; Point* tail_;
//EdgeEvent edgeEvent = new EdgeEvent(); Node *af_head_, *af_middle_, *af_tail_;
void InitTriangulation(); void InitTriangulation();
void InitEdges(std::vector<Point*> polyline); void InitEdges(std::vector<Point*> polyline);

View File

@ -1,4 +1,4 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
@ -79,18 +79,18 @@ bool random_distribution = false;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int num_points = 0; int num_points = 0;
double max, min; double max, min;
double zoom; double zoom;
if (argc != 5) { if (argc != 5) {
cout << "-== USAGE ==-" << endl; cout << "-== USAGE ==-" << endl;
cout << "Load Data File: p2t filename center_x center_y zoom" << endl; cout << "Load Data File: p2t filename center_x center_y zoom" << endl;
cout << " Random Points: p2t random num_points width zoom" << endl; cout << " Random Points: p2t random num_points width zoom" << endl;
return 1; return 1;
} }
if(string(argv[1]) == "random") { if(string(argv[1]) == "random") {
num_points = atoi(argv[2]); num_points = atoi(argv[2]);
random_distribution = true; random_distribution = true;
@ -103,10 +103,10 @@ int main(int argc, char* argv[])
zoom = atof(argv[4]); zoom = atof(argv[4]);
cx = atof(argv[2]); cx = atof(argv[2]);
cy = atof(argv[3]); cy = atof(argv[3]);
} }
vector<p2t::Point*> polyline; vector<p2t::Point*> polyline;
if(random_distribution) { if(random_distribution) {
// Create a simple bounding box // Create a simple bounding box
polyline.push_back(new Point(min,min)); polyline.push_back(new Point(min,min));
@ -115,7 +115,7 @@ int main(int argc, char* argv[])
polyline.push_back(new Point(max,min)); polyline.push_back(new Point(max,min));
} else { } else {
// Load pointset from file // Load pointset from file
// Parse and tokenize data file // Parse and tokenize data file
string line; string line;
ifstream myfile(argv[1]); ifstream myfile(argv[1]);
@ -142,25 +142,25 @@ int main(int argc, char* argv[])
cout << "Number of constrained edges = " << polyline.size() << endl; cout << "Number of constrained edges = " << polyline.size() << endl;
polylines.push_back(polyline); polylines.push_back(polyline);
Init(); Init();
/* /*
* Perform triangulation! * Perform triangulation!
*/ */
double init_time = glfwGetTime(); double init_time = glfwGetTime();
/* /*
* STEP 1: Create CDT and add primary polyline * STEP 1: Create CDT and add primary polyline
* NOTE: polyline must be a simple polygon. The polyline's points * NOTE: polyline must be a simple polygon. The polyline's points
* constitute constrained edges. No repeat points!!! * constitute constrained edges. No repeat points!!!
*/ */
CDT* cdt = new CDT(polyline); CDT* cdt = new CDT(polyline);
/* /*
* STEP 2: Add holes or Steiner points if necessary * STEP 2: Add holes or Steiner points if necessary
*/ */
string s(argv[1]); string s(argv[1]);
if(s.find("dude.dat", 0) != string::npos) { if(s.find("dude.dat", 0) != string::npos) {
// Add head hole // Add head hole
@ -182,12 +182,12 @@ int main(int argc, char* argv[])
cdt->AddPoint(new Point(x, y)); cdt->AddPoint(new Point(x, y));
} }
} }
/* /*
* STEP 3: Triangulate! * STEP 3: Triangulate!
*/ */
cdt->Triangulate(); cdt->Triangulate();
double dt = glfwGetTime() - init_time; double dt = glfwGetTime() - init_time;
triangles = cdt->GetTriangles(); triangles = cdt->GetTriangles();
@ -196,9 +196,10 @@ int main(int argc, char* argv[])
cout << "Number of points = " << num_points << endl; cout << "Number of points = " << num_points << endl;
cout << "Number of triangles = " << triangles.size() << endl; cout << "Number of triangles = " << triangles.size() << endl;
cout << "Elapsed time (ms) = " << dt*1000.0 << endl; cout << "Elapsed time (ms) = " << dt*1000.0 << endl;
MainLoop(zoom);
MainLoop(zoom);
delete cdt;
ShutDown(0); ShutDown(0);
return 0; return 0;
} }
@ -216,7 +217,7 @@ void Init()
glfwSetWindowTitle("Poly2Tri - C++"); glfwSetWindowTitle("Poly2Tri - C++");
glfwSwapInterval(1); glfwSwapInterval(1);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
@ -310,10 +311,10 @@ void Draw(const double zoom)
glVertex2f(c.x, c.y); glVertex2f(c.x, c.y);
glEnd(); glEnd();
} }
// green // green
glColor3f(0, 1, 0); glColor3f(0, 1, 0);
for(int i = 0; i < polylines.size(); i++) { for(int i = 0; i < polylines.size(); i++) {
vector<Point*> poly = polylines[i]; vector<Point*> poly = polylines[i];
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
@ -376,7 +377,7 @@ vector<Point*> CreateHeadHole() {
head_hole.push_back(new Point(320, 423)); head_hole.push_back(new Point(320, 423));
head_hole.push_back(new Point(329, 413)); head_hole.push_back(new Point(329, 413));
head_hole.push_back(new Point(332, 423)); head_hole.push_back(new Point(332, 423));
return head_hole; return head_hole;
} }
@ -389,7 +390,7 @@ vector<Point*> CreateChestHole() {
chest_hole.push_back(new Point(329.8148,510.41534)); chest_hole.push_back(new Point(329.8148,510.41534));
chest_hole.push_back(new Point(339.91632,480.11077)); chest_hole.push_back(new Point(339.91632,480.11077));
chest_hole.push_back(new Point(334.86556,478.09046)); chest_hole.push_back(new Point(334.86556,478.09046));
return chest_hole; return chest_hole;
} }

0
waf vendored Normal file → Executable file
View File

28
wscript
View File

@ -5,42 +5,42 @@ srcdir = '.'
blddir = 'build' blddir = 'build'
p2t_source_files = ['poly2tri/common/shapes.cc', p2t_source_files = ['poly2tri/common/shapes.cc',
'poly2tri/sweep/cdt.cc', 'poly2tri/sweep/cdt.cc',
'poly2tri/sweep/advancing_front.cc', 'poly2tri/sweep/advancing_front.cc',
'poly2tri/sweep/sweep_context.cc', 'poly2tri/sweep/sweep_context.cc',
'poly2tri/sweep/sweep.cc'] 'poly2tri/sweep/sweep.cc']
testbed_source_files = ['testbed/main.cc'] testbed_source_files = ['testbed/main.cc']
#Platform specific libs #Platform specific libs
if sys.platform == 'win32': if sys.platform == 'win32':
# MS Windows # MS Windows
sys_libs = ['glfw', 'opengl32'] sys_libs = ['glfw', 'opengl32']
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
# Apple OSX # Apple OSX
sys_libs = ['glfw', 'OpenGL'] sys_libs = ['glfw', 'OpenGL']
else: else:
# GNU/Linux, BSD, etc # GNU/Linux, BSD, etc
sys_libs = ['glfw', 'GL'] sys_libs = ['glfw', 'GL']
def init(): def init():
print(' init called') print(' init called')
def set_options(opt): def set_options(opt):
print(' set_options') print(' set_options')
opt.tool_options('g++') opt.tool_options('g++')
def configure(conf): def configure(conf):
print(' calling the configuration') print(' calling the configuration')
conf.check_tool('g++') conf.check_tool('g++')
#conf.env.CXXFLAGS = ['-O0', '-pg', '-g'] #conf.env.CXXFLAGS = ['-O0', '-pg', '-g']
#conf.env.CXXFLAGS = ['-O0', '-g'] conf.env.CXXFLAGS = ['-O0', '-g']
conf.env.CXXFLAGS = ['-O3', '-ffast-math'] #conf.env.CXXFLAGS = ['-O3', '-ffast-math']
def build(bld): def build(bld):
print(' building') print(' building')
''' '''
# A static library # A static library
# The extension (.a) is added automatically # The extension (.a) is added automatically
@ -49,7 +49,7 @@ def build(bld):
source = p2t_source_files, source = p2t_source_files,
name = 'poly2tri', name = 'poly2tri',
target = 'poly2tri') target = 'poly2tri')
# 1. A simple program # 1. A simple program
bld.new_task_gen( bld.new_task_gen(
features = 'cxx cprogram', features = 'cxx cprogram',
@ -64,6 +64,6 @@ def build(bld):
source = testbed_source_files + p2t_source_files, source = testbed_source_files + p2t_source_files,
target = 'p2t', target = 'p2t',
libs = sys_libs) libs = sys_libs)
def shutdown(): def shutdown():
print(' shutdown called') print(' shutdown called')