Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/basegfx/source/range/b2dpolyrange.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 <basegfx/range/b2dpolyrange.hxx>
21
22
#include <basegfx/range/b2drange.hxx>
23
#include <basegfx/range/b2drangeclipper.hxx>
24
#include <basegfx/polygon/b2dpolypolygon.hxx>
25
26
#include <algorithm>
27
#include <vector>
28
29
namespace basegfx
30
{
31
    class ImplB2DPolyRange
32
    {
33
    public:
34
        ImplB2DPolyRange()
35
173k
        {}
36
37
        bool operator==(const ImplB2DPolyRange& rRHS) const
38
629
        {
39
629
            return maRanges == rRHS.maRanges && maOrient == rRHS.maOrient;
40
629
        }
41
42
        sal_uInt32 count() const
43
9.42k
        {
44
9.42k
            return maRanges.size();
45
9.42k
        }
46
47
        B2DPolyRange::ElementType getElement(sal_uInt32 nIndex) const
48
0
        {
49
0
            return std::make_tuple(maRanges[nIndex], maOrient[nIndex]);
50
0
        }
51
52
        void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient)
53
0
        {
54
0
            maRanges.push_back(rRange);
55
0
            maOrient.push_back(eOrient);
56
0
            maBounds.expand(rRange);
57
0
        }
58
59
        void clear()
60
0
        {
61
0
            std::vector<B2DRange>().swap(maRanges);
62
0
            std::vector<B2VectorOrientation>().swap(maOrient);
63
64
0
            maBounds.reset();
65
0
        }
66
67
        bool overlaps( const B2DRange& rRange ) const
68
0
        {
69
0
            if( !maBounds.overlaps( rRange ) )
70
0
                return false;
71
72
0
            const std::vector<B2DRange>::const_iterator aEnd( maRanges.end() );
73
0
            return std::any_of( maRanges.begin(),
74
0
                                 aEnd,
75
0
                                 [&rRange](const B2DRange& aRange) { return aRange.overlaps(rRange); } );
76
0
        }
77
78
        B2DPolyPolygon solveCrossovers() const
79
0
        {
80
0
            return utils::solveCrossovers(maRanges,maOrient);
81
0
        }
82
83
        void transform(const basegfx::B2DHomMatrix& rTranslate)
84
0
        {
85
0
            maBounds.transform(rTranslate);
86
0
            for (auto &a : maRanges)
87
0
                a.transform(rTranslate);
88
0
        }
89
90
    private:
91
        B2DRange                         maBounds;
92
        std::vector<B2DRange>            maRanges;
93
        std::vector<B2VectorOrientation> maOrient;
94
    };
95
96
173k
    B2DPolyRange::B2DPolyRange() = default;
97
98
248k
    B2DPolyRange::~B2DPolyRange() = default;
99
100
74.5k
    B2DPolyRange::B2DPolyRange( const B2DPolyRange& ) = default;
101
102
0
    B2DPolyRange& B2DPolyRange::operator=( const B2DPolyRange& ) = default;
103
104
    bool B2DPolyRange::operator==(const B2DPolyRange& rRange) const
105
629
    {
106
629
        if(mpImpl.same_object(rRange.mpImpl))
107
0
            return true;
108
109
629
        return ((*mpImpl) == (*rRange.mpImpl));
110
629
    }
111
112
    sal_uInt32 B2DPolyRange::count() const
113
9.42k
    {
114
9.42k
        return mpImpl->count();
115
9.42k
    }
116
117
    B2DPolyRange::ElementType B2DPolyRange::getElement(sal_uInt32 nIndex) const
118
0
    {
119
0
        return mpImpl->getElement(nIndex);
120
0
    }
121
122
    void B2DPolyRange::appendElement(const B2DRange& rRange, B2VectorOrientation eOrient)
123
0
    {
124
0
        mpImpl->appendElement(rRange, eOrient);
125
0
    }
126
127
    void B2DPolyRange::clear()
128
0
    {
129
0
        mpImpl->clear();
130
0
    }
131
132
    bool B2DPolyRange::overlaps( const B2DRange& rRange ) const
133
0
    {
134
0
        return mpImpl->overlaps(rRange);
135
0
    }
136
137
    void B2DPolyRange::transform(const basegfx::B2DHomMatrix& rTranslate)
138
0
    {
139
0
        mpImpl->transform(rTranslate);
140
0
    }
141
142
    B2DPolyPolygon B2DPolyRange::solveCrossovers() const
143
0
    {
144
0
        return mpImpl->solveCrossovers();
145
0
    }
146
} // end of namespace basegfx
147
148
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */