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 .
22 #include <basegfx/point/b3dpoint.hxx>
23 #include <basegfx/basegfxdllapi.h>
25 namespace com::sun::star::drawing
{ struct PolyPolygonShape3D
; }
33 namespace basegfx::utils
35 // B3DPolyPolygon tools
37 // get size of PolyPolygon. Control vectors are included in that ranges.
38 BASEGFX_DLLPUBLIC B3DRange
getRange(const B3DPolyPolygon
& rCandidate
);
40 /** Create a unit 3D line polyPolygon which defines a cube.
42 B3DPolyPolygon
const & createUnitCubePolyPolygon();
44 /** Create a unit 3D fill polyPolygon which defines a cube.
46 B3DPolyPolygon
const & createUnitCubeFillPolyPolygon();
48 /** Create a 3D line polyPolygon from a B3DRange which defines a cube.
50 BASEGFX_DLLPUBLIC B3DPolyPolygon
createCubePolyPolygonFromB3DRange( const B3DRange
& rRange
);
52 /** Create a 3D fill polyPolygon from a B3DRange which defines a cube.
54 BASEGFX_DLLPUBLIC B3DPolyPolygon
createCubeFillPolyPolygonFromB3DRange( const B3DRange
& rRange
);
56 /** Create a unit 3D line polyPolygon which defines a sphere with the given count of hor and ver segments.
57 Result will be centered at (0.0, 0.0, 0.0) and sized [-1.0 .. 1.0] in all dimensions.
58 If nHorSeg == 0 and/or nVerSeg == 0, a default will be calculated to have a step at least each 15 degrees.
59 With VerStart, VerStop and hor range in cartesian may be specified to create a partial sphere only.
61 B3DPolyPolygon
createUnitSpherePolyPolygon(
62 sal_uInt32 nHorSeg
, sal_uInt32 nVerSeg
,
63 double fVerStart
= M_PI_2
, double fVerStop
= -M_PI_2
,
64 double fHorStart
= 0.0, double fHorStop
= 2 * M_PI
);
66 /** Create a 3D line polyPolygon from a B3DRange which defines a sphere with the given count of hor and ver segments.
67 If nHorSeg == 0 and/or nVerSeg == 0, a default will be calculated to have a step at least each 15 degrees.
68 With VerStart, VerStop and hor range in cartesian may be specified to create a partial sphere only.
70 BASEGFX_DLLPUBLIC B3DPolyPolygon
createSpherePolyPolygonFromB3DRange(
71 const B3DRange
& rRange
,
72 sal_uInt32 nHorSeg
, sal_uInt32 nVerSeg
,
73 double fVerStart
= M_PI_2
, double fVerStop
= -M_PI_2
,
74 double fHorStart
= 0.0, double fHorStop
= 2 * M_PI
);
76 /** same as createUnitSpherePolyPolygon, but creates filled polygons (closed and oriented)
77 There is one extra, the bool bNormals defines if normals will be set, default is false
79 BASEGFX_DLLPUBLIC B3DPolyPolygon
createUnitSphereFillPolyPolygon(
80 sal_uInt32 nHorSeg
, sal_uInt32 nVerSeg
,
81 bool bNormals
= false,
82 double fVerStart
= M_PI_2
, double fVerStop
= -M_PI_2
,
83 double fHorStart
= 0.0, double fHorStop
= 2 * M_PI
);
85 /** same as createSpherePolyPolygonFromB3DRange, but creates filled polygons (closed and oriented)
86 There is one extra, the bool bNormals defines if normals will be set, default is false
88 BASEGFX_DLLPUBLIC B3DPolyPolygon
createSphereFillPolyPolygonFromB3DRange(
89 const B3DRange
& rRange
,
90 sal_uInt32 nHorSeg
, sal_uInt32 nVerSeg
,
91 bool bNormals
= false,
92 double fVerStart
= M_PI_2
, double fVerStop
= -M_PI_2
,
93 double fHorStart
= 0.0, double fHorStop
= 2 * M_PI
);
95 /** Create/replace normals for given 3d geometry with default normals from given center to outside.
96 rCandidate: the 3d geometry to change
97 rCenter: the center of the 3d geometry
99 BASEGFX_DLLPUBLIC B3DPolyPolygon
applyDefaultNormalsSphere( const B3DPolyPolygon
& rCandidate
, const B3DPoint
& rCenter
);
101 /** invert normals for given 3d geometry.
103 BASEGFX_DLLPUBLIC B3DPolyPolygon
invertNormals( const B3DPolyPolygon
& rCandidate
);
105 /** Create/replace texture coordinates for given 3d geometry with parallel projected one
106 rRange: the full range of the 3d geometry
107 If bChangeX, x texture coordinate will be recalculated.
108 If bChangeY, y texture coordinate will be recalculated.
110 BASEGFX_DLLPUBLIC B3DPolyPolygon
applyDefaultTextureCoordinatesParallel( const B3DPolyPolygon
& rCandidate
, const B3DRange
& rRange
, bool bChangeX
= true, bool bChangeY
= true);
112 /** Create/replace texture coordinates for given 3d geometry with spherical one
113 rCenter: the centre of the used 3d geometry
114 If bChangeX, x texture coordinate will be recalculated.
115 If bChangeY, y texture coordinate will be recalculated.
117 BASEGFX_DLLPUBLIC B3DPolyPolygon
applyDefaultTextureCoordinatesSphere( const B3DPolyPolygon
& rCandidate
, const B3DPoint
& rCenter
, bool bChangeX
= true, bool bChangeY
= true);
119 // isInside test for B3DPoint. On border is not inside.
120 // It is assumed that the orientations of the given polygon are correct.
121 BASEGFX_DLLPUBLIC
bool isInside(const B3DPolyPolygon
& rCandidate
, const B3DPoint
& rPoint
);
123 /// converters for css::drawing::PolyPolygonShape3D
124 BASEGFX_DLLPUBLIC B3DPolyPolygon
UnoPolyPolygonShape3DToB3DPolyPolygon(
125 const css::drawing::PolyPolygonShape3D
& rPolyPolygonShape3DSource
);
126 BASEGFX_DLLPUBLIC
void B3DPolyPolygonToUnoPolyPolygonShape3D(
127 const B3DPolyPolygon
& rPolyPolygonSource
,
128 css::drawing::PolyPolygonShape3D
& rPolyPolygonShape3DRetval
);
130 } // end of namespace basegfx::utils
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */