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_B2DLINEGEOMETRY_HXX 29 #define _BGFX_POLYGON_B2DLINEGEOMETRY_HXX 30 31 #include <sal/types.h> 32 #include <basegfx/numeric/ftools.hxx> 33 #include <basegfx/polygon/b2dpolypolygon.hxx> 34 #include <basegfx/polygon/b2dpolygon.hxx> 35 36 ////////////////////////////////////////////////////////////////////////////// 37 38 namespace basegfx 39 { 40 namespace tools 41 { 42 /** Create line start/end geometry element, mostly arrows and things like that. 43 44 @param rCandidate 45 The polygon which needs to get that line ends and needs to have two points 46 at least. 47 48 @param rArrow 49 The line start/end geometry. It is assumed that the tip is pointing 50 upwards. Result will be rotated and scaled to fit. 51 52 @param bStart 53 describes if creation is for start or end of candidate. 54 55 @param fWidth 56 defines the size of the element, it's describing the target width in X 57 of the arrow. 58 59 @param fDockingPosition needs to be in [0.0 ..1.0] range, where 0.0 means 60 that the tip of the arrow will be aligned with the polygon start, 1.0 means 61 the bottom. The default of 0.5 describes a centered arrow. 62 63 @param pConsumedLength 64 Using this parameter it is possible to get back how much from the candidate 65 geometry is overlapped by the created element (consumed). 66 67 @param fCandidateLength 68 This should contain the length of rCandidate to allow work without 69 again calculating the length (which may be expensive with beziers). If 0.0 is 70 given, the length is calculated on demand. 71 72 @return 73 The Line start and end polygon, correctly rotated and scaled 74 */ 75 B2DPolyPolygon createAreaGeometryForLineStartEnd( 76 const B2DPolygon& rCandidate, 77 const B2DPolyPolygon& rArrow, 78 bool bStart, 79 double fWidth, 80 double fCandidateLength = 0.0, // 0.0 -> calculate self 81 double fDockingPosition = 0.5, // 0->top, 1->bottom 82 double* pConsumedLength = 0L); 83 84 /** create filled polygon geometry for lines with a line width 85 86 This method will create bezier based, fillable polygons which 87 will resample the curve if it was extended for the given half 88 line width. It will remove extrema positions from contained 89 bezier segments and get as close as possible and defined by 90 the given parameters to the ideal result. 91 92 It will check edges for trivial bezier to avoid unnecessary 93 bezier polygons. Care is taken to produce the in-between 94 polygon points (the ones original on the source poygon) since 95 it has showed that without those, the raster converters leave 96 non-filled gaps. 97 98 @param rCandidate 99 The source polygon defining the hairline polygon path 100 101 @param fHalfLineWidth 102 The width of the line to one side 103 104 @param eJoin 105 The LineJoin if the edges meeting in a point do not have a C1 106 or C2 continuity 107 108 @param fMaxAllowedAngle 109 Allows to hand over the maximum allowed angle between an edge and 110 it's control vectors. The smaller, the more subdivisions will be 111 needed to create the filled geometry. Allowed range is cropped to 112 [F_PI2 .. 0.01 * F_PI2]. 113 114 @param fMaxPartOfEdge 115 Allows to influence from with relative length of a control vector 116 compared to it's edge a split is forced. The smaller, the more 117 subdivisions will be needed to create the filled geometry. Allowed 118 range is cropped to [1.0 .. 0.01] 119 120 @praram fMiterMinimumAngle 121 The minimum wanted angle between two edges when edge rounding 122 is using miter. When an edge is smaller than this (tighter) 123 the usual fallback to bevel is used. Allowed range is cropped 124 to [F_PI .. 0.01 * F_PI]. 125 126 @return 127 The PolyPolygon containing the geometry of the extended line by 128 it's line width. Contains bezier segments and edge roundings as 129 needed and defined. 130 */ 131 B2DPolyPolygon createAreaGeometry( 132 const B2DPolygon& rCandidate, 133 double fHalfLineWidth, 134 B2DLineJoin eJoin = B2DLINEJOIN_ROUND, 135 double fMaxAllowedAngle = (12.5 * F_PI180), 136 double fMaxPartOfEdge = 0.4, 137 double fMiterMinimumAngle = (15.0 * F_PI180)); 138 } // end of namespace tools 139 } // end of namespace basegfx 140 141 ////////////////////////////////////////////////////////////////////////////// 142 143 #endif /* _BGFX_POLYGON_B2DLINEGEOMETRY_HXX */ 144 // eof 145