PGROUTING  3.2
isPlanar_driver.cpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: isPlanar_driver.cpp
3 
4 Generated with Template by:
5 Copyright (c) 2020 pgRouting developers
7 
8 Function's developer:
9 Copyright (c) 2020 Himanshu Raj
11 
12 ------
13 
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18 
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23 
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 
28 ********************************************************************PGR-GNU*/
29 
31 
32 #include <vector>
33 #include <algorithm>
34 #include <string>
35 
36 #include "cpp_common/pgr_alloc.hpp"
37 #include "cpp_common/pgr_assert.h"
38 
41 
42 
43 
44 bool
46  pgr_edge_t *data_edges,
47  size_t total_edges,
48 
49  char ** log_msg,
50  char ** notice_msg,
51  char ** err_msg) {
52  std::ostringstream log;
53  std::ostringstream err;
54  std::ostringstream notice;
55  bool result = false;
56  try {
57  pgassert(!(*log_msg));
58  pgassert(!(*notice_msg));
59  pgassert(!(*err_msg));
60  pgassert(total_edges != 0);
61 
62  graphType gType = UNDIRECTED;
63  log << "Working with Undirected Graph\n";
64  pgrouting::UndirectedGraph undigraph(gType);
65  undigraph.insert_edges(data_edges, total_edges);
67  result = fn_isPlanar.isPlanar(undigraph);
68  return result;
69 
70  pgassert(*err_msg == NULL);
71  *log_msg = log.str().empty()?
72  *log_msg :
73  pgr_msg(log.str().c_str());
74  *notice_msg = notice.str().empty()?
75  *notice_msg :
76  pgr_msg(notice.str().c_str());
77  } catch (AssertFailedException &except) {
78  err << except.what();
79  *err_msg = pgr_msg(err.str().c_str());
80  *log_msg = pgr_msg(log.str().c_str());
81  } catch (std::exception &except) {
82  err << except.what();
83  *err_msg = pgr_msg(err.str().c_str());
84  *log_msg = pgr_msg(log.str().c_str());
85  } catch(...) {
86  err << "Caught unknown exception!";
87  *err_msg = pgr_msg(err.str().c_str());
88  *log_msg = pgr_msg(log.str().c_str());
89  }
90  return result;
91 }
pgr_base_graph.hpp
isPlanar_driver.h
pgr_edge_t
Definition: pgr_edge_t.h:37
pgr_msg
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
AssertFailedException::what
virtual const char * what() const
Definition: pgr_assert.cpp:67
do_pgr_isPlanar
bool do_pgr_isPlanar(pgr_edge_t *data_edges, size_t total_edges, char **log_msg, char **notice_msg, char **err_msg)
Definition: isPlanar_driver.cpp:45
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
UNDIRECTED
@ UNDIRECTED
Definition: graph_enum.h:30
pgrouting::graph::Pgr_base_graph::insert_edges
void insert_edges(const T *edges, size_t count)
Inserts count edges of type T into the graph.
Definition: pgr_base_graph.hpp:357
pgrouting::functions::Pgr_boyerMyrvold::isPlanar
bool isPlanar(G &graph)
Definition: pgr_boyerMyrvold.hpp:56
pgr_alloc.hpp
graphType
graphType
Definition: graph_enum.h:30
pgr_assert.h
An assert functionality that uses C++ throw().
pgrouting::graph::Pgr_base_graph
Definition: pgr_base_graph.hpp:168
pgrouting::functions::Pgr_boyerMyrvold
Definition: pgr_boyerMyrvold.hpp:47
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139
pgr_boyerMyrvold.hpp