1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_BASEGFX_POLYGON_B3DPOLYGONTOOLS_HXX
21 #define INCLUDED_BASEGFX_POLYGON_B3DPOLYGONTOOLS_HXX
23 #include <basegfx/point/b3dpoint.hxx>
24 #include <basegfx/vector/b3dvector.hxx>
26 #include <basegfx/basegfxdllapi.h>
29 namespace basegfx
{ class B3DPolyPolygon
; }
41 /** Check if given polygon is closed. This is kind of a
42 'classic' method to support old polygon definitions.
43 Those old polygon definitions define the closed state
44 of the polygon using identical start and endpoints. This
45 method corrects this (removes double start/end points)
46 and sets the Closed()-state of the polygon correctly.
48 BASEGFX_DLLPUBLIC
void checkClosed(B3DPolygon
& rCandidate
);
50 // Get successor and predecessor indices. Returning the same index means there
51 // is none. Same for successor.
52 BASEGFX_DLLPUBLIC sal_uInt32
getIndexOfSuccessor(sal_uInt32 nIndex
, const B3DPolygon
& rCandidate
);
54 // get size of polygon. Control vectors are included in that ranges.
55 BASEGFX_DLLPUBLIC B3DRange
getRange(const B3DPolygon
& rCandidate
);
57 // get length of polygon
58 BASEGFX_DLLPUBLIC
double getLength(const B3DPolygon
& rCandidate
);
60 /** Apply given LineDashing to given polygon
62 For a description see applyLineDashing in b2dpolygontoos.hxx
64 BASEGFX_DLLPUBLIC
void applyLineDashing(
65 const B3DPolygon
& rCandidate
,
66 const ::std::vector
<double>& rDotDashArray
,
67 B3DPolyPolygon
* pLineTarget
,
68 double fFullDashDotLen
);
70 /** Create/replace normals for given 3d geometry with default normals from given center to outside.
71 rCandidate: the 3d geometry to change
72 rCenter: the center of the 3d geometry
74 BASEGFX_DLLPUBLIC B3DPolygon
applyDefaultNormalsSphere( const B3DPolygon
& rCandidate
, const B3DPoint
& rCenter
);
76 /** invert normals for given 3d geometry.
78 BASEGFX_DLLPUBLIC B3DPolygon
invertNormals( const B3DPolygon
& rCandidate
);
80 /** Create/replace texture coordinates for given 3d geometry with parallel projected one
81 rRange: the full range of the 3d geometry
82 If bChangeX, x texture coordinate will be recalculated.
83 If bChangeY, y texture coordinate will be recalculated.
85 BASEGFX_DLLPUBLIC B3DPolygon
applyDefaultTextureCoordinatesParallel( const B3DPolygon
& rCandidate
, const B3DRange
& rRange
, bool bChangeX
, bool bChangeY
);
87 /** Create/replace texture coordinates for given 3d geometry with spherical one
88 rCenter: the centre of the used 3d geometry
89 If bChangeX, x texture coordinate will be recalculated.
90 If bChangeY, y texture coordinate will be recalculated.
92 BASEGFX_DLLPUBLIC B3DPolygon
applyDefaultTextureCoordinatesSphere( const B3DPolygon
& rCandidate
, const B3DPoint
& rCenter
, bool bChangeX
, bool bChangeY
);
94 // isInside tests for B3DPoint. On border is not inside as long as not true is given in bWithBorder flag.
95 BASEGFX_DLLPUBLIC
bool isInside(const B3DPolygon
& rCandidate
, const B3DPoint
& rPoint
, bool bWithBorder
);
97 // calculates if given point is on given line, taking care of the numerical epsilon
98 BASEGFX_DLLPUBLIC
bool isPointOnLine(const B3DPoint
& rStart
, const B3DPoint
& rEnd
, const B3DPoint
& rCandidate
, bool bWithPoints
);
100 // calculates if given point is on given polygon, taking care of the numerical epsilon. Uses
101 // isPointOnLine internally
102 BASEGFX_DLLPUBLIC
bool isPointOnPolygon(const B3DPolygon
& rCandidate
, const B3DPoint
& rPoint
);
104 // helper to get a fCut position between a plane (given with normal and a point)
105 // and a line given by start and end point
106 BASEGFX_DLLPUBLIC
bool getCutBetweenLineAndPlane(const B3DVector
& rPlaneNormal
, const B3DPoint
& rPlanePoint
, const B3DPoint
& rEdgeStart
, const B3DPoint
& rEdgeEnd
, double& fCut
);
108 /** snap some polygon coordinates to discrete coordinates
110 This method allows to snap some polygon points to discrete (integer) values
111 which equals e.g. a snap to discrete coordinates. It will snap points of
112 horizontal and vertical edges
118 The modified version of the source polygon
120 BASEGFX_DLLPUBLIC B3DPolygon
snapPointsOfHorizontalOrVerticalEdges(const B3DPolygon
& rCandidate
);
122 } // end of namespace utils
123 } // end of namespace basegfx
125 #endif // INCLUDED_BASEGFX_POLYGON_B3DPOLYGONTOOLS_HXX
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */