2
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
3
* http://code.google.com/p/poly2tri/
7
* Redistribution and use in source and binary forms, with or without modification,
8
* are permitted provided that the following conditions are met:
10
* * Redistributions of source code must retain the above copyright notice,
11
* this list of conditions and the following disclaimer.
12
* * Redistributions in binary form must reproduce the above copyright notice,
13
* this list of conditions and the following disclaimer in the documentation
14
* and/or other materials provided with the distribution.
15
* * Neither the name of Poly2Tri nor the names of its contributors may be
16
* used to endorse or promote products derived from this software without specific
17
* prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
#ifndef SWEEP_CONTEXT_H
33
#define SWEEP_CONTEXT_H
41
// Inital triangle factor, seed triangle will extend 30% of
42
// PointSet width to both left and right.
43
const double kAlpha = 0.3;
55
SweepContext(const std::vector<Point*>& polyline);
59
void set_head(Point* p1);
63
void set_tail(Point* p1);
67
size_t point_count() const;
69
Node& LocateNode(const Point& point);
71
void RemoveNode(Node* node);
73
void CreateAdvancingFront(const std::vector<Node*>& nodes);
75
/// Try to map a node to all sides of this triangle that don't have a neighbor
76
void MapTriangleToNodes(Triangle& t);
78
void AddToMap(Triangle* triangle);
80
Point* GetPoint(size_t index);
84
void RemoveFromMap(Triangle* triangle);
86
void AddHole(const std::vector<Point*>& polyline);
88
void AddPoint(Point* point);
90
AdvancingFront* front() const;
92
void MeshClean(Triangle& triangle);
94
std::vector<Triangle*> &GetTriangles();
95
std::list<Triangle*> &GetMap();
97
std::vector<Edge*> edge_list;
106
Basin() : left_node(NULL), bottom_node(NULL), right_node(NULL), width(0.0), left_highest(false)
116
left_highest = false;
121
Edge* constrained_edge;
124
EdgeEvent() : constrained_edge(NULL), right(false)
130
EdgeEvent edge_event;
136
std::vector<Triangle*> triangles_;
137
std::list<Triangle*> map_;
138
std::vector<Point*> points_;
141
AdvancingFront* front_;
142
// head point used with advancing front
144
// tail point used with advancing front
147
Node *af_head_, *af_middle_, *af_tail_;
149
void InitTriangulation();
150
void InitEdges(const std::vector<Point*>& polyline);
154
inline AdvancingFront* SweepContext::front() const
159
inline size_t SweepContext::point_count() const
161
return points_.size();
164
inline void SweepContext::set_head(Point* p1)
169
inline Point* SweepContext::head() const
174
inline void SweepContext::set_tail(Point* p1)
179
inline Point* SweepContext::tail() const