Added == and != operators to ranges, some other goodies, too. Also changed remaining sal_Bool to bool. Renamed B(2|3)(d|i)box to ...volume.

This commit is contained in:
Armin Weiss 2004-01-16 13:30:10 +00:00
parent c794c5ce7e
commit 99a300e39a
14 changed files with 251 additions and 30 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b2dpoint.hxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: thb $ $Date: 2004-01-16 10:33:55 $
* last change: $Author: aw $ $Date: 2004-01-16 14:29:59 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -158,6 +158,17 @@ namespace basegfx
return (const B2DPoint&) ::basegfx::B2DTuple::getEmptyTuple();
}
};
// external operators
//////////////////////////////////////////////////////////////////////////
/** Transform B2DPoint by given transformation matrix.
Since this is a Point, translational components of the
matrix are used.
*/
B2DPoint operator*( const B2DHomMatrix& rMat, const B2DPoint& rPoint );
} // end of namespace basegfx
#endif // _BGFX_POINT_B2DPOINT_HXX

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b1drange.hxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: thb $ $Date: 2004-01-16 13:40:16 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:00 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -104,6 +104,16 @@ namespace basegfx
maRange.reset();
}
bool operator==( const B1DRange& rRange ) const
{
return (maRange == rRange.maRange);
}
bool operator!=( const B1DRange& rRange ) const
{
return (maRange != rRange.maRange);
}
void operator=(const B1DRange& rRange)
{
maRange = rRange.maRange;
@ -153,6 +163,11 @@ namespace basegfx
{
maRange.expand(rRange.maRange);
}
void grow(double fValue)
{
maRange.grow(fValue);
}
};
} // end of namespace basegfx

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b1irange.hxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: thb $ $Date: 2004-01-15 19:57:00 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -98,6 +98,16 @@ namespace basegfx
maRange.reset();
}
bool operator==( const B1IRange& rRange ) const
{
return (maRange == rRange.maRange);
}
bool operator!=( const B1IRange& rRange ) const
{
return (maRange != rRange.maRange);
}
void operator=(const B1IRange& rRange)
{
maRange = rRange.maRange;

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b2drange.hxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: thb $ $Date: 2004-01-16 13:40:18 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -129,6 +129,18 @@ namespace basegfx
maRangeY.reset();
}
bool operator==( const B2DRange& rRange ) const
{
return (maRangeX == rRange.maRangeX
&& maRangeY == rRange.maRangeY);
}
bool operator!=( const B2DRange& rRange ) const
{
return (maRangeX != rRange.maRangeX
|| maRangeY != rRange.maRangeY);
}
void operator=(const B2DRange& rRange)
{
maRangeX = rRange.maRangeX;
@ -232,6 +244,12 @@ namespace basegfx
maRangeX.expand(rRange.maRangeX);
maRangeY.expand(rRange.maRangeY);
}
void grow(double fValue)
{
maRangeX.grow(fValue);
maRangeY.grow(fValue);
}
};
} // end of namespace basegfx

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b2irange.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: thb $ $Date: 2004-01-16 13:40:21 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -129,6 +129,18 @@ namespace basegfx
maRangeY.reset();
}
bool operator==( const B2IRange& rRange ) const
{
return (maRangeX == rRange.maRangeX
&& maRangeY == rRange.maRangeY);
}
bool operator!=( const B2IRange& rRange ) const
{
return (maRangeX != rRange.maRangeX
|| maRangeY != rRange.maRangeY);
}
void operator=(const B2IRange& rRange)
{
maRangeX = rRange.maRangeX;

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b3drange.hxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: thb $ $Date: 2004-01-16 13:40:23 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -147,6 +147,20 @@ namespace basegfx
maRangeZ.reset();
}
bool operator==( const B3DRange& rRange ) const
{
return (maRangeX == rRange.maRangeX
&& maRangeY == rRange.maRangeY
&& maRangeZ == rRange.maRangeZ);
}
bool operator!=( const B3DRange& rRange ) const
{
return (maRangeX != rRange.maRangeX
|| maRangeY != rRange.maRangeY
|| maRangeZ != rRange.maRangeZ);
}
void operator=(const B3DRange& rRange)
{
maRangeX = rRange.maRangeX;
@ -275,6 +289,13 @@ namespace basegfx
maRangeY.expand(rRange.maRangeY);
maRangeZ.expand(rRange.maRangeZ);
}
void grow(double fValue)
{
maRangeX.grow(fValue);
maRangeY.grow(fValue);
maRangeZ.grow(fValue);
}
};
} // end of namespace basegfx

View file

@ -0,0 +1,78 @@
/*************************************************************************
*
* $RCSfile: b3dvolume.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: aw $ $Date: 2004-01-16 14:30:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BGFX_RANGE_B3DBOX_HXX
#define _BGFX_RANGE_B3DBOX_HXX
#ifndef _BGFX_RANGE_B3DRANGE_HXX
#include <basegfx/range/b3drange.hxx>
#endif
namespace basegfx
{
// syntactic sugar: a B3DRange exactly models a Volume in 3D, thus,
// for interface clarity, we provide an alias name
/// Alias name for interface clarity (not everybody is aware of the identity)
typedef B3DRange B3DVolume;
}
#endif // _BGFX_RANGE_B3DBOX_HXX

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b3irange.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: thb $ $Date: 2004-01-16 13:40:26 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -146,6 +146,20 @@ namespace basegfx
maRangeZ.reset();
}
bool operator==( const B3IRange& rRange ) const
{
return (maRangeX == rRange.maRangeX
&& maRangeY == rRange.maRangeY
&& maRangeZ == rRange.maRangeZ);
}
bool operator!=( const B3IRange& rRange ) const
{
return (maRangeX != rRange.maRangeX
|| maRangeY != rRange.maRangeY
|| maRangeZ != rRange.maRangeZ);
}
void operator=(const B3IRange& rRange)
{
maRangeX = rRange.maRangeX;

View file

@ -1,10 +1,10 @@
/*************************************************************************
*
* $RCSfile: b3ibox.hxx,v $
* $RCSfile: b3ivolume.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: thb $ $Date: 2004-01-15 19:58:01 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses

View file

@ -2,9 +2,9 @@
*
* $RCSfile: basicrange.hxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: thb $ $Date: 2004-01-16 10:34:10 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -132,6 +132,16 @@ namespace basegfx
return !((rRange.mnMinimum < mnMinimum) || (rRange.mnMaximum > mnMaximum));
}
bool operator==( const BasicRange& rRange ) const
{
return (mnMinimum == rRange.mnMinimum && mnMaximum == rRange.mnMaximum);
}
bool operator!=( const BasicRange& rRange ) const
{
return (mnMinimum != rRange.mnMinimum || mnMaximum != rRange.mnMaximum);
}
void operator=(const BasicRange& rRange)
{
mnMinimum = rRange.mnMinimum;
@ -164,11 +174,31 @@ namespace basegfx
}
}
void grow(T nValue)
{
bool bLessThanZero(nValue < 0);
if(nValue > 0 || bLessThanZero)
{
mnMinimum -= nValue;
mnMaximum += nValue;
if(bLessThanZero)
{
// test if range did collapse
if(mnMinimum > mnMaximum)
{
// if yes, collapse to center
mnMinimum = mnMaximum = (mnMinimum + mnMaximum) / 2.0;
}
}
}
}
typename Traits::DifferenceType getRange() const
{
return (mnMaximum - mnMinimum);
}
};
// some pre-fabricated traits

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b2dpoint.cxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: aw $ $Date: 2003-11-28 11:18:04 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -89,6 +89,12 @@ namespace basegfx
return *this;
}
B2DPoint operator*( const ::basegfx::B2DHomMatrix& rMat, const B2DPoint& rPoint )
{
B2DPoint aRes( rPoint );
return aRes *= rMat;
}
} // end of namespace basegfx
// eof

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b3dpoint.cxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: aw $ $Date: 2003-11-28 11:18:04 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -89,6 +89,12 @@ namespace basegfx
return *this;
}
B3DPoint operator*( const ::basegfx::B3DHomMatrix& rMat, const B3DPoint& rPoint )
{
B3DPoint aRes( rPoint );
return aRes *= rMat;
}
} // end of namespace basegfx
// eof

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b2dvector.cxx,v $
*
* $Revision: 1.9 $
* $Revision: 1.10 $
*
* last change: $Author: thb $ $Date: 2004-01-16 10:34:37 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -199,7 +199,7 @@ namespace basegfx
return aPerpendicular;
}
B2DVector operator*( const B2DHomMatrix& rMat, const B2DVector& rVec )
B2DVector operator*( const ::basegfx::B2DHomMatrix& rMat, const B2DVector& rVec )
{
B2DVector aRes( rVec );
return aRes*=rMat;

View file

@ -2,9 +2,9 @@
*
* $RCSfile: b3dvector.cxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: aw $ $Date: 2003-11-28 11:18:16 $
* last change: $Author: aw $ $Date: 2004-01-16 14:30:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -114,7 +114,7 @@ namespace basegfx
return aNew;
}
B3DVector& B3DVector::operator*=( const B3DHomMatrix& rMat )
B3DVector& B3DVector::operator*=( const ::basegfx::B3DHomMatrix& rMat )
{
const double fTempX( rMat.get(0,0)*mfX + rMat.get(0,1)*mfY + rMat.get(0,2)*mfZ );
const double fTempY( rMat.get(1,0)*mfX + rMat.get(1,1)*mfY + rMat.get(1,2)*mfZ );
@ -126,7 +126,7 @@ namespace basegfx
return *this;
}
B3DVector operator*( const B3DHomMatrix& rMat, const B3DVector& rVec )
B3DVector operator*( const ::basegfx::B3DHomMatrix& rMat, const B3DVector& rVec )
{
B3DVector aRes( rVec );
return aRes*=rMat;