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 : : #include "cppunit/TestAssert.h"
30 : : #include "cppunit/TestFixture.h"
31 : : #include "cppunit/extensions/HelperMacros.h"
32 : :
33 : : #include <basegfx/matrix/b2dhommatrix.hxx>
34 : : #include <basegfx/matrix/b2dhommatrixtools.hxx>
35 : : #include <basegfx/polygon/b2dpolygon.hxx>
36 : : #include <basegfx/polygon/b2dpolygontools.hxx>
37 : : #include <basegfx/curve/b2dcubicbezier.hxx>
38 : : #include <basegfx/curve/b2dbeziertools.hxx>
39 : : #include <basegfx/polygon/b2dpolypolygontools.hxx>
40 : : #include <basegfx/polygon/b2dpolygonclipper.hxx>
41 : : #include <basegfx/polygon/b2dpolypolygon.hxx>
42 : : #include <basegfx/range/b2irange.hxx>
43 : : #include <basegfx/range/b2ibox.hxx>
44 : : #include <basegfx/range/b1drange.hxx>
45 : : #include <basegfx/range/b1irange.hxx>
46 : : #include <basegfx/range/b1ibox.hxx>
47 : : #include <basegfx/range/b2drange.hxx>
48 : : #include <basegfx/range/b2dpolyrange.hxx>
49 : : #include <basegfx/numeric/ftools.hxx>
50 : : #include <basegfx/color/bcolor.hxx>
51 : : #include <basegfx/color/bcolortools.hxx>
52 : :
53 : : #include <basegfx/tools/rectcliptools.hxx>
54 : :
55 : : #include <iostream>
56 : : #include <fstream>
57 : :
58 : : using namespace ::basegfx;
59 : :
60 : :
61 : : namespace basegfx2d
62 : : {
63 : :
64 [ - + ]: 15 : class b2dsvgdimpex : public CppUnit::TestFixture
65 : : {
66 : : private:
67 : : ::rtl::OUString aPath0;
68 : : ::rtl::OUString aPath1;
69 : : ::rtl::OUString aPath2;
70 : : ::rtl::OUString aPath3;
71 : :
72 : : public:
73 : : // initialise your test code values here.
74 : 5 : void setUp()
75 : : {
76 : : // simple rectangle
77 : : aPath0 = ::rtl::OUString(
78 : 5 : "M 10 10-10 10-10-10 10-10Z" );
79 : :
80 : : // simple bezier polygon
81 : : aPath1 = ::rtl::OUString(
82 : : "m11430 0c-8890 3810 5715 6985 5715 6985 "
83 : : "0 0-17145-1905-17145-1905 0 0 22860-10160 "
84 : 5 : "16510 6350-6350 16510-3810-11430-3810-11430z" );
85 : :
86 : : // '@' as a bezier polygon
87 : : aPath2 = ::rtl::OUString(
88 : : "m1917 1114c-89-189-233-284-430-284-167 "
89 : : "0-306 91-419 273-113 182-170 370-170 564 "
90 : : "0 145 33 259 98 342 65 84 150 126 257 126 "
91 : : "77 0 154-19 231-57 77-38 147-97 210-176 63"
92 : : "-79 99-143 109-190 38-199 76-398 114-598z"
93 : : "m840 1646c-133 73-312 139-537 197-225 57"
94 : : "-440 86-644 87-483-1-866-132-1150-392-284"
95 : : "-261-426-619-426-1076 0-292 67-560 200-803 "
96 : : "133-243 321-433 562-569 241-136 514-204 821"
97 : : "-204 405 0 739 125 1003 374 264 250 396 550 "
98 : : "396 899 0 313-88 576-265 787-177 212-386 318"
99 : : "-627 318-191 0-308-94-352-281-133 187-315 281"
100 : : "-546 281-172 0-315-67-428-200-113-133-170-301"
101 : : "-170-505 0-277 90-527 271-751 181-223 394"
102 : : "-335 640-335 196 0 353 83 470 250 13-68 26"
103 : : "-136 41-204 96 0 192 0 288 0-74 376-148 752"
104 : : "-224 1128-21 101-31 183-31 245 0 39 9 70 26 "
105 : : "93 17 24 39 36 67 36 145 0 279-80 400-240 121"
106 : : "-160 182-365 182-615 0-288-107-533-322-734"
107 : : "-215-201-487-301-816-301-395 0-715 124-960 "
108 : : "373-245 249-368 569-368 958 0 385 119 685 "
109 : : "357 900 237 216 557 324 958 325 189-1 389-27 "
110 : 5 : "600-77 211-52 378-110 503-174 27 70 54 140 81 210z" );
111 : :
112 : : // first part of 'Hello World' as a line polygon
113 : : aPath3 = ::rtl::OUString(
114 : : "m1598 125h306v2334h-306v-1105h-1293v1105h-305v"
115 : : "-2334h305v973h1293zm2159 1015 78-44 85 235-91 "
116 : : "47-91 40-90 34-90 29-89 21-88 16-88 10-88 3-102"
117 : : "-4-97-12-91-19-85-26-40-16-39-18-38-20-36-22-34"
118 : : "-24-33-26-32-27-30-30-29-31-27-33-25-33-23-36-21"
119 : : "-36-19-38-18-40-16-40-26-86-18-91-11-97-4-103 3"
120 : : "-98 11-94 17-89 24-84 31-79 37-75 22-35 23-34 24"
121 : : "-33 27-32 28-30 29-28 31-27 31-24 33-22 34-21 35"
122 : : "-18 37-17 38-14 38-13 41-11 41-8 86-12 91-4 82 4 "
123 : : "78 10 37 9 37 9 36 12 35 14 33 15 33 17 32 19 31 "
124 : : "21 30 22 30 25 55 54 26 29 24 31 22 32 21 33 19 "
125 : : "34 18 36 30 74 23 80 17 84 10 89 3 94v78h-1277l6 "
126 : : "75 10 70 14 66 19 62 23 57 13 26 14 26 15 25 17 "
127 : : "23 17 22 19 21 19 20 21 18 21 18 23 16 23 14 24 "
128 : : "14 26 12 26 11 27 10 28 8 59 13 63 7 67 3 80-3 81"
129 : : "-9 79-14 80-21 78-26 79-32zm-1049-808-12 53h963l"
130 : : "-7-51-11-49-14-46-17-43-21-40-24-38-27-36-31-32"
131 : : "-33-29-35-25-37-22-38-17-40-14-41-9-42-6-44-2-48 "
132 : : "2-46 6-44 9-42 13-40 17-38 21-36 24-34 28-32 32"
133 : : "-29 34-26 38-23 41-20 44-17 47zm1648-1293h288v"
134 : : "2459h-288zm752-2459h288v2459h-288zm1286-1750 86-11 "
135 : : "91-4 91 4 85 12 42 8 39 11 39 13 38 14 36 17 35 18 "
136 : : "34 20 33 23 31 24 30 26 29 28 28 30 26 32 25 33 23 "
137 : : "34 21 35 37 75 31 80 24 84 16 90 11 94 3 100-3 100"
138 : : "-11 95-16 89-24 85-31 80-37 74-21 35-23 35-25 32-26 "
139 : : "32-28 30-29 28-30 26-31 24-33 22-34 21-35 18-36 17"
140 : : "-38 14-39 13-39 10-42 9-85 12-91 4-91-4-86-12-41-9"
141 : : "-40-10-39-13-37-14-36-17-35-18-34-21-33-22-31-24-30"
142 : : "-26-29-28-28-30-26-32-25-32-23-35-21-35-38-74-30-80"
143 : : "-24-85-17-89-11-95-3-100 3-101 11-95 17-90 24-85 30"
144 : : "-79 38-75 21-35 23-35 25-32 26-32 28-30 29-28 30-26 "
145 : 5 : "31-24 33-22 34-20 35-18 36-16 37-15 39-12 40-11z" );
146 : 5 : }
147 : :
148 : 5 : void tearDown()
149 : : {
150 : 5 : }
151 : :
152 : 5 : void impex()
153 : : {
154 [ + - ]: 5 : B2DPolyPolygon aPoly;
155 : 5 : ::rtl::OUString aExport;
156 : :
157 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("importing simple rectangle from SVG-D",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
158 : : tools::importFromSvgD( aPoly,
159 [ + - ]: 5 : aPath0 ));
160 [ + - ]: 5 : aExport = tools::exportToSvgD( aPoly );
161 : 5 : const char* sExportString = "m10 10h-20v-20h20z";
162 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("exporting rectangle to SVG-D",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
163 [ + - ]: 5 : !aExport.compareToAscii(sExportString) );
164 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("importing simple rectangle from SVG-D (round-trip",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
165 : : tools::importFromSvgD( aPoly,
166 [ + - ]: 5 : aExport ));
167 [ + - ]: 5 : aExport = tools::exportToSvgD( aPoly );
168 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("exporting rectangle to SVG-D (round-trip)",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
169 [ + - ]: 5 : !aExport.compareToAscii(sExportString));
170 : :
171 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("importing simple bezier polygon from SVG-D",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
172 : : tools::importFromSvgD( aPoly,
173 [ + - ]: 5 : aPath1 ));
174 [ + - ]: 5 : aExport = tools::exportToSvgD( aPoly );
175 : :
176 : : // Adaptions for B2DPolygon bezier change (see #i77162#):
177 : : //
178 : : // The import/export of aPath1 does not reproduce aExport again. This is
179 : : // correct since aPath1 contains a segment with non-used control points
180 : : // which gets exported now correctly as 'l' and also a point (#4, index 3)
181 : : // with C2 continuity which produces a 's' staement now.
182 : : //
183 : : // The old SVGexport identified nun-used ControlVectors erraneously as bezier segments
184 : : // because the 2nd vector at the start point was used, even when added
185 : : // with start point was identical to end point. Exactly for that reason
186 : : // i reworked the B2DPolygon to use prev, next control points.
187 : : //
188 : : // so for correct unit test i add the new exported string here as sExportStringSimpleBezier
189 : : // and compare to it.
190 : : const char* sExportStringSimpleBezier =
191 : : "m11430 0c-8890 3810 5715 6985 5715 6985"
192 : : "l-17145-1905c0 0 22860-10160 16510 6350"
193 : 5 : "s-3810-11430-3810-11430z";
194 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("exporting bezier polygon to SVG-D", !aExport.compareToAscii(sExportStringSimpleBezier));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
195 : :
196 : : // Adaptions for B2DPolygon bezier change (see #i77162#):
197 : : //
198 : : // a 2nd good test is that re-importing of aExport has to create the same
199 : : // B2DPolPolygon again:
200 [ + - ]: 5 : B2DPolyPolygon aReImport;
201 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("importing simple bezier polygon from SVG-D", tools::importFromSvgD( aReImport, aExport));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
202 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("re-imported polygon needs to be identical", aReImport == aPoly);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
203 : :
204 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("importing '@' from SVG-D", tools::importFromSvgD( aPoly, aPath2 ));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
205 [ + - ]: 5 : aExport = tools::exportToSvgD( aPoly );
206 : :
207 : : // Adaptions for B2DPolygon bezier change (see #i77162#):
208 : : //
209 : : // same here, the corrected export with the corrected B2DPolygon is simply more efficient,
210 : : // so i needed to change the compare string. Also adding the re-import comparison below.
211 : : const char* sExportString1 =
212 : : "m1917 1114c-89-189-233-284-430-284-167 0-306 91-419 273s-170 370-17"
213 : : "0 564c0 145 33 259 98 342 65 84 150 126 257 126q115.5 0 231-57s147-97 210-176 99-143 109-190c38-199 76-398 114"
214 : : "-598zm840 1646c-133 73-312 139-537 197-225 57-440 86-644 87-483-1-866-132-1150-392-284-261-426-619-426-1076 0-"
215 : : "292 67-560 200-803s321-433 562-569 514-204 821-204c405 0 739 125 1003 374 264 250 396 550 396 899 0 313-88 576"
216 : : "-265 787q-265.5 318-627 318c-191 0-308-94-352-281-133 187-315 281-546 281-172 0-315-67-428-200s-170-301-170-50"
217 : : "5c0-277 90-527 271-751 181-223 394-335 640-335 196 0 353 83 470 250 13-68 26-136 41-204q144 0 288 0c-74 376-14"
218 : : "8 752-224 1128-21 101-31 183-31 245 0 39 9 70 26 93 17 24 39 36 67 36 145 0 279-80 400-240s182-365 182-615c0-2"
219 : : "88-107-533-322-734s-487-301-816-301c-395 0-715 124-960 373s-368 569-368 958q0 577.5 357 900c237 216 557 324 95"
220 : 5 : "8 325 189-1 389-27 600-77 211-52 378-110 503-174q40.5 105 81 210z";
221 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("re-importing '@' from SVG-D", tools::importFromSvgD( aReImport, aExport));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
222 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("re-imported '@' needs to be identical", aReImport == aPoly);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
223 : :
224 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("exporting '@' to SVG-D", !aExport.compareToAscii(sExportString1));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
225 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("importing '@' from SVG-D (round-trip",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
226 : : tools::importFromSvgD( aPoly,
227 [ + - ]: 5 : aExport ));
228 [ + - ]: 5 : aExport = tools::exportToSvgD( aPoly );
229 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("exporting '@' to SVG-D (round-trip)",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
230 [ + - ]: 5 : !aExport.compareToAscii(sExportString1));
231 : :
232 : :
233 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("importing complex polygon from SVG-D",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
234 : : tools::importFromSvgD( aPoly,
235 [ + - ]: 5 : aPath3 ));
236 [ + - ]: 5 : aExport = tools::exportToSvgD( aPoly );
237 : : const char* sExportString2 =
238 : : "m1598 125h306v2334h-306v-1105h-1293v1105h-305v-2334h305v973h1293"
239 : : "zm2159 1015 78-44 85 235-91 47-91 40-90 34-90 29-89 21-88 16-88 10-88 3-102-4-97"
240 : : "-12-91-19-85-26-40-16-39-18-38-20-36-22-34-24-33-26-32-27-30-30-29-31-27-33-25-3"
241 : : "3-23-36-21-36-19-38-18-40-16-40-26-86-18-91-11-97-4-103 3-98 11-94 17-89 24-84 3"
242 : : "1-79 37-75 22-35 23-34 24-33 27-32 28-30 29-28 31-27 31-24 33-22 34-21 35-18 37-"
243 : : "17 38-14 38-13 41-11 41-8 86-12 91-4 82 4 78 10 37 9 37 9 36 12 35 14 33 15 33 1"
244 : : "7 32 19 31 21 30 22 30 25 55 54 26 29 24 31 22 32 21 33 19 34 18 36 30 74 23 80 "
245 : : "17 84 10 89 3 94v78h-1277l6 75 10 70 14 66 19 62 23 57 13 26 14 26 15 25 17 23 1"
246 : : "7 22 19 21 19 20 21 18 21 18 23 16 23 14 24 14 26 12 26 11 27 10 28 8 59 13 63 7"
247 : : " 67 3 80-3 81-9 79-14 80-21 78-26 79-32zm-1049-808-12 53h963l-7-51-11-49-14-46-1"
248 : : "7-43-21-40-24-38-27-36-31-32-33-29-35-25-37-22-38-17-40-14-41-9-42-6-44-2-48 2-4"
249 : : "6 6-44 9-42 13-40 17-38 21-36 24-34 28-32 32-29 34-26 38-23 41-20 44-17 47zm1648"
250 : : "-1293h288v2459h-288zm752-2459h288v2459h-288zm1286-1750 86-11 91-4 91 4 85 12 42 "
251 : : "8 39 11 39 13 38 14 36 17 35 18 34 20 33 23 31 24 30 26 29 28 28 30 26 32 25 33 "
252 : : "23 34 21 35 37 75 31 80 24 84 16 90 11 94 3 100-3 100-11 95-16 89-24 85-31 80-37"
253 : : " 74-21 35-23 35-25 32-26 32-28 30-29 28-30 26-31 24-33 22-34 21-35 18-36 17-38 1"
254 : : "4-39 13-39 10-42 9-85 12-91 4-91-4-86-12-41-9-40-10-39-13-37-14-36-17-35-18-34-2"
255 : : "1-33-22-31-24-30-26-29-28-28-30-26-32-25-32-23-35-21-35-38-74-30-80-24-85-17-89-"
256 : : "11-95-3-100 3-101 11-95 17-90 24-85 30-79 38-75 21-35 23-35 25-32 26-32 28-30 29"
257 : 5 : "-28 30-26 31-24 33-22 34-20 35-18 36-16 37-15 39-12 40-11z";
258 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
259 [ + - ]: 5 : !aExport.compareToAscii(sExportString2));
260 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("importing complex polygon from SVG-D (round-trip",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
261 : : tools::importFromSvgD( aPoly,
262 [ + - ]: 5 : aExport ));
263 [ + - ]: 5 : aExport = tools::exportToSvgD( aPoly );
264 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D (round-trip)",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
265 [ + - ]: 5 : !aExport.compareToAscii(sExportString2));
266 : :
267 : : const B2DPolygon aRect(
268 [ + - ][ + - ]: 5 : tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) ));
269 [ + - ][ + - ]: 5 : aExport = tools::exportToSvgD( B2DPolyPolygon(aRect), false, false);
[ + - ]
270 : :
271 : 5 : const char* sExportStringRect = "M0 0H4000V4000H0Z";
272 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("exporting to rectangle svg-d string",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
273 [ + - ][ + - ]: 10 : !aExport.compareToAscii(sExportStringRect));
[ + - + - ]
274 : 5 : }
275 : :
276 : : // Change the following lines only, if you add, remove or rename
277 : : // member functions of the current class,
278 : : // because these macros are need by auto register mechanism.
279 : :
280 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2dsvgdimpex);
[ + - ][ + - ]
[ # # ]
281 [ + - ][ + - ]: 5 : CPPUNIT_TEST(impex);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
282 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
283 : : }; // class b2dsvgdimpex
284 : :
285 [ - + ]: 15 : class b2drange : public CppUnit::TestFixture
286 : : {
287 : : private:
288 : : public:
289 : 5 : void check()
290 : : {
291 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("simple range rounding from double to integer",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
292 [ + - ]: 5 : fround(B2DRange(1.2, 2.3, 3.5, 4.8)) == B2IRange(1, 2, 4, 5));
293 : 5 : }
294 : :
295 : : // Change the following lines only, if you add, remove or rename
296 : : // member functions of the current class,
297 : : // because these macros are need by auto register mechanism.
298 : :
299 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2drange);
[ + - ][ + - ]
[ # # ]
300 [ + - ][ + - ]: 5 : CPPUNIT_TEST(check);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
301 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
302 : : };
303 : :
304 [ - + ]: 15 : class b2dpolyrange : public CppUnit::TestFixture
305 : : {
306 : : private:
307 : : public:
308 : 5 : void check()
309 : : {
310 [ + - ]: 5 : B2DPolyRange aRange;
311 [ + - ][ + - ]: 5 : aRange.appendElement(B2DRange(0,0,1,1),ORIENTATION_POSITIVE);
312 [ + - ][ + - ]: 5 : aRange.appendElement(B2DRange(2,2,3,3),ORIENTATION_POSITIVE);
313 : :
314 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("simple poly range - count",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
315 [ + - ]: 5 : aRange.count() == 2);
316 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("simple poly range - first element",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
317 [ + - ]: 5 : aRange.getElement(0).head == B2DRange(0,0,1,1));
318 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("simple poly range - second element",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
319 [ + - ]: 5 : aRange.getElement(1).head == B2DRange(2,2,3,3));
320 : :
321 : : // B2DPolyRange relies on correctly orientated rects
322 [ + - ]: 5 : const B2DRange aRect(0,0,1,1);
323 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("createPolygonFromRect - correct orientation",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
324 : : tools::getOrientation(
325 [ + - + - ]: 10 : tools::createPolygonFromRect(aRect)) == ORIENTATION_POSITIVE );
326 : 5 : }
327 : :
328 : : // Change the following lines only, if you add, remove or rename
329 : : // member functions of the current class,
330 : : // because these macros are need by auto register mechanism.
331 : :
332 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2dpolyrange);
[ + - ][ + - ]
[ # # ]
333 [ + - ][ + - ]: 5 : CPPUNIT_TEST(check);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
334 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
335 : : };
336 : :
337 [ + - ][ + - ]: 120 : class b2dhommatrix : public CppUnit::TestFixture
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
338 : : {
339 : : private:
340 : : B2DHomMatrix maIdentity;
341 : : B2DHomMatrix maScale;
342 : : B2DHomMatrix maTranslate;
343 : : B2DHomMatrix maShear;
344 : : B2DHomMatrix maAffine;
345 : : B2DHomMatrix maPerspective;
346 : :
347 : : public:
348 : : // initialise your test code values here.
349 : 40 : void setUp()
350 : : {
351 : : // setup some test matrices
352 : 40 : maIdentity.identity(); // force compact layout
353 : 40 : maIdentity.set(0,0, 1.0);
354 : 40 : maIdentity.set(0,1, 0.0);
355 : 40 : maIdentity.set(0,2, 0.0);
356 : 40 : maIdentity.set(1,0, 0.0);
357 : 40 : maIdentity.set(1,1, 1.0);
358 : 40 : maIdentity.set(1,2, 0.0);
359 : :
360 : 40 : maScale.identity(); // force compact layout
361 : 40 : maScale.set(0,0, 2.0);
362 : 40 : maScale.set(1,1, 20.0);
363 : :
364 : 40 : maTranslate.identity(); // force compact layout
365 : 40 : maTranslate.set(0,2, 20.0);
366 : 40 : maTranslate.set(1,2, 2.0);
367 : :
368 : 40 : maShear.identity(); // force compact layout
369 : 40 : maShear.set(0,1, 3.0);
370 : 40 : maShear.set(1,0, 7.0);
371 : 40 : maShear.set(1,1, 22.0);
372 : :
373 : 40 : maAffine.identity(); // force compact layout
374 : 40 : maAffine.set(0,0, 1.0);
375 : 40 : maAffine.set(0,1, 2.0);
376 : 40 : maAffine.set(0,2, 3.0);
377 : 40 : maAffine.set(1,0, 4.0);
378 : 40 : maAffine.set(1,1, 5.0);
379 : 40 : maAffine.set(1,2, 6.0);
380 : :
381 : 40 : maPerspective.set(0,0, 1.0);
382 : 40 : maPerspective.set(0,1, 2.0);
383 : 40 : maPerspective.set(0,2, 3.0);
384 : 40 : maPerspective.set(1,0, 4.0);
385 : 40 : maPerspective.set(1,1, 5.0);
386 : 40 : maPerspective.set(1,2, 6.0);
387 : 40 : maPerspective.set(2,0, 7.0);
388 : 40 : maPerspective.set(2,1, 8.0);
389 : 40 : maPerspective.set(2,2, 9.0);
390 : 40 : }
391 : :
392 : 40 : void tearDown()
393 : : {
394 : 40 : }
395 : :
396 : 5 : void equal()
397 : : {
398 [ + - ]: 5 : B2DHomMatrix aIdentity;
399 [ + - ]: 5 : B2DHomMatrix aScale;
400 [ + - ]: 5 : B2DHomMatrix aTranslate;
401 [ + - ]: 5 : B2DHomMatrix aShear;
402 [ + - ]: 5 : B2DHomMatrix aAffine;
403 [ + - ]: 5 : B2DHomMatrix aPerspective;
404 : :
405 : : // setup some test matrices
406 [ + - ]: 5 : aIdentity.identity(); // force compact layout
407 [ + - ]: 5 : aIdentity.set(0,0, 1.0);
408 [ + - ]: 5 : aIdentity.set(0,1, 0.0);
409 [ + - ]: 5 : aIdentity.set(0,2, 0.0);
410 [ + - ]: 5 : aIdentity.set(1,0, 0.0);
411 [ + - ]: 5 : aIdentity.set(1,1, 1.0);
412 [ + - ]: 5 : aIdentity.set(1,2, 0.0);
413 : :
414 [ + - ]: 5 : aScale.identity(); // force compact layout
415 [ + - ]: 5 : aScale.set(0,0, 2.0);
416 [ + - ]: 5 : aScale.set(1,1, 20.0);
417 : :
418 [ + - ]: 5 : aTranslate.identity(); // force compact layout
419 [ + - ]: 5 : aTranslate.set(0,2, 20.0);
420 [ + - ]: 5 : aTranslate.set(1,2, 2.0);
421 : :
422 [ + - ]: 5 : aShear.identity(); // force compact layout
423 [ + - ]: 5 : aShear.set(0,1, 3.0);
424 [ + - ]: 5 : aShear.set(1,0, 7.0);
425 [ + - ]: 5 : aShear.set(1,1, 22.0);
426 : :
427 [ + - ]: 5 : aAffine.identity(); // force compact layout
428 [ + - ]: 5 : aAffine.set(0,0, 1.0);
429 [ + - ]: 5 : aAffine.set(0,1, 2.0);
430 [ + - ]: 5 : aAffine.set(0,2, 3.0);
431 [ + - ]: 5 : aAffine.set(1,0, 4.0);
432 [ + - ]: 5 : aAffine.set(1,1, 5.0);
433 [ + - ]: 5 : aAffine.set(1,2, 6.0);
434 : :
435 [ + - ]: 5 : aPerspective.set(0,0, 1.0);
436 [ + - ]: 5 : aPerspective.set(0,1, 2.0);
437 [ + - ]: 5 : aPerspective.set(0,2, 3.0);
438 [ + - ]: 5 : aPerspective.set(1,0, 4.0);
439 [ + - ]: 5 : aPerspective.set(1,1, 5.0);
440 [ + - ]: 5 : aPerspective.set(1,2, 6.0);
441 [ + - ]: 5 : aPerspective.set(2,0, 7.0);
442 [ + - ]: 5 : aPerspective.set(2,1, 8.0);
443 [ + - ]: 5 : aPerspective.set(2,2, 9.0);
444 : :
445 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("operator==: identity matrix", aIdentity == maIdentity);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
446 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("operator==: scale matrix", aScale == maScale);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
447 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("operator==: translate matrix", aTranslate == maTranslate);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
448 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("operator==: shear matrix", aShear == maShear);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
449 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("operator==: affine matrix", aAffine == maAffine);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
450 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("operator==: perspective matrix", aPerspective == maPerspective);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
451 : 5 : }
452 : :
453 : 5 : void identity()
454 : : {
455 [ + - ]: 5 : B2DHomMatrix ident;
456 : :
457 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("identity", maIdentity == ident);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
458 : 5 : }
459 : :
460 : 5 : void scale()
461 : : {
462 [ + - ]: 5 : B2DHomMatrix mat;
463 [ + - ]: 5 : mat.scale(2.0,20.0);
464 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("scale", maScale == mat);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
465 : 5 : }
466 : :
467 : 5 : void rotate()
468 : : {
469 [ + - ]: 5 : B2DHomMatrix mat;
470 [ + - ]: 5 : mat.rotate(90*F_PI180);
471 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("rotate pi/2 yields exact matrix",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
472 : : mat.get(0,0) == 0.0 &&
473 : : mat.get(0,1) == -1.0 &&
474 : : mat.get(0,2) == 0.0 &&
475 : : mat.get(1,0) == 1.0 &&
476 : : mat.get(1,1) == 0.0 &&
477 [ + - ]: 5 : mat.get(1,2) == 0.0);
478 [ + - ]: 5 : mat.rotate(90*F_PI180);
479 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("rotate pi yields exact matrix",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
480 : : mat.get(0,0) == -1.0 &&
481 : : mat.get(0,1) == 0.0 &&
482 : : mat.get(0,2) == 0.0 &&
483 : : mat.get(1,0) == 0.0 &&
484 : : mat.get(1,1) == -1.0 &&
485 [ + - ]: 5 : mat.get(1,2) == 0.0);
486 [ + - ]: 5 : mat.rotate(90*F_PI180);
487 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("rotate 3/2 pi yields exact matrix",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
488 : : mat.get(0,0) == 0.0 &&
489 : : mat.get(0,1) == 1.0 &&
490 : : mat.get(0,2) == 0.0 &&
491 : : mat.get(1,0) == -1.0 &&
492 : : mat.get(1,1) == 0.0 &&
493 [ + - ]: 5 : mat.get(1,2) == 0.0);
494 [ + - ]: 5 : mat.rotate(90*F_PI180);
495 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("rotate 2 pi yields exact matrix",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
496 : : mat.get(0,0) == 1.0 &&
497 : : mat.get(0,1) == 0.0 &&
498 : : mat.get(0,2) == 0.0 &&
499 : : mat.get(1,0) == 0.0 &&
500 : : mat.get(1,1) == 1.0 &&
501 [ + - + - ]: 10 : mat.get(1,2) == 0.0);
502 : 5 : }
503 : :
504 : 5 : void translate()
505 : : {
506 [ + - ]: 5 : B2DHomMatrix mat;
507 [ + - ]: 5 : mat.translate(20.0,2.0);
508 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("translate", maTranslate == mat);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
509 : 5 : }
510 : :
511 : 5 : void shear()
512 : : {
513 [ + - ]: 5 : B2DHomMatrix mat;
514 [ + - ]: 5 : mat.shearX(3.0);
515 [ + - ]: 5 : mat.shearY(7.0);
516 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("translate", maShear == mat);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
517 : 5 : }
518 : :
519 : 5 : void multiply()
520 : : {
521 [ + - ]: 5 : B2DHomMatrix affineAffineProd;
522 : :
523 [ + - ]: 5 : affineAffineProd.set(0,0, 9);
524 [ + - ]: 5 : affineAffineProd.set(0,1, 12);
525 [ + - ]: 5 : affineAffineProd.set(0,2, 18);
526 [ + - ]: 5 : affineAffineProd.set(1,0, 24);
527 [ + - ]: 5 : affineAffineProd.set(1,1, 33);
528 [ + - ]: 5 : affineAffineProd.set(1,2, 48);
529 : :
530 [ + - ]: 5 : B2DHomMatrix affinePerspectiveProd;
531 : :
532 [ + - ]: 5 : affinePerspectiveProd.set(0,0, 30);
533 [ + - ]: 5 : affinePerspectiveProd.set(0,1, 36);
534 [ + - ]: 5 : affinePerspectiveProd.set(0,2, 42);
535 [ + - ]: 5 : affinePerspectiveProd.set(1,0, 66);
536 [ + - ]: 5 : affinePerspectiveProd.set(1,1, 81);
537 [ + - ]: 5 : affinePerspectiveProd.set(1,2, 96);
538 [ + - ]: 5 : affinePerspectiveProd.set(2,0, 7);
539 [ + - ]: 5 : affinePerspectiveProd.set(2,1, 8);
540 [ + - ]: 5 : affinePerspectiveProd.set(2,2, 9);
541 : :
542 [ + - ]: 5 : B2DHomMatrix perspectiveAffineProd;
543 : :
544 [ + - ]: 5 : perspectiveAffineProd.set(0,0, 9);
545 [ + - ]: 5 : perspectiveAffineProd.set(0,1, 12);
546 [ + - ]: 5 : perspectiveAffineProd.set(0,2, 18);
547 [ + - ]: 5 : perspectiveAffineProd.set(1,0, 24);
548 [ + - ]: 5 : perspectiveAffineProd.set(1,1, 33);
549 [ + - ]: 5 : perspectiveAffineProd.set(1,2, 48);
550 [ + - ]: 5 : perspectiveAffineProd.set(2,0, 39);
551 [ + - ]: 5 : perspectiveAffineProd.set(2,1, 54);
552 [ + - ]: 5 : perspectiveAffineProd.set(2,2, 78);
553 : :
554 [ + - ]: 5 : B2DHomMatrix perspectivePerspectiveProd;
555 : :
556 [ + - ]: 5 : perspectivePerspectiveProd.set(0,0, 30);
557 [ + - ]: 5 : perspectivePerspectiveProd.set(0,1, 36);
558 [ + - ]: 5 : perspectivePerspectiveProd.set(0,2, 42);
559 [ + - ]: 5 : perspectivePerspectiveProd.set(1,0, 66);
560 [ + - ]: 5 : perspectivePerspectiveProd.set(1,1, 81);
561 [ + - ]: 5 : perspectivePerspectiveProd.set(1,2, 96);
562 [ + - ]: 5 : perspectivePerspectiveProd.set(2,0, 102);
563 [ + - ]: 5 : perspectivePerspectiveProd.set(2,1, 126);
564 [ + - ]: 5 : perspectivePerspectiveProd.set(2,2, 150);
565 : :
566 [ + - ]: 5 : B2DHomMatrix temp;
567 : :
568 [ + - ]: 5 : temp = maAffine;
569 [ + - ]: 5 : temp*=maAffine;
570 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("multiply: both compact", temp == affineAffineProd);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
571 : :
572 [ + - ]: 5 : temp = maPerspective;
573 [ + - ]: 5 : temp*=maAffine;
574 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("multiply: first compact", temp == affinePerspectiveProd);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
575 : :
576 [ + - ]: 5 : temp = maAffine;
577 [ + - ]: 5 : temp*=maPerspective;
578 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("multiply: second compact", temp == perspectiveAffineProd);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
579 : :
580 [ + - ]: 5 : temp = maPerspective;
581 [ + - ]: 5 : temp*=maPerspective;
582 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("multiply: none compact", temp == perspectivePerspectiveProd);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
583 : 5 : }
584 : :
585 : 360 : void impFillMatrix(B2DHomMatrix& rSource, double fScaleX, double fScaleY, double fShearX, double fRotate)
586 : : {
587 : : // fill rSource with a linear combination of scale, shear and rotate
588 : 360 : rSource.identity();
589 : 360 : rSource.scale(fScaleX, fScaleY);
590 : 360 : rSource.shearX(fShearX);
591 : 360 : rSource.rotate(fRotate);
592 : 360 : }
593 : :
594 : 180 : bool impDecomposeComposeTest(double fScaleX, double fScaleY, double fShearX, double fRotate)
595 : : {
596 : : // linear combine matrix with given values
597 [ + - ]: 180 : B2DHomMatrix aSource;
598 [ + - ]: 180 : impFillMatrix(aSource, fScaleX, fScaleY, fShearX, fRotate);
599 : :
600 : : // decompose that matrix
601 : 180 : B2DTuple aDScale;
602 : 180 : B2DTuple aDTrans;
603 : : double fDRot;
604 : : double fDShX;
605 [ + - ]: 180 : bool bWorked = aSource.decompose(aDScale, aDTrans, fDRot, fDShX);
606 : :
607 : : // linear combine another matrix with decomposition results
608 [ + - ]: 180 : B2DHomMatrix aRecombined;
609 [ + - ]: 180 : impFillMatrix(aRecombined, aDScale.getX(), aDScale.getY(), fDShX, fDRot);
610 : :
611 : : // if decomposition worked, matrices need to be the same
612 [ + - ][ + - ]: 180 : return bWorked && aSource == aRecombined;
[ + - ][ + - ]
[ + - ]
613 : : }
614 : :
615 : 5 : void decompose()
616 : : {
617 : : // test matrix decompositions. Each matrix decomposed and rebuilt
618 : : // using the decompose result should be the same as before. Test
619 : : // with all ranges of values. Translations are not tested since these
620 : : // are just the two rightmost values and uncritical
621 : : static double fSX(10.0);
622 : : static double fSY(12.0);
623 : : static double fR(45.0 * F_PI180);
624 : : static double fS(15.0 * F_PI180);
625 : :
626 : : // check all possible scaling combinations
627 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test A1", impDecomposeComposeTest(fSX, fSY, 0.0, 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
628 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test A2", impDecomposeComposeTest(-fSX, fSY, 0.0, 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
629 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test A3", impDecomposeComposeTest(fSX, -fSY, 0.0, 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
630 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test A4", impDecomposeComposeTest(-fSX, -fSY, 0.0, 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
631 : :
632 : : // check all possible scaling combinations with positive rotation
633 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test B1", impDecomposeComposeTest(fSX, fSY, 0.0, fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
634 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test B2", impDecomposeComposeTest(-fSX, fSY, 0.0, fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
635 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test B3", impDecomposeComposeTest(fSX, -fSY, 0.0, fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
636 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test B4", impDecomposeComposeTest(-fSX, -fSY, 0.0, fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
637 : :
638 : : // check all possible scaling combinations with negative rotation
639 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test C1", impDecomposeComposeTest(fSX, fSY, 0.0, -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
640 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test C2", impDecomposeComposeTest(-fSX, fSY, 0.0, -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
641 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test C3", impDecomposeComposeTest(fSX, -fSY, 0.0, -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
642 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test C4", impDecomposeComposeTest(-fSX, -fSY, 0.0, -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
643 : :
644 : : // check all possible scaling combinations with positive shear
645 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test D1", impDecomposeComposeTest(fSX, fSY, tan(fS), 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
646 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test D2", impDecomposeComposeTest(-fSX, fSY, tan(fS), 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
647 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test D3", impDecomposeComposeTest(fSX, -fSY, tan(fS), 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
648 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test D4", impDecomposeComposeTest(-fSX, -fSY, tan(fS), 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
649 : :
650 : : // check all possible scaling combinations with negative shear
651 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test E1", impDecomposeComposeTest(fSX, fSY, tan(-fS), 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
652 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test E2", impDecomposeComposeTest(-fSX, fSY, tan(-fS), 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
653 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test E3", impDecomposeComposeTest(fSX, -fSY, tan(-fS), 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
654 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test E4", impDecomposeComposeTest(-fSX, -fSY, tan(-fS), 0.0));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
655 : :
656 : : // check all possible scaling combinations with positive rotate and positive shear
657 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test F1", impDecomposeComposeTest(fSX, fSY, tan(fS), fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
658 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test F2", impDecomposeComposeTest(-fSX, fSY, tan(fS), fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
659 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test F3", impDecomposeComposeTest(fSX, -fSY, tan(fS), fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
660 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test F4", impDecomposeComposeTest(-fSX, -fSY, tan(fS), fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
661 : :
662 : : // check all possible scaling combinations with negative rotate and positive shear
663 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test G1", impDecomposeComposeTest(fSX, fSY, tan(fS), -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
664 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test G2", impDecomposeComposeTest(-fSX, fSY, tan(fS), -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
665 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test G3", impDecomposeComposeTest(fSX, -fSY, tan(fS), -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
666 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test G4", impDecomposeComposeTest(-fSX, -fSY, tan(fS), -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
667 : :
668 : : // check all possible scaling combinations with positive rotate and negative shear
669 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test H1", impDecomposeComposeTest(fSX, fSY, tan(-fS), fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
670 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test H2", impDecomposeComposeTest(-fSX, fSY, tan(-fS), fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
671 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test H3", impDecomposeComposeTest(fSX, -fSY, tan(-fS), fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
672 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test H4", impDecomposeComposeTest(-fSX, -fSY, tan(-fS), fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
673 : :
674 : : // check all possible scaling combinations with negative rotate and negative shear
675 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test I1", impDecomposeComposeTest(fSX, fSY, tan(-fS), -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
676 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test I2", impDecomposeComposeTest(-fSX, fSY, tan(-fS), -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
677 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test I3", impDecomposeComposeTest(fSX, -fSY, tan(-fS), -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
678 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test I4", impDecomposeComposeTest(-fSX, -fSY, tan(-fS), -fR));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
679 : :
680 : : // cover special case of 180 degree rotation
681 : : B2DHomMatrix aTest=tools::createScaleShearXRotateTranslateB2DHomMatrix(
682 : : 6425,3938,
683 : : 0,
684 : : 180*F_PI180,
685 [ + - ]: 5 : 10482,4921);
686 : : // decompose that matrix
687 : 5 : B2DTuple aDScale;
688 : 5 : B2DTuple aDTrans;
689 : : double fDRot;
690 : : double fDShX;
691 [ + - ]: 5 : aTest.decompose(aDScale, aDTrans, fDRot, fDShX);
692 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", aDScale.getX() == 6425 && aDScale.getY() == 3938);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
[ + - ]
693 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", aDTrans.getX() == 10482 && aDTrans.getY() == 4921);
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
[ + - ]
694 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", fDRot == 180*F_PI180);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
695 : 5 : }
696 : :
697 : : // Change the following lines only, if you add, remove or rename
698 : : // member functions of the current class,
699 : : // because these macros are need by auto register mechanism.
700 : :
701 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2dhommatrix);
[ + - ][ + - ]
[ # # ]
702 [ + - ][ + - ]: 5 : CPPUNIT_TEST(equal);
[ + - ][ + - ]
[ + - ][ + - ]
703 [ + - ][ + - ]: 5 : CPPUNIT_TEST(identity);
[ + - ][ + - ]
[ + - ][ + - ]
704 [ + - ][ + - ]: 5 : CPPUNIT_TEST(scale);
[ + - ][ + - ]
[ + - ][ + - ]
705 [ + - ][ + - ]: 5 : CPPUNIT_TEST(translate);
[ + - ][ + - ]
[ + - ][ + - ]
706 [ + - ][ + - ]: 5 : CPPUNIT_TEST(rotate);
[ + - ][ + - ]
[ + - ][ + - ]
707 [ + - ][ + - ]: 5 : CPPUNIT_TEST(shear);
[ + - ][ + - ]
[ + - ][ + - ]
708 [ + - ][ + - ]: 5 : CPPUNIT_TEST(multiply);
[ + - ][ + - ]
[ + - ][ + - ]
709 [ + - ][ + - ]: 5 : CPPUNIT_TEST(decompose);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
710 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
711 : :
712 : : }; // class b2dhommatrix
713 : :
714 : :
715 [ - + ]: 15 : class b2dpoint : public CppUnit::TestFixture
716 : : {
717 : : public:
718 : : // insert your test code here.
719 : : // this is only demonstration code
720 : 5 : void EmptyMethod()
721 : : {
722 : : // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
723 : 5 : }
724 : :
725 : : // Change the following lines only, if you add, remove or rename
726 : : // member functions of the current class,
727 : : // because these macros are need by auto register mechanism.
728 : :
729 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2dpoint);
[ + - ][ + - ]
[ # # ]
730 [ + - ][ + - ]: 5 : CPPUNIT_TEST(EmptyMethod);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
731 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
732 : : }; // class b2dpoint
733 : :
734 : :
735 [ - + ]: 15 : class b2dpolygon : public CppUnit::TestFixture
736 : : {
737 : : public:
738 : : // insert your test code here.
739 : 5 : void testBasics()
740 : : {
741 [ + - ]: 5 : B2DPolygon aPoly;
742 : :
743 [ + - ]: 5 : aPoly.appendBezierSegment(B2DPoint(1,1),B2DPoint(2,2),B2DPoint(3,3));
744 : :
745 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#1 first polygon point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
746 [ + - ]: 5 : aPoly.getB2DPoint(0) == B2DPoint(3,3));
747 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#1 first control point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
748 [ + - ]: 5 : aPoly.getPrevControlPoint(0) == B2DPoint(2,2));
749 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#1 second control point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
750 [ + - ]: 5 : aPoly.getNextControlPoint(0) == B2DPoint(3,3));
751 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("next control point not used",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
752 [ + - ]: 5 : aPoly.isNextControlPointUsed(0) == false);
753 : :
754 [ + - ]: 5 : aPoly.setNextControlPoint(0,B2DPoint(4,4));
755 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#1.1 second control point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
756 [ + - ]: 5 : aPoly.getNextControlPoint(0) == B2DPoint(4,4));
757 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("next control point used",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
758 [ + - ]: 5 : aPoly.isNextControlPointUsed(0) == true);
759 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("areControlPointsUsed() wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
760 [ + - ]: 5 : aPoly.areControlPointsUsed() == true);
761 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("getContinuityInPoint() wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
762 [ + - ]: 5 : aPoly.getContinuityInPoint(0) == CONTINUITY_C2);
763 : :
764 [ + - ]: 5 : aPoly.resetControlPoints();
765 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("resetControlPoints() did not clear",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
766 [ + - ]: 5 : aPoly.getB2DPoint(0) == B2DPoint(3,3));
767 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("resetControlPoints() did not clear",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
768 [ + - ]: 5 : aPoly.getPrevControlPoint(0) == B2DPoint(3,3));
769 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("resetControlPoints() did not clear",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
770 [ + - ]: 5 : aPoly.getNextControlPoint(0) == B2DPoint(3,3));
771 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("areControlPointsUsed() wrong #2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
772 [ + - ]: 5 : aPoly.areControlPointsUsed() == false);
773 : :
774 [ + - ]: 5 : aPoly.clear();
775 [ + - ]: 5 : aPoly.append(B2DPoint(0,0));
776 [ + - ]: 5 : aPoly.appendBezierSegment(B2DPoint(1,1),B2DPoint(2,2),B2DPoint(3,3));
777 : :
778 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#2 first polygon point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
779 [ + - ]: 5 : aPoly.getB2DPoint(0) == B2DPoint(0,0));
780 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#2 first control point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
781 [ + - ]: 5 : aPoly.getPrevControlPoint(0) == B2DPoint(0,0));
782 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#2 second control point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
783 [ + - ]: 5 : aPoly.getNextControlPoint(0) == B2DPoint(1,1));
784 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#2 third control point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
785 [ + - ]: 5 : aPoly.getPrevControlPoint(1) == B2DPoint(2,2));
786 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#2 fourth control point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
787 [ + - ]: 5 : aPoly.getNextControlPoint(1) == B2DPoint(3,3));
788 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("#2 second polygon point wrong",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
789 [ + - + - ]: 10 : aPoly.getB2DPoint(1) == B2DPoint(3,3));
790 : 5 : }
791 : : // Change the following lines only, if you add, remove or rename
792 : : // member functions of the current class,
793 : : // because these macros are need by auto register mechanism.
794 : :
795 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2dpolygon);
[ + - ][ + - ]
[ # # ]
796 [ + - ][ + - ]: 5 : CPPUNIT_TEST(testBasics);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
797 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
798 : : }; // class b2dpolygon
799 : :
800 : :
801 [ - + ]: 15 : class b2dpolygontools : public CppUnit::TestFixture
802 : : {
803 : : public:
804 : : // insert your test code here.
805 : : // this is only demonstration code
806 : 5 : void testIsRectangle()
807 : : {
808 : : B2DPolygon aRect1(
809 : : tools::createPolygonFromRect(
810 [ + - ][ + - ]: 5 : B2DRange(0,0,1,1) ) );
811 : :
812 [ + - ]: 5 : B2DPolygon aRect2;
813 [ + - ]: 5 : aRect2.append( B2DPoint(0,0) );
814 [ + - ]: 5 : aRect2.append( B2DPoint(1,0) );
815 [ + - ]: 5 : aRect2.append( B2DPoint(1,.5));
816 [ + - ]: 5 : aRect2.append( B2DPoint(1,1) );
817 [ + - ]: 5 : aRect2.append( B2DPoint(0,1) );
818 [ + - ]: 5 : aRect2.setClosed(true);
819 : :
820 [ + - ]: 5 : B2DPolygon aNonRect1;
821 [ + - ]: 5 : aNonRect1.append( B2DPoint(0,0) );
822 [ + - ]: 5 : aNonRect1.append( B2DPoint(1,0) );
823 [ + - ]: 5 : aNonRect1.append( B2DPoint(1,1) );
824 [ + - ]: 5 : aNonRect1.append( B2DPoint(0.5,1) );
825 [ + - ]: 5 : aNonRect1.append( B2DPoint(0.5,0) );
826 [ + - ]: 5 : aNonRect1.setClosed(true);
827 : :
828 [ + - ]: 5 : B2DPolygon aNonRect2;
829 [ + - ]: 5 : aNonRect2.append( B2DPoint(0,0) );
830 [ + - ]: 5 : aNonRect2.append( B2DPoint(1,1) );
831 [ + - ]: 5 : aNonRect2.append( B2DPoint(1,0) );
832 [ + - ]: 5 : aNonRect2.append( B2DPoint(0,1) );
833 [ + - ]: 5 : aNonRect2.setClosed(true);
834 : :
835 [ + - ]: 5 : B2DPolygon aNonRect3;
836 [ + - ]: 5 : aNonRect3.append( B2DPoint(0,0) );
837 [ + - ]: 5 : aNonRect3.append( B2DPoint(1,0) );
838 [ + - ]: 5 : aNonRect3.append( B2DPoint(1,1) );
839 [ + - ]: 5 : aNonRect3.setClosed(true);
840 : :
841 [ + - ]: 5 : B2DPolygon aNonRect4;
842 [ + - ]: 5 : aNonRect4.append( B2DPoint(0,0) );
843 [ + - ]: 5 : aNonRect4.append( B2DPoint(1,0) );
844 [ + - ]: 5 : aNonRect4.append( B2DPoint(1,1) );
845 [ + - ]: 5 : aNonRect4.append( B2DPoint(0,1) );
846 : :
847 [ + - ]: 5 : B2DPolygon aNonRect5;
848 [ + - ]: 5 : aNonRect5.append( B2DPoint(0,0) );
849 [ + - ]: 5 : aNonRect5.append( B2DPoint(1,0) );
850 [ + - ]: 5 : aNonRect5.append( B2DPoint(1,1) );
851 [ + - ]: 5 : aNonRect5.append( B2DPoint(0,1) );
852 [ + - ]: 5 : aNonRect5.setControlPoints(1,B2DPoint(1,0),B2DPoint(-11,0));
853 [ + - ]: 5 : aNonRect5.setClosed(true);
854 : :
855 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 1",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
856 [ + - ]: 5 : tools::isRectangle( aRect1 ));
857 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
858 [ + - ]: 5 : tools::isRectangle( aRect2 ));
859 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 1",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
860 [ + - ]: 5 : !tools::isRectangle( aNonRect1 ));
861 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
862 [ + - ]: 5 : !tools::isRectangle( aNonRect2 ));
863 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 3",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
864 [ + - ]: 5 : !tools::isRectangle( aNonRect3 ));
865 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 4",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
866 [ + - ]: 5 : !tools::isRectangle( aNonRect4 ));
867 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 5",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
868 [ + - + - ]: 10 : !tools::isRectangle( aNonRect5 ));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
869 : 5 : }
870 : :
871 : : // Change the following lines only, if you add, remove or rename
872 : : // member functions of the current class,
873 : : // because these macros are need by auto register mechanism.
874 : :
875 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2dpolygontools);
[ + - ][ + - ]
[ # # ]
876 [ + - ][ + - ]: 5 : CPPUNIT_TEST(testIsRectangle);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
877 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
878 : : }; // class b2dpolygontools
879 : :
880 : :
881 [ - + ]: 15 : class b2dpolypolygon : public CppUnit::TestFixture
882 : : {
883 : : public:
884 : : // insert your test code here.
885 : 5 : void EmptyMethod()
886 : : {
887 : 5 : }
888 : :
889 : : // Change the following lines only, if you add, remove or rename
890 : : // member functions of the current class,
891 : : // because these macros are need by auto register mechanism.
892 : :
893 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2dpolypolygon);
[ + - ][ + - ]
[ # # ]
894 [ + - ][ + - ]: 5 : CPPUNIT_TEST(EmptyMethod);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
895 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
896 : : }; // class b2dpolypolygon
897 : :
898 [ - + ]: 15 : class b1Xrange : public CppUnit::TestFixture
899 : : {
900 : : public:
901 : 10 : template<class Type> void implCheck()
902 : : {
903 : : // test interval axioms
904 : : // (http://en.wikipedia.org/wiki/Interval_%28mathematics%29)
905 [ + - ][ + - ]: 10 : Type aRange;
906 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("default ctor - empty range", aRange.isEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
907 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("center - get cop-out value since range is empty", aRange.getCenter()==0);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
908 : :
909 : : // degenerate interval
910 [ + - + - ]: 10 : aRange.expand(1);
911 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("degenerate range - still, not empty!", !aRange.isEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
912 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("degenerate range - size of 0", aRange.getRange() == 0);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
913 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("same value as degenerate range - is inside range", aRange.isInside(1));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
914 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("center - must be the single range value", aRange.getCenter()==1);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
915 : :
916 : : // proper interval
917 [ + - + - ]: 10 : aRange.expand(2);
918 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("proper range - size of 1", aRange.getRange() == 1);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
919 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("smaller value of range - is inside *closed* range", aRange.isInside(1));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
920 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("larger value of range - is inside *closed* range", aRange.isInside(2));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
921 : :
922 : : // center for proper interval that works for ints, too
923 [ + - + - ]: 10 : aRange.expand(3);
924 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("center - must be half of the range", aRange.getCenter()==2);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
925 : :
926 : : // check overlap
927 [ + - + - ]: 10 : Type aRange2(0,1);
928 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("range overlapping *includes* upper bound", aRange.overlaps(aRange2));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
929 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("range overlapping *includes* upper bound, but only barely", !aRange.overlapsMore(aRange2));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
930 : :
931 [ + - + - ]: 10 : Type aRange3(0,2);
932 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("range overlapping is fully overlapping now", aRange.overlapsMore(aRange3));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
933 : :
934 : : // check intersect
935 [ + - + - ]: 10 : Type aRange4(3,4);
936 [ + - ][ + - ]: 10 : aRange.intersect(aRange4);
937 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("range intersection is yielding empty range!", !aRange.isEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
938 : :
939 [ + - + - ]: 10 : Type aRange5(5,6);
940 [ + - ][ + - ]: 10 : aRange.intersect(aRange5);
941 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("range intersection is yielding nonempty range!", aRange.isEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
942 : :
943 : : // just so that this compiles -
944 : 10 : Type aRange6( aRange );
945 : : (void)aRange6;
946 : 10 : }
947 : :
948 : 5 : void check()
949 : : {
950 : 5 : implCheck<B1DRange>();
951 : 5 : implCheck<B1IRange>();
952 : 5 : }
953 : :
954 : : // Change the following lines only, if you add, remove or rename
955 : : // member functions of the current class,
956 : : // because these macros are need by auto register mechanism.
957 : :
958 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b1Xrange);
[ + - ][ + - ]
[ # # ]
959 [ + - ][ + - ]: 5 : CPPUNIT_TEST(check);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
960 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
961 : : }; // class b1Xrange
962 : :
963 : :
964 [ - + ]: 15 : class b1ibox : public CppUnit::TestFixture
965 : : {
966 : : public:
967 : 5 : void TestBox()
968 : : {
969 : : // test axioms - markedly different from proper mathematical
970 : : // intervals (behaviour modelled after how polygon fill
971 : : // algorithms fill pixels)
972 [ + - ]: 5 : B1IBox aBox;
973 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("default ctor - empty range", aBox.isEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
974 : :
975 : : // degenerate box
976 [ + - ]: 5 : aBox.expand(1);
977 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("degenerate box - still empty!", aBox.isEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
978 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("degenerate box - size of 0", aBox.getRange() == 0);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
979 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("same value as degenerate box - is outside (since empty)", !aBox.isInside(1));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
980 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("center - get cop-out value since box is empty", aBox.getCenter()==0);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
981 : :
982 : : // proper box
983 [ + - ]: 5 : aBox.expand(2);
984 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("proper box - size of 1", aBox.getRange() == 1);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
985 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("smaller value of box", aBox.isInside(1));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
986 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("larger value of box - must be outside", !aBox.isInside(2));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
987 : :
988 : : // center for proper box that works for ints, too
989 [ + - ]: 5 : aBox.expand(4);
990 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("center - must be center pixel of the box", aBox.getCenter()==2);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
991 : :
992 : : // check overlap, which is markedly different from Range
993 [ + - ]: 5 : B1IBox aBox2(0,1);
994 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("box overlapping *excludes* upper bound", !aBox.overlaps(aBox2));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
995 : :
996 [ + - ]: 5 : B1IBox aBox3(0,2);
997 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("box overlapping then includes upper bound-1", aBox.overlaps(aBox3));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
998 : :
999 : : // check intersect
1000 [ + - ]: 5 : B1IBox aBox4(4,5);
1001 [ + - ]: 5 : aBox.intersect(aBox4);
1002 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("box intersection is yielding nonempty box!", aBox.isEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1003 : :
1004 [ + - ]: 5 : B1IBox aBox5(2,5);
1005 [ + - ]: 5 : aBox5.intersect(aBox4);
1006 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE("box intersection is yielding empty box!", !aBox5.isEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1007 : :
1008 : : // just so that this compiles -
1009 : 5 : B1IBox aBox6( aBox );
1010 : : (void)aBox6;
1011 : 5 : }
1012 : :
1013 : : // Change the following lines only, if you add, remove or rename
1014 : : // member functions of the current class,
1015 : : // because these macros are need by auto register mechanism.
1016 : :
1017 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b1ibox);
[ + - ][ + - ]
[ # # ]
1018 [ + - ][ + - ]: 5 : CPPUNIT_TEST(TestBox);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1019 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1020 : : }; // class b1ibox
1021 : :
1022 : :
1023 [ - + ]: 15 : class b2Xrange : public CppUnit::TestFixture
1024 : : {
1025 : : public:
1026 : 10 : template<class Type> void implCheck()
1027 : : {
1028 : : // cohen sutherland clipping
1029 [ + - ][ + - ]: 10 : Type aRange(0,0,10,10);
1030 : :
1031 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("(0,0) is outside range!",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1032 : : tools::getCohenSutherlandClipFlags(B2IPoint(0,0),aRange) == 0);
1033 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("(-1,-1) is inside range!",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1034 : : tools::getCohenSutherlandClipFlags(B2IPoint(-1,-1),aRange) ==
1035 : : (tools::RectClipFlags::LEFT|tools::RectClipFlags::TOP));
1036 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("(10,10) is outside range!",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1037 : : tools::getCohenSutherlandClipFlags(B2IPoint(10,10),aRange) == 0);
1038 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("(11,11) is inside range!",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1039 : : tools::getCohenSutherlandClipFlags(B2IPoint(11,11),aRange) ==
1040 : : (tools::RectClipFlags::RIGHT|tools::RectClipFlags::BOTTOM));
1041 : :
1042 : : // just so that this compiles -
1043 : 10 : Type aRange1( aRange );
1044 : : (void)aRange1;
1045 : 10 : }
1046 : :
1047 : 5 : void check()
1048 : : {
1049 : 5 : implCheck<B2DRange>();
1050 : 5 : implCheck<B2IRange>();
1051 : 5 : }
1052 : :
1053 : : // Change the following lines only, if you add, remove or rename
1054 : : // member functions of the current class,
1055 : : // because these macros are need by auto register mechanism.
1056 : :
1057 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2Xrange);
[ + - ][ + - ]
[ # # ]
1058 [ + - ][ + - ]: 5 : CPPUNIT_TEST(check);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1059 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1060 : : }; // class b2Xrange
1061 : :
1062 : :
1063 [ - + ]: 15 : class b2ibox : public CppUnit::TestFixture
1064 : : {
1065 : : public:
1066 : 5 : void TestBox()
1067 : : {
1068 : : // cohen sutherland clipping
1069 [ + - ]: 5 : B2IBox aBox(0,0,10,10);
1070 : :
1071 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("(0,0) is outside range!",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1072 [ + - ]: 5 : tools::getCohenSutherlandClipFlags(B2IPoint(0,0),aBox) == 0);
1073 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("(-1,-1) is inside range!",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1074 : : tools::getCohenSutherlandClipFlags(B2IPoint(-1,-1),aBox) ==
1075 [ + - ]: 5 : (tools::RectClipFlags::LEFT|tools::RectClipFlags::TOP));
1076 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("(9,9) is outside range!",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1077 [ + - ]: 5 : tools::getCohenSutherlandClipFlags(B2IPoint(9,9),aBox) == 0);
1078 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("(10,10) is inside range!",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1079 : : tools::getCohenSutherlandClipFlags(B2IPoint(10,10),aBox) ==
1080 [ + - ]: 5 : (tools::RectClipFlags::RIGHT|tools::RectClipFlags::BOTTOM));
1081 : :
1082 : : // just so that this compiles -
1083 : 5 : B2IBox aBox1( aBox );
1084 : : (void)aBox1;
1085 : 5 : }
1086 : :
1087 : : // Change the following lines only, if you add, remove or rename
1088 : : // member functions of the current class,
1089 : : // because these macros are need by auto register mechanism.
1090 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2ibox);
[ + - ][ + - ]
[ # # ]
1091 [ + - ][ + - ]: 5 : CPPUNIT_TEST(TestBox);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1092 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1093 : : }; // class b2ibox
1094 : :
1095 : :
1096 [ - + ]: 15 : class b2dtuple : public CppUnit::TestFixture
1097 : : {
1098 : : public:
1099 : : // insert your test code here.
1100 : : // this is only demonstration code
1101 : 5 : void EmptyMethod()
1102 : : {
1103 : : // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
1104 : 5 : }
1105 : :
1106 : : // Change the following lines only, if you add, remove or rename
1107 : : // member functions of the current class,
1108 : : // because these macros are need by auto register mechanism.
1109 : :
1110 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(b2dtuple);
[ + - ][ + - ]
[ # # ]
1111 [ + - ][ + - ]: 5 : CPPUNIT_TEST(EmptyMethod);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1112 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1113 : : }; // class b2dtuple
1114 : :
1115 [ - + ]: 30 : class bcolor : public CppUnit::TestFixture
1116 : : {
1117 : : BColor maWhite;
1118 : : BColor maBlack;
1119 : : BColor maRed;
1120 : : BColor maGreen;
1121 : : BColor maBlue;
1122 : : BColor maYellow;
1123 : : BColor maMagenta;
1124 : : BColor maCyan;
1125 : :
1126 : : public:
1127 : 15 : bcolor() :
1128 : : maWhite(1,1,1),
1129 : : maBlack(0,0,0),
1130 : : maRed(1,0,0),
1131 : : maGreen(0,1,0),
1132 : : maBlue(0,0,1),
1133 : : maYellow(1,1,0),
1134 : : maMagenta(1,0,1),
1135 : 15 : maCyan(0,1,1)
1136 : 15 : {}
1137 : :
1138 : : // insert your test code here.
1139 : 5 : void hslTest()
1140 : : {
1141 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("white",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1142 [ + - ]: 5 : tools::rgb2hsl(maWhite) == BColor(0,0,1));
1143 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("black",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1144 [ + - ]: 5 : tools::rgb2hsl(maBlack) == BColor(0,0,0));
1145 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("red",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1146 [ + - ]: 5 : tools::rgb2hsl(maRed) == BColor(0,1,0.5));
1147 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("green",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1148 [ + - ]: 5 : tools::rgb2hsl(maGreen) == BColor(120,1,0.5));
1149 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("blue",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1150 [ + - ]: 5 : tools::rgb2hsl(maBlue) == BColor(240,1,0.5));
1151 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("yellow",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1152 [ + - ]: 5 : tools::rgb2hsl(maYellow) == BColor(60,1,0.5));
1153 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("magenta",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1154 [ + - ]: 5 : tools::rgb2hsl(maMagenta) == BColor(300,1,0.5));
1155 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("cyan",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1156 [ + - ]: 5 : tools::rgb2hsl(maCyan) == BColor(180,1,0.5));
1157 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("third hue case",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1158 [ + - ]: 5 : tools::rgb2hsl(BColor(0,0.5,1)) == BColor(210,1,0.5));
1159 : :
1160 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip white",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1161 [ + - ]: 5 : tools::hsl2rgb(tools::rgb2hsl(maWhite)) == maWhite);
1162 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip black",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1163 [ + - ]: 5 : tools::hsl2rgb(tools::rgb2hsl(maBlack)) == maBlack);
1164 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip red",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1165 [ + - ]: 5 : tools::hsl2rgb(tools::rgb2hsl(maRed)) == maRed);
1166 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip green",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1167 [ + - ]: 5 : tools::hsl2rgb(tools::rgb2hsl(maGreen)) == maGreen);
1168 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip blue",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1169 [ + - ]: 5 : tools::hsl2rgb(tools::rgb2hsl(maBlue)) == maBlue);
1170 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip yellow",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1171 [ + - ]: 5 : tools::hsl2rgb(tools::rgb2hsl(maYellow)) == maYellow);
1172 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip magenta",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1173 [ + - ]: 5 : tools::hsl2rgb(tools::rgb2hsl(maMagenta)) == maMagenta);
1174 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip cyan",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1175 [ + - ]: 5 : tools::hsl2rgb(tools::rgb2hsl(maCyan)) == maCyan);
1176 : :
1177 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("grey10",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1178 [ + - ]: 5 : tools::rgb2hsl(maWhite*.1) == BColor(0,0,.1));
1179 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("grey90",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1180 [ + - ]: 5 : tools::rgb2hsl(maWhite*.9) == BColor(0,0,.9));
1181 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("red/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1182 [ + - ]: 5 : tools::rgb2hsl(maRed*.5) == BColor(0,1,0.25));
1183 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("green/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1184 [ + - ]: 5 : tools::rgb2hsl(maGreen*.5) == BColor(120,1,0.25));
1185 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("blue/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1186 [ + - ]: 5 : tools::rgb2hsl(maBlue*.5) == BColor(240,1,0.25));
1187 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("yellow/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1188 [ + - ]: 5 : tools::rgb2hsl(maYellow*.5) == BColor(60,1,0.25));
1189 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("magenta/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1190 [ + - ]: 5 : tools::rgb2hsl(maMagenta*.5) == BColor(300,1,0.25));
1191 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("cyan/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1192 [ + - ]: 5 : tools::rgb2hsl(maCyan*.5) == BColor(180,1,0.25));
1193 : :
1194 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("pastel",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1195 [ + - ]: 5 : tools::rgb2hsl(BColor(.75,.25,.25)) == BColor(0,.5,.5));
1196 : 5 : }
1197 : :
1198 : : // insert your test code here.
1199 : 5 : void hsvTest()
1200 : : {
1201 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("white",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1202 [ + - ]: 5 : tools::rgb2hsv(maWhite) == BColor(0,0,1));
1203 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("black",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1204 [ + - ]: 5 : tools::rgb2hsv(maBlack) == BColor(0,0,0));
1205 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("red",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1206 [ + - ]: 5 : tools::rgb2hsv(maRed) == BColor(0,1,1));
1207 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("green",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1208 [ + - ]: 5 : tools::rgb2hsv(maGreen) == BColor(120,1,1));
1209 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("blue",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1210 [ + - ]: 5 : tools::rgb2hsv(maBlue) == BColor(240,1,1));
1211 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("yellow",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1212 [ + - ]: 5 : tools::rgb2hsv(maYellow) == BColor(60,1,1));
1213 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("magenta",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1214 [ + - ]: 5 : tools::rgb2hsv(maMagenta) == BColor(300,1,1));
1215 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("cyan",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1216 [ + - ]: 5 : tools::rgb2hsv(maCyan) == BColor(180,1,1));
1217 : :
1218 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip white",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1219 [ + - ]: 5 : tools::hsv2rgb(tools::rgb2hsv(maWhite)) == maWhite);
1220 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip black",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1221 [ + - ]: 5 : tools::hsv2rgb(tools::rgb2hsv(maBlack)) == maBlack);
1222 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip red",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1223 [ + - ]: 5 : tools::hsv2rgb(tools::rgb2hsv(maRed)) == maRed);
1224 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip green",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1225 [ + - ]: 5 : tools::hsv2rgb(tools::rgb2hsv(maGreen)) == maGreen);
1226 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip blue",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1227 [ + - ]: 5 : tools::hsv2rgb(tools::rgb2hsv(maBlue)) == maBlue);
1228 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip yellow",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1229 [ + - ]: 5 : tools::hsv2rgb(tools::rgb2hsv(maYellow)) == maYellow);
1230 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip magenta",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1231 [ + - ]: 5 : tools::hsv2rgb(tools::rgb2hsv(maMagenta)) == maMagenta);
1232 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("roundtrip cyan",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1233 [ + - ]: 5 : tools::hsv2rgb(tools::rgb2hsv(maCyan)) == maCyan);
1234 : :
1235 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("grey10",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1236 [ + - ]: 5 : tools::rgb2hsv(maWhite*.1) == BColor(0,0,.1));
1237 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("grey90",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1238 [ + - ]: 5 : tools::rgb2hsv(maWhite*.9) == BColor(0,0,.9));
1239 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("red/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1240 [ + - ]: 5 : tools::rgb2hsv(maRed*.5) == BColor(0,1,0.5));
1241 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("green/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1242 [ + - ]: 5 : tools::rgb2hsv(maGreen*.5) == BColor(120,1,0.5));
1243 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("blue/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1244 [ + - ]: 5 : tools::rgb2hsv(maBlue*.5) == BColor(240,1,0.5));
1245 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("yellow/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1246 [ + - ]: 5 : tools::rgb2hsv(maYellow*.5) == BColor(60,1,0.5));
1247 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("magenta/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1248 [ + - ]: 5 : tools::rgb2hsv(maMagenta*.5) == BColor(300,1,0.5));
1249 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("cyan/2",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1250 [ + - ]: 5 : tools::rgb2hsv(maCyan*.5) == BColor(180,1,0.5));
1251 : :
1252 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("pastel",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1253 [ + - ]: 5 : tools::rgb2hsv(BColor(.5,.25,.25)) == BColor(0,.5,.5));
1254 : 5 : }
1255 : :
1256 : 5 : void ciexyzTest()
1257 : : {
1258 : 5 : tools::rgb2ciexyz(maWhite);
1259 : 5 : tools::rgb2ciexyz(maBlack);
1260 : 5 : tools::rgb2ciexyz(maRed);
1261 : 5 : tools::rgb2ciexyz(maGreen);
1262 : 5 : tools::rgb2ciexyz(maBlue);
1263 : 5 : tools::rgb2ciexyz(maYellow);
1264 : 5 : tools::rgb2ciexyz(maMagenta);
1265 : 5 : tools::rgb2ciexyz(maCyan);
1266 : 5 : }
1267 : :
1268 : : // Change the following lines only, if you add, remove or rename
1269 : : // member functions of the current class,
1270 : : // because these macros are need by auto register mechanism.
1271 : :
1272 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(bcolor);
[ + - ][ + - ]
[ # # ]
1273 [ + - ][ + - ]: 5 : CPPUNIT_TEST(hslTest);
[ + - ][ + - ]
[ + - ][ + - ]
1274 [ + - ][ + - ]: 5 : CPPUNIT_TEST(hsvTest);
[ + - ][ + - ]
[ + - ][ + - ]
1275 [ + - ][ + - ]: 5 : CPPUNIT_TEST(ciexyzTest);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1276 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1277 : : }; // class b2dvector
1278 : :
1279 : : // -----------------------------------------------------------------------------
1280 : :
1281 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dsvgdimpex);
1282 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2drange);
1283 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolyrange);
1284 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dhommatrix);
1285 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpoint);
1286 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygon);
1287 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygontools);
1288 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolypolygon);
1289 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b1Xrange);
1290 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b1ibox);
1291 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2Xrange);
1292 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2ibox);
1293 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dtuple);
1294 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::bcolor);
1295 [ + - ][ + - ]: 15 : } // namespace basegfx2d
1296 : :
1297 : :
1298 : : // -----------------------------------------------------------------------------
1299 : :
1300 : : // this macro creates an empty function, which will called by the RegisterAllFunctions()
1301 : : // to let the user the possibility to also register some functions by hand.
1302 : : // NOADDITIONAL;
1303 : :
1304 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|