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_B3DPOLYPOLYGON_HXX
25 #define _BGFX_POLYGON_B3DPOLYPOLYGON_HXX
26 
27 #include <sal/types.h>
28 #include <o3tl/cow_wrapper.hxx>
29 
30 // predeclarations
31 class ImplB3DPolyPolygon;
32 
33 namespace basegfx
34 {
35 	class B3DPolygon;
36 	class B3DHomMatrix;
37 	class B2DHomMatrix;
38 } // end of namespace basegfx
39 
40 //////////////////////////////////////////////////////////////////////////////
41 
42 namespace basegfx
43 {
44 	class B3DPolyPolygon
45 	{
46     public:
47         typedef o3tl::cow_wrapper< ImplB3DPolyPolygon > ImplType;
48 
49 	private:
50         ImplType                                        mpPolyPolygon;
51 
52 	public:
53 		B3DPolyPolygon();
54 		B3DPolyPolygon(const B3DPolyPolygon& rPolyPolygon);
55 		explicit B3DPolyPolygon(const B3DPolygon& rPolygon);
56 		~B3DPolyPolygon();
57 
58 		// assignment operator
59 		B3DPolyPolygon& operator=(const B3DPolyPolygon& 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 B3DPolyPolygon& rPolyPolygon) const;
66 		bool operator!=(const B3DPolyPolygon& rPolyPolygon) const;
67 
68 		// polygon interface
69 		sal_uInt32 count() const;
70 
71 		// B3DPolygon interface
72 		B3DPolygon getB3DPolygon(sal_uInt32 nIndex) const;
73 		void setB3DPolygon(sal_uInt32 nIndex, const B3DPolygon& rPolygon);
74 
75 		// BColor interface
76 		bool areBColorsUsed() const;
77 		void clearBColors();
78 
79 		// Normals interface
80 		void transformNormals(const B3DHomMatrix& rMatrix);
81 		bool areNormalsUsed() const;
82 		void clearNormals();
83 
84 		// TextureCoordinate interface
85 		void transformTextureCoordiantes(const B2DHomMatrix& rMatrix);
86 		bool areTextureCoordinatesUsed() const;
87 		void clearTextureCoordinates();
88 
89 		// insert/append single polygon
90 		void insert(sal_uInt32 nIndex, const B3DPolygon& rPolygon, sal_uInt32 nCount = 1);
91 		void append(const B3DPolygon& rPolygon, sal_uInt32 nCount = 1);
92 
93 		// insert/append multiple polygons
94 		void insert(sal_uInt32 nIndex, const B3DPolyPolygon& rPolyPolygon);
95 		void append(const B3DPolyPolygon& rPolyPolygon);
96 
97 		// remove
98 		void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1);
99 
100 		// reset to empty state
101 		void clear();
102 
103 		// closed state
104 		bool isClosed() const;
105 		void setClosed(bool bNew);
106 
107 		// flip polygon direction
108 		void flip();
109 
110 		// test if PolyPolygon has double points
111 		bool hasDoublePoints() const;
112 
113 		// remove double points, at the begin/end and follow-ups, too
114 		void removeDoublePoints();
115 
116 		// apply transformation given in matrix form to the polygon
117 		void transform(const basegfx::B3DHomMatrix& rMatrix);
118 	};
119 } // end of namespace basegfx
120 
121 #endif /* _BGFX_POLYGON_B3DPOLYPOLYGON_HXX */
122