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