Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
714d3577
Kaydet (Commit)
714d3577
authored
Ara 08, 2003
tarafından
Thorsten Behrens
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Updated unit tests
üst
2c3b8d0c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
48 deletions
+107
-48
b2dbeziertools.hxx
basegfx/inc/basegfx/curve/b2dbeziertools.hxx
+4
-27
basegfx2d.cxx
basegfx/test/basegfx2d.cxx
+101
-19
export.map
basegfx/test/export.map
+2
-2
No files found.
basegfx/inc/basegfx/curve/b2dbeziertools.hxx
Dosyayı görüntüle @
714d3577
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
*
*
* $RCSfile: b2dbeziertools.hxx,v $
* $RCSfile: b2dbeziertools.hxx,v $
*
*
* $Revision: 1.
4
$
* $Revision: 1.
5
$
*
*
* last change: $Author: thb $ $Date: 2003-12-08 1
3:24:04
$
* last change: $Author: thb $ $Date: 2003-12-08 1
6:55:59
$
*
*
* The Contents of this file are made available subject to the terms of
* The Contents of this file are made available subject to the terms of
* either of the following licenses
* either of the following licenses
...
@@ -149,7 +149,7 @@ namespace basegfx
...
@@ -149,7 +149,7 @@ namespace basegfx
*/
*/
sal_Int32
adaptiveSubdivideByAngle
(
B2DPolygon
&
rPoly
,
sal_Int32
adaptiveSubdivideByAngle
(
B2DPolygon
&
rPoly
,
const
B2DCubicBezier
&
rCurve
,
const
B2DCubicBezier
&
rCurve
,
double
distanc
eBound
);
double
angl
eBound
);
/** Subdivide given cubic bezier segment.
/** Subdivide given cubic bezier segment.
...
@@ -226,32 +226,9 @@ namespace basegfx
...
@@ -226,32 +226,9 @@ namespace basegfx
@return the number of line segments created
@return the number of line segments created
*/
*/
sal_Int32
adaptiveSubdivideByAngle
(
B2DPolygon
&
rPoly
,
const
B2DQuadraticBezier
&
rCurve
,
double
distanceBound
);
/** Subdivide given quadratic bezier segment.
This function adaptively subdivides the given bezier
segment into as much straight line segments as necessary,
such that the maximal angle change between any adjacent
lines is less than the given error value.
@param rPoly
Output polygon. The subdivided bezier segment is added to
this polygon via B2DPolygon::append().
@param rCurve
The cubic bezier curve to subdivide
@param angleBound
Bound on the maximal angle difference between two adjacent
polygon lines, in degrees.
@return the number of line segments created
*/
sal_Int32
adaptiveSubdivideByAngle
(
B2DPolygon
&
rPoly
,
sal_Int32
adaptiveSubdivideByAngle
(
B2DPolygon
&
rPoly
,
const
B2DQuadraticBezier
&
rCurve
,
const
B2DQuadraticBezier
&
rCurve
,
double
angleBound
);
double
angleBound
);
}
}
#endif // _BGFX_CURVE_B2DBEZIERTOOLS_HXX2
#endif // _BGFX_CURVE_B2DBEZIERTOOLS_HXX2
basegfx/test/basegfx2d.cxx
Dosyayı görüntüle @
714d3577
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <cppunit/simpleheader.hxx>
#include <cppunit/simpleheader.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/curve/b2dcubicbezier.hxx>
#include <basegfx/curve/b2dcubicbezier.hxx>
#include <basegfx/curve/b2dbeziertools.hxx>
#include <basegfx/curve/b2dbeziertools.hxx>
...
@@ -15,6 +16,23 @@
...
@@ -15,6 +16,23 @@
using
namespace
::
basegfx
;
using
namespace
::
basegfx
;
using
namespace
::
std
;
using
namespace
::
std
;
namespace
{
void
plotRes
(
const
B2DPolygon
&
res
)
{
cout
<<
"plot '-' using ($1):($2) with lp"
<<
endl
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
res
.
count
();
++
i
)
{
const
B2DPoint
currPoint
(
res
.
getB2DPoint
(
i
)
);
cout
<<
currPoint
.
getX
()
<<
" "
<<
currPoint
.
getY
()
<<
endl
;
}
cout
<<
"e"
<<
endl
;
}
}
namespace
basegfx2d
namespace
basegfx2d
{
{
...
@@ -58,21 +76,33 @@ public:
...
@@ -58,21 +76,33 @@ public:
// Choosing R=1, A=0, B=pi/2
// Choosing R=1, A=0, B=pi/2
const
double
h
(
4.0
/
3.0
*
tan
(
F_PI
/
8.0
)
);
const
double
h
(
4.0
/
3.0
*
tan
(
F_PI
/
8.0
)
);
aQuarterCircle
=
B2DCubicBezier
(
a10
,
aQuarterCircle
=
B2DCubicBezier
(
a10
+
B2DPoint
(
1.0
,
0.0
),
B2DPoint
(
1.0
,
h
),
B2DPoint
(
1.0
,
h
)
+
B2DPoint
(
1.0
,
0.0
),
B2DPoint
(
h
,
1.0
),
B2DPoint
(
h
,
1.0
)
+
B2DPoint
(
1.0
,
0.0
),
a01
);
a01
+
B2DPoint
(
1.0
,
0.0
));
aCusp
=
B2DCubicBezier
(
a00
,
a11
,
a01
,
a10
);
aCusp
=
B2DCubicBezier
(
a00
+
B2DPoint
(
2.0
,
0.0
),
a11
+
B2DPoint
(
2.0
,
0.0
),
aLoop
=
B2DCubicBezier
(
a00
,
a01
,
a10
,
a00
);
a01
+
B2DPoint
(
2.0
,
0.0
),
a10
+
B2DPoint
(
2.0
,
0.0
));
aStraightLineDistinctEndPoints
=
B2DCubicBezier
(
a00
,
middle
,
middle
,
a11
);
aStraightLineIdenticalEndPoints
=
B2DCubicBezier
(
a00
,
a11
,
a11
,
a00
);
aLoop
=
B2DCubicBezier
(
a00
+
B2DPoint
(
3.0
,
0.0
),
aCrossing
=
B2DCubicBezier
(
a00
,
a01
+
B2DPoint
(
3.0
,
0.0
),
B2DPoint
(
2.0
,
2.0
),
a10
+
B2DPoint
(
3.0
,
0.0
),
B2DPoint
(
-
1.0
,
2.0
),
a00
+
B2DPoint
(
3.0
,
0.0
));
a10
);
aStraightLineDistinctEndPoints
=
B2DCubicBezier
(
a00
+
B2DPoint
(
4.0
,
0.0
),
middle
+
B2DPoint
(
4.0
,
0.0
),
middle
+
B2DPoint
(
4.0
,
0.0
),
a11
+
B2DPoint
(
4.0
,
0.0
));
aStraightLineIdenticalEndPoints
=
B2DCubicBezier
(
a00
+
B2DPoint
(
5.0
,
0.0
),
a11
+
B2DPoint
(
5.0
,
0.0
),
a11
+
B2DPoint
(
5.0
,
0.0
),
a00
+
B2DPoint
(
5.0
,
0.0
));
aCrossing
=
B2DCubicBezier
(
a00
+
B2DPoint
(
6.0
,
0.0
),
B2DPoint
(
2.0
,
2.0
)
+
B2DPoint
(
6.0
,
0.0
),
B2DPoint
(
-
1.0
,
2.0
)
+
B2DPoint
(
6.0
,
0.0
),
a10
+
B2DPoint
(
6.0
,
0.0
));
cout
<<
"#!/usr/bin/gnuplot -persist"
<<
endl
cout
<<
"#!/usr/bin/gnuplot -persist"
<<
endl
<<
"#"
<<
endl
<<
"#"
<<
endl
...
@@ -89,6 +119,8 @@ public:
...
@@ -89,6 +119,8 @@ public:
cout
<<
"# bezier subdivision"
<<
endl
cout
<<
"# bezier subdivision"
<<
endl
<<
"plot [t=0:1] "
;
<<
"plot [t=0:1] "
;
cout
<<
" bez("
cout
<<
" bez("
<<
aHalfCircle
.
getStartPoint
().
getX
()
<<
","
<<
aHalfCircle
.
getStartPoint
().
getX
()
<<
","
<<
aHalfCircle
.
getControlPointA
().
getX
()
<<
","
<<
aHalfCircle
.
getControlPointA
().
getX
()
<<
","
...
@@ -172,13 +204,63 @@ public:
...
@@ -172,13 +204,63 @@ public:
{
{
}
}
void
adaptive
Subdivide
ByDistance
()
void
adaptiveByDistance
()
{
{
#if 0
const double fBound( 0.0001 );
B2DPolygon result;
adaptiveSubdivideByDistance( result, aHalfCircle, fBound );
plotRes(result); result.clear();
adaptiveSubdivideByDistance( result, aQuarterCircle, fBound );
plotRes(result); result.clear();
adaptiveSubdivideByDistance( result, aLoop, fBound );
plotRes(result); result.clear();
adaptiveSubdivideByDistance( result, aStraightLineDistinctEndPoints, fBound );
plotRes(result); result.clear();
adaptiveSubdivideByDistance( result, aStraightLineIdenticalEndPoints, fBound );
plotRes(result); result.clear();
adaptiveSubdivideByDistance( result, aCrossing, fBound );
plotRes(result); result.clear();
adaptiveSubdivideByDistance( result, aCusp, fBound );
plotRes(result); result.clear();
#endif
CPPUNIT_ASSERT_MESSAGE
(
"identity"
,
true
);
CPPUNIT_ASSERT_MESSAGE
(
"identity"
,
true
);
}
}
void
adaptive
Subdivide
ByAngle
()
void
adaptiveByAngle
()
{
{
const
double
fBound
(
5.0
);
B2DPolygon
result
;
adaptiveSubdivideByAngle
(
result
,
aHalfCircle
,
fBound
);
plotRes
(
result
);
result
.
clear
();
adaptiveSubdivideByAngle
(
result
,
aQuarterCircle
,
fBound
);
plotRes
(
result
);
result
.
clear
();
adaptiveSubdivideByAngle
(
result
,
aLoop
,
fBound
);
plotRes
(
result
);
result
.
clear
();
adaptiveSubdivideByAngle
(
result
,
aStraightLineDistinctEndPoints
,
fBound
);
plotRes
(
result
);
result
.
clear
();
adaptiveSubdivideByAngle
(
result
,
aStraightLineIdenticalEndPoints
,
fBound
);
plotRes
(
result
);
result
.
clear
();
adaptiveSubdivideByAngle
(
result
,
aCrossing
,
fBound
);
plotRes
(
result
);
result
.
clear
();
adaptiveSubdivideByAngle
(
result
,
aCusp
,
fBound
);
plotRes
(
result
);
result
.
clear
();
CPPUNIT_ASSERT_MESSAGE
(
"identity"
,
true
);
CPPUNIT_ASSERT_MESSAGE
(
"identity"
,
true
);
}
}
...
@@ -187,8 +269,8 @@ public:
...
@@ -187,8 +269,8 @@ public:
// because these macros are need by auto register mechanism.
// because these macros are need by auto register mechanism.
CPPUNIT_TEST_SUITE
(
b2dbeziertools
);
CPPUNIT_TEST_SUITE
(
b2dbeziertools
);
CPPUNIT_TEST
(
adaptive
SubdivideByDistance
);
// TODO: add tests for quadratic bezier (subdivide and degree reduction)
CPPUNIT_TEST
(
adaptive
ByDistance
);
// TODO: add tests for quadratic bezier (subdivide and degree reduction)
CPPUNIT_TEST
(
adaptive
Subdivide
ByAngle
);
CPPUNIT_TEST
(
adaptiveByAngle
);
CPPUNIT_TEST_SUITE_END
();
CPPUNIT_TEST_SUITE_END
();
};
// class b2dcubicbezier
};
// class b2dcubicbezier
...
...
basegfx/test/export.map
Dosyayı görüntüle @
714d3577
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
#
#
# $RCSfile: export.map,v $
# $RCSfile: export.map,v $
#
#
# $Revision: 1.
1
$
# $Revision: 1.
2
$
#
#
# last change: $Author: thb $ $Date: 2003-12-08 1
3:21:2
4 $
# last change: $Author: thb $ $Date: 2003-12-08 1
6:56:0
4 $
#
#
# The Contents of this file are made available subject to the terms of
# The Contents of this file are made available subject to the terms of
# either of the following licenses
# either of the following licenses
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment