fix some problems

This commit is contained in:
Giemsa 2014-01-22 11:01:45 +09:00
parent b5abae7c15
commit d84fb6f6d5
8 changed files with 41 additions and 41 deletions

View File

@ -187,7 +187,7 @@ int Triangle::EdgeIndex(const Point* p1, const Point* p2)
return -1;
}
void Triangle::MarkConstrainedEdge(const int index)
void Triangle::MarkConstrainedEdge(int index)
{
constrained_edge[index] = true;
}
@ -279,7 +279,7 @@ bool Triangle::GetConstrainedEdgeCW(const Point& p)
return constrained_edge[0];
}
void Triangle::SetConstrainedEdgeCCW(const Point& p, const bool ce)
void Triangle::SetConstrainedEdgeCCW(const Point& p, bool ce)
{
if (&p == points_[0]) {
constrained_edge[2] = ce;
@ -290,7 +290,7 @@ void Triangle::SetConstrainedEdgeCCW(const Point& p, const bool ce)
}
}
void Triangle::SetConstrainedEdgeCW(const Point& p, const bool ce)
void Triangle::SetConstrainedEdgeCW(const Point& p, bool ce)
{
if (&p == points_[0]) {
constrained_edge[1] = ce;
@ -321,7 +321,7 @@ bool Triangle::GetDelunayEdgeCW(const Point& p)
return delaunay_edge[0];
}
void Triangle::SetDelunayEdgeCCW(const Point& p, const bool e)
void Triangle::SetDelunayEdgeCCW(const Point& p, bool e)
{
if (&p == points_[0]) {
delaunay_edge[2] = e;
@ -332,7 +332,7 @@ void Triangle::SetDelunayEdgeCCW(const Point& p, const bool e)
}
}
void Triangle::SetDelunayEdgeCW(const Point& p, const bool e)
void Triangle::SetDelunayEdgeCW(const Point& p, bool e)
{
if (&p == points_[0]) {
delaunay_edge[1] = e;

View File

@ -57,7 +57,7 @@ struct Point {
std::vector<Edge*> edge_list;
/// Construct using coordinates.
Point(const double x, const double y) : x(x), y(y) {}
Point(double x, double y) : x(x), y(y) {}
/// Set this point to all zeros.
void set_zero()
@ -67,7 +67,7 @@ struct Point {
}
/// Set this point to some specified coordinates.
void set(const double x_, const double y_)
void set(double x_, double y_)
{
x = x_;
y = y_;
@ -96,7 +96,7 @@ struct Point {
}
/// Multiply this point by a scalar.
void operator *=(const double a)
void operator *=(double a)
{
x *= a;
y *= a;
@ -158,16 +158,16 @@ bool constrained_edge[3];
/// Flags to determine if an edge is a Delauney edge
bool delaunay_edge[3];
Point* GetPoint(const int index);
Point* GetPoint(int index);
Point* PointCW(const Point& point);
Point* PointCCW(const Point& point);
Point* OppositePoint(Triangle& t, const Point& p);
Triangle* GetNeighbor(const int index);
Triangle* GetNeighbor(int index);
void MarkNeighbor(Point* p1, Point* p2, Triangle* t);
void MarkNeighbor(Triangle& t);
void MarkConstrainedEdge(const int index);
void MarkConstrainedEdge(int index);
void MarkConstrainedEdge(Edge& edge);
void MarkConstrainedEdge(Point* p, Point* q);
@ -178,12 +178,12 @@ Triangle* NeighborCW(const Point& point);
Triangle* NeighborCCW(const Point& point);
bool GetConstrainedEdgeCCW(const Point& p);
bool GetConstrainedEdgeCW(const Point& p);
void SetConstrainedEdgeCCW(const Point& p, const bool ce);
void SetConstrainedEdgeCW(const Point& p, const bool ce);
void SetConstrainedEdgeCCW(const Point& p, bool ce);
void SetConstrainedEdgeCW(const Point& p, bool ce);
bool GetDelunayEdgeCCW(const Point& p);
bool GetDelunayEdgeCW(const Point& p);
void SetDelunayEdgeCCW(const Point& p, const bool e);
void SetDelunayEdgeCW(const Point& p, const bool e);
void SetDelunayEdgeCCW(const Point& p, bool e);
void SetDelunayEdgeCW(const Point& p, bool e);
bool Contains(const Point* p);
bool Contains(const Edge& e);
@ -199,7 +199,7 @@ void ClearNeighbors();
void ClearDelunayEdges();
inline bool IsInterior();
inline void IsInterior(const bool b);
inline void IsInterior(bool b);
Triangle& NeighborAcross(const Point& opoint);
@ -271,24 +271,24 @@ inline double Cross(const Point& a, const Point& b)
/// Perform the cross product on a point and a scalar. In 2D this produces
/// a point.
inline Point Cross(const Point& a, const double s)
inline Point Cross(const Point& a, double s)
{
return Point(s * a.y, -s * a.x);
}
/// Perform the cross product on a scalar and a point. In 2D this produces
/// a point.
inline Point Cross(const double s, const Point& a)
inline Point Cross(double s, const Point& a)
{
return Point(-s * a.y, s * a.x);
}
inline Point* Triangle::GetPoint(const int index)
inline Point* Triangle::GetPoint(int index)
{
return points_[index];
}
inline Triangle* Triangle::GetNeighbor(const int index)
inline Triangle* Triangle::GetNeighbor(int index)
{
return neighbors_[index];
}
@ -313,7 +313,7 @@ inline bool Triangle::IsInterior()
return interior_;
}
inline void Triangle::IsInterior(const bool b)
inline void Triangle::IsInterior(bool b)
{
interior_ = b;
}

View File

@ -39,7 +39,7 @@ AdvancingFront::AdvancingFront(Node& head, Node& tail)
search_node_ = &head;
}
Node* AdvancingFront::LocateNode(const double x)
Node* AdvancingFront::LocateNode(double x)
{
Node* node = search_node_;
@ -61,7 +61,7 @@ Node* AdvancingFront::LocateNode(const double x)
return NULL;
}
Node* AdvancingFront::FindSearchNode(const double x)
Node* AdvancingFront::FindSearchNode(double x)
{
(void)x; // suppress compiler warnings "unused parameter 'x'"
// TODO: implement BST index

View File

@ -74,7 +74,7 @@ Node* search();
void set_search(Node* node);
/// Locate insertion point along advancing front
Node* LocateNode(const double x);
Node* LocateNode(double x);
Node* LocatePoint(const Point* point);
@ -82,7 +82,7 @@ private:
Node* head_, *tail_, *search_node_;
Node* FindSearchNode(const double x);
Node* FindSearchNode(double x);
};
inline Node* AdvancingFront::head()

View File

@ -32,13 +32,13 @@
namespace p2t {
CDT::CDT(const std::vector<Point*> &polyline)
CDT::CDT(const std::vector<Point*>& polyline)
{
sweep_context_ = new SweepContext(polyline);
sweep_ = new Sweep;
}
void CDT::AddHole(const std::vector<Point*> &polyline)
void CDT::AddHole(const std::vector<Point*>& polyline)
{
sweep_context_->AddHole(polyline);
}
@ -52,12 +52,12 @@ void CDT::Triangulate()
sweep_->Triangulate(*sweep_context_);
}
std::vector<p2t::Triangle*> &CDT::GetTriangles()
std::vector<p2t::Triangle*> CDT::GetTriangles()
{
return sweep_context_->GetTriangles();
}
std::list<p2t::Triangle*> &CDT::GetMap()
std::list<p2t::Triangle*> CDT::GetMap()
{
return sweep_context_->GetMap();
}

View File

@ -53,7 +53,7 @@ public:
*
* @param polyline
*/
CDT(const std::vector<Point*> &polyline);
CDT(const std::vector<Point*>& polyline);
/**
* Destructor - clean up memory
@ -65,7 +65,7 @@ public:
*
* @param polyline
*/
void AddHole(const std::vector<Point*> &polyline);
void AddHole(const std::vector<Point*>& polyline);
/**
* Add a steiner point
@ -82,12 +82,12 @@ public:
/**
* Get CDT triangles
*/
std::vector<Triangle*> &GetTriangles();
std::vector<Triangle*> GetTriangles();
/**
* Get triangle map
*/
std::list<Triangle*> &GetMap();
std::list<Triangle*> GetMap();
private:

View File

@ -34,7 +34,7 @@
namespace p2t {
SweepContext::SweepContext(const std::vector<Point*> &polyline) : points_(polyline),
SweepContext::SweepContext(const std::vector<Point*>& polyline) : points_(polyline),
front_(0),
head_(0),
tail_(0),
@ -45,7 +45,7 @@ SweepContext::SweepContext(const std::vector<Point*> &polyline) : points_(polyli
InitEdges(points_);
}
void SweepContext::AddHole(const std::vector<Point*> &polyline)
void SweepContext::AddHole(const std::vector<Point*>& polyline)
{
InitEdges(polyline);
for(unsigned int i = 0; i < polyline.size(); i++) {
@ -95,7 +95,7 @@ void SweepContext::InitTriangulation()
}
void SweepContext::InitEdges(std::vector<Point*> polyline)
void SweepContext::InitEdges(const std::vector<Point*>& polyline)
{
size_t num_points = polyline.size();
for (size_t i = 0; i < num_points; i++) {
@ -120,7 +120,7 @@ Node& SweepContext::LocateNode(const Point& point)
return *front_->LocateNode(point.x);
}
void SweepContext::CreateAdvancingFront(const std::vector<Node*> &nodes)
void SweepContext::CreateAdvancingFront(const std::vector<Node*>& nodes)
{
(void) nodes;

View File

@ -52,7 +52,7 @@ class SweepContext {
public:
/// Constructor
SweepContext(const std::vector<Point*> &polyline);
SweepContext(const std::vector<Point*>& polyline);
/// Destructor
~SweepContext();
@ -70,7 +70,7 @@ Node& LocateNode(const Point& point);
void RemoveNode(Node* node);
void CreateAdvancingFront(const std::vector<Node*> &nodes);
void CreateAdvancingFront(const 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);
@ -83,7 +83,7 @@ Point* GetPoints();
void RemoveFromMap(Triangle* triangle);
void AddHole(const std::vector<Point*> &polyline);
void AddHole(const std::vector<Point*>& polyline);
void AddPoint(Point* point);
@ -147,7 +147,7 @@ Point* tail_;
Node *af_head_, *af_middle_, *af_tail_;
void InitTriangulation();
void InitEdges(std::vector<Point*> polyline);
void InitEdges(const std::vector<Point*>& polyline);
};