Logo Search packages:      
Sourcecode: inkscape version File versions

std::vector< std::pair< Geom::Point, int > > Inkscape::Selection::getSnapPointsConvexHull ( SnapPreferences const *  snapprefs  )  const

Gets the snap points of a selection that form a convex hull.

Returns:
Selection's convex hull points

Definition at line 465 of file selection.cpp.

References Inkscape::Util::first(), and itemList().

                                                                                                             {
    GSList const *items = const_cast<Selection *>(this)->itemList();

    std::vector<std::pair<Geom::Point, int> > p;
    for (GSList const *iter = items; iter != NULL; iter = iter->next) {
            sp_item_snappoints(SP_ITEM(iter->data), false, p, snapprefs);
    }

    std::vector<std::pair<Geom::Point, int> > pHull;
    if (!p.empty()) {
      std::vector<std::pair<Geom::Point, int> >::iterator i;
        Geom::RectHull cvh((p.front()).first);
        for (i = p.begin(); i != p.end(); i++) {
            // these are the points we get back
            cvh.add((*i).first);
        }

        Geom::OptRect rHull = cvh.bounds();
        if (rHull) {
            for ( unsigned i = 0 ; i < 4 ; ++i ) {
                pHull.push_back(std::make_pair(rHull->corner(i), SNAPSOURCE_CONVEX_HULL_CORNER));
            }
        }
    }

    return pHull;
}


Generated by  Doxygen 1.6.0   Back to index