21 #ifndef COLLINEAR_SEGMENT_CHAIN_H_INCLUDED
22 #define COLLINEAR_SEGMENT_CHAIN_H_INCLUDED
45 const std::vector<Line_segment>& segments
65 m_segments = csc.m_segments;
86 void read(std::istream& in);
91 void write(std::ostream& out)
const;
98 class Compare_starting_point
102 : m_orientation(orientation)
111 if(m_orientation < M_PI_4 || m_orientation > M_PI_4*3)
113 return (s1.get_start_x() < s2.get_start_x());
117 return (s1.get_start_y() < s2.get_start_y());
120 double m_orientation;
126 std::vector<Line_segment> m_segments;
132 template<
class InputIterator>
137 double distance_threshold,
138 double orientation_threshold
141 typedef std::vector<Line_segment> Segment_vector;
143 std::vector<Segment_vector> candidates(1, Segment_vector(1, *first));
145 for(InputIterator it = first; it != last; it++)
151 for(
unsigned int j = 0; j < candidates.size(); j++)
154 Segment_vector chains = candidates[j];
155 for(
unsigned int k = 0;
k < chains.size();
k++)
158 bool is_collinear =
false;
160 < orientation_threshold)
164 double dist = line2.find_distance_to_point(center);
165 if(dist < distance_threshold)
170 if(!found && is_collinear)
185 candidates.push_back(Segment_vector(1, seg));
190 std::vector<Collinear_segment_chain> chains(candidates.begin(), candidates.end());
Line_segment & operator=(const Line_segment &ls)
Assignment operator.
Definition: gr_line_segment.cpp:115
const std::vector< Line_segment > & get_segments() const
Returns underlying vector of Line_segment's.
Definition: collinear_segment_chain.h:78
Represent a collinear line segment, a collinear line segment is inherited from an Line_segment...
Definition: collinear_segment_chain.h:36
for k
Definition: APPgetLargeConnectedEdges.m:61
void push_back(Value_type x)
inserts an element at the back of the vector in amortized constant time.
Definition: m_vector.h:1128
double orientation
Orientation of this line segment, defined as the angle between the x axis and the segment...
Definition: gr_line_segment.h:428
const kjb::Vector & get_centre() const
Returns the mid-point.
Definition: gr_line_segment.h:150
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
void read(std::istream &in)
Reads this Collinear_segment_chain from an input stream.
Definition: collinear_segment_chain.cpp:110
double get_orientation() const
Returns the orientation.
Definition: gr_line_segment.h:235
double dist(const pt a, const pt b)
compute approx. Great Circle distance between two UTM points
Definition: layer.cpp:45
Collinear_segment_chain(const Collinear_segment_chain &csc)
Copy Constructor constructrs a new Collinear_segment_chain from an existing Collinear_segment_chain.
Definition: collinear_segment_chain.h:52
void write(std::ostream &out) const
Writes this Collinear_segment_chain to an output stream.
Definition: collinear_segment_chain.cpp:140
Parametric representation of a 2D line in terms of three parameters (a,b,c) (as in ax+by+c = 0)...
Definition: g_line.h:30
Collinear_segment_chain & operator=(const Collinear_segment_chain &csc)
Assignment operator Assigns a Collinear_segment_chain to another Collinear_segment_chain.
Definition: collinear_segment_chain.h:60
std::vector< Collinear_segment_chain > find_collinear_segment_chains(InputIterator first, InputIterator last, double distance_threshold, double orientation_threshold)
Find a set of collinear_segments_chains.
Definition: collinear_segment_chain.h:134
const kjb::Vector & get_end() const
Returns the rightmost point of the segment.
Definition: gr_line_segment.h:180
~Collinear_segment_chain()
Nothing.
Definition: collinear_segment_chain.h:73
const kjb::Vector & get_start() const
Returns the leftmost point of the segment.
Definition: gr_line_segment.h:165
Collinear_segment_chain(const std::vector< Line_segment > &segments)
Constructs a new Collinear_segment_chain.
Definition: collinear_segment_chain.cpp:48
Line_segment()
Constructor without initializations.
Definition: gr_line_segment.h:67
Support for error handling exception classes in libKJB.
Class to manipulate a line segment The class is parametrized in terms the position of the centre...
Definition: gr_line_segment.h:62