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