From d84fb6f6d5558aea2645a67d370d1ad4735b4003 Mon Sep 17 00:00:00 2001 From: Giemsa Date: Wed, 22 Jan 2014 11:01:45 +0900 Subject: [PATCH] fix some problems --- poly2tri/common/shapes.cc | 10 +++++----- poly2tri/common/shapes.h | 32 +++++++++++++++---------------- poly2tri/sweep/advancing_front.cc | 4 ++-- poly2tri/sweep/advancing_front.h | 4 ++-- poly2tri/sweep/cdt.cc | 8 ++++---- poly2tri/sweep/cdt.h | 8 ++++---- poly2tri/sweep/sweep_context.cc | 8 ++++---- poly2tri/sweep/sweep_context.h | 8 ++++---- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/poly2tri/common/shapes.cc b/poly2tri/common/shapes.cc index 770983f..d0de13e 100644 --- a/poly2tri/common/shapes.cc +++ b/poly2tri/common/shapes.cc @@ -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; diff --git a/poly2tri/common/shapes.h b/poly2tri/common/shapes.h index e710143..aa582b1 100644 --- a/poly2tri/common/shapes.h +++ b/poly2tri/common/shapes.h @@ -57,7 +57,7 @@ struct Point { std::vector 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; } diff --git a/poly2tri/sweep/advancing_front.cc b/poly2tri/sweep/advancing_front.cc index e9079ce..38723be 100644 --- a/poly2tri/sweep/advancing_front.cc +++ b/poly2tri/sweep/advancing_front.cc @@ -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 diff --git a/poly2tri/sweep/advancing_front.h b/poly2tri/sweep/advancing_front.h index 6a6e7ce..645dcec 100644 --- a/poly2tri/sweep/advancing_front.h +++ b/poly2tri/sweep/advancing_front.h @@ -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() diff --git a/poly2tri/sweep/cdt.cc b/poly2tri/sweep/cdt.cc index fb19dd9..09d088a 100644 --- a/poly2tri/sweep/cdt.cc +++ b/poly2tri/sweep/cdt.cc @@ -32,13 +32,13 @@ namespace p2t { -CDT::CDT(const std::vector &polyline) +CDT::CDT(const std::vector& polyline) { sweep_context_ = new SweepContext(polyline); sweep_ = new Sweep; } -void CDT::AddHole(const std::vector &polyline) +void CDT::AddHole(const std::vector& polyline) { sweep_context_->AddHole(polyline); } @@ -52,12 +52,12 @@ void CDT::Triangulate() sweep_->Triangulate(*sweep_context_); } -std::vector &CDT::GetTriangles() +std::vector CDT::GetTriangles() { return sweep_context_->GetTriangles(); } -std::list &CDT::GetMap() +std::list CDT::GetMap() { return sweep_context_->GetMap(); } diff --git a/poly2tri/sweep/cdt.h b/poly2tri/sweep/cdt.h index 46af402..ea3286d 100644 --- a/poly2tri/sweep/cdt.h +++ b/poly2tri/sweep/cdt.h @@ -53,7 +53,7 @@ public: * * @param polyline */ - CDT(const std::vector &polyline); + CDT(const std::vector& polyline); /** * Destructor - clean up memory @@ -65,7 +65,7 @@ public: * * @param polyline */ - void AddHole(const std::vector &polyline); + void AddHole(const std::vector& polyline); /** * Add a steiner point @@ -82,12 +82,12 @@ public: /** * Get CDT triangles */ - std::vector &GetTriangles(); + std::vector GetTriangles(); /** * Get triangle map */ - std::list &GetMap(); + std::list GetMap(); private: diff --git a/poly2tri/sweep/sweep_context.cc b/poly2tri/sweep/sweep_context.cc index 17d43f0..a9f1fdf 100644 --- a/poly2tri/sweep/sweep_context.cc +++ b/poly2tri/sweep/sweep_context.cc @@ -34,7 +34,7 @@ namespace p2t { -SweepContext::SweepContext(const std::vector &polyline) : points_(polyline), +SweepContext::SweepContext(const std::vector& polyline) : points_(polyline), front_(0), head_(0), tail_(0), @@ -45,7 +45,7 @@ SweepContext::SweepContext(const std::vector &polyline) : points_(polyli InitEdges(points_); } -void SweepContext::AddHole(const std::vector &polyline) +void SweepContext::AddHole(const std::vector& polyline) { InitEdges(polyline); for(unsigned int i = 0; i < polyline.size(); i++) { @@ -95,7 +95,7 @@ void SweepContext::InitTriangulation() } -void SweepContext::InitEdges(std::vector polyline) +void SweepContext::InitEdges(const std::vector& 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 &nodes) +void SweepContext::CreateAdvancingFront(const std::vector& nodes) { (void) nodes; diff --git a/poly2tri/sweep/sweep_context.h b/poly2tri/sweep/sweep_context.h index d7023ce..ba0d065 100644 --- a/poly2tri/sweep/sweep_context.h +++ b/poly2tri/sweep/sweep_context.h @@ -52,7 +52,7 @@ class SweepContext { public: /// Constructor -SweepContext(const std::vector &polyline); +SweepContext(const std::vector& polyline); /// Destructor ~SweepContext(); @@ -70,7 +70,7 @@ Node& LocateNode(const Point& point); void RemoveNode(Node* node); -void CreateAdvancingFront(const std::vector &nodes); +void CreateAdvancingFront(const std::vector& 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 &polyline); +void AddHole(const std::vector& polyline); void AddPoint(Point* point); @@ -147,7 +147,7 @@ Point* tail_; Node *af_head_, *af_middle_, *af_tail_; void InitTriangulation(); -void InitEdges(std::vector polyline); +void InitEdges(const std::vector& polyline); };