LCOV - code coverage report
Current view: top level - basegfx/source/range - b2dpolyrange.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 53 62 85.5 %
Date: 2014-04-11 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 <boost/tuple/tuple.hpp>
      29             : #include <algorithm>
      30             : #include <vector>
      31             : 
      32             : namespace basegfx
      33             : {
      34        1262 :     class ImplB2DPolyRange
      35             :     {
      36             :     public:
      37         808 :         ImplB2DPolyRange() :
      38             :             maBounds(),
      39             :             maRanges(),
      40         808 :             maOrient()
      41         808 :         {}
      42             : 
      43         230 :         bool operator==(const ImplB2DPolyRange& rRHS) const
      44             :         {
      45         230 :             return maRanges == rRHS.maRanges && maOrient == rRHS.maOrient;
      46             :         }
      47             : 
      48        1351 :         sal_uInt32 count() const
      49             :         {
      50        1351 :             return maRanges.size();
      51             :         }
      52             : 
      53          42 :         B2DPolyRange::ElementType getElement(sal_uInt32 nIndex) const
      54             :         {
      55          42 :             return boost::make_tuple(maRanges[nIndex],
      56          84 :                                      maOrient[nIndex]);
      57             :         }
      58             : 
      59         533 :         void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
      60             :         {
      61         533 :             maRanges.insert(maRanges.end(), nCount, rRange);
      62         533 :             maOrient.insert(maOrient.end(), nCount, eOrient);
      63         533 :             maBounds.expand(rRange);
      64         533 :         }
      65             : 
      66         165 :         void clear()
      67             :         {
      68         165 :             std::vector<B2DRange> aTmpRanges;
      69         330 :             std::vector<B2VectorOrientation> aTmpOrient;
      70             : 
      71         165 :             maRanges.swap(aTmpRanges);
      72         165 :             maOrient.swap(aTmpOrient);
      73             : 
      74         330 :             maBounds.reset();
      75         165 :         }
      76             : 
      77           0 :         bool overlaps( const B2DRange& rRange ) const
      78             :         {
      79           0 :             if( !maBounds.overlaps( rRange ) )
      80           0 :                 return false;
      81             : 
      82           0 :             const std::vector<B2DRange>::const_iterator aEnd( maRanges.end() );
      83             :             return std::find_if( maRanges.begin(),
      84             :                                  aEnd,
      85             :                                  boost::bind<bool>( boost::mem_fn( &B2DRange::overlaps ),
      86             :                                                     _1,
      87           0 :                                                     boost::cref(rRange) ) ) != aEnd;
      88             :         }
      89             : 
      90         201 :         B2DPolyPolygon solveCrossovers() const
      91             :         {
      92         201 :             return tools::solveCrossovers(maRanges,maOrient);
      93             :         }
      94             : 
      95             :     private:
      96             :         B2DRange                         maBounds;
      97             :         std::vector<B2DRange>            maRanges;
      98             :         std::vector<B2VectorOrientation> maOrient;
      99             :     };
     100             : 
     101         808 :     B2DPolyRange::B2DPolyRange() :
     102         808 :         mpImpl()
     103         808 :     {}
     104             : 
     105        1082 :     B2DPolyRange::~B2DPolyRange()
     106        1082 :     {}
     107             : 
     108         274 :     B2DPolyRange::B2DPolyRange( const B2DPolyRange& rRange ) :
     109         274 :         mpImpl( rRange.mpImpl )
     110         274 :     {}
     111             : 
     112           6 :     B2DPolyRange& B2DPolyRange::operator=( const B2DPolyRange& rRange )
     113             :     {
     114           6 :         mpImpl = rRange.mpImpl;
     115           6 :         return *this;
     116             :     }
     117             : 
     118         235 :     bool B2DPolyRange::operator==(const B2DPolyRange& rRange) const
     119             :     {
     120         235 :         if(mpImpl.same_object(rRange.mpImpl))
     121           5 :             return true;
     122             : 
     123         230 :         return ((*mpImpl) == (*rRange.mpImpl));
     124             :     }
     125             : 
     126           0 :     bool B2DPolyRange::operator!=(const B2DPolyRange& rRange) const
     127             :     {
     128           0 :         return !(*this == rRange);
     129             :     }
     130             : 
     131        1351 :     sal_uInt32 B2DPolyRange::count() const
     132             :     {
     133        1351 :         return mpImpl->count();
     134             :     }
     135             : 
     136          42 :     B2DPolyRange::ElementType B2DPolyRange::getElement(sal_uInt32 nIndex) const
     137             :     {
     138          42 :         return mpImpl->getElement(nIndex);
     139             :     }
     140             : 
     141         533 :     void B2DPolyRange::appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
     142             :     {
     143         533 :         mpImpl->appendElement(rRange, eOrient, nCount );
     144         533 :     }
     145             : 
     146         165 :     void B2DPolyRange::clear()
     147             :     {
     148         165 :         mpImpl->clear();
     149         165 :     }
     150             : 
     151           0 :     bool B2DPolyRange::overlaps( const B2DRange& rRange ) const
     152             :     {
     153           0 :         return mpImpl->overlaps(rRange);
     154             :     }
     155             : 
     156         201 :     B2DPolyPolygon B2DPolyRange::solveCrossovers() const
     157             :     {
     158         201 :         return mpImpl->solveCrossovers();
     159             :     }
     160        1923 : } // end of namespace basegfx
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10