40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * \brief Template concepts used by 2Geom
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Copyright 2007 Michael Sloan <mgsloan@gmail.com>
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * This library is free software; you can redistribute it and/or
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * modify it either under the terms of the GNU Lesser General Public
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * License version 2.1 as published by the Free Software Foundation
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * (the "LGPL") or, at your option, under the terms of the Mozilla
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Public License Version 1.1 (the "MPL"). If you do not alter this
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * notice, a recipient may use your version of this file under either
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * the MPL or the LGPL.
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * You should have received a copy of the LGPL along with this library
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * in the file COPYING-LGPL-2.1; if not, output to the Free Software
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * You should have received a copy of the MPL along with this library
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * in the file COPYING-MPL-1.1
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * The contents of this file are subject to the Mozilla Public License
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Version 1.1 (the "License"); you may not use this file except in
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * compliance with the License. You may obtain a copy of the License at
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * OF ANY KIND, either express or implied. See the LGPL or the MPL for
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * the specific language governing rights and limitations.
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen//forward decls
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen//A concept for one-dimensional functions defined on [0,1]
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen typedef typename ResultTraits<OutputType>::bounds_type BoundsType;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen typedef typename ResultTraits<OutputType>::sb_type SbType;
e4369b05aaa20df73a37f4d319ce456865cc74f3Krzysztof Kosiński //Is a pure derivative (ignoring others) accessor ever much faster?
e4369b05aaa20df73a37f4d319ce456865cc74f3Krzysztof Kosiński //u = number of values returned. first val is value.
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen /*With portion, Interval makes some sense, but instead I'm opting for
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen doubles, for the following reasons:
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen A) This way a reversed portion may be specified
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen B) Performance might be a bit better for piecewise and such
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen C) Interval version provided below
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen t = portion(t, d, d);
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński typedef typename ShapeTraits<T>::TimeType Time;
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński typedef typename ShapeTraits<T>::IntervalType Interval;
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński typedef typename ShapeTraits<T>::AffineClosureType AffineClosure;
e4369b05aaa20df73a37f4d319ce456865cc74f3Krzysztof Kosiński typedef typename ShapeTraits<T>::IntersectionType Isect;
e4369b05aaa20df73a37f4d319ce456865cc74f3Krzysztof Kosiński //bool_ = are_near(shape, other, c);
981b809bc6ed10a21e89444d9447e5475801874fjohanengeleninline T portion(const T& t, const Interval& i) { return portion(t, i.min(), i.max()); }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen t = t + d; t += d;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen t = t - d; t -= d;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen t = t * d; t *= d;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen t = t / d; t /= d;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen i += j; i = i + j;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen i -= j; i = i - j;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen i *= j; i = i * j;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński} // end namespace Geom
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#endif // LIB2GEOM_SEEN_CONCEPTS_H
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen Local Variables:
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen c-file-style:"stroustrup"
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen indent-tabs-mode:nil
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen fill-column:99
a4030d5ca449e7e384bc699cd249ee704faaeab0Chris Morgan// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :