fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / basegfx / polygon / b3dpolygontools.hxx
blob9ed32b42fb901312596179ff4445bf0909d835f2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX
21 #define _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX
23 #include <basegfx/point/b3dpoint.hxx>
24 #include <basegfx/vector/b3dvector.hxx>
25 #include <basegfx/polygon/b3dpolypolygon.hxx>
26 #include <basegfx/vector/b2enums.hxx>
27 #include <vector>
28 #include <basegfx/basegfxdllapi.h>
30 //////////////////////////////////////////////////////////////////////////////
32 namespace basegfx
34 // predefinitions
35 class B3DPolygon;
36 class B3DRange;
38 namespace tools
40 // B3DPolygon tools
42 /** Check if given polygon is closed. This is kind of a
43 'classic' method to support old polygon definitions.
44 Those old polygon definitions define the closed state
45 of the polygon using identical start and endpoints. This
46 method corrects this (removes double start/end points)
47 and sets the Closed()-state of the polygon correctly.
49 BASEGFX_DLLPUBLIC void checkClosed(B3DPolygon& rCandidate);
51 // Get successor and predecessor indices. Returning the same index means there
52 // is none. Same for successor.
53 BASEGFX_DLLPUBLIC sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const B3DPolygon& rCandidate);
55 // get size of polygon. Control vectors are included in that ranges.
56 BASEGFX_DLLPUBLIC B3DRange getRange(const B3DPolygon& rCandidate);
58 // get normal vector of polygon
59 BASEGFX_DLLPUBLIC B3DVector getNormal(const B3DPolygon& rCandidate);
61 // get area of polygon
62 BASEGFX_DLLPUBLIC double getArea(const ::basegfx::B3DPolygon& rCandidate);
64 // get length of polygon
65 BASEGFX_DLLPUBLIC double getLength(const B3DPolygon& rCandidate);
67 /** Apply given LineDashing to given polygon
69 For a description see applyLineDashing in b2dpolygontoos.hxx
71 BASEGFX_DLLPUBLIC void applyLineDashing(
72 const B3DPolygon& rCandidate,
73 const ::std::vector<double>& rDotDashArray,
74 B3DPolyPolygon* pLineTarget,
75 B3DPolyPolygon* pGapTarget = 0,
76 double fFullDashDotLen = 0.0);
78 /** Create/replace normals for given 3d geometry with default normals from given center to outside.
79 rCandidate: the 3d geometry to change
80 rCenter: the center of the 3d geometry
82 BASEGFX_DLLPUBLIC B3DPolygon applyDefaultNormalsSphere( const B3DPolygon& rCandidate, const B3DPoint& rCenter);
84 /** invert normals for given 3d geometry.
86 BASEGFX_DLLPUBLIC B3DPolygon invertNormals( const B3DPolygon& rCandidate);
88 /** Create/replace texture coordinates for given 3d geometry with parallel projected one
89 rRange: the full range of the 3d geometry
90 If bChangeX, x texture coordinate will be recalculated.
91 If bChangeY, y texture coordinate will be recalculated.
93 BASEGFX_DLLPUBLIC B3DPolygon applyDefaultTextureCoordinatesParallel( const B3DPolygon& rCandidate, const B3DRange& rRange, bool bChangeX = true, bool bChangeY = true);
95 /** Create/replace texture coordinates for given 3d geometry with spherical one
96 rCenter: the centre of the used 3d geometry
97 If bChangeX, x texture coordinate will be recalculated.
98 If bChangeY, y texture coordinate will be recalculated.
100 BASEGFX_DLLPUBLIC B3DPolygon applyDefaultTextureCoordinatesSphere( const B3DPolygon& rCandidate, const B3DPoint& rCenter, bool bChangeX = true, bool bChangeY = true);
102 // isInside tests for B3DPoint. On border is not inside as long as not true is given in bWithBorder flag.
103 BASEGFX_DLLPUBLIC bool isInside(const B3DPolygon& rCandidate, const B3DPoint& rPoint, bool bWithBorder = false);
105 // calculates if given point is on given line, taking care of the numerical epsilon
106 BASEGFX_DLLPUBLIC bool isPointOnLine(const B3DPoint& rStart, const B3DPoint& rEnd, const B3DPoint& rCandidate, bool bWithPoints = false);
108 // calculates if given point is on given polygon, taking care of the numerical epsilon. Uses
109 // isPointOnLine internally
110 BASEGFX_DLLPUBLIC bool isPointOnPolygon(const B3DPolygon& rCandidate, const B3DPoint& rPoint, bool bWithPoints = true);
112 // helper to get a fCut position between a plane (given with normal and a point)
113 // and a line given by start and end point
114 BASEGFX_DLLPUBLIC bool getCutBetweenLineAndPlane(const B3DVector& rPlaneNormal, const B3DPoint& rPlanePoint, const B3DPoint& rEdgeStart, const B3DPoint& rEdgeEnd, double& fCut);
116 /** snap some polygon coordinates to discrete coordinates
118 This method allows to snap some polygon points to discrete (integer) values
119 which equals e.g. a snap to discrete coordinates. It will snap points of
120 horizontal and vertical edges
122 @param rCandidate
123 The source polygon
125 @return
126 The modified version of the source polygon
128 BASEGFX_DLLPUBLIC B3DPolygon snapPointsOfHorizontalOrVerticalEdges(const B3DPolygon& rCandidate);
130 } // end of namespace tools
131 } // end of namespace basegfx
133 #endif /* _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX */
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */