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.
8
* Johan Engelen <goejendaagh@zonnet.nl>
10
* Copyright 2008 authors
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.
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
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/
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.
36
#ifndef SEEN_GEOM_PATHVECTOR_H
37
#define SEEN_GEOM_PATHVECTOR_H
39
#include <2geom/forward.h>
40
#include <2geom/path.h>
41
#include <2geom/transforms.h>
45
typedef std::vector<Geom::Path> PathVector;
47
/* general path transformation: */
49
void operator*= (PathVector & path_in, Matrix const &m) {
50
for(PathVector::iterator it = path_in.begin(); it != path_in.end(); ++it) {
55
PathVector operator*(PathVector const & path_in, Matrix const &m) {
56
PathVector ret(path_in);
61
/* specific path transformations: Translation:
62
* This makes it possible to make optimized implementations for Translate transforms */
64
void operator*= (PathVector & path_in, Translate const &m) {
65
for(PathVector::iterator it = path_in.begin(); it != path_in.end(); ++it) {
70
PathVector operator*(PathVector const & path_in, Translate const &m) {
71
PathVector ret(path_in);
76
/* user friendly approach to Translate transforms: just add an offset Point to the whole path */
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);
84
PathVector operator+(PathVector const &path_in, Point const &p) {
85
PathVector ret(path_in);
91
Geom::Point initialPoint(PathVector const &path_in)
93
return path_in.front().initialPoint();
97
Geom::Point finalPoint(PathVector const &path_in)
99
return path_in.back().finalPoint();
102
PathVector reverse_paths_and_order (PathVector const & path_in);
104
OptRect bounds_fast( PathVector const & pv );
105
OptRect bounds_exact( PathVector const & pv );
107
struct PathVectorPosition {
108
// pathvector[path_nr].pointAt(t) is the position
109
unsigned int path_nr;
111
PathVectorPosition() {}
112
PathVectorPosition(unsigned int path_nr,
113
double t) : path_nr(path_nr), t(t) {}
115
boost::optional<PathVectorPosition> nearestPoint(PathVector const & path_in, Point const& _point, double *distance_squared = NULL);
117
std::vector<PathVectorPosition> allNearestPoints(PathVector const & path_in, Point const& _point, double *distance_squared = NULL);
120
Point pointAt(PathVector const & path_in, PathVectorPosition const pvp) {
121
return path_in[pvp.path_nr].pointAt(pvp.t);
126
} // end namespace Geom
128
#endif // SEEN_GEOM_PATHVECTOR_H
133
c-file-style:"stroustrup"
134
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
139
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :