LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/basegfx/range - b1drange.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 27 85.2 %
Date: 2012-08-25 Functions: 10 12 83.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _BGFX_RANGE_B1DRANGE_HXX
      30                 :            : #define _BGFX_RANGE_B1DRANGE_HXX
      31                 :            : 
      32                 :            : #include <basegfx/range/basicrange.hxx>
      33                 :            : #include <basegfx/basegfxdllapi.h>
      34                 :            : 
      35                 :            : 
      36                 :            : namespace basegfx
      37                 :            : {
      38                 :            :     class B1IRange;
      39                 :            : 
      40                 :            :     /** A one-dimensional interval over doubles
      41                 :            : 
      42                 :            :         This is a set of real numbers, bounded by a lower and an upper
      43                 :            :         value. All inbetween values are included in the set (see also
      44                 :            :         http://en.wikipedia.org/wiki/Interval_%28mathematics%29).
      45                 :            : 
      46                 :            :         The set is closed, i.e. the upper and the lower bound are
      47                 :            :         included (if you're used to the notation - we're talking about
      48                 :            :         [a,b] here, compared to half-open [a,b) or open intervals
      49                 :            :         (a,b)).
      50                 :            : 
      51                 :            :         That means, isInside(val) will return true also for values of
      52                 :            :         val=a or val=b.
      53                 :            :      */
      54                 :            :     class B1DRange
      55                 :            :     {
      56                 :            :         ::basegfx::BasicRange< double, DoubleTraits >   maRange;
      57                 :            : 
      58                 :            :     public:
      59                 :          5 :         B1DRange() {}
      60                 :            : 
      61                 :            :         /// Create degenerate interval consisting of a single double number
      62                 :            :         explicit B1DRange(double fStartValue)
      63                 :            :         :   maRange(fStartValue)
      64                 :            :         {
      65                 :            :         }
      66                 :            : 
      67                 :            :         /// Create proper interval between the two given double values
      68                 :         20 :         B1DRange(double fStartValue1, double fStartValue2)
      69                 :         20 :         :   maRange(fStartValue1)
      70                 :            :         {
      71                 :         20 :             expand(fStartValue2);
      72                 :         20 :         }
      73                 :            : 
      74                 :            :         /** Check if the interval set is empty
      75                 :            : 
      76                 :            :             @return false, if no value is in this set - having a
      77                 :            :             single value included will already return true.
      78                 :            :          */
      79                 :         20 :         bool isEmpty() const
      80                 :            :         {
      81                 :         20 :             return maRange.isEmpty();
      82                 :            :         }
      83                 :            : 
      84                 :            :         /// reset the object to empty state again, clearing all values
      85                 :            :         void reset()
      86                 :            :         {
      87                 :            :             maRange.reset();
      88                 :            :         }
      89                 :            : 
      90                 :            :         bool operator==( const B1DRange& rRange ) const
      91                 :            :         {
      92                 :            :             return (maRange == rRange.maRange);
      93                 :            :         }
      94                 :            : 
      95                 :          0 :         bool operator!=( const B1DRange& rRange ) const
      96                 :            :         {
      97                 :          0 :             return (maRange != rRange.maRange);
      98                 :            :         }
      99                 :            : 
     100                 :            :         bool equal(const B1DRange& rRange) const
     101                 :            :         {
     102                 :            :             return (maRange.equal(rRange.maRange));
     103                 :            :         }
     104                 :            : 
     105                 :            :         /// get lower bound of the set. returns arbitrary values for empty sets.
     106                 :          0 :         double getMinimum() const
     107                 :            :         {
     108                 :          0 :             return maRange.getMinimum();
     109                 :            :         }
     110                 :            : 
     111                 :            :         /// get upper bound of the set. returns arbitrary values for empty sets.
     112                 :            :         double getMaximum() const
     113                 :            :         {
     114                 :            :             return maRange.getMaximum();
     115                 :            :         }
     116                 :            : 
     117                 :            :         /// return difference between upper and lower value. returns 0 for empty sets.
     118                 :         10 :         double getRange() const
     119                 :            :         {
     120                 :         10 :             return maRange.getRange();
     121                 :            :         }
     122                 :            : 
     123                 :            :         /// return middle of upper and lower value. returns 0 for empty sets.
     124                 :         15 :         double getCenter() const
     125                 :            :         {
     126                 :         15 :             return maRange.getCenter();
     127                 :            :         }
     128                 :            : 
     129                 :            :         /// yields true if value is contained in set
     130                 :         15 :         bool isInside(double fValue) const
     131                 :            :         {
     132                 :         15 :             return maRange.isInside(fValue);
     133                 :            :         }
     134                 :            : 
     135                 :            :         /// yields true if rRange is inside, or equal to set
     136                 :            :         bool isInside(const B1DRange& rRange) const
     137                 :            :         {
     138                 :            :             return maRange.isInside(rRange.maRange);
     139                 :            :         }
     140                 :            : 
     141                 :            :         /// yields true if rRange at least partly inside set
     142                 :          5 :         bool overlaps(const B1DRange& rRange) const
     143                 :            :         {
     144                 :          5 :             return maRange.overlaps(rRange.maRange);
     145                 :            :         }
     146                 :            : 
     147                 :            :         /// yields true if overlaps(rRange) does, and the overlap is larger than infinitesimal
     148                 :         10 :         bool overlapsMore(const B1DRange& rRange) const
     149                 :            :         {
     150                 :         10 :             return maRange.overlapsMore(rRange.maRange);
     151                 :            :         }
     152                 :            : 
     153                 :            :         /// add fValue to the set, expanding as necessary
     154                 :         35 :         void expand(double fValue)
     155                 :            :         {
     156                 :         35 :             maRange.expand(fValue);
     157                 :         35 :         }
     158                 :            : 
     159                 :            :         /// add rRange to the set, expanding as necessary
     160                 :            :         void expand(const B1DRange& rRange)
     161                 :            :         {
     162                 :            :             maRange.expand(rRange.maRange);
     163                 :            :         }
     164                 :            : 
     165                 :            :         /// calc set intersection
     166                 :         10 :         void intersect(const B1DRange& rRange)
     167                 :            :         {
     168                 :         10 :             maRange.intersect(rRange.maRange);
     169                 :         10 :         }
     170                 :            : 
     171                 :            :         /// grow set by fValue on both sides
     172                 :            :         void grow(double fValue)
     173                 :            :         {
     174                 :            :             maRange.grow(fValue);
     175                 :            :         }
     176                 :            :     };
     177                 :            : 
     178                 :            : } // end of namespace basegfx
     179                 :            : 
     180                 :            : 
     181                 :            : #endif /* _BGFX_RANGE_B1DRANGE_HXX */
     182                 :            : 
     183                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10