From b7b17f36b9e3d2814dcf0f4db1fb329976c2e85a Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Mon, 8 Sep 2008 22:20:36 +0000 Subject: 2geom update (rev. 1578); fixes node editing of some degenerate paths (bzr r6784) --- src/nodepath.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/nodepath.cpp') diff --git a/src/nodepath.cpp b/src/nodepath.cpp index e049c40df..5345485e2 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -1960,11 +1960,15 @@ sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Po SPCurve *curve = create_curve(nodepath); // perhaps we can use nodepath->curve here instead? Geom::PathVector const &pathv = curve->get_pathvector(); - Geom::PathVectorPosition pvpos = Geom::nearestPoint(pathv, p); + boost::optional pvpos = Geom::nearestPoint(pathv, p); + if (!pvpos) { + g_print ("Possible error?\n"); + return; + } // calculate index for nodepath's representation. - unsigned int segment_index = floor(pvpos.t) + 1; - for (unsigned int i = 0; i < pvpos.path_nr; ++i) { + unsigned int segment_index = floor(pvpos->t) + 1; + for (unsigned int i = 0; i < pvpos->path_nr; ++i) { segment_index += pathv[i].size() + 1; if (pathv[i].closed()) { segment_index += 1; @@ -2004,13 +2008,17 @@ sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p) SPCurve *curve = create_curve(nodepath); // perhaps we can use nodepath->curve here instead? Geom::PathVector const &pathv = curve->get_pathvector(); - Geom::PathVectorPosition pvpos = Geom::nearestPoint(pathv, p); + boost::optional pvpos = Geom::nearestPoint(pathv, p); + if (!pvpos) { + g_print ("Possible error?\n"); + return; + } // calculate index for nodepath's representation. double int_part; - double t = std::modf(pvpos.t, &int_part); + double t = std::modf(pvpos->t, &int_part); unsigned int segment_index = (unsigned int)int_part + 1; - for (unsigned int i = 0; i < pvpos.path_nr; ++i) { + for (unsigned int i = 0; i < pvpos->path_nr; ++i) { segment_index += pathv[i].size() + 1; if (pathv[i].closed()) { segment_index += 1; -- cgit v1.2.3