xref: /trunk/main/chart2/source/view/inc/Clipping.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CHART2_CLIPPING_HXX
29 #define _CHART2_CLIPPING_HXX
30 
31 #include <basegfx/range/b2drectangle.hxx>
32 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
33 
34 //.............................................................................
35 namespace chart
36 {
37 //.............................................................................
38 
39 //-----------------------------------------------------------------------------
40 /**
41 */
42 
43 class Clipping
44 {
45     /** This class uses the Liang-Biarsky parametric line-clipping algorithm as described in:
46 			Computer Graphics: principles and practice, 2nd ed.,
47 			James D. Foley et al.,
48 			Section 3.12.4 on page 117.
49     */
50 
51 public:
52     /**	@descr	The intersection between an open polygon and a rectangle is
53 			calculated and the resulting lines are placed into the poly-polygon aResult.
54 		@param	rPolygon	The polygon is required to be open, ie. it's start and end point
55 			have different coordinates and that it is continuous, ie. has no holes.
56 		@param	rRectangle	The clipping area.
57 		@param	aResult	The resulting lines that are the parts of the given polygon lying inside
58 			the clipping area are stored into aResult whose prior content is deleted first.
59 	 */
60     static void clipPolygonAtRectangle(
61                                 const ::com::sun::star::drawing::PolyPolygonShape3D& rPolygon
62                                 , const ::basegfx::B2DRectangle& rRectangle
63                                 , ::com::sun::star::drawing::PolyPolygonShape3D& aResult
64                                 , bool bSplitPiecesToDifferentPolygons = true );
65 };
66 
67 //.............................................................................
68 } //namespace chart
69 //.............................................................................
70 #endif
71