mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-30 01:03:30 +01:00
added p2t namespace
This commit is contained in:
parent
793760887b
commit
5dbe785975
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -30,3 +30,4 @@
|
||||
*/
|
||||
#include "common/shapes.h"
|
||||
#include "sweep/cdt.h"
|
||||
|
||||
|
@ -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_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "sweep_context.h"
|
||||
#include "sweep.h"
|
||||
|
||||
namespace p2t {
|
||||
|
||||
class CDT
|
||||
{
|
||||
public:
|
||||
@ -55,3 +57,5 @@ Sweep* sweep_;
|
||||
/// Destructor
|
||||
~CDT();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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&
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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_;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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_;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user