Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX
21
#define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX
22
23
#include <drawinglayer/drawinglayerdllapi.h>
24
25
#include <drawinglayer/geometry/viewinformation3d.hxx>
26
#include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
27
#include <basegfx/polygon/b2dpolypolygon.hxx>
28
#include <optional>
29
30
31
namespace drawinglayer::primitive3d
32
    {
33
        /** SdrLathePrimitive3D class
34
35
            This 3D primitive expands the SdrPrimitive3D to a 3D rotation definition.
36
            The given 2D tools::PolyPolygon geometry is imagined as lying on the XY-plane in 3D
37
            and gets rotated around the Y-Axis.
38
39
            Various possibilities e.g. for creating diagonals (edge roudings in 3D)
40
            and similar are given.
41
42
            The decomposition will create all necessary 3D planes for visualisation.
43
         */
44
        class DRAWINGLAYER_DLLPUBLIC SdrLathePrimitive3D final : public SdrPrimitive3D
45
        {
46
        private:
47
            /// geometry helper for slices
48
            basegfx::B2DPolyPolygon                     maCorrectedPolyPolygon;
49
            Slice3DVector                               maSlices;
50
51
            /// primitive geometry data
52
            basegfx::B2DPolyPolygon                     maPolyPolygon;
53
            sal_uInt32                                  mnHorizontalSegments;
54
            sal_uInt32                                  mnVerticalSegments;
55
            double                                      mfDiagonal;
56
            double                                      mfBackScale;
57
            double                                      mfRotation;
58
59
            /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition
60
            std::optional<geometry::ViewInformation3D> mpLastRLGViewInformation;
61
62
            bool                                        mbSmoothNormals : 1; // Plane self
63
            bool                                        mbSmoothLids : 1; // Front/back
64
            bool                                        mbCharacterMode : 1;
65
            bool                                        mbCloseFront : 1;
66
            bool                                        mbCloseBack : 1;
67
68
            /// create slices
69
            void impCreateSlices();
70
71
            /// get (evtl. create) slices
72
            const Slice3DVector& getSlices() const;
73
74
            /// local decomposition.
75
            virtual Primitive3DContainer create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override;
76
77
        public:
78
            /// constructor
79
            SdrLathePrimitive3D(
80
                const basegfx::B3DHomMatrix& rTransform,
81
                const basegfx::B2DVector& rTextureSize,
82
                const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
83
                const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute,
84
                basegfx::B2DPolyPolygon aPolyPolygon,
85
                sal_uInt32 nHorizontalSegments,
86
                sal_uInt32 nVerticalSegments,
87
                double fDiagonal,
88
                double fBackScale,
89
                double fRotation,
90
                bool bSmoothNormals,
91
                bool bSmoothLids,
92
                bool bCharacterMode,
93
                bool bCloseFront,
94
                bool bCloseBack);
95
            virtual ~SdrLathePrimitive3D() override;
96
97
            /// data read access
98
0
            const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; }
99
0
            sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; }
100
0
            sal_uInt32 getVerticalSegments() const { return mnVerticalSegments; }
101
0
            double getDiagonal() const { return mfDiagonal; }
102
0
            double getBackScale() const { return mfBackScale; }
103
0
            double getRotation() const { return mfRotation; }
104
0
            bool getSmoothNormals() const { return mbSmoothNormals; }
105
0
            bool getSmoothLids() const { return mbSmoothLids; }
106
0
            bool getCharacterMode() const { return mbCharacterMode; }
107
0
            bool getCloseFront() const { return mbCloseFront; }
108
0
            bool getCloseBack() const { return mbCloseBack; }
109
110
            /// compare operator
111
            virtual bool operator==(const BasePrimitive3D& rPrimitive) const override;
112
113
            /// get range
114
            virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const override;
115
116
            /// Overridden to allow for reduced line mode to decide if to buffer decomposition or not
117
            virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override;
118
119
            /// provide unique ID
120
            DeclPrimitive3DIDBlock()
121
        };
122
123
} // end of namespace drawinglayer::primitive3d
124
125
126
#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX
127
128
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */