xref: /AOO41X/main/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx (revision ddde725d65c83fe3ba1186d46f6e3e08f12ba47e)
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_POLYGON_B2DPOLYPOLYGON_HXX
25 #define _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
26 
27 #include <sal/types.h>
28 #include <o3tl/cow_wrapper.hxx>
29 #include <basegfx/range/b2drange.hxx>
30 
31 // predeclarations
32 class ImplB2DPolyPolygon;
33 
34 namespace basegfx
35 {
36     class B2DPolygon;
37     class B2DHomMatrix;
38 } // end of namespace basegfx
39 
40 //////////////////////////////////////////////////////////////////////////////
41 
42 namespace basegfx
43 {
44     class B2DPolyPolygon
45     {
46     public:
47         typedef o3tl::cow_wrapper< ImplB2DPolyPolygon > ImplType;
48 
49     private:
50         ImplType                                        mpPolyPolygon;
51 
52     public:
53         B2DPolyPolygon();
54         B2DPolyPolygon(const B2DPolyPolygon& rPolyPolygon);
55         explicit B2DPolyPolygon(const B2DPolygon& rPolygon);
56         ~B2DPolyPolygon();
57 
58         // assignment operator
59         B2DPolyPolygon& operator=(const B2DPolyPolygon& rPolyPolygon);
60 
61         /// unshare this poly-polygon (and all included polygons) with all internally shared instances
62         void makeUnique();
63 
64         // compare operators
65         bool operator==(const B2DPolyPolygon& rPolyPolygon) const;
66         bool operator!=(const B2DPolyPolygon& rPolyPolygon) const;
67 
68         // polygon interface
69         sal_uInt32 count() const;
70 
71         B2DPolygon getB2DPolygon(sal_uInt32 nIndex) const;
72         void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon);
73 
74         // test for curve
75         bool areControlPointsUsed() const;
76 
77         // insert/append single polygon
78         void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
79         void append(const B2DPolygon& rPolygon, sal_uInt32 nCount = 1);
80 
81         /** Default adaptive subdivision access
82 
83             For details refer to B2DPolygon::getDefaultAdaptiveSubdivision()
84 
85             @return
86             The default subdivision of this polygon
87         */
88         B2DPolyPolygon getDefaultAdaptiveSubdivision() const;
89 
90         /** Get the B2DRange (Rectangle dimensions) of this B2DPolyPolygon
91 
92             For details refer to B2DPolygon::getB2DRange()
93 
94             @return
95             The outer range of the bezier curve/polygon
96         */
97         B2DRange getB2DRange() const;
98 
99         // insert/append multiple polygons
100         void insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon);
101         void append(const B2DPolyPolygon& rPolyPolygon);
102 
103         // remove
104         void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1);
105 
106         // reset to empty state
107         void clear();
108 
109         // closed state
110         bool isClosed() const;
111         void setClosed(bool bNew);
112 
113         // flip polygon direction
114         void flip();
115 
116         // test if PolyPolygon has double points
117         bool hasDoublePoints() const;
118 
119         // remove double points, at the begin/end and follow-ups, too
120         void removeDoublePoints();
121 
122         // apply transformation given in matrix form to the polygon
123         void transform(const basegfx::B2DHomMatrix& rMatrix);
124 
125         // polygon iterators (same iterator validity conditions as for vector)
126         const B2DPolygon* begin() const;
127         const B2DPolygon* end() const;
128         B2DPolygon* begin();
129         B2DPolygon* end();
130     };
131 
132     // typedef for a vector of B2DPolyPolygons
133     typedef ::std::vector< B2DPolyPolygon > B2DPolyPolygonVector;
134 
135 } // end of namespace basegfx
136 
137 #endif /* _BGFX_POLYGON_B2DPOLYPOLYGON_HXX */
138