xref: /aoo41x/main/basegfx/source/range/b3drange.cxx (revision 09dbbe93)
1*09dbbe93SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*09dbbe93SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*09dbbe93SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*09dbbe93SAndrew Rist  * distributed with this work for additional information
6*09dbbe93SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*09dbbe93SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*09dbbe93SAndrew Rist  * "License"); you may not use this file except in compliance
9*09dbbe93SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*09dbbe93SAndrew Rist  *
11*09dbbe93SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*09dbbe93SAndrew Rist  *
13*09dbbe93SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*09dbbe93SAndrew Rist  * software distributed under the License is distributed on an
15*09dbbe93SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*09dbbe93SAndrew Rist  * KIND, either express or implied.  See the License for the
17*09dbbe93SAndrew Rist  * specific language governing permissions and limitations
18*09dbbe93SAndrew Rist  * under the License.
19*09dbbe93SAndrew Rist  *
20*09dbbe93SAndrew Rist  *************************************************************/
21*09dbbe93SAndrew Rist 
22*09dbbe93SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_basegfx.hxx"
26cdf0e10cSrcweir #include <basegfx/range/b3drange.hxx>
27cdf0e10cSrcweir #include <basegfx/range/b3irange.hxx>
28cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
29cdf0e10cSrcweir #include <basegfx/matrix/b3dhommatrix.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir namespace basegfx
32cdf0e10cSrcweir {
B3DRange(const B3IRange & rRange)33cdf0e10cSrcweir 	B3DRange::B3DRange(const B3IRange& rRange) :
34cdf0e10cSrcweir         maRangeX(),
35cdf0e10cSrcweir         maRangeY(),
36cdf0e10cSrcweir         maRangeZ()
37cdf0e10cSrcweir     {
38cdf0e10cSrcweir         if( !rRange.isEmpty() )
39cdf0e10cSrcweir         {
40cdf0e10cSrcweir             maRangeX = rRange.getMinX();
41cdf0e10cSrcweir             maRangeY = rRange.getMinY();
42cdf0e10cSrcweir             maRangeZ = rRange.getMinZ();
43cdf0e10cSrcweir 
44cdf0e10cSrcweir             maRangeX.expand( rRange.getMaxX() );
45cdf0e10cSrcweir             maRangeY.expand( rRange.getMaxY() );
46cdf0e10cSrcweir             maRangeZ.expand( rRange.getMaxZ() );
47cdf0e10cSrcweir         }
48cdf0e10cSrcweir     }
49cdf0e10cSrcweir 
transform(const B3DHomMatrix & rMatrix)50cdf0e10cSrcweir 	void B3DRange::transform(const B3DHomMatrix& rMatrix)
51cdf0e10cSrcweir 	{
52cdf0e10cSrcweir 		if(!isEmpty() && !rMatrix.isIdentity())
53cdf0e10cSrcweir 		{
54cdf0e10cSrcweir 			const B3DRange aSource(*this);
55cdf0e10cSrcweir 			reset();
56cdf0e10cSrcweir 			expand(rMatrix * B3DPoint(aSource.getMinX(), aSource.getMinY(), aSource.getMinZ()));
57cdf0e10cSrcweir 			expand(rMatrix * B3DPoint(aSource.getMaxX(), aSource.getMinY(), aSource.getMinZ()));
58cdf0e10cSrcweir 			expand(rMatrix * B3DPoint(aSource.getMinX(), aSource.getMaxY(), aSource.getMinZ()));
59cdf0e10cSrcweir 			expand(rMatrix * B3DPoint(aSource.getMaxX(), aSource.getMaxY(), aSource.getMinZ()));
60cdf0e10cSrcweir 			expand(rMatrix * B3DPoint(aSource.getMinX(), aSource.getMinY(), aSource.getMaxZ()));
61cdf0e10cSrcweir 			expand(rMatrix * B3DPoint(aSource.getMaxX(), aSource.getMinY(), aSource.getMaxZ()));
62cdf0e10cSrcweir 			expand(rMatrix * B3DPoint(aSource.getMinX(), aSource.getMaxY(), aSource.getMaxZ()));
63cdf0e10cSrcweir 			expand(rMatrix * B3DPoint(aSource.getMaxX(), aSource.getMaxY(), aSource.getMaxZ()));
64cdf0e10cSrcweir 		}
65cdf0e10cSrcweir 	}
66cdf0e10cSrcweir 
fround(const B3DRange & rRange)67cdf0e10cSrcweir 	B3IRange fround(const B3DRange& rRange )
68cdf0e10cSrcweir 	{
69cdf0e10cSrcweir 		return rRange.isEmpty() ?
70cdf0e10cSrcweir             B3IRange() :
71cdf0e10cSrcweir             B3IRange(fround(rRange.getMinX()),
72cdf0e10cSrcweir                      fround(rRange.getMinY()),
73cdf0e10cSrcweir                      fround(rRange.getMinZ()),
74cdf0e10cSrcweir                      fround(rRange.getMaxX()),
75cdf0e10cSrcweir                      fround(rRange.getMaxY()),
76cdf0e10cSrcweir                      fround(rRange.getMaxZ()));
77cdf0e10cSrcweir 	}
78cdf0e10cSrcweir 
79cdf0e10cSrcweir } // end of namespace basegfx
80cdf0e10cSrcweir 
81cdf0e10cSrcweir // eof
82