LCOV - code coverage report
Current view: top level - basegfx/source/range - b2dpolyrange.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 53 62 85.5 %
Date: 2014-11-03 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        3729 :     class ImplB2DPolyRange
      35             :     {
      36             :     public:
      37        2497 :         ImplB2DPolyRange() :
      38             :             maBounds(),
      39             :             maRanges(),
      40        2497 :             maOrient()
      41        2497 :         {}
      42             : 
      43         762 :         bool operator==(const ImplB2DPolyRange& rRHS) const
      44             :         {
      45         762 :             return maRanges == rRHS.maRanges && maOrient == rRHS.maOrient;
      46             :         }
      47             : 
      48        3797 :         sal_uInt32 count() const
      49             :         {
      50        3797 :             return maRanges.size();
      51             :         }
      52             : 
      53          84 :         B2DPolyRange::ElementType getElement(sal_uInt32 nIndex) const
      54             :         {
      55          84 :             return boost::make_tuple(maRanges[nIndex],
      56         168 :                                      maOrient[nIndex]);
      57             :         }
      58             : 
      59        1230 :         void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
      60             :         {
      61        1230 :             maRanges.insert(maRanges.end(), nCount, rRange);
      62        1230 :             maOrient.insert(maOrient.end(), nCount, eOrient);
      63        1230 :             maBounds.expand(rRange);
      64        1230 :         }
      65             : 
      66         396 :         void clear()
      67             :         {
      68         396 :             std::vector<B2DRange> aTmpRanges;
      69         792 :             std::vector<B2VectorOrientation> aTmpOrient;
      70             : 
      71         396 :             maRanges.swap(aTmpRanges);
      72         396 :             maOrient.swap(aTmpOrient);
      73             : 
      74         792 :             maBounds.reset();
      75         396 :         }
      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         468 :         B2DPolyPolygon solveCrossovers() const
      91             :         {
      92         468 :             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        2497 :     B2DPolyRange::B2DPolyRange() :
     102        2497 :         mpImpl()
     103        2497 :     {}
     104             : 
     105        3391 :     B2DPolyRange::~B2DPolyRange()
     106        3391 :     {}
     107             : 
     108         894 :     B2DPolyRange::B2DPolyRange( const B2DPolyRange& rRange ) :
     109         894 :         mpImpl( rRange.mpImpl )
     110         894 :     {}
     111             : 
     112          12 :     B2DPolyRange& B2DPolyRange::operator=( const B2DPolyRange& rRange )
     113             :     {
     114          12 :         mpImpl = rRange.mpImpl;
     115          12 :         return *this;
     116             :     }
     117             : 
     118         796 :     bool B2DPolyRange::operator==(const B2DPolyRange& rRange) const
     119             :     {
     120         796 :         if(mpImpl.same_object(rRange.mpImpl))
     121          34 :             return true;
     122             : 
     123         762 :         return ((*mpImpl) == (*rRange.mpImpl));
     124             :     }
     125             : 
     126           0 :     bool B2DPolyRange::operator!=(const B2DPolyRange& rRange) const
     127             :     {
     128           0 :         return !(*this == rRange);
     129             :     }
     130             : 
     131        3797 :     sal_uInt32 B2DPolyRange::count() const
     132             :     {
     133        3797 :         return mpImpl->count();
     134             :     }
     135             : 
     136          84 :     B2DPolyRange::ElementType B2DPolyRange::getElement(sal_uInt32 nIndex) const
     137             :     {
     138          84 :         return mpImpl->getElement(nIndex);
     139             :     }
     140             : 
     141        1230 :     void B2DPolyRange::appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
     142             :     {
     143        1230 :         mpImpl->appendElement(rRange, eOrient, nCount );
     144        1230 :     }
     145             : 
     146         396 :     void B2DPolyRange::clear()
     147             :     {
     148         396 :         mpImpl->clear();
     149         396 :     }
     150             : 
     151           0 :     bool B2DPolyRange::overlaps( const B2DRange& rRange ) const
     152             :     {
     153           0 :         return mpImpl->overlaps(rRange);
     154             :     }
     155             : 
     156         468 :     B2DPolyPolygon B2DPolyRange::solveCrossovers() const
     157             :     {
     158         468 :         return mpImpl->solveCrossovers();
     159             :     }
     160        2568 : } // end of namespace basegfx
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10