LCOV - code coverage report
Current view: top level - basegfx/inc/basegfx/range - b3drange.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 37 47 78.7 %
Date: 2012-08-25 Functions: 13 16 81.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 6 66.7 %

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

Generated by: LCOV version 1.10