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_B3DPOLYPOLYGONTOOLS_HXX
21 #define INCLUDED_BASEGFX_POLYGON_B3DPOLYPOLYGONTOOLS_HXX
23 #include <basegfx/point/b2dpoint.hxx>
24 #include <basegfx/vector/b2dvector.hxx>
25 #include <basegfx/numeric/ftools.hxx>
26 #include <basegfx/point/b3dpoint.hxx>
27 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
29 #include <basegfx/basegfxdllapi.h>
40 // B3DPolyPolygon tools
42 // get size of PolyPolygon. Control vectors are included in that ranges.
43 BASEGFX_DLLPUBLIC B3DRange
getRange(const B3DPolyPolygon
& rCandidate
);
45 /** Create a unit 3D line polyPolygon which defines a cube.
47 BASEGFX_DLLPUBLIC B3DPolyPolygon
createUnitCubePolyPolygon();
49 /** Create a unit 3D fill polyPolygon which defines a cube.
51 BASEGFX_DLLPUBLIC B3DPolyPolygon
createUnitCubeFillPolyPolygon();
53 /** Create a 3D line polyPolygon from a B3DRange which defines a cube.
55 BASEGFX_DLLPUBLIC B3DPolyPolygon
createCubePolyPolygonFromB3DRange( const B3DRange
& rRange
);
57 /** Create a 3D fill polyPolygon from a B3DRange which defines a cube.
59 BASEGFX_DLLPUBLIC B3DPolyPolygon
createCubeFillPolyPolygonFromB3DRange( const B3DRange
& rRange
);
61 /** Create a unit 3D line polyPolygon which defines a sphere with the given count of hor and ver segments.
62 Result will be centered at (0.0, 0.0, 0.0) and sized [-1.0 .. 1.0] in all dimensions.
63 If nHorSeg == 0 and/or nVerSeg == 0, a default will be calculated to have a step at least each 15 degrees.
64 With VerStart, VerStop and hor range in cartesian may be specified to create a partial sphere only.
66 BASEGFX_DLLPUBLIC B3DPolyPolygon
createUnitSpherePolyPolygon(
67 sal_uInt32 nHorSeg
, sal_uInt32 nVerSeg
= 0L,
68 double fVerStart
= F_PI2
, double fVerStop
= -F_PI2
,
69 double fHorStart
= 0.0, double fHorStop
= F_2PI
);
71 /** Create a 3D line polyPolygon from a B3DRange which defines a sphere with the given count of hor and ver segments.
72 If nHorSeg == 0 and/or nVerSeg == 0, a default will be calculated to have a step at least each 15 degrees.
73 With VerStart, VerStop and hor range in cartesian may be specified to create a partial sphere only.
75 BASEGFX_DLLPUBLIC B3DPolyPolygon
createSpherePolyPolygonFromB3DRange(
76 const B3DRange
& rRange
,
77 sal_uInt32 nHorSeg
, sal_uInt32 nVerSeg
= 0L,
78 double fVerStart
= F_PI2
, double fVerStop
= -F_PI2
,
79 double fHorStart
= 0.0, double fHorStop
= F_2PI
);
81 /** same as createUnitSpherePolyPolygon, but creates filled polygons (closed and oriented)
82 There is one extra, the bool bNormals defines if normals will be set, default is false
84 BASEGFX_DLLPUBLIC B3DPolyPolygon
createUnitSphereFillPolyPolygon(
85 sal_uInt32 nHorSeg
, sal_uInt32 nVerSeg
= 0L,
86 bool bNormals
= false,
87 double fVerStart
= F_PI2
, double fVerStop
= -F_PI2
,
88 double fHorStart
= 0.0, double fHorStop
= F_2PI
);
90 /** same as createSpherePolyPolygonFromB3DRange, but creates filled polygons (closed and oriented)
91 There is one extra, the bool bNormals defines if normals will be set, default is false
93 BASEGFX_DLLPUBLIC B3DPolyPolygon
createSphereFillPolyPolygonFromB3DRange(
94 const B3DRange
& rRange
,
95 sal_uInt32 nHorSeg
, sal_uInt32 nVerSeg
= 0L,
96 bool bNormals
= false,
97 double fVerStart
= F_PI2
, double fVerStop
= -F_PI2
,
98 double fHorStart
= 0.0, double fHorStop
= F_2PI
);
100 /** Create/replace normals for given 3d geometry with default normals from given center to outside.
101 rCandidate: the 3d geometry to change
102 rCenter: the center of the 3d geometry
104 BASEGFX_DLLPUBLIC B3DPolyPolygon
applyDefaultNormalsSphere( const B3DPolyPolygon
& rCandidate
, const B3DPoint
& rCenter
);
106 /** invert normals for given 3d geometry.
108 BASEGFX_DLLPUBLIC B3DPolyPolygon
invertNormals( const B3DPolyPolygon
& rCandidate
);
110 /** Create/replace texture coordinates for given 3d geometry with parallel projected one
111 rRange: the full range of the 3d geometry
112 If bChangeX, x texture coordinate will be recalculated.
113 If bChangeY, y texture coordinate will be recalculated.
115 BASEGFX_DLLPUBLIC B3DPolyPolygon
applyDefaultTextureCoordinatesParallel( const B3DPolyPolygon
& rCandidate
, const B3DRange
& rRange
, bool bChangeX
= true, bool bChangeY
= true);
117 /** Create/replace texture coordinates for given 3d geometry with spherical one
118 rCenter: the centre of the used 3d geometry
119 If bChangeX, x texture coordinate will be recalculated.
120 If bChangeY, y texture coordinate will be recalculated.
122 BASEGFX_DLLPUBLIC B3DPolyPolygon
applyDefaultTextureCoordinatesSphere( const B3DPolyPolygon
& rCandidate
, const B3DPoint
& rCenter
, bool bChangeX
= true, bool bChangeY
= true);
124 // isInside test for B3DPoint. On border is not inside as long as not true is given
125 // in bWithBorder flag. It is assumed that the orientations of the given polygon are correct.
126 BASEGFX_DLLPUBLIC
bool isInside(const B3DPolyPolygon
& rCandidate
, const B3DPoint
& rPoint
, bool bWithBorder
= false);
128 /// converters for css::drawing::PolyPolygonShape3D
129 BASEGFX_DLLPUBLIC B3DPolyPolygon
UnoPolyPolygonShape3DToB3DPolyPolygon(
130 const css::drawing::PolyPolygonShape3D
& rPolyPolygonShape3DSource
,
131 bool bCheckClosed
= true);
132 BASEGFX_DLLPUBLIC
void B3DPolyPolygonToUnoPolyPolygonShape3D(
133 const B3DPolyPolygon
& rPolyPolygonSource
,
134 css::drawing::PolyPolygonShape3D
& rPolyPolygonShape3DRetval
);
136 } // end of namespace tools
137 } // end of namespace basegfx
139 #endif // INCLUDED_BASEGFX_POLYGON_B3DPOLYPOLYGONTOOLS_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */