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 _BGFX_POLYPOLYGON_B2DPOLYGONCLIPPER_HXX
25 #define _BGFX_POLYPOLYGON_B2DPOLYGONCLIPPER_HXX
26 
27 #include <basegfx/polygon/b2dpolypolygon.hxx>
28 #include <basegfx/polygon/b2dpolygon.hxx>
29 #include <basegfx/basegfxdllapi.h>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 
33 namespace basegfx
34 {
35 	// predefinitions
36 	class B2DRange;
37 
38 	namespace tools
39 	{
40 		// This method clips the given PolyPolygon against a horizontal or vertical axis (parallel to X or Y axis). The axis is
41 		// defined by bParallelToXAxis (true -> it's parallel to the X-Axis of the coordinate system, else to the Y-Axis) and the
42 		// fValueOnOtherAxis (gives the translation to the coordinate system axis). For example, when You want to define
43 		// a clip axis parallel to X.Axis and 100 above it, use bParallelToXAxis = true and fValueOnOtherAxis = 100.
44 		// The value bAboveAxis defines on which side the return value will be (true -> above X, right of Y).
45 		// The switch bStroke decides if the polygon is interpreted as area (false) or strokes (true).
46 		BASEGFX_DLLPUBLIC B2DPolyPolygon clipPolyPolygonOnParallelAxis(const B2DPolyPolygon& rCandidate, bool bParallelToXAxis, bool bAboveAxis, double fValueOnOtherAxis, bool bStroke);
47 		BASEGFX_DLLPUBLIC B2DPolyPolygon clipPolygonOnParallelAxis(const B2DPolygon& rCandidate, bool bParallelToXAxis, bool bAboveAxis, double fValueOnOtherAxis, bool bStroke);
48 
49 		// Clip the given PolyPolygon against the given range. bInside defines if the result will contain the
50 		// parts which are contained in the range or vice versa.
51 		// The switch bStroke decides if the polygon is interpreted as area (false) or strokes (true).
52 		BASEGFX_DLLPUBLIC B2DPolyPolygon clipPolyPolygonOnRange(const B2DPolyPolygon& rCandidate, const B2DRange& rRange, bool bInside, bool bStroke);
53 		BASEGFX_DLLPUBLIC B2DPolyPolygon clipPolygonOnRange(const B2DPolygon& rCandidate, const B2DRange& rRange, bool bInside, bool bStroke);
54 
55 		// Clip given PolyPolygon against the endless edge (ray) defined by the given two points. bAbove defines on which side
56 		// of the edge the result will be together with the definition of the edge. If the edge is seen as a vector
57 		// from A to B and bAbove is true, the result will contain the geometry left of the vector.
58 		// The switch bStroke decides if the polygon is interpreted as area (false) or strokes (true).
59 		BASEGFX_DLLPUBLIC B2DPolyPolygon clipPolyPolygonOnEdge(const B2DPolyPolygon& rCandidate, const B2DPoint& rPointA, const B2DPoint& rPointB, bool bAbove, bool bStroke);
60 		BASEGFX_DLLPUBLIC B2DPolyPolygon clipPolygonOnEdge(const B2DPolygon& rCandidate, const B2DPoint& rPointA, const B2DPoint& rPointB, bool bAbove, bool bStroke);
61 
62 		// Clip given PolyPolygon against given clipping polygon.
63 		// The switch bStroke decides if the polygon is interpreted as area (false) or strokes (true).
64 		// With stroke polygons, You get all line snippets inside rCip.
65 		// With filled polygons, You get all PolyPolygon parts which were inside rClip.
66 		// The switch bInside decides if the parts inside the clip polygon or outside shall be created.
67         // The clip polygon is always assumed closed, even when it's isClosed() is false.
68 		BASEGFX_DLLPUBLIC B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon& rCandidate, const B2DPolyPolygon& rClip, bool bInside, bool bStroke);
69 		BASEGFX_DLLPUBLIC B2DPolyPolygon clipPolygonOnPolyPolygon(const B2DPolygon& rCandidate, const B2DPolyPolygon& rClip, bool bInside, bool bStroke);
70 
71 		// clip the given polygon against the given range. the resulting polygon will always contain
72 		// the inside parts which will always be interpreted as areas. the incoming polygon is expected
73 		// to be a simple triangle list. the result is also a simple triangle list.
74 		BASEGFX_DLLPUBLIC B2DPolygon clipTriangleListOnRange( const B2DPolygon& rCandidate, const B2DRange& rRange );
75 
76 	} // end of namespace tools
77 } // end of namespace basegfx
78 
79 #endif /* _BGFX_POLYPOLYGON_B2DPOLYGONCLIPPER_HXX */
80