~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/2geom/pathvector.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Ted Gould, Kees Cook
  • Date: 2009-06-24 14:00:43 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624140043-07stp20mry48hqup
Tags: 0.47~pre0-0ubuntu1
* New upstream release

[ Ted Gould ]
* debian/control: Adding libgsl0 and removing version specifics on boost

[ Kees Cook ]
* debian/watch: updated to run uupdate and mangle pre-release versions.
* Dropped patches that have been taken upstream:
  - 01_mips
  - 02-poppler-0.8.3
  - 03-chinese-inkscape
  - 05_fix_latex_patch
  - 06_gcc-4.4
  - 07_cdr2svg
  - 08_skip-bad-utf-on-pdf-import
  - 09_gtk-clist
  - 10_belarussian
  - 11_libpng
  - 12_desktop
  - 13_slider
  - 100_svg_import_improvements
  - 102_sp_pattern_painter_free
  - 103_bitmap_type_print

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \file
 
3
 * \brief PathVector - std::vector containing Geom::Path
 
4
 * This file provides a set of operations that can be performed on PathVector,
 
5
 * e.g. an affine transform.
 
6
 *
 
7
 * Authors:
 
8
 *  Johan Engelen <goejendaagh@zonnet.nl>
 
9
 * 
 
10
 * Copyright 2008  authors
 
11
 *
 
12
 * This library is free software; you can redistribute it and/or
 
13
 * modify it either under the terms of the GNU Lesser General Public
 
14
 * License version 2.1 as published by the Free Software Foundation
 
15
 * (the "LGPL") or, at your option, under the terms of the Mozilla
 
16
 * Public License Version 1.1 (the "MPL"). If you do not alter this
 
17
 * notice, a recipient may use your version of this file under either
 
18
 * the MPL or the LGPL.
 
19
 *
 
20
 * You should have received a copy of the LGPL along with this library
 
21
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
 
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
23
 * You should have received a copy of the MPL along with this library
 
24
 * in the file COPYING-MPL-1.1
 
25
 *
 
26
 * The contents of this file are subject to the Mozilla Public License
 
27
 * Version 1.1 (the "License"); you may not use this file except in
 
28
 * compliance with the License. You may obtain a copy of the License at
 
29
 * http://www.mozilla.org/MPL/
 
30
 *
 
31
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
 
32
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
 
33
 * the specific language governing rights and limitations.
 
34
 */
 
35
 
 
36
#ifndef SEEN_GEOM_PATHVECTOR_H
 
37
#define SEEN_GEOM_PATHVECTOR_H
 
38
 
 
39
#include <2geom/forward.h>
 
40
#include <2geom/path.h>
 
41
#include <2geom/transforms.h>
 
42
 
 
43
namespace Geom {
 
44
 
 
45
typedef std::vector<Geom::Path> PathVector;
 
46
 
 
47
/* general path transformation: */
 
48
inline
 
49
void operator*= (PathVector & path_in, Matrix const &m) {
 
50
    for(PathVector::iterator it = path_in.begin(); it != path_in.end(); ++it) {
 
51
        (*it) *= m;
 
52
    }
 
53
}
 
54
inline
 
55
PathVector operator*(PathVector const & path_in, Matrix const &m) {
 
56
    PathVector ret(path_in);
 
57
    ret *= m;
 
58
    return ret;
 
59
}
 
60
 
 
61
/* specific path transformations: Translation: 
 
62
 * This makes it possible to make optimized implementations for Translate transforms */
 
63
inline
 
64
void operator*= (PathVector & path_in, Translate const &m) {
 
65
    for(PathVector::iterator it = path_in.begin(); it != path_in.end(); ++it) {
 
66
        (*it) *= m;
 
67
    }
 
68
}
 
69
inline
 
70
PathVector operator*(PathVector const & path_in, Translate const &m) {
 
71
    PathVector ret(path_in);
 
72
    ret *= m;
 
73
    return ret;
 
74
}
 
75
 
 
76
/* user friendly approach to Translate transforms: just add an offset Point to the whole path */
 
77
inline
 
78
void operator+=(PathVector &path_in, Point const &p) {
 
79
    for(PathVector::iterator it = path_in.begin(); it != path_in.end(); ++it) {
 
80
        (*it) *= Translate(p);
 
81
    }
 
82
}
 
83
inline
 
84
PathVector operator+(PathVector const &path_in, Point const &p) {
 
85
    PathVector ret(path_in);
 
86
    ret *= Translate(p);
 
87
    return ret;
 
88
}
 
89
 
 
90
inline
 
91
Geom::Point initialPoint(PathVector const &path_in)
 
92
{
 
93
    return path_in.front().initialPoint();
 
94
}
 
95
 
 
96
inline
 
97
Geom::Point finalPoint(PathVector const &path_in)
 
98
{
 
99
    return path_in.back().finalPoint();
 
100
}
 
101
 
 
102
PathVector reverse_paths_and_order (PathVector const & path_in);
 
103
 
 
104
OptRect bounds_fast( PathVector const & pv );
 
105
OptRect bounds_exact( PathVector const & pv );
 
106
 
 
107
struct PathVectorPosition {
 
108
    // pathvector[path_nr].pointAt(t) is the position
 
109
    unsigned int path_nr;
 
110
    double       t;
 
111
    PathVectorPosition() {}
 
112
    PathVectorPosition(unsigned int path_nr,
 
113
                       double       t) : path_nr(path_nr), t(t) {}
 
114
};
 
115
boost::optional<PathVectorPosition> nearestPoint(PathVector const & path_in, Point const& _point, double *distance_squared = NULL);
 
116
 
 
117
std::vector<PathVectorPosition> allNearestPoints(PathVector const & path_in, Point const& _point, double *distance_squared = NULL);
 
118
 
 
119
inline
 
120
Point pointAt(PathVector const & path_in, PathVectorPosition const pvp) {
 
121
    return path_in[pvp.path_nr].pointAt(pvp.t);
 
122
}
 
123
 
 
124
 
 
125
 
 
126
} // end namespace Geom
 
127
 
 
128
#endif // SEEN_GEOM_PATHVECTOR_H
 
129
 
 
130
/*
 
131
  Local Variables:
 
132
  mode:c++
 
133
  c-file-style:"stroustrup"
 
134
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
135
  indent-tabs-mode:nil
 
136
  fill-column:99
 
137
  End:
 
138
*/
 
139
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :