summaryrefslogtreecommitdiffstats
path: root/src/helper/geom-pathinfo.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-07-06 10:01:17 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-07-06 10:01:17 +0000
commit936f6512b26120b882a1c68e50968a15002f3af4 (patch)
tree82d18a24db63832d51f5d59544dc9561680fe372 /src/helper/geom-pathinfo.cpp
parentFix a bug displaying arcs (diff)
downloadinkscape-936f6512b26120b882a1c68e50968a15002f3af4.tar.gz
inkscape-936f6512b26120b882a1c68e50968a15002f3af4.zip
Fixes from branch review
(bzr r13645.1.102)
Diffstat (limited to 'src/helper/geom-pathinfo.cpp')
-rw-r--r--src/helper/geom-pathinfo.cpp176
1 files changed, 0 insertions, 176 deletions
diff --git a/src/helper/geom-pathinfo.cpp b/src/helper/geom-pathinfo.cpp
deleted file mode 100644
index d73f8f707..000000000
--- a/src/helper/geom-pathinfo.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * \file
- * \brief Pathinfo iterate a Geom::PathVector and allow get info about it.
- * \Usualy need a curve index to get the results
- * \TODO: migrate more Inkscape loops to use it.
- */ /*
- * Authors:
- * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es>
- *
- * This code is in public domain
- */
-
-#include <helper/geom-pathinfo.h>
-#include <2geom/sbasis-to-bezier.h>
-
-/**
- * @brief Pathinfo store the _data of a Geom::PathVector and allow get info about it
- *
- */
-Pathinfo::Pathinfo() {}
-
-Pathinfo::~Pathinfo() {}
-
-
-void Pathinfo::set(Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2)
-{
- set(path_from_piecewise(remove_short_cuts(pwd2, 0.1), 0.001));
-}
-/** Store the base path _data
- */
-void Pathinfo::set(Geom::PathVector path_vector, bool skip_degenerate)
-{
- _data.clear();
- size_t counter = 0;
- for (Geom::PathVector::const_iterator path_it = path_vector.begin();
- path_it != path_vector.end(); ++path_it)
- {
- if (path_it->empty()) {
- continue;
- }
- Geom::Path::const_iterator curve_it1 = path_it->begin();
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- if (path_it->closed()) {
- Geom::Curve const &closingline = path_it->back_closed();
- if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
- curve_endit = path_it->end_open();
- }
- }
- while (curve_it1 != curve_endit) {
- if(curve_it1->isDegenerate() && skip_degenerate ){
- ++curve_it1;
- continue;
- }
- ++curve_it1;
- counter++;
- }
- if (path_it->closed()) {
- _data.push_back(std::make_pair(counter - 1, true));
- } else {
- _data.push_back(std::make_pair(counter - 1, false));
- }
- }
-}
-
-/** Size of pathvector
- */
-size_t Pathinfo::size() const
-{
- return _data.back().first + 1;
-}
-
-/** Size of subpath
- */
-size_t Pathinfo::subPathSize(size_t subpath_index) const
-{
- size_t size = 0;
- if( _data.size() > subpath_index){
- double prev = 0;
- if(subpath_index != 0){
- prev = _data[subpath_index - 1].first;
- }
- size = prev - _data[subpath_index].first + 1;
- }
- return size;
-}
-
-/** Get subpath index from a curve index
- */
-size_t Pathinfo::subPathIndex(size_t index) const
-{
- for (size_t i = 0; i < _data.size(); i++) {
- if (index <= _data[i].first) {
- return i;
- }
- }
- return 0;
-}
-
-/** Get subpath last index given a curve index
- */
-size_t Pathinfo::last(size_t index) const
-{
- for (size_t i = 0; i < _data.size(); i++) {
- if (index <= _data[i].first) {
- return _data[i].first;
- }
- }
- return 0;
-}
-
-/** Get subpath first index given a curve index
- */
-size_t Pathinfo::first(size_t index) const
-{
- for (size_t i = 0; i < _data.size(); i++) {
- if (index <= _data[i].first) {
- if (i == 0) {
- return 0;
- } else {
- return _data[i - 1].first + 1;
- }
- }
- }
- return 0;
-}
-
-/** Get previous index given a curve index
- */
-boost::optional<size_t> Pathinfo::previous(size_t index) const
-{
- if (first(index) == index && closed(index)) {
- return last(index);
- }
- if (first(index) == index && !closed(index)) {
- return boost::none;
- }
- return index - 1;
-}
-
-/** Get next index given a curve index
- */
-boost::optional<size_t> Pathinfo::next(size_t index) const
-{
- if (last(index) == index && closed(index)) {
- return first(index);
- }
- if (last(index) == index && !closed(index)) {
- return boost::none;
- }
- return index + 1;
-}
-
-/** Get if subpath is closed given a curve index
- */
-bool Pathinfo::closed(size_t index) const
-{
- for (size_t i = 0; i < _data.size(); i++) {
- if (index <= _data[i].first) {
- return _data[i].second;
- }
- }
- return false;
-}
-
-/*
- 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:fileencoding=utf-8:textwidth=99
-// :