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/tuple/b2dtuple.hxx>
25 #include <basegfx/polygon/b2dpolypolygon.hxx>
27 #include <boost/bind.hpp>
28 #include <boost/tuple/tuple.hpp>
34 class ImplB2DPolyRange
43 bool operator==(const ImplB2DPolyRange
& rRHS
) const
45 return maRanges
== rRHS
.maRanges
&& maOrient
== rRHS
.maOrient
;
48 sal_uInt32
count() const
50 return maRanges
.size();
53 B2DPolyRange::ElementType
getElement(sal_uInt32 nIndex
) const
55 return boost::make_tuple(maRanges
[nIndex
],
59 void appendElement(const B2DRange
& rRange
, B2VectorOrientation eOrient
, sal_uInt32 nCount
)
61 maRanges
.insert(maRanges
.end(), nCount
, rRange
);
62 maOrient
.insert(maOrient
.end(), nCount
, eOrient
);
63 maBounds
.expand(rRange
);
68 std::vector
<B2DRange
> aTmpRanges
;
69 std::vector
<B2VectorOrientation
> aTmpOrient
;
71 maRanges
.swap(aTmpRanges
);
72 maOrient
.swap(aTmpOrient
);
77 bool overlaps( const B2DRange
& rRange
) const
79 if( !maBounds
.overlaps( rRange
) )
82 const std::vector
<B2DRange
>::const_iterator
aEnd( maRanges
.end() );
83 return std::any_of( maRanges
.begin(),
85 boost::bind
<bool>( boost::mem_fn( &B2DRange::overlaps
),
87 boost::cref(rRange
) ) );
90 B2DPolyPolygon
solveCrossovers() const
92 return tools::solveCrossovers(maRanges
,maOrient
);
97 std::vector
<B2DRange
> maRanges
;
98 std::vector
<B2VectorOrientation
> maOrient
;
101 B2DPolyRange::B2DPolyRange() :
105 B2DPolyRange::~B2DPolyRange()
108 B2DPolyRange::B2DPolyRange( const B2DPolyRange
& rRange
) :
109 mpImpl( rRange
.mpImpl
)
112 B2DPolyRange
& B2DPolyRange::operator=( const B2DPolyRange
& rRange
)
114 mpImpl
= rRange
.mpImpl
;
118 bool B2DPolyRange::operator==(const B2DPolyRange
& rRange
) const
120 if(mpImpl
.same_object(rRange
.mpImpl
))
123 return ((*mpImpl
) == (*rRange
.mpImpl
));
126 bool B2DPolyRange::operator!=(const B2DPolyRange
& rRange
) const
128 return !(*this == rRange
);
131 sal_uInt32
B2DPolyRange::count() const
133 return mpImpl
->count();
136 B2DPolyRange::ElementType
B2DPolyRange::getElement(sal_uInt32 nIndex
) const
138 return mpImpl
->getElement(nIndex
);
141 void B2DPolyRange::appendElement(const B2DRange
& rRange
, B2VectorOrientation eOrient
, sal_uInt32 nCount
)
143 mpImpl
->appendElement(rRange
, eOrient
, nCount
);
146 void B2DPolyRange::clear()
151 bool B2DPolyRange::overlaps( const B2DRange
& rRange
) const
153 return mpImpl
->overlaps(rRange
);
156 B2DPolyPolygon
B2DPolyRange::solveCrossovers() const
158 return mpImpl
->solveCrossovers();
160 } // end of namespace basegfx
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */