LCOV - code coverage report
Current view: top level - basegfx/source/range - b2dpolyrange.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 52 61 85.2 %
Date: 2015-06-13 12:38:46 Functions: 21 24 87.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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/tuple/b2dtuple.hxx>
      25             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      26             : 
      27             : #include <boost/bind.hpp>
      28             : #include <algorithm>
      29             : #include <vector>
      30             : 
      31             : namespace basegfx
      32             : {
      33        1898 :     class ImplB2DPolyRange
      34             :     {
      35             :     public:
      36        1292 :         ImplB2DPolyRange() :
      37             :             maBounds(),
      38             :             maRanges(),
      39        1292 :             maOrient()
      40        1292 :         {}
      41             : 
      42         396 :         bool operator==(const ImplB2DPolyRange& rRHS) const
      43             :         {
      44         396 :             return maRanges == rRHS.maRanges && maOrient == rRHS.maOrient;
      45             :         }
      46             : 
      47        1874 :         sal_uInt32 count() const
      48             :         {
      49        1874 :             return maRanges.size();
      50             :         }
      51             : 
      52          42 :         B2DPolyRange::ElementType getElement(sal_uInt32 nIndex) const
      53             :         {
      54          42 :             return std::make_tuple(maRanges[nIndex], maOrient[nIndex]);
      55             :         }
      56             : 
      57         610 :         void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
      58             :         {
      59         610 :             maRanges.insert(maRanges.end(), nCount, rRange);
      60         610 :             maOrient.insert(maOrient.end(), nCount, eOrient);
      61         610 :             maBounds.expand(rRange);
      62         610 :         }
      63             : 
      64         193 :         void clear()
      65             :         {
      66         193 :             std::vector<B2DRange> aTmpRanges;
      67         386 :             std::vector<B2VectorOrientation> aTmpOrient;
      68             : 
      69         193 :             maRanges.swap(aTmpRanges);
      70         193 :             maOrient.swap(aTmpOrient);
      71             : 
      72         386 :             maBounds.reset();
      73         193 :         }
      74             : 
      75           0 :         bool overlaps( const B2DRange& rRange ) const
      76             :         {
      77           0 :             if( !maBounds.overlaps( rRange ) )
      78           0 :                 return false;
      79             : 
      80           0 :             const std::vector<B2DRange>::const_iterator aEnd( maRanges.end() );
      81             :             return std::any_of( maRanges.begin(),
      82             :                                  aEnd,
      83             :                                  boost::bind<bool>( boost::mem_fn( &B2DRange::overlaps ),
      84             :                                                     _1,
      85           0 :                                                     boost::cref(rRange) ) );
      86             :         }
      87             : 
      88         229 :         B2DPolyPolygon solveCrossovers() const
      89             :         {
      90         229 :             return tools::solveCrossovers(maRanges,maOrient);
      91             :         }
      92             : 
      93             :     private:
      94             :         B2DRange                         maBounds;
      95             :         std::vector<B2DRange>            maRanges;
      96             :         std::vector<B2VectorOrientation> maOrient;
      97             :     };
      98             : 
      99        1292 :     B2DPolyRange::B2DPolyRange() :
     100        1292 :         mpImpl()
     101        1292 :     {}
     102             : 
     103        1607 :     B2DPolyRange::~B2DPolyRange()
     104        1607 :     {}
     105             : 
     106         315 :     B2DPolyRange::B2DPolyRange( const B2DPolyRange& rRange ) :
     107         315 :         mpImpl( rRange.mpImpl )
     108         315 :     {}
     109             : 
     110           6 :     B2DPolyRange& B2DPolyRange::operator=( const B2DPolyRange& rRange )
     111             :     {
     112           6 :         mpImpl = rRange.mpImpl;
     113           6 :         return *this;
     114             :     }
     115             : 
     116         413 :     bool B2DPolyRange::operator==(const B2DPolyRange& rRange) const
     117             :     {
     118         413 :         if(mpImpl.same_object(rRange.mpImpl))
     119          17 :             return true;
     120             : 
     121         396 :         return ((*mpImpl) == (*rRange.mpImpl));
     122             :     }
     123             : 
     124           0 :     bool B2DPolyRange::operator!=(const B2DPolyRange& rRange) const
     125             :     {
     126           0 :         return !(*this == rRange);
     127             :     }
     128             : 
     129        1874 :     sal_uInt32 B2DPolyRange::count() const
     130             :     {
     131        1874 :         return mpImpl->count();
     132             :     }
     133             : 
     134          42 :     B2DPolyRange::ElementType B2DPolyRange::getElement(sal_uInt32 nIndex) const
     135             :     {
     136          42 :         return mpImpl->getElement(nIndex);
     137             :     }
     138             : 
     139         610 :     void B2DPolyRange::appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
     140             :     {
     141         610 :         mpImpl->appendElement(rRange, eOrient, nCount );
     142         610 :     }
     143             : 
     144         193 :     void B2DPolyRange::clear()
     145             :     {
     146         193 :         mpImpl->clear();
     147         193 :     }
     148             : 
     149           0 :     bool B2DPolyRange::overlaps( const B2DRange& rRange ) const
     150             :     {
     151           0 :         return mpImpl->overlaps(rRange);
     152             :     }
     153             : 
     154         229 :     B2DPolyPolygon B2DPolyRange::solveCrossovers() const
     155             :     {
     156         229 :         return mpImpl->solveCrossovers();
     157             :     }
     158        2106 : } // end of namespace basegfx
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11