1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _BGFX_POLYGON_B3DPOLYGON_HXX 29 #define _BGFX_POLYGON_B3DPOLYGON_HXX 30 31 #include <sal/types.h> 32 #include <o3tl/cow_wrapper.hxx> 33 34 ////////////////////////////////////////////////////////////////////////////// 35 // predeclarations 36 class ImplB3DPolygon; 37 38 namespace basegfx 39 { 40 class B3DPolygon; 41 class B3DPoint; 42 class B3DHomMatrix; 43 class B3DVector; 44 class B2DPoint; 45 class B2DHomMatrix; 46 class BColor; 47 } // end of namespace basegfx 48 49 ////////////////////////////////////////////////////////////////////////////// 50 51 namespace basegfx 52 { 53 class B3DPolygon 54 { 55 public: 56 typedef o3tl::cow_wrapper< ImplB3DPolygon > ImplType; 57 58 private: 59 // internal data. 60 ImplType mpPolygon; 61 62 public: 63 B3DPolygon(); 64 B3DPolygon(const B3DPolygon& rPolygon); 65 B3DPolygon(const B3DPolygon& rPolygon, sal_uInt32 nIndex, sal_uInt32 nCount); 66 ~B3DPolygon(); 67 68 // assignment operator 69 B3DPolygon& operator=(const B3DPolygon& rPolygon); 70 71 /// unshare this polygon with all internally shared instances 72 void makeUnique(); 73 74 // compare operators 75 bool operator==(const B3DPolygon& rPolygon) const; 76 bool operator!=(const B3DPolygon& rPolygon) const; 77 78 // member count 79 sal_uInt32 count() const; 80 81 // Coordinate interface 82 B3DPoint getB3DPoint(sal_uInt32 nIndex) const; 83 void setB3DPoint(sal_uInt32 nIndex, const B3DPoint& rValue); 84 85 // Coordinate insert/append 86 void insert(sal_uInt32 nIndex, const B3DPoint& rPoint, sal_uInt32 nCount = 1); 87 void append(const B3DPoint& rPoint, sal_uInt32 nCount = 1); 88 89 // BColor interface 90 BColor getBColor(sal_uInt32 nIndex) const; 91 void setBColor(sal_uInt32 nIndex, const BColor& rValue); 92 bool areBColorsUsed() const; 93 void clearBColors(); 94 95 // Normals interface 96 B3DVector getNormal() const; // plane normal 97 B3DVector getNormal(sal_uInt32 nIndex) const; // normal in each point 98 void setNormal(sal_uInt32 nIndex, const B3DVector& rValue); 99 void transformNormals(const B3DHomMatrix& rMatrix); 100 bool areNormalsUsed() const; 101 void clearNormals(); 102 103 // TextureCoordinate interface 104 B2DPoint getTextureCoordinate(sal_uInt32 nIndex) const; 105 void setTextureCoordinate(sal_uInt32 nIndex, const B2DPoint& rValue); 106 void transformTextureCoordiantes(const B2DHomMatrix& rMatrix); 107 bool areTextureCoordinatesUsed() const; 108 void clearTextureCoordinates(); 109 110 // insert/append other 2D polygons 111 void insert(sal_uInt32 nIndex, const B3DPolygon& rPoly, sal_uInt32 nIndex2 = 0, sal_uInt32 nCount = 0); 112 void append(const B3DPolygon& rPoly, sal_uInt32 nIndex = 0, sal_uInt32 nCount = 0); 113 114 // remove 115 void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); 116 117 // clear all points 118 void clear(); 119 120 // closed state 121 bool isClosed() const; 122 void setClosed(bool bNew); 123 124 // flip polygon direction 125 void flip(); 126 127 // test if Polygon has double points 128 bool hasDoublePoints() const; 129 130 // remove double points, at the begin/end and follow-ups, too 131 void removeDoublePoints(); 132 133 // apply transformation given in matrix form to the polygon 134 void transform(const B3DHomMatrix& rMatrix); 135 }; 136 } // end of namespace basegfx 137 138 ////////////////////////////////////////////////////////////////////////////// 139 140 141 #endif /* _BGFX_POLYGON_B3DPOLYGON_HXX */ 142