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_B3DPOLYGON_HXX
25 #define _BGFX_POLYGON_B3DPOLYGON_HXX
26 
27 #include <sal/types.h>
28 #include <o3tl/cow_wrapper.hxx>
29 #include <basegfx/basegfxdllapi.h>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 // predeclarations
33 class ImplB3DPolygon;
34 
35 namespace basegfx
36 {
37 	class B3DPolygon;
38 	class B3DPoint;
39 	class B3DHomMatrix;
40 	class B3DVector;
41 	class B2DPoint;
42 	class B2DHomMatrix;
43 	class BColor;
44 } // end of namespace basegfx
45 
46 //////////////////////////////////////////////////////////////////////////////
47 
48 namespace basegfx
49 {
50 	class BASEGFX_DLLPUBLIC B3DPolygon
51 	{
52     public:
53         typedef o3tl::cow_wrapper< ImplB3DPolygon > ImplType;
54 
55 	private:
56 		// internal data.
57         ImplType                                    mpPolygon;
58 
59 	public:
60 		B3DPolygon();
61 		B3DPolygon(const B3DPolygon& rPolygon);
62 		B3DPolygon(const B3DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount);
63 		~B3DPolygon();
64 
65 		// assignment operator
66 		B3DPolygon& operator=(const B3DPolygon& rPolygon);
67 
68         /// unshare this polygon with all internally shared instances
69         void makeUnique();
70 
71 		// compare operators
72 		bool operator==(const B3DPolygon& rPolygon) const;
73 		bool operator!=(const B3DPolygon& rPolygon) const;
74 
75 		// member count
76 		sal_uInt32 count() const;
77 
78 		// Coordinate interface
79 		B3DPoint getB3DPoint(sal_uInt32 nIndex) const;
80 		void setB3DPoint(sal_uInt32 nIndex, const B3DPoint& rValue);
81 
82 		// Coordinate insert/append
83 		void insert(sal_uInt32 nIndex, const B3DPoint& rPoint, sal_uInt32 nCount = 1);
84 		void append(const B3DPoint& rPoint, sal_uInt32 nCount = 1);
85 
86 		// BColor interface
87 		BColor getBColor(sal_uInt32 nIndex) const;
88 		void setBColor(sal_uInt32 nIndex, const BColor& rValue);
89 		bool areBColorsUsed() const;
90 		void clearBColors();
91 
92 		// Normals interface
93 		B3DVector getNormal() const; // plane normal
94 		B3DVector getNormal(sal_uInt32 nIndex) const; // normal in each point
95 		void setNormal(sal_uInt32 nIndex, const B3DVector& rValue);
96 		void transformNormals(const B3DHomMatrix& rMatrix);
97 		bool areNormalsUsed() const;
98 		void clearNormals();
99 
100 		// TextureCoordinate interface
101 		B2DPoint getTextureCoordinate(sal_uInt32 nIndex) const;
102 		void setTextureCoordinate(sal_uInt32 nIndex, const B2DPoint& rValue);
103 		void transformTextureCoordiantes(const B2DHomMatrix& rMatrix);
104 		bool areTextureCoordinatesUsed() const;
105 		void clearTextureCoordinates();
106 
107 		// insert/append other 2D polygons
108 		void insert(sal_uInt32 nIndex, const B3DPolygon& rPoly, sal_uInt32 nIndex2 = 0, sal_uInt32 nCount = 0);
109 		void append(const B3DPolygon& rPoly, sal_uInt32 nIndex = 0, sal_uInt32 nCount = 0);
110 
111 		// remove
112 		void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1);
113 
114 		// clear all points
115 		void clear();
116 
117 		// closed state
118 		bool isClosed() const;
119 		void setClosed(bool bNew);
120 
121 		// flip polygon direction
122 		void flip();
123 
124 		// test if Polygon has double points
125 		bool hasDoublePoints() const;
126 
127 		// remove double points, at the begin/end and follow-ups, too
128 		void removeDoublePoints();
129 
130 		// apply transformation given in matrix form to the polygon
131 		void transform(const B3DHomMatrix& rMatrix);
132 	};
133 } // end of namespace basegfx
134 
135 //////////////////////////////////////////////////////////////////////////////
136 
137 
138 #endif /* _BGFX_POLYGON_B3DPOLYGON_HXX */
139