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; return -1;
} }
void Triangle::MarkConstrainedEdge(const int index) void Triangle::MarkConstrainedEdge(int index)
{ {
constrained_edge[index] = true; constrained_edge[index] = true;
} }
@ -279,7 +279,7 @@ bool Triangle::GetConstrainedEdgeCW(const Point& p)
return constrained_edge[0]; 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]) { if (&p == points_[0]) {
constrained_edge[2] = ce; 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]) { if (&p == points_[0]) {
constrained_edge[1] = ce; constrained_edge[1] = ce;
@ -321,7 +321,7 @@ bool Triangle::GetDelunayEdgeCW(const Point& p)
return delaunay_edge[0]; 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]) { if (&p == points_[0]) {
delaunay_edge[2] = e; 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]) { if (&p == points_[0]) {
delaunay_edge[1] = e; delaunay_edge[1] = e;

View File

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

View File

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

View File

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

View File

@ -52,12 +52,12 @@ void CDT::Triangulate()
sweep_->Triangulate(*sweep_context_); sweep_->Triangulate(*sweep_context_);
} }
std::vector<p2t::Triangle*> &CDT::GetTriangles() std::vector<p2t::Triangle*> CDT::GetTriangles()
{ {
return sweep_context_->GetTriangles(); return sweep_context_->GetTriangles();
} }
std::list<p2t::Triangle*> &CDT::GetMap() std::list<p2t::Triangle*> CDT::GetMap()
{ {
return sweep_context_->GetMap(); return sweep_context_->GetMap();
} }

View File

@ -82,12 +82,12 @@ public:
/** /**
* Get CDT triangles * Get CDT triangles
*/ */
std::vector<Triangle*> &GetTriangles(); std::vector<Triangle*> GetTriangles();
/** /**
* Get triangle map * Get triangle map
*/ */
std::list<Triangle*> &GetMap(); std::list<Triangle*> GetMap();
private: private:

View File

@ -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(); size_t num_points = polyline.size();
for (size_t i = 0; i < num_points; i++) { for (size_t i = 0; i < num_points; i++) {

View File

@ -147,7 +147,7 @@ Point* tail_;
Node *af_head_, *af_middle_, *af_tail_; Node *af_head_, *af_middle_, *af_tail_;
void InitTriangulation(); void InitTriangulation();
void InitEdges(std::vector<Point*> polyline); void InitEdges(const std::vector<Point*>& polyline);
}; };