From: johanengelen Date: Sun, 2 Dec 2007 23:14:54 +0000 (+0000) Subject: Fix compile. Don't #include .cpp files! X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6c61d5ee45d84179713334a29ffda3f4aa029179;p=inkscape.git Fix compile. Don't #include .cpp files! --- diff --git a/src/nodepath.cpp b/src/nodepath.cpp index f48a83b4f..1239f961b 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -49,6 +49,7 @@ #include #include "live_effects/lpeobject.h" #include "live_effects/parameter/parameter.h" +#include "util/mathfns.h" class NR::Matrix; @@ -4046,15 +4047,6 @@ static void sp_nodepath_subpath_open(Inkscape::NodePath::SubPath *sp,Inkscape::N new_path->p.other = NULL; } -/** - * Returns area in triangle given by points; may be negative. - */ -inline double -triangle_area (NR::Point p1, NR::Point p2, NR::Point p3) -{ - return (p1[NR::X]*p2[NR::Y] + p1[NR::Y]*p3[NR::X] + p2[NR::X]*p3[NR::Y] - p2[NR::Y]*p3[NR::X] - p1[NR::Y]*p2[NR::X] - p1[NR::X]*p3[NR::Y]); -} - /** * Return new node in subpath with given properties. * \param pos Position of node. @@ -4079,7 +4071,7 @@ sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp, Inkscape::NodePath::Node * // use the type from sodipodi:nodetypes n->type = type; } else { - if (fabs (triangle_area (*pos, *ppos, *npos)) < 1e-2) { + if (fabs (Inkscape::Util::triangle_area (*pos, *ppos, *npos)) < 1e-2) { // points are (almost) collinear if (NR::L2(*pos - *ppos) < 1e-6 || NR::L2(*pos - *npos) < 1e-6) { // endnode, or a node with a retracted handle diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 99b4977b9..a0c2249c7 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -46,7 +46,7 @@ #include "bad-uri-exception.h" #include "xml/repr.h" -#include "nodepath.cpp" // for triangle_area() +#include "util/mathfns.h" // for triangle_area() #define noSHAPE_VERBOSE @@ -1143,7 +1143,7 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p) // Determine whether a node is at a smooth part of the path, by // calculating a measure for the collinearity of the handles - bool c1 = fabs (triangle_area (pos, ppos, npos)) < 1; // points are (almost) collinear + bool c1 = fabs (Inkscape::Util::triangle_area (pos, ppos, npos)) < 1; // points are (almost) collinear bool c2 = NR::L2(pos - ppos) < 1e-6 || NR::L2(pos - npos) < 1e-6; // endnode, or a node with a retracted handle if (!(c1 & !c2)) { *p = pos; // only return non-smooth nodes ("cusps") diff --git a/src/util/Makefile_insert b/src/util/Makefile_insert index 41d3b9fb4..913dda26b 100644 --- a/src/util/Makefile_insert +++ b/src/util/Makefile_insert @@ -16,6 +16,7 @@ util_libinkutil_a_SOURCES = \ util/list.h \ util/list-container.h \ util/map-list.h \ + util/mathfns.h \ util/reverse-list.h \ util/share.h \ util/share.cpp \ diff --git a/src/util/mathfns.h b/src/util/mathfns.h new file mode 100644 index 000000000..9ebd8bc2f --- /dev/null +++ b/src/util/mathfns.h @@ -0,0 +1,43 @@ +/* + * Inkscape::Util::... some mathmatical functions + * + * Authors: + * Johan Engelen + * + * Copyright (C) 2007 Johan Engelen + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_UTIL_MATHFNS_H +#define SEEN_INKSCAPE_UTIL_MATHFNS_H + + +namespace Inkscape { + +namespace Util { + +/** + * Returns area in triangle given by points; may be negative. + */ +inline double +triangle_area (NR::Point p1, NR::Point p2, NR::Point p3) +{ + return (p1[NR::X]*p2[NR::Y] + p1[NR::Y]*p3[NR::X] + p2[NR::X]*p3[NR::Y] - p2[NR::Y]*p3[NR::X] - p1[NR::Y]*p2[NR::X] - p1[NR::X]*p3[NR::Y]); +} + +} + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :