Renaming for clarification of collinear edges vs. distance which is defined otherwise.

This commit is contained in:
Matthias Koefferlein 2024-01-24 13:33:56 +01:00
parent 55993c11e3
commit 899985e616
5 changed files with 164 additions and 140 deletions

View File

@ -54,7 +54,7 @@ db::Edge::distance_type edge_projection (const db::Edge &a, const db::Edge &b)
* This function applies Euclidian metrics.
* If no such part is found, this function returns false.
*/
bool euclidian_near_part_of_edge (zero_distance_type zero_distance, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &other, db::Edge *output)
bool euclidian_near_part_of_edge (collinear_mode_type coll_mode, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &other, db::Edge *output)
{
// Handle the case of point-like basic edge: cannot determine
// orientation
@ -68,8 +68,8 @@ bool euclidian_near_part_of_edge (zero_distance_type zero_distance, db::coord_tr
int s2 = e.side_of (g.p2 ());
// "kissing corner" issue: force include zero if the edges are collinear and overlap.
bool include_zero = (zero_distance == AlwaysIncludeZeroDistance);
if (zero_distance == IncludeZeroDistanceWhenTouch && s1 == 0 && s2 == 0 && e.intersect (g)) {
bool include_zero = (coll_mode == AlwaysIncludeCollinear);
if (coll_mode == IncludeCollinearWhenTouch && s1 == 0 && s2 == 0 && e.intersect (g)) {
include_zero = true;
}
@ -198,7 +198,7 @@ bool euclidian_near_part_of_edge (zero_distance_type zero_distance, db::coord_tr
* This function applies Square metrics.
* If no such part is found, this function returns false.
*/
static bool var_near_part_of_edge (zero_distance_type zero_distance, db::coord_traits<db::Coord>::distance_type d, db::coord_traits<db::Coord>::distance_type dd, const db::Edge &e, const db::Edge &other, db::Edge *output)
static bool var_near_part_of_edge (collinear_mode_type coll_mode, db::coord_traits<db::Coord>::distance_type d, db::coord_traits<db::Coord>::distance_type dd, const db::Edge &e, const db::Edge &other, db::Edge *output)
{
// Handle the case of point-like basic edge: cannot determine
// orientation
@ -212,8 +212,8 @@ static bool var_near_part_of_edge (zero_distance_type zero_distance, db::coord_t
int s2 = e.side_of (g.p2 ());
// "kissing corner" issue: force include zero if the edges are collinear and overlap
bool include_zero = (zero_distance == AlwaysIncludeZeroDistance);
if (zero_distance == IncludeZeroDistanceWhenTouch && s1 == 0 && s2 == 0 && e.intersect (g)) {
bool include_zero = (coll_mode == AlwaysIncludeCollinear);
if (coll_mode == IncludeCollinearWhenTouch && s1 == 0 && s2 == 0 && e.intersect (g)) {
include_zero = true;
}
@ -316,9 +316,9 @@ static bool var_near_part_of_edge (zero_distance_type zero_distance, db::coord_t
* This function applies Projected metrics.
* If no such part is found, this function returns false.
*/
bool projected_near_part_of_edge (zero_distance_type zero_distance, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &other, db::Edge *output)
bool projected_near_part_of_edge (collinear_mode_type coll_mode, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &other, db::Edge *output)
{
return var_near_part_of_edge (zero_distance, d, 0, e, other, output);
return var_near_part_of_edge (coll_mode, d, 0, e, other, output);
}
/**
@ -327,22 +327,22 @@ bool projected_near_part_of_edge (zero_distance_type zero_distance, db::coord_tr
* This function applies Square metrics.
* If no such part is found, this function returns false.
*/
bool square_near_part_of_edge (zero_distance_type zero_distance, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &other, db::Edge *output)
bool square_near_part_of_edge (collinear_mode_type coll_mode, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &other, db::Edge *output)
{
return var_near_part_of_edge (zero_distance, d, d, e, other, output);
return var_near_part_of_edge (coll_mode, d, d, e, other, output);
}
// ---------------------------------------------------------------------------------
// Implementation of EdgeRelationFilter
EdgeRelationFilter::EdgeRelationFilter (edge_relation_type r, distance_type d, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection, zero_distance_type include_zero)
: m_whole_edges (false), m_include_zero (include_zero), m_r (r), m_d (d), m_metrics (metrics), m_ignore_angle (0), m_min_projection (min_projection), m_max_projection (max_projection)
EdgeRelationFilter::EdgeRelationFilter (edge_relation_type r, distance_type d, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection, collinear_mode_type collinear_mode)
: m_whole_edges (false), m_collinear_mode (collinear_mode), m_r (r), m_d (d), m_metrics (metrics), m_ignore_angle (0), m_min_projection (min_projection), m_max_projection (max_projection)
{
set_ignore_angle (ignore_angle);
}
EdgeRelationFilter::EdgeRelationFilter (edge_relation_type r, distance_type d, const EdgesCheckOptions &options)
: m_whole_edges (options.whole_edges), m_include_zero (options.include_zero), m_r (r), m_d (d), m_metrics (options.metrics), m_ignore_angle (0), m_min_projection (options.min_projection), m_max_projection (options.max_projection)
: m_whole_edges (options.whole_edges), m_collinear_mode (options.collinear_mode), m_r (r), m_d (d), m_metrics (options.metrics), m_ignore_angle (0), m_min_projection (options.min_projection), m_max_projection (options.max_projection)
{
set_ignore_angle (options.ignore_angle);
}
@ -407,14 +407,14 @@ EdgeRelationFilter::check (const db::Edge &a, const db::Edge &b, db::EdgePair *o
bool in1, in2;
if (m_metrics == Euclidian) {
in2 = euclidian_near_part_of_edge (m_include_zero, m_d, an, bn, ! m_whole_edges && output ? &output->second () : 0);
in1 = euclidian_near_part_of_edge (m_include_zero, m_d, bn, an, ! m_whole_edges && output ? &output->first () : 0);
in2 = euclidian_near_part_of_edge (m_collinear_mode, m_d, an, bn, ! m_whole_edges && output ? &output->second () : 0);
in1 = euclidian_near_part_of_edge (m_collinear_mode, m_d, bn, an, ! m_whole_edges && output ? &output->first () : 0);
} else if (m_metrics == Square) {
in2 = square_near_part_of_edge (m_include_zero, m_d, an, bn, ! m_whole_edges && output ? &output->second () : 0);
in1 = square_near_part_of_edge (m_include_zero, m_d, bn, an, ! m_whole_edges && output ? &output->first () : 0);
in2 = square_near_part_of_edge (m_collinear_mode, m_d, an, bn, ! m_whole_edges && output ? &output->second () : 0);
in1 = square_near_part_of_edge (m_collinear_mode, m_d, bn, an, ! m_whole_edges && output ? &output->first () : 0);
} else {
in2 = projected_near_part_of_edge (m_include_zero, m_d, an, bn, ! m_whole_edges && output ? &output->second () : 0);
in1 = projected_near_part_of_edge (m_include_zero, m_d, bn, an, ! m_whole_edges && output ? &output->first () : 0);
in2 = projected_near_part_of_edge (m_collinear_mode, m_d, an, bn, ! m_whole_edges && output ? &output->second () : 0);
in1 = projected_near_part_of_edge (m_collinear_mode, m_d, bn, an, ! m_whole_edges && output ? &output->first () : 0);
}
if (in1 && in2) {

View File

@ -99,23 +99,23 @@ enum edge_relation_type
};
/**
* @brief An enum specifying whether the edge relation includes zero distance
* @brief An enum specifying whether how collinear edges are handled
*/
enum zero_distance_type {
enum collinear_mode_type {
/**
* @brief Never include zero distance
* @brief Never include collinear edges
*/
NeverIncludeZeroDistance = 0,
NeverIncludeCollinear = 0,
/**
* @brief include zero distance when edges touch (e.g. kissing corner case)
* @brief include collinear edges when they touch (e.g. kissing corner case)
*/
IncludeZeroDistanceWhenTouch = 1,
IncludeCollinearWhenTouch = 1,
/**
* @brief always include zero distance
* @brief always include collinear edges
*/
AlwaysIncludeZeroDistance = 2
AlwaysIncludeCollinear = 2
};
/**
@ -133,13 +133,13 @@ struct DB_PUBLIC EdgesCheckOptions
double _ignore_angle = 90,
distance_type _min_projection = 0,
distance_type _max_projection = std::numeric_limits<distance_type>::max (),
zero_distance_type _include_zero = IncludeZeroDistanceWhenTouch)
collinear_mode_type _collinear_mode = IncludeCollinearWhenTouch)
: whole_edges (_whole_edges),
metrics (_metrics),
ignore_angle (_ignore_angle),
min_projection (_min_projection),
max_projection (_max_projection),
include_zero (_include_zero)
collinear_mode (_collinear_mode)
{ }
/**
@ -183,13 +183,13 @@ struct DB_PUBLIC EdgesCheckOptions
distance_type max_projection;
/**
* @brief Specifies zero distance handling
* @brief Specifies collinear edge handling
*
* This allows implementing the "kissing corners" case. When set to "WhenTouch", kissing corners will
* be reported as errors, when set to "Never", they won't. Note that with merged inputs, edges
* This allows implementing the "kissing corners" case. When set to "IncludeCollinearWhenTouch", kissing corners will
* be reported as errors, when set to "NeverIncludeCollinear", they won't. Note that with merged inputs, edges
* will not overlap except at the corners.
*/
zero_distance_type include_zero;
collinear_mode_type collinear_mode;
};
/**
@ -217,7 +217,7 @@ struct DB_PUBLIC EdgeRelationFilter
* to each other. If the length of the projection of either edge on the other is >= min_projection
* or < max_projection, the edges are considered for the check.
*/
EdgeRelationFilter (edge_relation_type r, distance_type d, metrics_type metrics = db::Euclidian, double ignore_angle = 90, distance_type min_projection = 0, distance_type max_projection = std::numeric_limits<distance_type>::max (), zero_distance_type include_zero = AlwaysIncludeZeroDistance);
EdgeRelationFilter (edge_relation_type r, distance_type d, metrics_type metrics = db::Euclidian, double ignore_angle = 90, distance_type min_projection = 0, distance_type max_projection = std::numeric_limits<distance_type>::max (), collinear_mode_type include_zero = AlwaysIncludeCollinear);
/**
* Constructs an edge relation filter from a CheckOptions structure
@ -249,19 +249,19 @@ struct DB_PUBLIC EdgeRelationFilter
}
/**
* @brief Sets a value indicating whether zero distance shall be included in the check
* @brief Sets a value indicating whether collinear edges shall be included in the check
*/
void set_include_zero (zero_distance_type f)
void set_collinear_mode (collinear_mode_type f)
{
m_include_zero = f;
m_collinear_mode = f;
}
/**
* @brief Gets a value indicating whether zero distance shall be included in the check
* @brief Gets a value indicating whether collinear edges shall be included in the check
*/
zero_distance_type include_zero () const
collinear_mode_type collinear_mode () const
{
return m_include_zero;
return m_collinear_mode;
}
/**
@ -361,7 +361,7 @@ struct DB_PUBLIC EdgeRelationFilter
private:
bool m_whole_edges;
zero_distance_type m_include_zero;
collinear_mode_type m_collinear_mode;
edge_relation_type m_r;
distance_type m_d;
metrics_type m_metrics;
@ -372,9 +372,9 @@ private:
// Internal methods exposed for testing purposes
DB_PUBLIC bool projected_near_part_of_edge (zero_distance_type include_zero, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &g, db::Edge *output);
DB_PUBLIC bool square_near_part_of_edge (zero_distance_type include_zero, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &g, db::Edge *output);
DB_PUBLIC bool euclidian_near_part_of_edge (zero_distance_type include_zero, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &g, db::Edge *output);
DB_PUBLIC bool projected_near_part_of_edge (collinear_mode_type include_zero, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &g, db::Edge *output);
DB_PUBLIC bool square_near_part_of_edge (collinear_mode_type include_zero, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &g, db::Edge *output);
DB_PUBLIC bool euclidian_near_part_of_edge (collinear_mode_type include_zero, db::coord_traits<db::Coord>::distance_type d, const db::Edge &e, const db::Edge &g, db::Edge *output);
DB_PUBLIC db::Edge::distance_type edge_projection (const db::Edge &a, const db::Edge &b);
}

View File

@ -130,7 +130,7 @@ struct DB_PUBLIC RegionCheckOptions
RectFilter _rect_filter = NoRectFilter,
bool _negative = false,
PropertyConstraint _prop_constraint = IgnoreProperties,
zero_distance_type _include_zero = IncludeZeroDistanceWhenTouch)
collinear_mode_type _include_zero = IncludeCollinearWhenTouch)
: EdgesCheckOptions (_whole_edges, _metrics, _ignore_angle, _min_projection, _max_projection, _include_zero),
shielded (_shielded),
opposite_filter (_opposite_filter),

View File

@ -3234,6 +3234,30 @@ gsi::Enum<db::metrics_type> decl_Metrics ("db", "Metrics",
"This enum has been introduced in version 0.27."
);
gsi::Enum<db::collinear_mode_type> decl_CollinearMode ("db", "CollinearMode",
gsi::enum_const ("NeverIncludeCollinear", db::NeverIncludeCollinear,
"@brief Specifies that check functions should never include collinear edges.\n"
"With this specification, the check functions will ignore edges which are collinear."
) +
gsi::enum_const ("AlwaysIncludeCollinear", db::AlwaysIncludeCollinear,
"@brief Specifies that check functions should always include collinear edges\n"
"With this specification, the check functions will also check edges which are collinear."
) +
gsi::enum_const ("IncludeCollinearWhenTouch", db::IncludeCollinearWhenTouch,
"@brief Specifies that check functions should include collinear edges when they touch\n"
"With this specification, the check functions will also check edges which are collinear, but only if they touch in at least one point. "
"This is the mode that allows checking the 'kissing corner' cases."
),
"@brief This class represents the collinear_mode type for \\Region#width and related checks.\n"
"This mode determines how collinear edges are treated in the DRC checks. Formally these edges do neither represent "
"a space other other relation as they do not face each other. There are three modes available to treat this boundary case: "
"Ignore collinear edges (\\NeverIncludeCollinear), always include them (\\AlwaysIncludeCollinear) or only include them "
"if they share at least one common point (\\IncludeCollinearWhenTouch). The latter mode allows activating checks for "
"the 'kissing corner' case and is the default mode in most checks."
"\n"
"This enum has been introduced in version 0.29."
);
// Inject the Region::Metrics declarations into Region and Edges:
// (Edges injection has to be done here because only here defs() is available)
gsi::ClassExt<db::Region> inject_Metrics_in_Region (decl_Metrics.defs ());

View File

@ -51,139 +51,139 @@ TEST(1)
TEST(2)
{
db::Edge output;
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 10), db::Point (100, 200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (100, 200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 10), db::Point (100, 200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (100, 200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(0,-50;100,-50)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(0,-50;187,-50)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(100,-50;187,-50)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(-87,-50;187,-50)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (0, -50)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (0, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(-87,-50;0,-50)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -100), db::Point (300, -100)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, 0), db::Point (300, -100)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -100), db::Point (300, -100)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, 0), db::Point (300, -100)), &output), true);
EXPECT_EQ (output.to_string (), "(-94,-34;164,-77)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 0), db::Point (100, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 0), db::Point (100, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(0,0;50,-100)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (40, 0), db::Point (140, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (40, 0), db::Point (140, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(40,0;90,-100)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 0), db::Point (200, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 0), db::Point (200, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(100,0;145,-89)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -200), db::Point (200, -200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (200, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -200), db::Point (200, -200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (200, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(100,0;145,-89)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (120, 200), db::Point (120, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (120, 200), db::Point (120, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(120,0;120,-98)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 200), db::Point (100, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 200), db::Point (100, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(100,0;100,-100)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 200), db::Point (80, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 200), db::Point (80, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(80,0;80,-100)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-80, 200), db::Point (-80, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-80, 200), db::Point (-80, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(-80,0;-80,-60)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 0), db::Point (-200, -200)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 0), db::Point (-200, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(80,0;-45,-89)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(100,-50;100,-50)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (50, -50), db::Point (50, -50)), &output), true);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (50, -50), db::Point (50, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(50,-50;50,-50)");
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (190, -50), db::Point (190, -50)), &output), false);
EXPECT_EQ (euclidian_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (190, -50), db::Point (190, -50)), &output), false);
}
TEST(3)
{
db::Edge output;
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (100, 200)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (100, 200)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(0,-50;100,-50)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(0,-50;200,-50)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(100,-50;200,-50)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(-100,-50;200,-50)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (0, -50)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (0, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(-100,-50;0,-50)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -100), db::Point (300, -100)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, 0), db::Point (300, -100)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -100), db::Point (300, -100)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, 0), db::Point (300, -100)), &output), true);
EXPECT_EQ (output.to_string (), "(-100,-33;200,-83)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 0), db::Point (100, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 0), db::Point (100, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(0,0;50,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (40, 0), db::Point (140, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (40, 0), db::Point (140, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(40,0;90,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 0), db::Point (200, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 0), db::Point (200, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(100,0;150,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -200), db::Point (200, -200)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (200, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -200), db::Point (200, -200)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (200, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(100,0;150,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (120, 200), db::Point (120, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (120, 200), db::Point (120, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(120,0;120,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 200), db::Point (100, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 200), db::Point (100, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(100,0;100,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 200), db::Point (80, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 200), db::Point (80, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(80,0;80,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-80, 200), db::Point (-80, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-80, 200), db::Point (-80, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(-80,0;-80,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 0), db::Point (-200, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 0), db::Point (-200, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(80,0;-60,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(-100,0;-100,-100)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(100,-50;100,-50)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (50, -50), db::Point (50, -50)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (50, -50), db::Point (50, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(50,-50;50,-50)");
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (190, -50), db::Point (190, -50)), &output), true);
EXPECT_EQ (square_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (190, -50), db::Point (190, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(190,-50;190,-50)");
}
TEST(4)
{
db::Edge output;
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (100, 200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (100, 200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(0,-50;100,-50)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(0,-50;100,-50)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (300, -50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (300, -50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (300, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(0,-50;100,-50)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (0, -50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -100), db::Point (300, -100)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, 0), db::Point (300, -100)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -50), db::Point (0, -50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, -100), db::Point (300, -100)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-300, 0), db::Point (300, -100)), &output), true);
EXPECT_EQ (output.to_string (), "(0,-50;100,-67)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 0), db::Point (100, -200)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 0), db::Point (100, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(0,0;50,-100)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (40, 0), db::Point (140, -200)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (40, 0), db::Point (140, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(40,0;90,-100)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 0), db::Point (200, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -200), db::Point (200, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (200, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (120, 200), db::Point (120, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 200), db::Point (100, -200)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 0), db::Point (200, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, -200), db::Point (200, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (0, 200), db::Point (200, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (120, 200), db::Point (120, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 200), db::Point (100, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(100,0;100,-100)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 200), db::Point (80, -200)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 200), db::Point (80, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(80,0;80,-100)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-80, 200), db::Point (-80, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 0), db::Point (-200, -200)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-80, 200), db::Point (-80, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (80, 0), db::Point (-200, -200)), &output), true);
EXPECT_EQ (output.to_string (), "(80,0;0,-57)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (), db::Edge (db::Point (-100, 200), db::Point (-100, -200)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, 50), db::Point (100, 50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (100, -50), db::Point (100, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(100,-50;100,-50)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (50, -50), db::Point (50, -50)), &output), true);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (50, -50), db::Point (50, -50)), &output), true);
EXPECT_EQ (output.to_string (), "(50,-50;50,-50)");
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeZeroDistance, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (190, -50), db::Point (190, -50)), &output), false);
EXPECT_EQ (projected_near_part_of_edge (db::AlwaysIncludeCollinear, 100, db::Edge (db::Point (0, 0), db::Point (100, 0)), db::Edge (db::Point (190, -50), db::Point (190, -50)), &output), false);
}
TEST(5)
@ -291,7 +291,7 @@ TEST(7)
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(1,30;1,20)");
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (-1, 30), db::Point (-1, 20)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (0, 30), db::Point (0, 20)), &output);
EXPECT_EQ (res, false);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (1, 30), db::Point (1, 20)), &output);
@ -300,7 +300,7 @@ TEST(7)
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (-1, 30), db::Point (-1, 20)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::AlwaysIncludeZeroDistance);
f.set_collinear_mode (db::AlwaysIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (0, 300), db::Point (0, -200)), &output);
EXPECT_EQ (res, true);
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(0,110;0,-100)");
@ -309,7 +309,7 @@ TEST(7)
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(1,110;1,-100)");
f.set_metrics (db::Square);
f.set_include_zero (db::AlwaysIncludeZeroDistance);
f.set_collinear_mode (db::AlwaysIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (0, 30), db::Point (0, 20)), &output);
EXPECT_EQ (res, true);
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(0,30;0,20)");
@ -318,7 +318,7 @@ TEST(7)
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(1,30;1,20)");
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (-1, 30), db::Point (-1, 20)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (0, 30), db::Point (0, 20)), &output);
EXPECT_EQ (res, false);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (1, 30), db::Point (1, 20)), &output);
@ -327,7 +327,7 @@ TEST(7)
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (-1, 30), db::Point (-1, 20)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::AlwaysIncludeZeroDistance);
f.set_collinear_mode (db::AlwaysIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (0, 300), db::Point (0, -200)), &output);
EXPECT_EQ (res, true);
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(0,110;0,-100)");
@ -336,7 +336,7 @@ TEST(7)
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(1,110;1,-100)");
f.set_metrics (db::Projection);
f.set_include_zero (db::AlwaysIncludeZeroDistance);
f.set_collinear_mode (db::AlwaysIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (0, 30), db::Point (0, -20)), &output);
EXPECT_EQ (res, true);
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(0,10;0,0)");
@ -345,7 +345,7 @@ TEST(7)
EXPECT_EQ (output.first ().to_string () + ":" + output.second ().to_string (), "(0,0;0,10):(1,10;1,0)");
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (-1, 30), db::Point (-1, -20)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (0, 30), db::Point (0, 11)), &output);
EXPECT_EQ (res, false);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 10)), db::Edge (db::Point (1, 30), db::Point (1, -20)), &output);
@ -361,7 +361,7 @@ TEST(8_KissingCornerProblem)
// if the projection is >0.
db::EdgeRelationFilter f (db::WidthRelation, 10);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
db::EdgePair output;
bool res;
@ -382,7 +382,7 @@ TEST(8_KissingCornerProblem)
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 100)), db::Edge (db::Point (0, -1), db::Point (0, -100)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::NeverIncludeZeroDistance);
f.set_collinear_mode (db::NeverIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 100)), db::Edge (db::Point (0, 201), db::Point (0, 101)), &output);
EXPECT_EQ (res, false);
@ -398,7 +398,7 @@ TEST(8_KissingCornerProblem)
EXPECT_EQ (res, false);
f = db::EdgeRelationFilter (db::SpaceRelation, 10);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
f.set_metrics (db::Euclidian);
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, 101), db::Point (0, 201)), &output);
@ -417,7 +417,7 @@ TEST(8_KissingCornerProblem)
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, -100), db::Point (0, -1)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::NeverIncludeZeroDistance);
f.set_collinear_mode (db::NeverIncludeCollinear);
f.set_metrics (db::Euclidian);
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, 101), db::Point (0, 201)), &output);
@ -440,7 +440,7 @@ TEST(9_KissingCornerProblemSquareMetrics)
// if the projection is >0.
db::EdgeRelationFilter f (db::WidthRelation, 10);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
db::EdgePair output;
bool res;
@ -461,7 +461,7 @@ TEST(9_KissingCornerProblemSquareMetrics)
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 100)), db::Edge (db::Point (0, -1), db::Point (0, -100)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::NeverIncludeZeroDistance);
f.set_collinear_mode (db::NeverIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 100)), db::Edge (db::Point (0, 201), db::Point (0, 101)), &output);
EXPECT_EQ (res, false);
@ -477,7 +477,7 @@ TEST(9_KissingCornerProblemSquareMetrics)
EXPECT_EQ (res, false);
f = db::EdgeRelationFilter (db::SpaceRelation, 10);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
f.set_metrics (db::Square);
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, 101), db::Point (0, 201)), &output);
@ -496,7 +496,7 @@ TEST(9_KissingCornerProblemSquareMetrics)
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, -100), db::Point (0, -1)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::NeverIncludeZeroDistance);
f.set_collinear_mode (db::NeverIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, 101), db::Point (0, 201)), &output);
EXPECT_EQ (res, false);
@ -518,7 +518,7 @@ TEST(10_KissingCornerProblemProjectionMetrics)
// if the projection is >0. It is not effective in projection metrics as there is no overlap.
db::EdgeRelationFilter f (db::WidthRelation, 10);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
db::EdgePair output;
bool res;
@ -537,7 +537,7 @@ TEST(10_KissingCornerProblemProjectionMetrics)
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 100)), db::Edge (db::Point (0, -1), db::Point (0, -100)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::NeverIncludeZeroDistance);
f.set_collinear_mode (db::NeverIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 0), db::Point (0, 100)), db::Edge (db::Point (0, 201), db::Point (0, 101)), &output);
EXPECT_EQ (res, false);
@ -553,7 +553,7 @@ TEST(10_KissingCornerProblemProjectionMetrics)
EXPECT_EQ (res, false);
f = db::EdgeRelationFilter (db::SpaceRelation, 10);
f.set_include_zero (db::IncludeZeroDistanceWhenTouch);
f.set_collinear_mode (db::IncludeCollinearWhenTouch);
f.set_metrics (db::Projection);
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, 101), db::Point (0, 201)), &output);
@ -570,7 +570,7 @@ TEST(10_KissingCornerProblemProjectionMetrics)
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, -100), db::Point (0, -1)), &output);
EXPECT_EQ (res, false);
f.set_include_zero (db::NeverIncludeZeroDistance);
f.set_collinear_mode (db::NeverIncludeCollinear);
res = f.check (db::Edge (db::Point (0, 100), db::Point (0, 0)), db::Edge (db::Point (0, 101), db::Point (0, 201)), &output);
EXPECT_EQ (res, false);