xref: /aoo42x/main/basegfx/source/tuple/b2dtuple.cxx (revision 09dbbe93)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_basegfx.hxx"
26 #include <basegfx/tuple/b2dtuple.hxx>
27 #include <basegfx/numeric/ftools.hxx>
28 #include <rtl/instance.hxx>
29 
30 namespace { struct EmptyTuple : public rtl::Static<basegfx::B2DTuple, EmptyTuple> {}; }
31 #include <basegfx/tuple/b2ituple.hxx>
32 
33 namespace basegfx
34 {
getEmptyTuple()35     const B2DTuple& B2DTuple::getEmptyTuple()
36     {
37         return EmptyTuple::get();
38     }
39 
B2DTuple(const B2ITuple & rTup)40 	B2DTuple::B2DTuple(const B2ITuple& rTup)
41 	:	mfX( rTup.getX() ),
42 		mfY( rTup.getY() )
43 	{}
44 
correctValues(const double fCompareValue)45 	void B2DTuple::correctValues(const double fCompareValue)
46 	{
47 		if(0.0 == fCompareValue)
48 		{
49 			if(::basegfx::fTools::equalZero(mfX))
50 			{
51 				mfX = 0.0;
52 			}
53 
54 			if(::basegfx::fTools::equalZero(mfY))
55 			{
56 				mfY = 0.0;
57 			}
58 		}
59 		else
60 		{
61 			if(::basegfx::fTools::equal(mfX, fCompareValue))
62 			{
63 				mfX = fCompareValue;
64 			}
65 
66 			if(::basegfx::fTools::equal(mfY, fCompareValue))
67 			{
68 				mfY = fCompareValue;
69 			}
70 		}
71 	}
72 
fround(const B2DTuple & rTup)73 	B2ITuple fround(const B2DTuple& rTup)
74 	{
75 		return B2ITuple(fround(rTup.getX()), fround(rTup.getY()));
76 	}
77 
78 } // end of namespace basegfx
79 
80 // eof
81