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 .
20 #include <basegfx/range/b2dpolyrange.hxx>
22 #include <basegfx/range/b2drange.hxx>
23 #include <basegfx/range/b2drangeclipper.hxx>
24 #include <basegfx/polygon/b2dpolypolygon.hxx>
31 class ImplB2DPolyRange
40 bool operator==(const ImplB2DPolyRange
& rRHS
) const
42 return maRanges
== rRHS
.maRanges
&& maOrient
== rRHS
.maOrient
;
45 sal_uInt32
count() const
47 return maRanges
.size();
50 B2DPolyRange::ElementType
getElement(sal_uInt32 nIndex
) const
52 return std::make_tuple(maRanges
[nIndex
], maOrient
[nIndex
]);
55 void appendElement(const B2DRange
& rRange
, B2VectorOrientation eOrient
, sal_uInt32 nCount
)
57 maRanges
.insert(maRanges
.end(), nCount
, rRange
);
58 maOrient
.insert(maOrient
.end(), nCount
, eOrient
);
59 maBounds
.expand(rRange
);
64 std::vector
<B2DRange
> aTmpRanges
;
65 std::vector
<B2VectorOrientation
> aTmpOrient
;
67 maRanges
.swap(aTmpRanges
);
68 maOrient
.swap(aTmpOrient
);
73 bool overlaps( const B2DRange
& rRange
) const
75 if( !maBounds
.overlaps( rRange
) )
78 const std::vector
<B2DRange
>::const_iterator
aEnd( maRanges
.end() );
79 return std::any_of( maRanges
.begin(),
81 [&rRange
](const B2DRange
& aRange
) { return aRange
.overlaps(rRange
); } );
84 B2DPolyPolygon
solveCrossovers() const
86 return utils::solveCrossovers(maRanges
,maOrient
);
89 void transform(const basegfx::B2DHomMatrix
& rTranslate
)
91 maBounds
.transform(rTranslate
);
92 for (auto &a
: maRanges
)
93 a
.transform(rTranslate
);
98 std::vector
<B2DRange
> maRanges
;
99 std::vector
<B2VectorOrientation
> maOrient
;
102 B2DPolyRange::B2DPolyRange() = default;
104 B2DPolyRange::~B2DPolyRange() = default;
106 B2DPolyRange::B2DPolyRange( const B2DPolyRange
& ) = default;
108 B2DPolyRange
& B2DPolyRange::operator=( const B2DPolyRange
& ) = default;
110 bool B2DPolyRange::operator==(const B2DPolyRange
& rRange
) const
112 if(mpImpl
.same_object(rRange
.mpImpl
))
115 return ((*mpImpl
) == (*rRange
.mpImpl
));
118 bool B2DPolyRange::operator!=(const B2DPolyRange
& rRange
) const
120 return !(*this == rRange
);
123 sal_uInt32
B2DPolyRange::count() const
125 return mpImpl
->count();
128 B2DPolyRange::ElementType
B2DPolyRange::getElement(sal_uInt32 nIndex
) const
130 return mpImpl
->getElement(nIndex
);
133 void B2DPolyRange::appendElement(const B2DRange
& rRange
, B2VectorOrientation eOrient
, sal_uInt32 nCount
)
135 mpImpl
->appendElement(rRange
, eOrient
, nCount
);
138 void B2DPolyRange::clear()
143 bool B2DPolyRange::overlaps( const B2DRange
& rRange
) const
145 return mpImpl
->overlaps(rRange
);
148 void B2DPolyRange::transform(const basegfx::B2DHomMatrix
& rTranslate
)
150 mpImpl
->transform(rTranslate
);
153 B2DPolyPolygon
B2DPolyRange::solveCrossovers() const
155 return mpImpl
->solveCrossovers();
157 } // end of namespace basegfx
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */