Coverage Report

Created: 2026-09-28 10:59

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