LCOV - code coverage report
Current view: top level - include/basegfx/range - b3drange.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 49 70 70.0 %
Date: 2014-04-11 Functions: 17 22 77.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             : #ifndef INCLUDED_BASEGFX_RANGE_B3DRANGE_HXX
      21             : #define INCLUDED_BASEGFX_RANGE_B3DRANGE_HXX
      22             : 
      23             : #include <basegfx/vector/b3dvector.hxx>
      24             : #include <basegfx/point/b3dpoint.hxx>
      25             : #include <basegfx/tuple/b3dtuple.hxx>
      26             : #include <basegfx/range/basicrange.hxx>
      27             : #include <basegfx/basegfxdllapi.h>
      28             : 
      29             : namespace basegfx
      30             : {
      31             :     // predeclarations
      32             :     class B3IRange;
      33             :     class B3DHomMatrix;
      34             : 
      35             :     class B3DRange
      36             :     {
      37             :         typedef ::basegfx::BasicRange< double, DoubleTraits >   MyBasicRange;
      38             : 
      39             :         MyBasicRange            maRangeX;
      40             :         MyBasicRange            maRangeY;
      41             :         MyBasicRange            maRangeZ;
      42             : 
      43             :     public:
      44      156309 :         B3DRange() {}
      45             : 
      46         204 :         explicit B3DRange(const B3DTuple& rTuple)
      47             :         :   maRangeX(rTuple.getX()),
      48             :             maRangeY(rTuple.getY()),
      49         204 :             maRangeZ(rTuple.getZ())
      50             :         {
      51         204 :         }
      52             : 
      53           0 :         B3DRange(double x1,
      54             :                  double y1,
      55             :                  double z1,
      56             :                  double x2,
      57             :                  double y2,
      58             :                  double z2)
      59             :         :   maRangeX(x1),
      60             :             maRangeY(y1),
      61           0 :             maRangeZ(z1)
      62             :         {
      63           0 :             maRangeX.expand(x2);
      64           0 :             maRangeY.expand(y2);
      65           0 :             maRangeZ.expand(z2);
      66           0 :         }
      67             : 
      68           0 :         B3DRange(const B3DTuple& rTuple1,
      69             :                  const B3DTuple& rTuple2)
      70             :         :   maRangeX(rTuple1.getX()),
      71             :             maRangeY(rTuple1.getY()),
      72           0 :             maRangeZ(rTuple1.getZ())
      73             :         {
      74           0 :             expand(rTuple2);
      75           0 :         }
      76             : 
      77        6330 :         bool isEmpty() const
      78             :         {
      79             :             return (
      80        6330 :                 maRangeX.isEmpty()
      81        6086 :                 || maRangeY.isEmpty()
      82       12416 :                 || maRangeZ.isEmpty()
      83        6330 :                 );
      84             :         }
      85             : 
      86       22201 :         void reset()
      87             :         {
      88       22201 :             maRangeX.reset();
      89       22201 :             maRangeY.reset();
      90       22201 :             maRangeZ.reset();
      91       22201 :         }
      92             : 
      93           0 :         bool operator==( const B3DRange& rRange ) const
      94             :         {
      95           0 :             return (maRangeX == rRange.maRangeX
      96           0 :                 && maRangeY == rRange.maRangeY
      97           0 :                 && maRangeZ == rRange.maRangeZ);
      98             :         }
      99             : 
     100             :         bool operator!=( const B3DRange& rRange ) const
     101             :         {
     102             :             return (maRangeX != rRange.maRangeX
     103             :                 || maRangeY != rRange.maRangeY
     104             :                 || maRangeZ != rRange.maRangeZ);
     105             :         }
     106             : 
     107             :         bool equal(const B3DRange& rRange) const
     108             :         {
     109             :             return (maRangeX.equal(rRange.maRangeX)
     110             :                     && maRangeY.equal(rRange.maRangeY)
     111             :                     && maRangeZ.equal(rRange.maRangeZ));
     112             :         }
     113             : 
     114       51742 :         double getMinX() const
     115             :         {
     116       51742 :             return maRangeX.getMinimum();
     117             :         }
     118             : 
     119       50830 :         double getMinY() const
     120             :         {
     121       50830 :             return maRangeY.getMinimum();
     122             :         }
     123             : 
     124       11321 :         double getMinZ() const
     125             :         {
     126       11321 :             return maRangeZ.getMinimum();
     127             :         }
     128             : 
     129       49744 :         double getMaxX() const
     130             :         {
     131       49744 :             return maRangeX.getMaximum();
     132             :         }
     133             : 
     134       49744 :         double getMaxY() const
     135             :         {
     136       49744 :             return maRangeY.getMaximum();
     137             :         }
     138             : 
     139       11311 :         double getMaxZ() const
     140             :         {
     141       11311 :             return maRangeZ.getMaximum();
     142             :         }
     143             : 
     144        2102 :         double getWidth() const
     145             :         {
     146        2102 :             return maRangeX.getRange();
     147             :         }
     148             : 
     149        1790 :         double getHeight() const
     150             :         {
     151        1790 :             return maRangeY.getRange();
     152             :         }
     153             : 
     154         554 :         double getDepth() const
     155             :         {
     156         554 :             return maRangeZ.getRange();
     157             :         }
     158             : 
     159             :         B3DPoint getMinimum() const
     160             :         {
     161             :             return B3DPoint(
     162             :                 maRangeX.getMinimum(),
     163             :                 maRangeY.getMinimum(),
     164             :                 maRangeZ.getMinimum()
     165             :                 );
     166             :         }
     167             : 
     168             :         B3DPoint getMaximum() const
     169             :         {
     170             :             return B3DPoint(
     171             :                 maRangeX.getMaximum(),
     172             :                 maRangeY.getMaximum(),
     173             :                 maRangeZ.getMaximum()
     174             :                 );
     175             :         }
     176             : 
     177           0 :         B3DVector getRange() const
     178             :         {
     179             :             return B3DVector(
     180             :                 maRangeX.getRange(),
     181             :                 maRangeY.getRange(),
     182             :                 maRangeZ.getRange()
     183           0 :                 );
     184             :         }
     185             : 
     186        3221 :         B3DPoint getCenter() const
     187             :         {
     188             :             return B3DPoint(
     189             :                 maRangeX.getCenter(),
     190             :                 maRangeY.getCenter(),
     191             :                 maRangeZ.getCenter()
     192        3221 :                 );
     193             :         }
     194             : 
     195             :         double getCenterX() const
     196             :         {
     197             :             return maRangeX.getCenter();
     198             :         }
     199             : 
     200             :         double getCenterY() const
     201             :         {
     202             :             return maRangeY.getCenter();
     203             :         }
     204             : 
     205             :         double getCenterZ() const
     206             :         {
     207             :             return maRangeZ.getCenter();
     208             :         }
     209             : 
     210             :         bool isInside(const B3DTuple& rTuple) const
     211             :         {
     212             :             return (
     213             :                 maRangeX.isInside(rTuple.getX())
     214             :                 && maRangeY.isInside(rTuple.getY())
     215             :                 && maRangeZ.isInside(rTuple.getZ())
     216             :                 );
     217             :         }
     218             : 
     219             :         bool isInside(const B3DRange& rRange) const
     220             :         {
     221             :             return (
     222             :                 maRangeX.isInside(rRange.maRangeX)
     223             :                 && maRangeY.isInside(rRange.maRangeY)
     224             :                 && maRangeZ.isInside(rRange.maRangeZ)
     225             :                 );
     226             :         }
     227             : 
     228           0 :         bool overlaps(const B3DRange& rRange) const
     229             :         {
     230             :             return (
     231           0 :                 maRangeX.overlaps(rRange.maRangeX)
     232           0 :                 && maRangeY.overlaps(rRange.maRangeY)
     233           0 :                 && maRangeZ.overlaps(rRange.maRangeZ)
     234           0 :                 );
     235             :         }
     236             : 
     237      282524 :         void expand(const B3DTuple& rTuple)
     238             :         {
     239      282524 :             maRangeX.expand(rTuple.getX());
     240      282524 :             maRangeY.expand(rTuple.getY());
     241      282524 :             maRangeZ.expand(rTuple.getZ());
     242      282524 :         }
     243             : 
     244      110098 :         void expand(const B3DRange& rRange)
     245             :         {
     246      110098 :             maRangeX.expand(rRange.maRangeX);
     247      110098 :             maRangeY.expand(rRange.maRangeY);
     248      110098 :             maRangeZ.expand(rRange.maRangeZ);
     249      110098 :         }
     250             : 
     251             :         void intersect(const B3DRange& rRange)
     252             :         {
     253             :             maRangeX.intersect(rRange.maRangeX);
     254             :             maRangeY.intersect(rRange.maRangeY);
     255             :             maRangeZ.intersect(rRange.maRangeZ);
     256             :         }
     257             : 
     258         590 :         void grow(double fValue)
     259             :         {
     260         590 :             maRangeX.grow(fValue);
     261         590 :             maRangeY.grow(fValue);
     262         590 :             maRangeZ.grow(fValue);
     263         590 :         }
     264             : 
     265             :          BASEGFX_DLLPUBLIC void transform(const B3DHomMatrix& rMatrix);
     266             :     };
     267             : 
     268             : } // end of namespace basegfx
     269             : 
     270             : 
     271             : #endif // INCLUDED_BASEGFX_RANGE_B3DRANGE_HXX
     272             : 
     273             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10