Very minor fixes: Uncrustify a few files and rename a shadowed var.
This commit is contained in:
parent
78e4787297
commit
146a78a8fb
|
@ -56,7 +56,7 @@ struct Point
|
|||
std::vector<Edge*> edge_list;
|
||||
|
||||
/// Construct using coordinates.
|
||||
Point( double x, double y ) : x( x ), y( y ) {}
|
||||
Point( double ax, double ay ) : x( ax ), y( ay ) {}
|
||||
|
||||
/// Set this point to all zeros.
|
||||
void set_zero()
|
||||
|
|
|
@ -31,79 +31,105 @@
|
|||
#include "advancing_front.h"
|
||||
|
||||
namespace p2t {
|
||||
|
||||
AdvancingFront::AdvancingFront(Node& head, Node& tail)
|
||||
AdvancingFront::AdvancingFront( Node& head, Node& tail )
|
||||
{
|
||||
head_ = &head;
|
||||
tail_ = &tail;
|
||||
search_node_ = &head;
|
||||
head_ = &head;
|
||||
tail_ = &tail;
|
||||
search_node_ = &head;
|
||||
}
|
||||
|
||||
Node* AdvancingFront::LocateNode(const double& x)
|
||||
{
|
||||
Node* node = search_node_;
|
||||
|
||||
if (x < node->value) {
|
||||
while ((node = node->prev) != NULL) {
|
||||
if (x >= node->value) {
|
||||
Node* AdvancingFront::LocateNode( const double& x )
|
||||
{
|
||||
Node* node = search_node_;
|
||||
|
||||
if( x < node->value )
|
||||
{
|
||||
while( (node = node->prev) != NULL )
|
||||
{
|
||||
if( x >= node->value )
|
||||
{
|
||||
search_node_ = node;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( (node = node->next) != NULL )
|
||||
{
|
||||
if( x < node->value )
|
||||
{
|
||||
search_node_ = node->prev;
|
||||
return node->prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Node* AdvancingFront::FindSearchNode( const double& x )
|
||||
{
|
||||
(void) x; // suppress compiler warnings "unused parameter 'x'"
|
||||
// TODO: implement BST index
|
||||
return search_node_;
|
||||
}
|
||||
|
||||
|
||||
Node* AdvancingFront::LocatePoint( const Point* point )
|
||||
{
|
||||
const double px = point->x;
|
||||
Node* node = FindSearchNode( px );
|
||||
const double nx = node->point->x;
|
||||
|
||||
if( px == nx )
|
||||
{
|
||||
if( point != node->point )
|
||||
{
|
||||
// We might have two nodes with same x value for a short time
|
||||
if( point == node->prev->point )
|
||||
{
|
||||
node = node->prev;
|
||||
}
|
||||
else if( point == node->next->point )
|
||||
{
|
||||
node = node->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( px < nx )
|
||||
{
|
||||
while( (node = node->prev) != NULL )
|
||||
{
|
||||
if( point == node->point )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( (node = node->next) != NULL )
|
||||
{
|
||||
if( point == node->point )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( node )
|
||||
search_node_ = node;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((node = node->next) != NULL) {
|
||||
if (x < node->value) {
|
||||
search_node_ = node->prev;
|
||||
return node->prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
Node* AdvancingFront::FindSearchNode(const double& x)
|
||||
{
|
||||
(void)x; // suppress compiler warnings "unused parameter 'x'"
|
||||
// TODO: implement BST index
|
||||
return search_node_;
|
||||
}
|
||||
|
||||
Node* AdvancingFront::LocatePoint(const Point* point)
|
||||
{
|
||||
const double px = point->x;
|
||||
Node* node = FindSearchNode(px);
|
||||
const double nx = node->point->x;
|
||||
|
||||
if (px == nx) {
|
||||
if (point != node->point) {
|
||||
// We might have two nodes with same x value for a short time
|
||||
if (point == node->prev->point) {
|
||||
node = node->prev;
|
||||
} else if (point == node->next->point) {
|
||||
node = node->next;
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
} else if (px < nx) {
|
||||
while ((node = node->prev) != NULL) {
|
||||
if (point == node->point) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((node = node->next) != NULL) {
|
||||
if (point == node->point)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(node) search_node_ = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
AdvancingFront::~AdvancingFront()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -35,84 +35,91 @@
|
|||
#include "../common/shapes.h"
|
||||
|
||||
namespace p2t {
|
||||
|
||||
struct Node;
|
||||
|
||||
// Advancing front node
|
||||
struct Node {
|
||||
Point* point;
|
||||
Triangle* triangle;
|
||||
struct Node
|
||||
{
|
||||
Point* point;
|
||||
Triangle* triangle;
|
||||
|
||||
Node* next;
|
||||
Node* prev;
|
||||
Node* next;
|
||||
Node* prev;
|
||||
|
||||
double value;
|
||||
double value;
|
||||
|
||||
Node(Point& p) : point(&p), triangle(NULL), next(NULL), prev(NULL), value(p.x)
|
||||
{
|
||||
}
|
||||
|
||||
Node(Point& p, Triangle& t) : point(&p), triangle(&t), next(NULL), prev(NULL), value(p.x)
|
||||
{
|
||||
}
|
||||
Node( Point& p ) : point( &p ), triangle( NULL ), next( NULL ), prev( NULL ), value( p.x )
|
||||
{
|
||||
}
|
||||
|
||||
Node( Point& p, Triangle& t ) : point( &p ), triangle( &t ), next( NULL ), prev( NULL ), value(
|
||||
p.x )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// Advancing front
|
||||
class AdvancingFront {
|
||||
class AdvancingFront
|
||||
{
|
||||
public:
|
||||
|
||||
AdvancingFront(Node& head, Node& tail);
|
||||
AdvancingFront( Node& head, Node& tail );
|
||||
// Destructor
|
||||
~AdvancingFront();
|
||||
~AdvancingFront();
|
||||
|
||||
Node* head();
|
||||
void set_head(Node* node);
|
||||
Node* tail();
|
||||
void set_tail(Node* node);
|
||||
Node* search();
|
||||
void set_search(Node* node);
|
||||
Node* head();
|
||||
void set_head( Node* node );
|
||||
Node* tail();
|
||||
void set_tail( Node* node );
|
||||
Node* search();
|
||||
void set_search( Node* node );
|
||||
|
||||
/// Locate insertion point along advancing front
|
||||
Node* LocateNode(const double& x);
|
||||
Node* LocateNode( const double& x );
|
||||
|
||||
Node* LocatePoint(const Point* point);
|
||||
Node* LocatePoint( const Point* point );
|
||||
|
||||
private:
|
||||
|
||||
Node* head_, *tail_, *search_node_;
|
||||
Node* head_, * tail_, * search_node_;
|
||||
|
||||
Node* FindSearchNode(const double& x);
|
||||
Node* FindSearchNode( const double& x );
|
||||
};
|
||||
|
||||
inline Node* AdvancingFront::head()
|
||||
{
|
||||
return head_;
|
||||
return head_;
|
||||
}
|
||||
inline void AdvancingFront::set_head(Node* node)
|
||||
|
||||
|
||||
inline void AdvancingFront::set_head( Node* node )
|
||||
{
|
||||
head_ = node;
|
||||
head_ = node;
|
||||
}
|
||||
|
||||
|
||||
inline Node* AdvancingFront::tail()
|
||||
{
|
||||
return tail_;
|
||||
return tail_;
|
||||
}
|
||||
inline void AdvancingFront::set_tail(Node* node)
|
||||
|
||||
|
||||
inline void AdvancingFront::set_tail( Node* node )
|
||||
{
|
||||
tail_ = node;
|
||||
tail_ = node;
|
||||
}
|
||||
|
||||
|
||||
inline Node* AdvancingFront::search()
|
||||
{
|
||||
return search_node_;
|
||||
return search_node_;
|
||||
}
|
||||
|
||||
inline void AdvancingFront::set_search(Node* node)
|
||||
|
||||
inline void AdvancingFront::set_search( Node* node )
|
||||
{
|
||||
search_node_ = node;
|
||||
search_node_ = node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
||||
* http://code.google.com/p/poly2tri/
|
||||
*
|
||||
|
@ -31,42 +31,46 @@
|
|||
#include "cdt.h"
|
||||
|
||||
namespace p2t {
|
||||
|
||||
CDT::CDT(std::vector<Point*> polyline)
|
||||
CDT::CDT( std::vector<Point*> polyline )
|
||||
{
|
||||
sweep_context_ = new SweepContext(polyline);
|
||||
sweep_ = new Sweep;
|
||||
sweep_context_ = new SweepContext( polyline );
|
||||
sweep_ = new Sweep;
|
||||
}
|
||||
|
||||
void CDT::AddHole(std::vector<Point*> polyline)
|
||||
|
||||
void CDT::AddHole( std::vector<Point*> polyline )
|
||||
{
|
||||
sweep_context_->AddHole(polyline);
|
||||
sweep_context_->AddHole( polyline );
|
||||
}
|
||||
|
||||
void CDT::AddPoint(Point* point) {
|
||||
sweep_context_->AddPoint(point);
|
||||
|
||||
void CDT::AddPoint( Point* point )
|
||||
{
|
||||
sweep_context_->AddPoint( point );
|
||||
}
|
||||
|
||||
|
||||
void CDT::Triangulate()
|
||||
{
|
||||
sweep_->Triangulate(*sweep_context_);
|
||||
sweep_->Triangulate( *sweep_context_ );
|
||||
}
|
||||
|
||||
|
||||
std::vector<p2t::Triangle*> CDT::GetTriangles()
|
||||
{
|
||||
return sweep_context_->GetTriangles();
|
||||
return sweep_context_->GetTriangles();
|
||||
}
|
||||
|
||||
|
||||
std::list<p2t::Triangle*> CDT::GetMap()
|
||||
{
|
||||
return sweep_context_->GetMap();
|
||||
return sweep_context_->GetMap();
|
||||
}
|
||||
|
||||
|
||||
CDT::~CDT()
|
||||
{
|
||||
delete sweep_context_;
|
||||
delete sweep_;
|
||||
delete sweep_context_;
|
||||
delete sweep_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,164 +33,193 @@
|
|||
#include "advancing_front.h"
|
||||
|
||||
namespace p2t {
|
||||
|
||||
SweepContext::SweepContext(std::vector<Point*> polyline) :
|
||||
front_(0),
|
||||
head_(0),
|
||||
tail_(0),
|
||||
af_head_(0),
|
||||
af_middle_(0),
|
||||
af_tail_(0)
|
||||
SweepContext::SweepContext( std::vector<Point*> polyline ) :
|
||||
front_( 0 ),
|
||||
head_( 0 ),
|
||||
tail_( 0 ),
|
||||
af_head_( 0 ),
|
||||
af_middle_( 0 ),
|
||||
af_tail_( 0 )
|
||||
{
|
||||
basin = Basin();
|
||||
edge_event = EdgeEvent();
|
||||
basin = Basin();
|
||||
edge_event = EdgeEvent();
|
||||
|
||||
points_ = polyline;
|
||||
points_ = polyline;
|
||||
|
||||
InitEdges(points_);
|
||||
InitEdges( points_ );
|
||||
}
|
||||
|
||||
void SweepContext::AddHole(std::vector<Point*> polyline)
|
||||
|
||||
void SweepContext::AddHole( std::vector<Point*> polyline )
|
||||
{
|
||||
InitEdges(polyline);
|
||||
for(unsigned int i = 0; i < polyline.size(); i++) {
|
||||
points_.push_back(polyline[i]);
|
||||
}
|
||||
InitEdges( polyline );
|
||||
|
||||
for( unsigned int i = 0; i < polyline.size(); i++ )
|
||||
{
|
||||
points_.push_back( polyline[i] );
|
||||
}
|
||||
}
|
||||
|
||||
void SweepContext::AddPoint(Point* point) {
|
||||
points_.push_back(point);
|
||||
|
||||
void SweepContext::AddPoint( Point* point )
|
||||
{
|
||||
points_.push_back( point );
|
||||
}
|
||||
|
||||
|
||||
std::vector<Triangle*> SweepContext::GetTriangles()
|
||||
{
|
||||
return triangles_;
|
||||
return triangles_;
|
||||
}
|
||||
|
||||
|
||||
std::list<Triangle*> SweepContext::GetMap()
|
||||
{
|
||||
return map_;
|
||||
return map_;
|
||||
}
|
||||
|
||||
|
||||
void SweepContext::InitTriangulation()
|
||||
{
|
||||
double xmax(points_[0]->x), xmin(points_[0]->x);
|
||||
double ymax(points_[0]->y), ymin(points_[0]->y);
|
||||
double xmax( points_[0]->x ), xmin( points_[0]->x );
|
||||
double ymax( points_[0]->y ), ymin( points_[0]->y );
|
||||
|
||||
// Calculate bounds.
|
||||
for (unsigned int i = 0; i < points_.size(); i++) {
|
||||
Point& p = *points_[i];
|
||||
if (p.x > xmax)
|
||||
xmax = p.x;
|
||||
if (p.x < xmin)
|
||||
xmin = p.x;
|
||||
if (p.y > ymax)
|
||||
ymax = p.y;
|
||||
if (p.y < ymin)
|
||||
ymin = p.y;
|
||||
}
|
||||
// Calculate bounds.
|
||||
for( unsigned int i = 0; i < points_.size(); i++ )
|
||||
{
|
||||
Point& p = *points_[i];
|
||||
|
||||
double dx = kAlpha * (xmax - xmin);
|
||||
double dy = kAlpha * (ymax - ymin);
|
||||
head_ = new Point(xmax + dx, ymin - dy);
|
||||
tail_ = new Point(xmin - dx, ymin - dy);
|
||||
if( p.x > xmax )
|
||||
xmax = p.x;
|
||||
|
||||
// Sort points along y-axis
|
||||
std::sort(points_.begin(), points_.end(), cmp);
|
||||
if( p.x < xmin )
|
||||
xmin = p.x;
|
||||
|
||||
}
|
||||
if( p.y > ymax )
|
||||
ymax = p.y;
|
||||
|
||||
void SweepContext::InitEdges(std::vector<Point*> polyline)
|
||||
{
|
||||
int num_points = polyline.size();
|
||||
for (int i = 0; i < num_points; i++) {
|
||||
int j = i < num_points - 1 ? i + 1 : 0;
|
||||
edge_list.push_back(new Edge(*polyline[i], *polyline[j]));
|
||||
}
|
||||
}
|
||||
|
||||
Point* SweepContext::GetPoint(const int& index)
|
||||
{
|
||||
return points_[index];
|
||||
}
|
||||
|
||||
void SweepContext::AddToMap(Triangle* triangle)
|
||||
{
|
||||
map_.push_back(triangle);
|
||||
}
|
||||
|
||||
Node& SweepContext::LocateNode(Point& point)
|
||||
{
|
||||
// TODO implement search tree
|
||||
return *front_->LocateNode(point.x);
|
||||
}
|
||||
|
||||
void SweepContext::CreateAdvancingFront(std::vector<Node*> nodes)
|
||||
{
|
||||
|
||||
(void) nodes;
|
||||
// Initial triangle
|
||||
Triangle* triangle = new Triangle(*points_[0], *tail_, *head_);
|
||||
|
||||
map_.push_back(triangle);
|
||||
|
||||
af_head_ = new Node(*triangle->GetPoint(1), *triangle);
|
||||
af_middle_ = new Node(*triangle->GetPoint(0), *triangle);
|
||||
af_tail_ = new Node(*triangle->GetPoint(2));
|
||||
front_ = new AdvancingFront(*af_head_, *af_tail_);
|
||||
|
||||
// TODO: More intuitive if head is middles next and not previous?
|
||||
// so swap head and tail
|
||||
af_head_->next = af_middle_;
|
||||
af_middle_->next = af_tail_;
|
||||
af_middle_->prev = af_head_;
|
||||
af_tail_->prev = af_middle_;
|
||||
}
|
||||
|
||||
void SweepContext::RemoveNode(Node* node)
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
|
||||
void SweepContext::MapTriangleToNodes(Triangle& t)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!t.GetNeighbor(i)) {
|
||||
Node* n = front_->LocatePoint(t.PointCW(*t.GetPoint(i)));
|
||||
if (n)
|
||||
n->triangle = &t;
|
||||
if( p.y < ymin )
|
||||
ymin = p.y;
|
||||
}
|
||||
}
|
||||
|
||||
double dx = kAlpha * (xmax - xmin);
|
||||
double dy = kAlpha * (ymax - ymin);
|
||||
head_ = new Point( xmax + dx, ymin - dy );
|
||||
tail_ = new Point( xmin - dx, ymin - dy );
|
||||
|
||||
// Sort points along y-axis
|
||||
std::sort( points_.begin(), points_.end(), cmp );
|
||||
}
|
||||
|
||||
void SweepContext::RemoveFromMap(Triangle* triangle)
|
||||
|
||||
void SweepContext::InitEdges( std::vector<Point*> polyline )
|
||||
{
|
||||
map_.remove(triangle);
|
||||
}
|
||||
int num_points = polyline.size();
|
||||
|
||||
void SweepContext::MeshClean(Triangle& triangle)
|
||||
{
|
||||
std::vector<Triangle *> triangles;
|
||||
triangles.push_back(&triangle);
|
||||
|
||||
while(!triangles.empty()){
|
||||
Triangle *t = triangles.back();
|
||||
triangles.pop_back();
|
||||
|
||||
if (t != NULL && !t->IsInterior()) {
|
||||
t->IsInterior(true);
|
||||
triangles_.push_back(t);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!t->constrained_edge[i])
|
||||
triangles.push_back(t->GetNeighbor(i));
|
||||
}
|
||||
for( int i = 0; i < num_points; i++ )
|
||||
{
|
||||
int j = i < num_points - 1 ? i + 1 : 0;
|
||||
edge_list.push_back( new Edge( *polyline[i], *polyline[j] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Point* SweepContext::GetPoint( const int& index )
|
||||
{
|
||||
return points_[index];
|
||||
}
|
||||
|
||||
|
||||
void SweepContext::AddToMap( Triangle* triangle )
|
||||
{
|
||||
map_.push_back( triangle );
|
||||
}
|
||||
|
||||
|
||||
Node& SweepContext::LocateNode( Point& point )
|
||||
{
|
||||
// TODO implement search tree
|
||||
return *front_->LocateNode( point.x );
|
||||
}
|
||||
|
||||
|
||||
void SweepContext::CreateAdvancingFront( std::vector<Node*> nodes )
|
||||
{
|
||||
(void) nodes;
|
||||
// Initial triangle
|
||||
Triangle* triangle = new Triangle( *points_[0], *tail_, *head_ );
|
||||
|
||||
map_.push_back( triangle );
|
||||
|
||||
af_head_ = new Node( *triangle->GetPoint( 1 ), *triangle );
|
||||
af_middle_ = new Node( *triangle->GetPoint( 0 ), *triangle );
|
||||
af_tail_ = new Node( *triangle->GetPoint( 2 ) );
|
||||
front_ = new AdvancingFront( *af_head_, *af_tail_ );
|
||||
|
||||
// TODO: More intuitive if head is middles next and not previous?
|
||||
// so swap head and tail
|
||||
af_head_->next = af_middle_;
|
||||
af_middle_->next = af_tail_;
|
||||
af_middle_->prev = af_head_;
|
||||
af_tail_->prev = af_middle_;
|
||||
}
|
||||
|
||||
|
||||
void SweepContext::RemoveNode( Node* node )
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
|
||||
|
||||
void SweepContext::MapTriangleToNodes( Triangle& t )
|
||||
{
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
if( !t.GetNeighbor( i ) )
|
||||
{
|
||||
Node* n = front_->LocatePoint( t.PointCW( *t.GetPoint( i ) ) );
|
||||
|
||||
if( n )
|
||||
n->triangle = &t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SweepContext::RemoveFromMap( Triangle* triangle )
|
||||
{
|
||||
map_.remove( triangle );
|
||||
}
|
||||
|
||||
|
||||
void SweepContext::MeshClean( Triangle& triangle )
|
||||
{
|
||||
std::vector<Triangle*> triangles;
|
||||
|
||||
triangles.push_back( &triangle );
|
||||
|
||||
while( !triangles.empty() )
|
||||
{
|
||||
Triangle* t = triangles.back();
|
||||
triangles.pop_back();
|
||||
|
||||
if( t != NULL && !t->IsInterior() )
|
||||
{
|
||||
t->IsInterior( true );
|
||||
triangles_.push_back( t );
|
||||
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
if( !t->constrained_edge[i] )
|
||||
triangles.push_back( t->GetNeighbor( i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SweepContext::~SweepContext()
|
||||
{
|
||||
|
||||
// Clean up memory
|
||||
|
||||
delete head_;
|
||||
|
@ -202,15 +231,15 @@ SweepContext::~SweepContext()
|
|||
|
||||
typedef std::list<Triangle*> type_list;
|
||||
|
||||
for(type_list::iterator iter = map_.begin(); iter != map_.end(); ++iter) {
|
||||
for( type_list::iterator iter = map_.begin(); iter != map_.end(); ++iter )
|
||||
{
|
||||
Triangle* ptr = *iter;
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < edge_list.size(); i++) {
|
||||
for( unsigned int i = 0; i < edge_list.size(); i++ )
|
||||
{
|
||||
delete edge_list[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <cstddef>
|
||||
|
||||
namespace p2t {
|
||||
|
||||
// Inital triangle factor, seed triangle will extend 30% of
|
||||
// PointSet width to both left and right.
|
||||
const double kAlpha = 0.3;
|
||||
|
@ -48,139 +47,147 @@ struct Node;
|
|||
struct Edge;
|
||||
class AdvancingFront;
|
||||
|
||||
class SweepContext {
|
||||
class SweepContext
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
SweepContext(std::vector<Point*> polyline);
|
||||
SweepContext( std::vector<Point*> polyline );
|
||||
/// Destructor
|
||||
~SweepContext();
|
||||
~SweepContext();
|
||||
|
||||
void set_head(Point* p1);
|
||||
void set_head( Point* p1 );
|
||||
|
||||
Point* head();
|
||||
Point* head();
|
||||
|
||||
void set_tail(Point* p1);
|
||||
void set_tail( Point* p1 );
|
||||
|
||||
Point* tail();
|
||||
Point* tail();
|
||||
|
||||
int point_count();
|
||||
int point_count();
|
||||
|
||||
Node& LocateNode(Point& point);
|
||||
Node& LocateNode( Point& point );
|
||||
|
||||
void RemoveNode(Node* node);
|
||||
void RemoveNode( Node* node );
|
||||
|
||||
void CreateAdvancingFront(std::vector<Node*> nodes);
|
||||
void CreateAdvancingFront( std::vector<Node*> nodes );
|
||||
|
||||
/// Try to map a node to all sides of this triangle that don't have a neighbor
|
||||
void MapTriangleToNodes(Triangle& t);
|
||||
void MapTriangleToNodes( Triangle& t );
|
||||
|
||||
void AddToMap(Triangle* triangle);
|
||||
void AddToMap( Triangle* triangle );
|
||||
|
||||
Point* GetPoint(const int& index);
|
||||
Point* GetPoint( const int& index );
|
||||
|
||||
Point* GetPoints();
|
||||
Point* GetPoints();
|
||||
|
||||
void RemoveFromMap(Triangle* triangle);
|
||||
void RemoveFromMap( Triangle* triangle );
|
||||
|
||||
void AddHole(std::vector<Point*> polyline);
|
||||
void AddHole( std::vector<Point*> polyline );
|
||||
|
||||
void AddPoint(Point* point);
|
||||
void AddPoint( Point* point );
|
||||
|
||||
AdvancingFront* front();
|
||||
AdvancingFront* front();
|
||||
|
||||
void MeshClean(Triangle& triangle);
|
||||
void MeshClean( Triangle& triangle );
|
||||
|
||||
std::vector<Triangle*> GetTriangles();
|
||||
std::list<Triangle*> GetMap();
|
||||
std::vector<Triangle*> GetTriangles();
|
||||
|
||||
std::vector<Edge*> edge_list;
|
||||
std::list<Triangle*> GetMap();
|
||||
|
||||
struct Basin {
|
||||
Node* left_node;
|
||||
Node* bottom_node;
|
||||
Node* right_node;
|
||||
double width;
|
||||
bool left_highest;
|
||||
std::vector<Edge*> edge_list;
|
||||
|
||||
Basin() : left_node(NULL), bottom_node(NULL), right_node(NULL), width(0.0), left_highest(false)
|
||||
{
|
||||
}
|
||||
struct Basin
|
||||
{
|
||||
Node* left_node;
|
||||
Node* bottom_node;
|
||||
Node* right_node;
|
||||
double width;
|
||||
bool left_highest;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
left_node = NULL;
|
||||
bottom_node = NULL;
|
||||
right_node = NULL;
|
||||
width = 0.0;
|
||||
left_highest = false;
|
||||
}
|
||||
};
|
||||
Basin() : left_node( NULL ), bottom_node( NULL ), right_node( NULL ), width( 0.0 ),
|
||||
left_highest( false )
|
||||
{
|
||||
}
|
||||
|
||||
struct EdgeEvent {
|
||||
Edge* constrained_edge;
|
||||
bool right;
|
||||
void Clear()
|
||||
{
|
||||
left_node = NULL;
|
||||
bottom_node = NULL;
|
||||
right_node = NULL;
|
||||
width = 0.0;
|
||||
left_highest = false;
|
||||
}
|
||||
};
|
||||
|
||||
EdgeEvent() : constrained_edge(NULL), right(false)
|
||||
{
|
||||
}
|
||||
};
|
||||
struct EdgeEvent
|
||||
{
|
||||
Edge* constrained_edge;
|
||||
bool right;
|
||||
|
||||
Basin basin;
|
||||
EdgeEvent edge_event;
|
||||
EdgeEvent() : constrained_edge( NULL ), right( false )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Basin basin;
|
||||
EdgeEvent edge_event;
|
||||
|
||||
private:
|
||||
|
||||
friend class Sweep;
|
||||
friend class Sweep;
|
||||
|
||||
std::vector<Triangle*> triangles_;
|
||||
std::list<Triangle*> map_;
|
||||
std::vector<Point*> points_;
|
||||
std::vector<Triangle*> triangles_;
|
||||
std::list<Triangle*> map_;
|
||||
std::vector<Point*> points_;
|
||||
|
||||
// Advancing front
|
||||
AdvancingFront* front_;
|
||||
AdvancingFront* front_;
|
||||
// head point used with advancing front
|
||||
Point* head_;
|
||||
Point* head_;
|
||||
// tail point used with advancing front
|
||||
Point* tail_;
|
||||
Point* tail_;
|
||||
|
||||
Node *af_head_, *af_middle_, *af_tail_;
|
||||
|
||||
void InitTriangulation();
|
||||
void InitEdges(std::vector<Point*> polyline);
|
||||
Node* af_head_, * af_middle_, * af_tail_;
|
||||
|
||||
void InitTriangulation();
|
||||
void InitEdges( std::vector<Point*> polyline );
|
||||
};
|
||||
|
||||
inline AdvancingFront* SweepContext::front()
|
||||
{
|
||||
return front_;
|
||||
return front_;
|
||||
}
|
||||
|
||||
|
||||
inline int SweepContext::point_count()
|
||||
{
|
||||
return points_.size();
|
||||
return points_.size();
|
||||
}
|
||||
|
||||
inline void SweepContext::set_head(Point* p1)
|
||||
|
||||
inline void SweepContext::set_head( Point* p1 )
|
||||
{
|
||||
head_ = p1;
|
||||
head_ = p1;
|
||||
}
|
||||
|
||||
|
||||
inline Point* SweepContext::head()
|
||||
{
|
||||
return head_;
|
||||
return head_;
|
||||
}
|
||||
|
||||
inline void SweepContext::set_tail(Point* p1)
|
||||
|
||||
inline void SweepContext::set_tail( Point* p1 )
|
||||
{
|
||||
tail_ = p1;
|
||||
tail_ = p1;
|
||||
}
|
||||
|
||||
|
||||
inline Point* SweepContext::tail()
|
||||
{
|
||||
return tail_;
|
||||
return tail_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue