mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-09 11:12:21 +00:00
Merge pull request #80 from mkaravel/feature/is_simple
Feature/is simple
This commit is contained in:
@@ -100,8 +100,8 @@ private:
|
||||
{
|
||||
public:
|
||||
has_cycles_dfs_data(std::size_t num_nodes)
|
||||
: m_visited(num_nodes)
|
||||
, m_parent_id(num_nodes)
|
||||
: m_visited(num_nodes, false)
|
||||
, m_parent_id(num_nodes, -1)
|
||||
{}
|
||||
|
||||
inline int parent_id(vertex_handle v) const
|
||||
@@ -139,7 +139,7 @@ private:
|
||||
{
|
||||
vertex_handle v = stack.top();
|
||||
stack.pop();
|
||||
|
||||
|
||||
data.set_visited(v, true);
|
||||
for (typename neighbor_container::const_iterator nit
|
||||
= m_neighbors[v->id()].begin();
|
||||
@@ -205,15 +205,9 @@ public:
|
||||
|
||||
inline bool has_cycles() const
|
||||
{
|
||||
has_cycles_dfs_data data(m_vertices.size());
|
||||
|
||||
// initialize all vertices as non-visited and with no parent set
|
||||
for (vertex_handle it = m_vertices.begin();
|
||||
it != m_vertices.end(); ++it)
|
||||
{
|
||||
data.set_visited(it, false);
|
||||
data.set_parent_id(it, -1);
|
||||
}
|
||||
// this is done by the constructor of has_cycles_dfs_data
|
||||
has_cycles_dfs_data data(m_num_rings + m_num_turns);
|
||||
|
||||
// for each non-visited vertex, start a DFS from that vertex
|
||||
for (vertex_handle it = m_vertices.begin();
|
||||
|
||||
@@ -579,6 +579,9 @@ void test_open_polygons()
|
||||
// 1st hole touches 2nd hole at two points
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,10 0,10 10,0 10),(1 1,1 9,9 9,9 8,2 8,2 1),(2 5,5 8,5 5))"),
|
||||
false);
|
||||
// polygon with many holes, where the last two touch at two points
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,20 0,20 20,0 20),(1 18,1 19,2 19,2 18),(3 18,3 19,4 19,4 18),(5 18,5 19,6 19,6 18),(7 18,7 19,8 19,8 18),(9 18,9 19,10 19,10 18),(11 18,11 19,12 19,12 18),(13 18,13 19,14 19,14 18),(15 18,15 19,16 19,16 18),(17 18,17 19,18 19,18 18),(1 1,1 9,9 9,9 8,2 8,2 1),(2 5,5 8,5 5))"),
|
||||
false);
|
||||
// two holes completely inside exterior ring but touching each
|
||||
// other at a point
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,10 0,10 10,0 10),(1 1,1 9,2 9),(1 1,9 2,9 1))"),
|
||||
|
||||
Reference in New Issue
Block a user