Commit de6e73a2 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix compilation issues with clang++

parent 01fd54e2
......@@ -83,11 +83,11 @@ AC_ARG_ENABLE([optimization], [AS_HELP_STRING([--disable-optimization],[disable
if test $enableval = no; then
[AC_MSG_RESULT(no)]
else
[CXXFLAGS="${CXXFLAGS} -O99"]
[CXXFLAGS="${CXXFLAGS} -O3"]
[AC_MSG_RESULT(yes)]
fi
,
[CXXFLAGS="${CXXFLAGS} -O99"]
[CXXFLAGS="${CXXFLAGS} -O3"]
[AC_MSG_RESULT(yes)]
)
......
......@@ -44,7 +44,7 @@ struct get_assortativity_coefficient
typedef typename mpl::if_<typename is_directed::apply<Graph>::type,
size_t, double>::type count_t;
count_t c = (is_directed::apply<Graph>::type::value) ? 1.0 : 0.5;
count_t c = (is_directed::apply<Graph>::type::value) ? count_t(1) : count_t(0.5);
count_t n_edges = 0;
count_t e_kk = 0;
tr1::unordered_map<double,count_t> a, b;
......@@ -124,7 +124,7 @@ struct get_scalar_assortativity_coefficient
typedef typename mpl::if_<typename is_directed::apply<Graph>::type,
size_t, double>::type count_t;
count_t c = (is_directed::apply<Graph>::type::value) ? 1.0 : 0.5;
count_t c = (is_directed::apply<Graph>::type::value) ? count_t(1) : count_t(0.5);
count_t n_edges = 0;
double e_xy = 0.0;
double a = 0.0, b = 0.0, da = 0.0, db = 0.0;
......
......@@ -128,7 +128,7 @@ typedef mpl::map21<
mpl::pair<mpl::int_<EDGE_CONTROL_POINTS>, vector<double> > >
attr_types;
namespace boost
namespace std
{
ostream& operator<<(ostream& out, const color_t& c)
{
......@@ -136,13 +136,29 @@ ostream& operator<<(ostream& out, const color_t& c)
return out;
}
istream& operator>>(istream& in, const color_t& c)
istream& operator>>(istream& in, color_t& c)
{
in >> get<0>(c) >> get<1>(c) >> get<2>(c) >> get<3>(c);
return in;
}
}
istream& operator>>(istream& in, vertex_shape_t& c)
{
int tmp;
in >> tmp;
c = vertex_shape_t(tmp);
return in;
}
istream& operator>>(istream& in, edge_marker_t& c)
{
int tmp;
in >> tmp;
c = edge_marker_t(tmp);
return in;
}
template <class T1, class T2>
struct specific_convert;
......@@ -395,27 +411,27 @@ public:
double get_size(Cairo::Context& cr)
{
double size = _attrs.get<double>(VERTEX_SIZE);
double size = _attrs.template get<double>(VERTEX_SIZE);
size *= get_user_dist(cr);
string text = _attrs.get<string>(VERTEX_TEXT);
string text = _attrs.template get<string>(VERTEX_TEXT);
if (text != "")
{
double text_pos = _attrs.get<double>(VERTEX_TEXT_POSITION);
double text_pos = _attrs.template get<double>(VERTEX_TEXT_POSITION);
if (text_pos < 0)
{
cr.select_font_face(_attrs.get<string>(VERTEX_FONT_FAMILY),
static_cast<Cairo::FontSlant>(_attrs.get<int32_t>(VERTEX_FONT_SLANT)),
static_cast<Cairo::FontWeight>(_attrs.get<int32_t>(VERTEX_FONT_WEIGHT)));
cr.set_font_size(_attrs.get<double>(VERTEX_FONT_SIZE) *
cr.select_font_face(_attrs.template get<string>(VERTEX_FONT_FAMILY),
static_cast<Cairo::FontSlant>(_attrs.template get<int32_t>(VERTEX_FONT_SLANT)),
static_cast<Cairo::FontWeight>(_attrs.template get<int32_t>(VERTEX_FONT_WEIGHT)));
cr.set_font_size(_attrs.template get<double>(VERTEX_FONT_SIZE) *
get_user_dist(cr));
Cairo::TextExtents extents;
cr.get_text_extents(text, extents);
double s = max(extents.width, extents.height) * 1.4;
if (_attrs.get<vertex_shape_t>(VERTEX_SHAPE) >= SHAPE_DOUBLE_CIRCLE)
if (_attrs.template get<vertex_shape_t>(VERTEX_SHAPE) >= SHAPE_DOUBLE_CIRCLE)
{
s /= 0.7;
double pw = _attrs.get<double>(VERTEX_PENWIDTH);
double pw = _attrs.template get<double>(VERTEX_PENWIDTH);
pw *= get_user_dist(cr);
s += pw;
}
......@@ -434,13 +450,13 @@ public:
double r = get_size(cr) / 2;
double dr = r;
double pw = _attrs.get<double>(VERTEX_PENWIDTH);
double pw = _attrs.template get<double>(VERTEX_PENWIDTH);
pw *= get_user_dist(cr);
r += pw / 2.5;
pos_t anchor;
size_t nsides = 0;
vertex_shape_t shape = _attrs.get<vertex_shape_t>(VERTEX_SHAPE);
vertex_shape_t shape = _attrs.template get<vertex_shape_t>(VERTEX_SHAPE);
switch (shape)
{
case SHAPE_TRIANGLE:
......@@ -466,7 +482,7 @@ public:
break;
default:
throw ValueException("Invalid vertex shape: " +
lexical_cast<string>(int(_attrs.get<vertex_shape_t>(VERTEX_SHAPE))));
lexical_cast<string>(int(_attrs.template get<vertex_shape_t>(VERTEX_SHAPE))));
}
anchor = _pos;
......@@ -486,39 +502,39 @@ public:
double size, pw;
size = get_size(cr);
string text = _attrs.get<string>(VERTEX_TEXT);
string text = _attrs.template get<string>(VERTEX_TEXT);
double text_pos = 0;
if (text != "")
{
string text = _attrs.get<string>(VERTEX_TEXT);
cr.select_font_face(_attrs.get<string>(VERTEX_FONT_FAMILY),
static_cast<Cairo::FontSlant>(_attrs.get<int32_t>(VERTEX_FONT_SLANT)),
static_cast<Cairo::FontWeight>(_attrs.get<int32_t>(VERTEX_FONT_WEIGHT)));
cr.set_font_size(_attrs.get<double>(VERTEX_FONT_SIZE) *
string text = _attrs.template get<string>(VERTEX_TEXT);
cr.select_font_face(_attrs.template get<string>(VERTEX_FONT_FAMILY),
static_cast<Cairo::FontSlant>(_attrs.template get<int32_t>(VERTEX_FONT_SLANT)),
static_cast<Cairo::FontWeight>(_attrs.template get<int32_t>(VERTEX_FONT_WEIGHT)));
cr.set_font_size(_attrs.template get<double>(VERTEX_FONT_SIZE) *
get_user_dist(cr));
text_pos = _attrs.get<double>(VERTEX_TEXT_POSITION);
text_pos = _attrs.template get<double>(VERTEX_TEXT_POSITION);
}
cr.save();
cr.translate(_pos.first, _pos.second);
if (_attrs.get<uint8_t>(VERTEX_HALO))
if (_attrs.template get<uint8_t>(VERTEX_HALO))
{
color_t c = _attrs.get<color_t>(VERTEX_HALO_COLOR);
color_t c = _attrs.template get<color_t>(VERTEX_HALO_COLOR);
cr.set_source_rgba(get<0>(c), get<1>(c), get<2>(c), get<3>(c));
cr.arc(0, 0, size, 0, 2 * M_PI);
cr.fill();
}
pw =_attrs.get<double>(VERTEX_PENWIDTH);
pw =_attrs.template get<double>(VERTEX_PENWIDTH);
pw *= get_user_dist(cr);
cr.set_line_width(pw);
color = _attrs.get<color_t>(VERTEX_COLOR);
color = _attrs.template get<color_t>(VERTEX_COLOR);
cr.set_source_rgba(get<0>(color), get<1>(color), get<2>(color),
get<3>(color));
size_t nsides = 0;
vertex_shape_t shape = _attrs.get<vertex_shape_t>(VERTEX_SHAPE);
vertex_shape_t shape = _attrs.template get<vertex_shape_t>(VERTEX_SHAPE);
switch (shape)
{
case SHAPE_CIRCLE:
......@@ -558,10 +574,10 @@ public:
break;
default:
throw ValueException("Invalid vertex shape: " +
lexical_cast<string>(int(_attrs.get<vertex_shape_t>(VERTEX_SHAPE))));
lexical_cast<string>(int(_attrs.template get<vertex_shape_t>(VERTEX_SHAPE))));
}
fillcolor = _attrs.get<color_t>(VERTEX_FILL_COLOR);
fillcolor = _attrs.template get<color_t>(VERTEX_FILL_COLOR);
cr.set_source_rgba(get<0>(fillcolor), get<1>(fillcolor),
get<2>(fillcolor), get<3>(fillcolor));
cr.fill_preserve();
......@@ -597,7 +613,7 @@ public:
anchor.second += extents.height;
cr.translate(anchor.first, anchor.second);
}
color = _attrs.get<color_t>(VERTEX_TEXT_COLOR);
color = _attrs.template get<color_t>(VERTEX_TEXT_COLOR);
cr.set_source_rgba(get<0>(color), get<1>(color), get<2>(color),
get<3>(color));
cr.show_text(text);
......@@ -625,7 +641,7 @@ public:
pos_t pos_begin, pos_end;
vector<double> controls =
_attrs.get<vector<double> >(EDGE_CONTROL_POINTS);
_attrs.template get<vector<double> >(EDGE_CONTROL_POINTS);
pos_begin = _s.get_anchor(_t.get_pos(), cr);
pos_end = _t.get_anchor(_s.get_pos(), cr);
......@@ -676,9 +692,9 @@ public:
pos_t pos_end_c = pos_end, pos_begin_c = pos_begin;
edge_marker_t start_marker = _attrs.get<edge_marker_t>(EDGE_START_MARKER);
edge_marker_t end_marker = _attrs.get<edge_marker_t>(EDGE_END_MARKER);
double marker_size = _attrs.get<double>(EDGE_MARKER_SIZE);
edge_marker_t start_marker = _attrs.template get<edge_marker_t>(EDGE_START_MARKER);
edge_marker_t end_marker = _attrs.template get<edge_marker_t>(EDGE_END_MARKER);
double marker_size = _attrs.template get<double>(EDGE_MARKER_SIZE);
marker_size *= get_user_dist(cr);
if (start_marker != MARKER_SHAPE_NONE && start_marker != MARKER_SHAPE_BAR)
......@@ -686,10 +702,10 @@ public:
if (end_marker != MARKER_SHAPE_NONE && end_marker != MARKER_SHAPE_BAR)
move_radially(pos_end_c, _t.get_pos(), marker_size / 2);
color_t color = _attrs.get<color_t>(EDGE_COLOR);
color_t color = _attrs.template get<color_t>(EDGE_COLOR);
cr.set_source_rgba(get<0>(color), get<1>(color), get<2>(color), 1);
double pw;
pw = _attrs.get<double>(EDGE_PENWIDTH);
pw = _attrs.template get<double>(EDGE_PENWIDTH);
pw *= get_user_dist(cr);
cr.set_line_width(pw);
......@@ -785,7 +801,7 @@ public:
void draw_marker(edge_attr_t attr, double size, Cairo::Context& cr)
{
edge_marker_t marker = _attrs.get<edge_marker_t>(attr);
edge_marker_t marker = _attrs.template get<edge_marker_t>(attr);
switch (marker)
{
case MARKER_SHAPE_ARROW:
......@@ -1207,11 +1223,12 @@ struct do_put_parallel_splines
double n = (pes.size() - 1.) / 2.;
for (size_t j = 0; j < pes.size(); ++j)
{
typedef typename property_traits<SplinesMap>::value_type::value_type val_t;
double one = pes[j].second ? 1 : -1;
sp[0] = 0.3;
sp[1] = one * (j - n) * parallel_distance / n;
sp[2] = 0.7;
sp[3] = one * (j - n) * parallel_distance / n;
sp[0] = val_t(0.3);
sp[1] = val_t(one * (j - n) * parallel_distance / n);
sp[2] = val_t(0.7);
sp[3] = val_t(one * (j - n) * parallel_distance / n);
put(spline, skey_t(pes[j].first), sp);
}
}
......
......@@ -36,11 +36,6 @@ struct get_line_graph
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
typedef boost::property<edge_index_t, size_t> EdgeProperty;
typedef typename property_map<LineGraph, vertex_index_t>::type
line_vertex_index_map_t;
line_vertex_index_map_t line_vertex_index(get(boost::vertex_index,
line_graph));
typedef typename graph_traits<LineGraph>::vertex_descriptor lg_vertex_t;
typedef HashedDescriptorMap<EdgeIndexMap,lg_vertex_t>
edge_to_vertex_map_t;
......
......@@ -164,7 +164,39 @@ void print_progress(size_t i, size_t n_iter, size_t current, size_t total,
}
}
class DegreeBlock;
//select blocks based on in/out degrees
class DegreeBlock
{
public:
typedef pair<size_t, size_t> block_t;
template <class Graph>
block_t get_block(typename graph_traits<Graph>::vertex_descriptor v,
const Graph& g) const
{
return make_pair(in_degreeS()(v, g), out_degree(v, g));
}
};
//select blocks based on property map
template <class PropertyMap>
class PropertyBlock
{
public:
typedef typename property_traits<PropertyMap>::value_type block_t;
PropertyBlock(PropertyMap p): _p(p) {}
template <class Graph>
block_t get_block(typename graph_traits<Graph>::vertex_descriptor v,
const Graph& g) const
{
return get(_p, v);
}
private:
PropertyMap _p;
};
// main rewire loop
template <template <class Graph, class EdgeIndexMap, class CorrProb,
......@@ -616,40 +648,6 @@ private:
_probs;
};
//select blocks based on in/out degrees
class DegreeBlock
{
public:
typedef pair<size_t, size_t> block_t;
template <class Graph>
block_t get_block(typename graph_traits<Graph>::vertex_descriptor v,
const Graph& g) const
{
return make_pair(in_degreeS()(v, g), out_degree(v, g));
}
};
//select blocks based on property map
template <class PropertyMap>
class PropertyBlock
{
public:
typedef typename property_traits<PropertyMap>::value_type block_t;
PropertyBlock(PropertyMap p): _p(p) {}
template <class Graph>
block_t get_block(typename graph_traits<Graph>::vertex_descriptor v,
const Graph& g) const
{
return get(_p, v);
}
private:
PropertyMap _p;
};
} // graph_tool namespace
#endif // GRAPH_REWIRING_HH
......@@ -20,10 +20,14 @@
// follow the requirements of the GNU GPL in regard to all of the
// software in the executable aside from CGAL.
#if (GCC_VERSION < 40400)
#if (GCC_VERSION < 40400 || defined __clang__)
# define CGAL_CFG_NO_TR1_ARRAY
# define CGAL_CFG_NO_TR1_TUPLE
#endif
#ifdef __clang__
# define CGAL_CFG_ARRAY_MEMBER_INITIALIZATION_BUG
#endif
#include <CGAL/version.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
......@@ -33,7 +37,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Triangulation_3<Kernel> SimpleTriangulation;
typedef CGAL::Delaunay_triangulation_3<Kernel> DelaunayTriangulation;
namespace std
namespace CGAL
{
bool operator==(const SimpleTriangulation::Vertex& a,
const SimpleTriangulation::Vertex& b)
......@@ -49,7 +53,7 @@ bool operator==(const SimpleTriangulation::Vertex& a,
typedef CGAL::Periodic_3_triangulation_traits_3<Kernel> GT;
typedef CGAL::Periodic_3_Delaunay_triangulation_3<GT>
PeriodicDelaunayTriangulation;
namespace std
namespace CGAL
{
bool operator==(const PeriodicDelaunayTriangulation::Vertex& a,
const PeriodicDelaunayTriangulation::Vertex& b)
......
......@@ -52,7 +52,7 @@ class gml_parse_error: public std::exception
public:
gml_parse_error(const string& w): _what(w) {}
~gml_parse_error() throw() {}
std::string what() {return _what;}
virtual const char* what() const throw() {return _what.c_str();}
private:
std::string _what;
......
......@@ -154,9 +154,8 @@ public:
private:
// Generic graph_action functor. See graph_filtering.hh for details.
template <class Action,
class TR1=boost::mpl::vector<>, class TR2=boost::mpl::vector<>,
class TR3=boost::mpl::vector<>, class TR4=boost::mpl::vector<> >
template <class Action, class GraphViews, class Wrap, class TR1, class TR2,
class TR3, class TR4>
friend struct detail::graph_action;
// python interface
......
......@@ -55,16 +55,6 @@ uint8_t lexical_cast<uint8_t,string>(const string& val)
// preserve internal representation. (we also need to make sure the
// representation is locale-independent).
template <class Val>
int print_float(char*& str, Val val)
{
char* locale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
int retval = print_float_dispatch(str, val);
setlocale(LC_NUMERIC, locale);
return retval;
}
int print_float_dispatch(char*& str, float val)
{
return asprintf(&str, "%a", val);
......@@ -81,11 +71,11 @@ int print_float_dispatch(char*& str, long double val)
}
template <class Val>
int scan_float(const char* str, Val& val)
int print_float(char*& str, Val val)
{
char* locale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
int retval = scan_float_dispatch(str, val);
int retval = print_float_dispatch(str, val);
setlocale(LC_NUMERIC, locale);
return retval;
}
......@@ -105,6 +95,17 @@ int scan_float_dispatch(const char* str, long double& val)
return sscanf(str, "%La", &val);
}
template <class Val>
int scan_float(const char* str, Val& val)
{
char* locale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
int retval = scan_float_dispatch(str, val);
setlocale(LC_NUMERIC, locale);
return retval;
}
template <>
string lexical_cast<string,float>(const float& val)
{
......
......@@ -155,7 +155,7 @@ struct label_biconnected_components
{
HistogramPropertyMap<CompMap> cm(comp_map, num_edges(g), hist);
biconnected_components(g, cm,
vertex_inserter<ArtMap>(art_map)).first;
vertex_inserter<ArtMap>(art_map));
}
};
......
......@@ -15,11 +15,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "graph.hh"
#include "graph_filtering.hh"
#include <boost/graph/transitive_closure.hpp>
#include "graph_filtering.hh"
#include "graph.hh"
#include "graph_properties.hh"
using namespace graph_tool;
using namespace boost;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment