1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bezierclip.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef BASEGFX_BEZIERCLIP_HXX
32 #define BASEGFX_BEZIERCLIP_HXX
38 typedef double value_type
;
39 Point2D( double _x
, double _y
) : x(_x
), y(_y
) {}
40 Point2D() : x(), y() {}
52 Point2D
& operator[]( int i
) { return reinterpret_cast<Point2D
*>(this)[i
]; }
53 const Point2D
& operator[]( int i
) const { return reinterpret_cast<const Point2D
*>(this)[i
]; }
58 // line L through p1 and p4 in normalized implicit form
63 // the upper and lower distance from this line
68 template <typename DataType
> DataType
calcLineDistance( const DataType
& a
,
77 typedef ::std::vector
< Point2D
> Polygon2D
;
79 /* little abs template */
80 template <typename NumType
> NumType
absval( NumType x
)
85 Polygon2D
convexHull( const Polygon2D
& rPoly
);
87 // TODO: find proper epsilon here (try ::std::numeric_limits<NumType>::epsilon()?)!
88 #define DBL_EPSILON 1.0e-100
90 /* little approximate comparions */
91 template <typename NumType
> bool tolZero( NumType n
) { return fabs(n
) < DBL_EPSILON
; }
92 template <typename NumType
> bool tolEqual( NumType n1
, NumType n2
) { return tolZero(n1
-n2
); }
93 template <typename NumType
> bool tolLessEqual( NumType n1
, NumType n2
) { return tolEqual(n1
,n2
) || n1
<n2
; }
94 template <typename NumType
> bool tolGreaterEqual( NumType n1
, NumType n2
) { return tolEqual(n1
,n2
) || n1
>n2
; }
96 #endif /* BASEGFX_BEZIERCLIP_HXX */