Updated poly2tri library from https://github.com/jhasse/poly2tri
This commit is contained in:
parent
5a707a66b9
commit
772b22265c
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -29,10 +29,16 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "shapes.h"
|
#include "shapes.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace p2t {
|
namespace p2t {
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& out, const Point& point) {
|
||||||
|
return out << point.x << "," << point.y;
|
||||||
|
}
|
||||||
|
|
||||||
Triangle::Triangle(Point& a, Point& b, Point& c)
|
Triangle::Triangle(Point& a, Point& b, Point& c)
|
||||||
{
|
{
|
||||||
points_[0] = &a; points_[1] = &b; points_[2] = &c;
|
points_[0] = &a; points_[1] = &b; points_[2] = &c;
|
||||||
@ -150,7 +156,7 @@ void Triangle::Legalize(Point& opoint, Point& npoint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Triangle::Index(const Point* p) const
|
int Triangle::Index(const Point* p)
|
||||||
{
|
{
|
||||||
if (p == points_[0]) {
|
if (p == points_[0]) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -163,7 +169,7 @@ int Triangle::Index(const Point* p) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Triangle::EdgeIndex(const Point* p1, const Point* p2) const
|
int Triangle::EdgeIndex(const Point* p1, const Point* p2)
|
||||||
{
|
{
|
||||||
if (points_[0] == p1) {
|
if (points_[0] == p1) {
|
||||||
if (points_[1] == p2) {
|
if (points_[1] == p2) {
|
||||||
@ -259,7 +265,7 @@ Triangle* Triangle::NeighborCCW(const Point& point)
|
|||||||
return neighbors_[1];
|
return neighbors_[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Triangle::GetConstrainedEdgeCCW(const Point& p) const
|
bool Triangle::GetConstrainedEdgeCCW(const Point& p)
|
||||||
{
|
{
|
||||||
if (&p == points_[0]) {
|
if (&p == points_[0]) {
|
||||||
return constrained_edge[2];
|
return constrained_edge[2];
|
||||||
@ -269,7 +275,7 @@ bool Triangle::GetConstrainedEdgeCCW(const Point& p) const
|
|||||||
return constrained_edge[1];
|
return constrained_edge[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Triangle::GetConstrainedEdgeCW(const Point& p) const
|
bool Triangle::GetConstrainedEdgeCW(const Point& p)
|
||||||
{
|
{
|
||||||
if (&p == points_[0]) {
|
if (&p == points_[0]) {
|
||||||
return constrained_edge[1];
|
return constrained_edge[1];
|
||||||
@ -301,7 +307,7 @@ void Triangle::SetConstrainedEdgeCW(const Point& p, bool ce)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Triangle::GetDelunayEdgeCCW(const Point& p) const
|
bool Triangle::GetDelunayEdgeCCW(const Point& p)
|
||||||
{
|
{
|
||||||
if (&p == points_[0]) {
|
if (&p == points_[0]) {
|
||||||
return delaunay_edge[2];
|
return delaunay_edge[2];
|
||||||
@ -311,7 +317,7 @@ bool Triangle::GetDelunayEdgeCCW(const Point& p) const
|
|||||||
return delaunay_edge[1];
|
return delaunay_edge[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Triangle::GetDelunayEdgeCW(const Point& p) const
|
bool Triangle::GetDelunayEdgeCW(const Point& p)
|
||||||
{
|
{
|
||||||
if (&p == points_[0]) {
|
if (&p == points_[0]) {
|
||||||
return delaunay_edge[1];
|
return delaunay_edge[1];
|
||||||
@ -356,10 +362,7 @@ Triangle& Triangle::NeighborAcross(const Point& opoint)
|
|||||||
|
|
||||||
void Triangle::DebugPrint()
|
void Triangle::DebugPrint()
|
||||||
{
|
{
|
||||||
using namespace std;
|
std::cout << *points_[0] << " " << *points_[1] << " " << *points_[2] << std::endl;
|
||||||
cout << points_[0]->x << "," << points_[0]->y << " ";
|
|
||||||
cout << points_[1]->x << "," << points_[1]->y << " ";
|
|
||||||
cout << points_[2]->x << "," << points_[2]->y << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -33,10 +33,10 @@
|
|||||||
#ifndef SHAPES_H
|
#ifndef SHAPES_H
|
||||||
#define SHAPES_H
|
#define SHAPES_H
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace p2t {
|
namespace p2t {
|
||||||
|
|
||||||
@ -119,6 +119,8 @@ struct Point {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream&, const Point&);
|
||||||
|
|
||||||
// Represents a simple polygon's edge
|
// Represents a simple polygon's edge
|
||||||
struct Edge {
|
struct Edge {
|
||||||
|
|
||||||
@ -130,13 +132,13 @@ struct Edge {
|
|||||||
if (p1.y > p2.y) {
|
if (p1.y > p2.y) {
|
||||||
q = &p1;
|
q = &p1;
|
||||||
p = &p2;
|
p = &p2;
|
||||||
} else if (p1.y == p2.y) {
|
} else if (std::abs(p1.y - p2.y) < 1e-10) {
|
||||||
if (p1.x > p2.x) {
|
if (p1.x > p2.x) {
|
||||||
q = &p1;
|
q = &p1;
|
||||||
p = &p2;
|
p = &p2;
|
||||||
} else if (p1.x == p2.x) {
|
} else if (std::abs(p1.x - p2.x) < 1e-10) {
|
||||||
// Repeat points
|
// Repeat points
|
||||||
assert(false);
|
throw std::runtime_error("Edge::Edge: p1 == p2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,23 +173,23 @@ void MarkConstrainedEdge(int index);
|
|||||||
void MarkConstrainedEdge(Edge& edge);
|
void MarkConstrainedEdge(Edge& edge);
|
||||||
void MarkConstrainedEdge(Point* p, Point* q);
|
void MarkConstrainedEdge(Point* p, Point* q);
|
||||||
|
|
||||||
int Index(const Point* p) const;
|
int Index(const Point* p);
|
||||||
int EdgeIndex(const Point* p1, const Point* p2) const;
|
int EdgeIndex(const Point* p1, const Point* p2);
|
||||||
|
|
||||||
Triangle* NeighborCW(const Point& point);
|
Triangle* NeighborCW(const Point& point);
|
||||||
Triangle* NeighborCCW(const Point& point);
|
Triangle* NeighborCCW(const Point& point);
|
||||||
bool GetConstrainedEdgeCCW(const Point& p) const;
|
bool GetConstrainedEdgeCCW(const Point& p);
|
||||||
bool GetConstrainedEdgeCW(const Point& p) const;
|
bool GetConstrainedEdgeCW(const Point& p);
|
||||||
void SetConstrainedEdgeCCW(const Point& p, bool ce);
|
void SetConstrainedEdgeCCW(const Point& p, bool ce);
|
||||||
void SetConstrainedEdgeCW(const Point& p, bool ce);
|
void SetConstrainedEdgeCW(const Point& p, bool ce);
|
||||||
bool GetDelunayEdgeCCW(const Point& p) const;
|
bool GetDelunayEdgeCCW(const Point& p);
|
||||||
bool GetDelunayEdgeCW(const Point& p) const;
|
bool GetDelunayEdgeCW(const Point& p);
|
||||||
void SetDelunayEdgeCCW(const Point& p, bool e);
|
void SetDelunayEdgeCCW(const Point& p, bool e);
|
||||||
void SetDelunayEdgeCW(const Point& p, bool e);
|
void SetDelunayEdgeCW(const Point& p, bool e);
|
||||||
|
|
||||||
bool Contains(const Point* p) const;
|
bool Contains(const Point* p);
|
||||||
bool Contains(const Edge& e) const;
|
bool Contains(const Edge& e);
|
||||||
bool Contains(const Point* p, const Point* q) const;
|
bool Contains(const Point* p, const Point* q);
|
||||||
void Legalize(Point& point);
|
void Legalize(Point& point);
|
||||||
void Legalize(Point& opoint, Point& npoint);
|
void Legalize(Point& opoint, Point& npoint);
|
||||||
/**
|
/**
|
||||||
@ -198,7 +200,7 @@ void ClearNeighbor(const Triangle *triangle);
|
|||||||
void ClearNeighbors();
|
void ClearNeighbors();
|
||||||
void ClearDelunayEdges();
|
void ClearDelunayEdges();
|
||||||
|
|
||||||
inline bool IsInterior() const;
|
inline bool IsInterior();
|
||||||
inline void IsInterior(bool b);
|
inline void IsInterior(bool b);
|
||||||
|
|
||||||
Triangle& NeighborAcross(const Point& opoint);
|
Triangle& NeighborAcross(const Point& opoint);
|
||||||
@ -293,22 +295,22 @@ inline Triangle* Triangle::GetNeighbor(int index)
|
|||||||
return neighbors_[index];
|
return neighbors_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Triangle::Contains(const Point* p) const
|
inline bool Triangle::Contains(const Point* p)
|
||||||
{
|
{
|
||||||
return p == points_[0] || p == points_[1] || p == points_[2];
|
return p == points_[0] || p == points_[1] || p == points_[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Triangle::Contains(const Edge& e) const
|
inline bool Triangle::Contains(const Edge& e)
|
||||||
{
|
{
|
||||||
return Contains(e.p) && Contains(e.q);
|
return Contains(e.p) && Contains(e.q);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Triangle::Contains(const Point* p, const Point* q) const
|
inline bool Triangle::Contains(const Point* p, const Point* q)
|
||||||
{
|
{
|
||||||
return Contains(p) && Contains(q);
|
return Contains(p) && Contains(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Triangle::IsInterior() const
|
inline bool Triangle::IsInterior()
|
||||||
{
|
{
|
||||||
return interior_;
|
return interior_;
|
||||||
}
|
}
|
||||||
@ -320,4 +322,4 @@ inline void Triangle::IsInterior(bool b)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -34,11 +34,18 @@
|
|||||||
|
|
||||||
// Otherwise #defines like M_PI are undeclared under Visual Studio
|
// Otherwise #defines like M_PI are undeclared under Visual Studio
|
||||||
#ifndef _USE_MATH_DEFINES
|
#ifndef _USE_MATH_DEFINES
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#endif /* _USE_MATH_DEFINES */
|
#endif /* _USE_MATH_DEFINES */
|
||||||
|
|
||||||
|
#include "shapes.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <math.h>
|
|
||||||
|
// C99 removes M_PI from math.h
|
||||||
|
#ifndef M_PI
|
||||||
|
#define M_PI 3.14159265358979323846264338327
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace p2t {
|
namespace p2t {
|
||||||
|
|
||||||
@ -121,4 +128,4 @@ bool InScanArea(const Point& pa, const Point& pb, const Point& pc, const Point&
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -35,4 +35,4 @@
|
|||||||
#include "common/shapes.h"
|
#include "common/shapes.h"
|
||||||
#include "sweep/cdt.h"
|
#include "sweep/cdt.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -30,6 +30,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "advancing_front.h"
|
#include "advancing_front.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
namespace p2t {
|
namespace p2t {
|
||||||
|
|
||||||
AdvancingFront::AdvancingFront(Node& head, Node& tail)
|
AdvancingFront::AdvancingFront(Node& head, Node& tail)
|
||||||
@ -105,4 +107,4 @@ AdvancingFront::~AdvancingFront()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -115,4 +115,4 @@ inline void AdvancingFront::set_search(Node* node)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -68,4 +68,4 @@ CDT::~CDT()
|
|||||||
delete sweep_;
|
delete sweep_;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -102,4 +102,4 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -28,19 +28,21 @@
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
#include <stdexcept>
|
|
||||||
#include "sweep.h"
|
#include "sweep.h"
|
||||||
#include "sweep_context.h"
|
#include "sweep_context.h"
|
||||||
#include "advancing_front.h"
|
#include "advancing_front.h"
|
||||||
#include "../common/utils.h"
|
#include "../common/utils.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace p2t {
|
namespace p2t {
|
||||||
|
|
||||||
// Triangulate simple polygon with holes
|
// Triangulate simple polygon with holes
|
||||||
void Sweep::Triangulate(SweepContext& tcx)
|
void Sweep::Triangulate(SweepContext& tcx)
|
||||||
{
|
{
|
||||||
tcx.InitTriangulation();
|
tcx.InitTriangulation();
|
||||||
tcx.CreateAdvancingFront(nodes_);
|
tcx.CreateAdvancingFront();
|
||||||
// Sweep points; build mesh
|
// Sweep points; build mesh
|
||||||
SweepPoints(tcx);
|
SweepPoints(tcx);
|
||||||
// Clean up
|
// Clean up
|
||||||
@ -699,13 +701,6 @@ void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t,
|
|||||||
Triangle& ot = t->NeighborAcross(p);
|
Triangle& ot = t->NeighborAcross(p);
|
||||||
Point& op = *ot.OppositePoint(*t, p);
|
Point& op = *ot.OppositePoint(*t, p);
|
||||||
|
|
||||||
if (&ot == NULL) {
|
|
||||||
// If we want to integrate the fillEdgeEvent do it here
|
|
||||||
// With current implementation we should never get here
|
|
||||||
//throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InScanArea(p, *t->PointCCW(p), *t->PointCW(p), op)) {
|
if (InScanArea(p, *t->PointCCW(p), *t->PointCW(p), op)) {
|
||||||
// Lets rotate shared edge one vertex CW
|
// Lets rotate shared edge one vertex CW
|
||||||
RotateTrianglePair(*t, p, ot, op);
|
RotateTrianglePair(*t, p, ot, op);
|
||||||
@ -772,13 +767,6 @@ void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle&
|
|||||||
Triangle& ot = t.NeighborAcross(p);
|
Triangle& ot = t.NeighborAcross(p);
|
||||||
Point& op = *ot.OppositePoint(t, p);
|
Point& op = *ot.OppositePoint(t, p);
|
||||||
|
|
||||||
if (&t.NeighborAcross(p) == NULL) {
|
|
||||||
// If we want to integrate the fillEdgeEvent do it here
|
|
||||||
// With current implementation we should never get here
|
|
||||||
//throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InScanArea(eq, *flip_triangle.PointCCW(eq), *flip_triangle.PointCW(eq), op)) {
|
if (InScanArea(eq, *flip_triangle.PointCCW(eq), *flip_triangle.PointCW(eq), op)) {
|
||||||
// flip with new edge op->eq
|
// flip with new edge op->eq
|
||||||
FlipEdgeEvent(tcx, eq, op, &ot, op);
|
FlipEdgeEvent(tcx, eq, op, &ot, op);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -282,4 +282,4 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -120,10 +120,9 @@ Node& SweepContext::LocateNode(const Point& point)
|
|||||||
return *front_->LocateNode(point.x);
|
return *front_->LocateNode(point.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SweepContext::CreateAdvancingFront(const std::vector<Node*>& nodes)
|
void SweepContext::CreateAdvancingFront()
|
||||||
{
|
{
|
||||||
|
|
||||||
(void) nodes;
|
|
||||||
// Initial triangle
|
// Initial triangle
|
||||||
Triangle* triangle = new Triangle(*points_[0], *tail_, *head_);
|
Triangle* triangle = new Triangle(*points_[0], *tail_, *head_);
|
||||||
|
|
||||||
@ -169,8 +168,8 @@ void SweepContext::MeshClean(Triangle& triangle)
|
|||||||
triangles.push_back(&triangle);
|
triangles.push_back(&triangle);
|
||||||
|
|
||||||
while(!triangles.empty()){
|
while(!triangles.empty()){
|
||||||
Triangle *t = triangles.back();
|
Triangle *t = triangles.back();
|
||||||
triangles.pop_back();
|
triangles.pop_back();
|
||||||
|
|
||||||
if (t != NULL && !t->IsInterior()) {
|
if (t != NULL && !t->IsInterior()) {
|
||||||
t->IsInterior(true);
|
t->IsInterior(true);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
* Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors
|
||||||
* http://code.google.com/p/poly2tri/
|
* https://github.com/jhasse/poly2tri
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -70,7 +70,7 @@ Node& LocateNode(const Point& point);
|
|||||||
|
|
||||||
void RemoveNode(Node* node);
|
void RemoveNode(Node* node);
|
||||||
|
|
||||||
void CreateAdvancingFront(const std::vector<Node*>& nodes);
|
void CreateAdvancingFront();
|
||||||
|
|
||||||
/// Try to map a node to all sides of this triangle that don't have a neighbor
|
/// 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);
|
||||||
|
Loading…
Reference in New Issue
Block a user