added p2t namespace

This commit is contained in:
zzzzrrr 2010-01-22 19:50:35 -05:00
parent 793760887b
commit 5dbe785975
13 changed files with 49 additions and 17 deletions

View File

@ -31,6 +31,8 @@
#include "shapes.h"
#include <iostream>
namespace p2t {
Triangle::Triangle(Point& a, Point& b, Point& c)
{
points_[0] = &a; points_[1] = &b; points_[2] = &c;
@ -328,5 +330,5 @@ void Triangle::DebugPrint()
cout << points_[2]->x << "," << points_[2]->y << endl;
}
}

View File

@ -38,6 +38,8 @@
#include <assert.h>
#include <cmath>
namespace p2t {
struct Node;
struct Edge;
@ -312,5 +314,8 @@ inline void Triangle::IsInterior(bool b)
interior_ = b;
}
}
#endif

View File

@ -29,17 +29,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UTILS_H
#define UTILS_H
#include <exception>
#include <math.h>
template<typename T, int size>
int array_length(T(&)[size])
{
return size;
}
namespace p2t {
const double PI_3div4 = 3 * M_PI / 4;
const double EPSILON = 1e-12;
@ -100,5 +93,5 @@ bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
return true;
}
#endif
}

View File

@ -30,3 +30,4 @@
*/
#include "common/shapes.h"
#include "sweep/cdt.h"

View File

@ -30,6 +30,8 @@
*/
#include "advancing_front.h"
namespace p2t {
AdvancingFront::AdvancingFront(Node& head, Node& tail)
{
head_ = &head;
@ -104,3 +106,6 @@ AdvancingFront::~AdvancingFront()
delete search_node_;
delete tail_;
}
}

View File

@ -30,6 +30,8 @@
*/
#include "../common/shapes.h"
namespace p2t {
struct Node;
// Advancing front node
@ -108,3 +110,5 @@ inline void AdvancingFront::set_search(Node* node)
search_node_ = node;
}
}

View File

@ -30,6 +30,8 @@
*/
#include "cdt.h"
namespace p2t {
CDT::CDT(Point** polyline, const int& point_count)
{
sweep_context_ = new SweepContext(polyline, point_count);
@ -45,12 +47,12 @@ void CDT::Triangulate()
sweep_->Triangulate(*sweep_context_);
}
std::vector<Triangle*> CDT::GetTriangles()
std::vector<p2t::Triangle*> CDT::GetTriangles()
{
return sweep_context_->GetTriangles();
}
std::list<Triangle*> CDT::GetMap()
std::list<p2t::Triangle*> CDT::GetMap()
{
return sweep_context_->GetMap();
}
@ -61,3 +63,5 @@ CDT::~CDT()
delete sweep_;
}
}

View File

@ -32,6 +32,8 @@
#include "sweep_context.h"
#include "sweep.h"
namespace p2t {
class CDT
{
public:
@ -55,3 +57,5 @@ Sweep* sweep_;
/// Destructor
~CDT();
};
}

View File

@ -33,6 +33,8 @@
#include "advancing_front.h"
#include "../common/utils.h"
namespace p2t {
// Triangulate simple polygon with holes
void Sweep::Triangulate(SweepContext& tcx)
{
@ -801,4 +803,5 @@ void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle&
}
}
}

View File

@ -28,7 +28,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Sweep-line, Constrained Delauney Triangulation (CDT) See: Domiter, V. and
* Zalik, B.(2008)'Sweep-line algorithm for constrained Delaunay triangulation',
@ -37,6 +36,8 @@
* "FlipScan" Constrained Edge Algorithm invented by Thomas Åhlén, thahlen@gmail.com
*/
namespace p2t {
class SweepContext;
struct Node;
struct Point;
@ -110,3 +111,5 @@ void FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& flip_t
void FinalizationPolygon(SweepContext& tcx);
};
}

View File

@ -33,6 +33,8 @@
#include <GL/glfw.h>
#include "advancing_front.h"
namespace p2t {
SweepContext::SweepContext(Point** polyline, const int& point_count)
{
basin = Basin();
@ -168,3 +170,5 @@ SweepContext::~SweepContext()
delete tail_;
delete front_;
}
}

View File

@ -31,6 +31,8 @@
#include <list>
#include <vector>
namespace p2t {
// Inital triangle factor, seed triangle will extend 30% of
// PointSet width to both left and right.
const double kAlpha = 0.3;
@ -41,7 +43,6 @@ struct Node;
struct Edge;
class AdvancingFront;
class SweepContext {
public:
@ -166,3 +167,5 @@ inline Point* SweepContext::tail()
{
return tail_;
}
}

View File

@ -40,7 +40,7 @@
using namespace std;
#include "../poly2tri/poly2tri.h"
using namespace p2t;
void Init();
void ShutDown(int return_code);
@ -76,6 +76,7 @@ bool draw_map = false;
int main(int argc, char* argv[])
{
if (argc != 5) {
cout << "Usage: p2t filename centerX centerY zoom" << endl;
return 1;
@ -101,7 +102,7 @@ int main(int argc, char* argv[])
string line;
ifstream myfile(argv[1]);
vector<Point*> points;
vector<p2t::Point*> points;
if (myfile.is_open()) {
while (!myfile.eof()) {
getline(myfile, line);