Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx
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
#include <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx>
21
#include <primitive3d/sdrdecompositiontools3d.hxx>
22
#include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
23
#include <basegfx/polygon/b3dpolypolygontools.hxx>
24
#include <drawinglayer/attribute/sdrfillattribute.hxx>
25
#include <drawinglayer/attribute/sdrlineattribute.hxx>
26
#include <drawinglayer/attribute/sdrshadowattribute.hxx>
27
#include <utility>
28
29
30
using namespace com::sun::star;
31
32
33
namespace drawinglayer::primitive3d
34
{
35
        Primitive3DContainer SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
36
0
        {
37
0
            Primitive3DContainer aRetval;
38
39
0
            if(getPolyPolygon3D().count())
40
0
            {
41
0
                std::vector< basegfx::B3DPolyPolygon > aFill { getPolyPolygon3D() };
42
43
                // get full range
44
0
                const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill));
45
46
                // #i98295# normal creation
47
0
                if(!getSdrLFSAttribute().getFill().isDefault())
48
0
                {
49
0
                    if(css::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind())
50
0
                    {
51
0
                        applyNormalsKindSphereTo3DGeometry(aFill, aRange);
52
0
                    }
53
0
                    else if(css::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind())
54
0
                    {
55
0
                        applyNormalsKindFlatTo3DGeometry(aFill);
56
0
                    }
57
58
0
                    if(getSdr3DObjectAttribute().getNormalsInvert())
59
0
                    {
60
0
                        applyNormalsInvertTo3DGeometry(aFill);
61
0
                    }
62
0
                }
63
64
                // #i98314# texture coordinates
65
0
                if(!getSdrLFSAttribute().getFill().isDefault())
66
0
                {
67
0
                    applyTextureTo3DGeometry(
68
0
                        getSdr3DObjectAttribute().getTextureProjectionX(),
69
0
                        getSdr3DObjectAttribute().getTextureProjectionY(),
70
0
                        aFill,
71
0
                        aRange,
72
0
                        getTextureSize());
73
0
                }
74
75
0
                if(!getSdrLFSAttribute().getFill().isDefault())
76
0
                {
77
                    // add fill
78
0
                    aRetval = create3DPolyPolygonFillPrimitives(
79
0
                        aFill,
80
0
                        getTransform(),
81
0
                        getTextureSize(),
82
0
                        getSdr3DObjectAttribute(),
83
0
                        getSdrLFSAttribute().getFill(),
84
0
                        getSdrLFSAttribute().getFillFloatTransGradient());
85
0
                }
86
0
                else
87
0
                {
88
                    // create simplified 3d hit test geometry
89
0
                    aRetval = createHiddenGeometryPrimitives3D(
90
0
                        aFill,
91
0
                        getTransform(),
92
0
                        getTextureSize(),
93
0
                        getSdr3DObjectAttribute());
94
0
                }
95
96
                // add line
97
0
                if(!getSdrLFSAttribute().getLine().isDefault())
98
0
                {
99
0
                    basegfx::B3DPolyPolygon aLine(getPolyPolygon3D());
100
0
                    aLine.clearNormals();
101
0
                    aLine.clearTextureCoordinates();
102
0
                    const Primitive3DContainer aLines(create3DPolyPolygonLinePrimitives(
103
0
                        aLine, getTransform(), getSdrLFSAttribute().getLine()));
104
0
                    aRetval.append(aLines);
105
0
                }
106
107
                // add shadow
108
0
                if(!getSdrLFSAttribute().getShadow().isDefault()
109
0
                    && !aRetval.empty())
110
0
                {
111
0
                    const Primitive3DContainer aShadow(createShadowPrimitive3D(
112
0
                        aRetval, getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()));
113
0
                    aRetval.append(aShadow);
114
0
                }
115
0
            }
116
117
0
            return aRetval;
118
0
        }
119
120
        SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D(
121
            basegfx::B3DPolyPolygon aPolyPolygon3D,
122
            const basegfx::B3DHomMatrix& rTransform,
123
            const basegfx::B2DVector& rTextureSize,
124
            const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
125
            const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute)
126
0
        :   SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute),
127
0
            maPolyPolygon3D(std::move(aPolyPolygon3D))
128
0
        {
129
0
        }
Unexecuted instantiation: drawinglayer::primitive3d::SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D(basegfx::B3DPolyPolygon, basegfx::B3DHomMatrix const&, basegfx::B2DVector const&, drawinglayer::attribute::SdrLineFillShadowAttribute3D const&, drawinglayer::attribute::Sdr3DObjectAttribute const&)
Unexecuted instantiation: drawinglayer::primitive3d::SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D(basegfx::B3DPolyPolygon, basegfx::B3DHomMatrix const&, basegfx::B2DVector const&, drawinglayer::attribute::SdrLineFillShadowAttribute3D const&, drawinglayer::attribute::Sdr3DObjectAttribute const&)
130
131
        bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
132
0
        {
133
0
            if(SdrPrimitive3D::operator==(rPrimitive))
134
0
            {
135
0
                const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive);
136
137
0
                return (getPolyPolygon3D() == rCompare.getPolyPolygon3D());
138
0
            }
139
140
0
            return false;
141
0
        }
142
143
        basegfx::B3DRange SdrPolyPolygonPrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
144
0
        {
145
            // added this implementation to make sure that non-visible objects of this
146
            // kind will deliver their expansion. If not implemented, it would never deliver
147
            // the used space for non-visible objects since the decomposition for that
148
            // case will be empty (what is correct). To support chart ATM which relies on
149
            // non-visible objects occupying space in 3D, this method was added
150
0
            basegfx::B3DRange aRetval;
151
152
0
            if(getPolyPolygon3D().count())
153
0
            {
154
0
                aRetval = basegfx::utils::getRange(getPolyPolygon3D());
155
0
                aRetval.transform(getTransform());
156
157
0
                if(!getSdrLFSAttribute().getLine().isDefault())
158
0
                {
159
0
                    const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
160
161
0
                    if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
162
0
                    {
163
                        // expand by half LineWidth as tube radius
164
0
                        aRetval.grow(rLine.getWidth() / 2.0);
165
0
                    }
166
0
                }
167
0
            }
168
169
0
            return aRetval;
170
0
        }
171
172
        // provide unique ID
173
        ImplPrimitive3DIDBlock(SdrPolyPolygonPrimitive3D, PRIMITIVE3D_ID_SDRPOLYPOLYGONPRIMITIVE3D)
174
175
} // end of namespace
176
177
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */