xref: /trunk/main/chart2/source/view/inc/Clipping.hxx (revision de7b3f82)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CHART2_CLIPPING_HXX
25 #define _CHART2_CLIPPING_HXX
26 
27 #include <basegfx/range/b2drectangle.hxx>
28 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
29 
30 //.............................................................................
31 namespace chart
32 {
33 //.............................................................................
34 
35 //-----------------------------------------------------------------------------
36 /**
37 */
38 
39 class Clipping
40 {
41     /** This class uses the Liang-Biarsky parametric line-clipping algorithm as described in:
42 			Computer Graphics: principles and practice, 2nd ed.,
43 			James D. Foley et al.,
44 			Section 3.12.4 on page 117.
45     */
46 
47 public:
48     /**	@descr	The intersection between an open polygon and a rectangle is
49 			calculated and the resulting lines are placed into the poly-polygon aResult.
50 		@param	rPolygon	The polygon is required to be open, ie. it's start and end point
51 			have different coordinates and that it is continuous, ie. has no holes.
52 		@param	rRectangle	The clipping area.
53 		@param	aResult	The resulting lines that are the parts of the given polygon lying inside
54 			the clipping area are stored into aResult whose prior content is deleted first.
55 	 */
56     static void clipPolygonAtRectangle(
57                                 const ::com::sun::star::drawing::PolyPolygonShape3D& rPolygon
58                                 , const ::basegfx::B2DRectangle& rRectangle
59                                 , ::com::sun::star::drawing::PolyPolygonShape3D& aResult
60                                 , bool bSplitPiecesToDifferentPolygons = true );
61 };
62 
63 //.............................................................................
64 } //namespace chart
65 //.............................................................................
66 #endif
67