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

Generated by: LCOV version 1.10