summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basegfx/Library_basegfx.mk1
-rw-r--r--basegfx/Package_inc.mk1
-rw-r--r--basegfx/StaticLibrary_basegfx_s.mk1
-rw-r--r--basegfx/inc/basegfx/tools/debugplotter.hxx111
-rw-r--r--basegfx/source/tools/debugplotter.cxx416
-rw-r--r--basegfx/test/basegfx2d.cxx321
6 files changed, 0 insertions, 851 deletions
diff --git a/basegfx/Library_basegfx.mk b/basegfx/Library_basegfx.mk
index 5e4885a55d86..af629188b050 100644
--- a/basegfx/Library_basegfx.mk
+++ b/basegfx/Library_basegfx.mk
@@ -66,7 +66,6 @@ $(eval $(call gb_Library_add_linked_libs,basegfx,\
$(eval $(call gb_Library_add_exception_objects,basegfx,\
basegfx/source/tools/b2dclipstate \
basegfx/source/tools/canvastools \
- basegfx/source/tools/debugplotter \
basegfx/source/tools/gradienttools \
basegfx/source/tools/keystoplerp \
basegfx/source/tools/liangbarsky \
diff --git a/basegfx/Package_inc.mk b/basegfx/Package_inc.mk
index 158948ecdf4b..6d1a4e745504 100644
--- a/basegfx/Package_inc.mk
+++ b/basegfx/Package_inc.mk
@@ -30,7 +30,6 @@ $(eval $(call gb_Package_Package,basegfx_inc,$(SRCDIR)/basegfx/inc))
$(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/lerp.hxx,basegfx/tools/lerp.hxx))
$(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/keystoplerp.hxx,basegfx/tools/keystoplerp.hxx))
-$(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/debugplotter.hxx,basegfx/tools/debugplotter.hxx))
$(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/canvastools.hxx,basegfx/tools/canvastools.hxx))
$(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/rectcliptools.hxx,basegfx/tools/rectcliptools.hxx))
$(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/b2dclipstate.hxx,basegfx/tools/b2dclipstate.hxx))
diff --git a/basegfx/StaticLibrary_basegfx_s.mk b/basegfx/StaticLibrary_basegfx_s.mk
index 9b113bd0c51b..891e23233be3 100644
--- a/basegfx/StaticLibrary_basegfx_s.mk
+++ b/basegfx/StaticLibrary_basegfx_s.mk
@@ -71,7 +71,6 @@ $(WORKDIR)/CustomTarget/basegfx/source/%.cxx : $(SRCDIR)/basegfx/source/%.cxx
# copied sources are generated cxx sources
$(eval $(call gb_StaticLibrary_add_generated_exception_objects,basegfx_s,\
CustomTarget/basegfx/source/tools/liangbarsky \
- CustomTarget/basegfx/source/tools/debugplotter \
CustomTarget/basegfx/source/tools/canvastools \
CustomTarget/basegfx/source/tools/gradienttools \
CustomTarget/basegfx/source/tools/keystoplerp \
diff --git a/basegfx/inc/basegfx/tools/debugplotter.hxx b/basegfx/inc/basegfx/tools/debugplotter.hxx
deleted file mode 100644
index a588d0f5f405..000000000000
--- a/basegfx/inc/basegfx/tools/debugplotter.hxx
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _BGFX_TOOLS_DEBUGPLOTTER_HXX
-#define _BGFX_TOOLS_DEBUGPLOTTER_HXX
-
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/vector/b2dvector.hxx>
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <rtl/string.hxx>
-#include <boost/utility.hpp> // for noncopyable
-#include <vector>
-#include <utility>
-#include <iosfwd>
-#include <basegfx/basegfxdllapi.h>
-
-
-namespace basegfx
-{
- class B2DCubicBezier;
-
- /** Generates debug output for various basegfx data types.
-
- Use this class to produce debug (trace) output for various
- basegfx geometry data types. By default, this class outputs
- via OSL_TRACE (i.e. to stderr), and uses the gnuplot output
- format.
-
- To be able to generate one coherent block of output, this
- class delays actual writing to its destructor
- */
- class BASEGFX_DLLPUBLIC DebugPlotter : private ::boost::noncopyable
- {
- public:
- /** Create new debug output object
-
- @param pTitle
- Title of the debug output, will appear in trace output
- */
- explicit DebugPlotter( const sal_Char* pTitle );
-
- /** Create new debug output object
-
- @param pTitle
- Title of the debug output, will appear in trace output
-
- @param rOutputStream
- Stream to write output to. Must stay valid over the
- lifetime of this object!
- */
- DebugPlotter( const sal_Char* pTitle,
- ::std::ostream& rOutputStream );
-
- ~DebugPlotter();
-
- void plot( const B2DPoint& rPoint,
- const sal_Char* pTitle );
- void plot( const B2DVector& rVec,
- const sal_Char* pTitle );
- void plot( const B2DCubicBezier& rBezier,
- const sal_Char* pTitle );
- void plot( const B2DRange& rRange,
- const sal_Char* pTitle );
- void plot( const B2DPolygon& rPoly,
- const sal_Char* pTitle );
- void plot( const B2DPolyPolygon& rPoly,
- const sal_Char* pTitle );
-
- private:
- void print( const sal_Char* );
-
- ::rtl::OString maTitle;
- ::std::vector< ::std::pair< B2DPoint, ::rtl::OString > > maPoints;
- ::std::vector< ::std::pair< B2DVector, ::rtl::OString > > maVectors;
- ::std::vector< ::std::pair< B2DRange, ::rtl::OString > > maRanges;
- ::std::vector< ::std::pair< B2DPolygon, ::rtl::OString > > maPolygons;
-
- ::std::ostream* mpOutputStream;
- };
-}
-
-#endif /* _BGFX_TOOLS_DEBUGPLOTTER_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basegfx/source/tools/debugplotter.cxx b/basegfx/source/tools/debugplotter.cxx
deleted file mode 100644
index e8581d5f0c0c..000000000000
--- a/basegfx/source/tools/debugplotter.cxx
+++ /dev/null
@@ -1,416 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <osl/diagnose.h>
-
-#include <basegfx/curve/b2dcubicbezier.hxx>
-
-#include <basegfx/tools/debugplotter.hxx>
-#include <boost/bind.hpp>
-
-#include <ostream>
-
-
-namespace basegfx
-{
- namespace
- {
- void outputHeader( const ::rtl::OString& rTitle,
- ::std::ostream* pStm )
- {
- // output gnuplot setup
- if( pStm )
- {
- *pStm << "#!/usr/bin/gnuplot -persist" << ::std::endl <<
- "#" << ::std::endl <<
- "# automatically generated by basegfx, don't change!" << ::std::endl <<
- "#" << ::std::endl <<
- "# --- " << rTitle.getStr() << " ---" << ::std::endl <<
- "#" << ::std::endl <<
- "set parametric" << ::std::endl <<
- "# set terminal postscript eps enhanced color " << ::std::endl <<
- "# set output \"plot.eps\"" << ::std::endl <<
- // This function plots a cubic bezier curve. P,q,r,s
- // are the control point elements of the corresponding
- // output coordinate component (i.e. x components for
- // the x plot, and y components for the y plot)
- "cubicBezier(p,q,r,s,t) = p*(1-t)**3+q*3*(1-t)**2*t+r*3*(1-t)*t**2+s*t**3" << ::std::endl <<
- // This function plots the derivative of a cubic
- // bezier curve. P,q,r,s are the control point
- // components of the _original_ curve
- "cubicBezDerivative(p,q,r,s,t) = 3*(q-p)*(1-t)**2+6*(r-q)*(1-t)*t+3*(s-r)*t**2" << ::std::endl <<
- // Plot a line's component of a line between a and b
- // (where a and b should be the corresponding
- // components of the line's start and end point,
- // respectively)
- "line(p,q,r) = p*(1-t)+q*t" << ::std::endl <<
- // Plot a line's x component of a line in implicit
- // form ax + by + c = 0
- "implicitLineX(a,b,c,t) = a*-c + t*-b" << ::std::endl <<
- // Plot a line's y component of a line in implicit
- // form ax + by + c = 0
- "implicitLineY(a,b,c,t) = b*-c + t*a" << ::std::endl <<
- "pointmarkx(c,t) = c-0.03*t" << ::std::endl << // hack for displaying single points in parametric form
- "pointmarky(c,t) = c+0.03*t" << ::std::endl << // hack for displaying single points in parametric form
- "# end of setup" << ::std::endl;
- }
- else
- {
- OSL_TRACE( "#!/usr/bin/gnuplot -persist\n",
- "#\n",
- "# automatically generated by basegfx, don't change!\n",
- "#\n",
- "# --- %s ---\n",
- "#\n",
- "set parametric\n",
- // This function plots a cubic bezier curve. P,q,r,s
- // are the control point elements of the corresponding
- // output coordinate component (i.e. x components for
- // the x plot, and y components for the y plot)
- "cubicBezier(p,q,r,s,t) = p*(1-t)**3+q*3*(1-t)**2*t+r*3*(1-t)*t**2+s*t**3\n",
- // This function plots the derivative of a cubic
- // bezier curve. P,q,r,s are the control point
- // components of the _original_ curve
- "cubicBezDerivative(p,q,r,s,t) = 3*(q-p)*(1-t)**2+6*(r-q)*(1-t)*t+3*(s-r)*t**2\n",
- // Plot a line's component of a line between a and b
- // (where a and b should be the corresponding
- // components of the line's start and end point,
- // respectively)
- "line(p,q,r) = p*(1-t)+q*t\n",
- // Plot a line's x component of a line in implicit
- // form ax + by + c = 0
- "implicitLineX(a,b,c,t) = a*-c + t*-b\n",
- // Plot a line's y component of a line in implicit
- // form ax + by + c = 0
- "implicitLineY(a,b,c,t) = b*-c + t*a\n",
- "pointmarkx(c,t) = c-0.03*t\n", // hack for displaying single points in parametric form
- "pointmarky(c,t) = c+0.03*t\n", // hack for displaying single points in parametric form
- "# end of setup\n",
- rTitle.getStr() );
- }
- }
-
- class Writer
- {
- public:
- Writer( ::std::ostream* pStm ) :
- mpStream( pStm )
- {
- }
-
- void outputPoint( const ::std::pair< B2DPoint, ::rtl::OString >& rElem )
- {
- if( mpStream )
- *mpStream << " " << rElem.first.getX() << "\t" << rElem.first.getY() << ::std::endl;
- else
- OSL_TRACE( " %f\t%f", rElem.first.getX(), rElem.first.getY() );
- }
-
- void outputVector( const ::std::pair< B2DVector, ::rtl::OString >& rElem )
- {
- if( mpStream )
- *mpStream << " " << rElem.first.getX() << "\t" << rElem.first.getY() << ::std::endl << ::std::endl;
- else
- OSL_TRACE( " %f\t%f", rElem.first.getX(), rElem.first.getY() );
- }
-
- void outputRect( const ::std::pair< B2DRange, ::rtl::OString >& rElem )
- {
- const double nX0( rElem.first.getMinX() );
- const double nY0( rElem.first.getMinY() );
- const double nX1( rElem.first.getMaxX() );
- const double nY1( rElem.first.getMaxY() );
-
- if( mpStream )
- *mpStream << " "
- << nX0 << "\t" << nY0 << "\t"
- << nX1 << "\t" << nY0 << "\t"
- << nX1 << "\t" << nY1 << "\t"
- << nX0 << "\t" << nY1 << "\t"
- << nX0 << "\t" << nY0 << ::std::endl << ::std::endl;
-
- else
- OSL_TRACE( " %f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n\n",
- nX0, nY0,
- nX1, nY0,
- nX1, nY1,
- nX0, nY1,
- nX0, nY0 );
- }
-
- private:
- ::std::ostream* mpStream;
- };
- }
-
- DebugPlotter::DebugPlotter( const sal_Char* pTitle ) :
- maTitle( pTitle ),
- maPoints(),
- maVectors(),
- maRanges(),
- maPolygons(),
- mpOutputStream(NULL)
- {
- }
-
- DebugPlotter::DebugPlotter( const sal_Char* pTitle,
- ::std::ostream& rOutputStream ) :
- maTitle( pTitle ),
- maPoints(),
- maVectors(),
- maRanges(),
- maPolygons(),
- mpOutputStream(&rOutputStream)
- {
- }
-
- DebugPlotter::~DebugPlotter()
- {
- const bool bHavePoints( !maPoints.empty() );
- const bool bHaveVectors( !maVectors.empty() );
- const bool bHaveRanges( !maRanges.empty() );
- const bool bHavePolygons( !maPolygons.empty() );
-
- if( bHavePoints ||
- bHaveVectors ||
- bHaveRanges ||
- bHavePolygons )
- {
- outputHeader( maTitle, mpOutputStream );
-
- print( "\n\n# parametric primitive output\n"
- "plot [t=0:1] \\\n" );
-
- // output plot declarations for used entities
- bool bNeedColon( false );
- if( bHavePoints )
- {
- print( " '-' using ($1):($2) title \"Points\" with points" );
- bNeedColon = true;
- }
- if( bHaveVectors )
- {
- if( bNeedColon )
- print( ", \\\n" );
-
- print( " '-' using ($1):($2) title \"Vectors\" with lp" );
- bNeedColon = true;
- }
- if( bHaveRanges )
- {
- if( bNeedColon )
- print( ", \\\n" );
-
- print( " '-' using ($1):($2) title \"Ranges\" with lines" );
- bNeedColon = true;
- }
- if( bHavePolygons )
- {
- const ::std::size_t nSize( maPolygons.size() );
- for( ::std::size_t i=0; i<nSize; ++i )
- {
- if( maPolygons.at(i).first.areControlPointsUsed() )
- {
- const B2DPolygon& rCurrPoly( maPolygons.at(i).first );
-
- const sal_uInt32 nCount( rCurrPoly.count() );
- for( sal_uInt32 k=0; k<nCount; ++k )
- {
- if( bNeedColon )
- print( ", \\\n" );
-
- const B2DPoint& rP0( rCurrPoly.getB2DPoint(k) );
- const B2DPoint& rP1( rCurrPoly.getNextControlPoint(k) );
- const B2DPoint& rP2( rCurrPoly.getPrevControlPoint((k + 1) % nCount) );
- const B2DPoint& rP3( k+1<nCount ? rCurrPoly.getB2DPoint(k+1) : rCurrPoly.getB2DPoint(k) );
-
- if( mpOutputStream )
- *mpOutputStream << " cubicBezier("
- << rP0.getX() << ","
- << rP1.getX() << ","
- << rP2.getX() << ","
- << rP3.getX() << ",t), \\\n cubicBezier("
- << rP0.getY() << ","
- << rP1.getY() << ","
- << rP2.getY() << ","
- << rP3.getY() << ",t)";
- else
- OSL_TRACE( " cubicBezier(%f,%f,%f,%f,t), \\\n"
- " cubicBezier(%f,%f,%f,%f,t)",
- rP0.getX(),
- rP1.getX(),
- rP2.getX(),
- rP3.getX(),
- rP0.getY(),
- rP1.getY(),
- rP2.getY(),
- rP3.getY() );
-
- bNeedColon = true;
- }
- }
- else
- {
- if( bNeedColon )
- print( ", \\\n" );
-
- if( mpOutputStream )
- *mpOutputStream << " '-' using ($1):($2) title \"Polygon "
- << maPolygons.at(i).second.getStr() << "\" with lp";
- else
- OSL_TRACE( " '-' using ($1):($2) title \"Polygon %s\" with lp",
- maPolygons.at(i).second.getStr() );
-
- bNeedColon = true;
- }
- }
- }
-
- if( bHavePoints )
- {
- Writer aWriter( mpOutputStream );
-
- ::std::for_each( maPoints.begin(),
- maPoints.end(),
- ::boost::bind( &Writer::outputPoint,
- ::boost::ref( aWriter ),
- _1 ) );
- print( "e\n" );
- }
-
- if( bHaveVectors )
- {
- Writer aWriter( mpOutputStream );
-
- ::std::for_each( maVectors.begin(),
- maVectors.end(),
- ::boost::bind( &Writer::outputVector,
- ::boost::ref( aWriter ),
- _1 ) );
- print( "e\n" );
- }
-
- if( bHaveRanges )
- {
- Writer aWriter( mpOutputStream );
-
- ::std::for_each( maRanges.begin(),
- maRanges.end(),
- ::boost::bind( &Writer::outputRect,
- ::boost::ref( aWriter ),
- _1 ) );
- print( "e\n" );
- }
-
- if( bHavePolygons )
- {
- const ::std::size_t nSize( maPolygons.size() );
- for( ::std::size_t i=0; i<nSize; ++i )
- {
- if( !maPolygons.at(i).first.areControlPointsUsed() )
- {
- const B2DPolygon& rCurrPoly( maPolygons.at(i).first );
-
- const sal_uInt32 nCount( rCurrPoly.count() );
- for( sal_uInt32 k=0; k<nCount; ++k )
- {
- const B2DPoint& rP( rCurrPoly.getB2DPoint(k) );
-
- if( mpOutputStream )
- *mpOutputStream << " " << rP.getX() << "," << rP.getY();
- else
- OSL_TRACE( " %f,%f",
- rP.getX(),
- rP.getX() );
- }
-
- print( "\ne\n" );
- }
- }
- }
- }
- }
-
- void DebugPlotter::plot( const B2DPoint& rPoint,
- const sal_Char* pTitle )
- {
- maPoints.push_back( ::std::make_pair( rPoint,
- ::rtl::OString( pTitle ) ) );
- }
-
- void DebugPlotter::plot( const B2DVector& rVec,
- const sal_Char* pTitle )
- {
- maVectors.push_back( ::std::make_pair( rVec,
- ::rtl::OString( pTitle ) ) );
- }
-
- void DebugPlotter::plot( const B2DCubicBezier& rBezier,
- const sal_Char* pTitle )
- {
- B2DPolygon aPoly;
- aPoly.append(rBezier.getStartPoint());
- aPoly.appendBezierSegment(rBezier.getControlPointA(), rBezier.getControlPointB(), rBezier.getEndPoint());
- maPolygons.push_back( ::std::make_pair( aPoly,
- ::rtl::OString( pTitle ) ) );
- }
-
- void DebugPlotter::plot( const B2DRange& rRange,
- const sal_Char* pTitle )
- {
- maRanges.push_back( ::std::make_pair( rRange,
- ::rtl::OString( pTitle ) ) );
- }
-
- void DebugPlotter::plot( const B2DPolygon& rPoly,
- const sal_Char* pTitle )
- {
- maPolygons.push_back( ::std::make_pair( rPoly,
- ::rtl::OString( pTitle ) ) );
- }
-
- void DebugPlotter::plot( const B2DPolyPolygon& rPoly,
- const sal_Char* pTitle )
- {
- const ::rtl::OString aTitle( pTitle );
- const sal_uInt32 nCount( rPoly.count() );
- for( sal_uInt32 i=0; i<nCount; ++i )
- maPolygons.push_back( ::std::make_pair( rPoly.getB2DPolygon( i ),
- aTitle ) );
- }
-
- void DebugPlotter::print( const sal_Char* pStr )
- {
- if( mpOutputStream )
- *mpOutputStream << pStr;
- else
- OSL_TRACE( pStr );
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx
index d0251aae9013..65f778f21282 100644
--- a/basegfx/test/basegfx2d.cxx
+++ b/basegfx/test/basegfx2d.cxx
@@ -53,7 +53,6 @@
#include <basegfx/color/bcolor.hxx>
#include <basegfx/color/bcolortools.hxx>
-#include <basegfx/tools/debugplotter.hxx>
#include <basegfx/tools/rectcliptools.hxx>
#include <iostream>
@@ -325,266 +324,6 @@ public:
SAL_CPPUNIT_TEST_SUITE_END();
};
-class b2dbeziertools : public CppUnit::TestFixture
-{
-private:
- B2DCubicBezier aHalfCircle; // not exactly, but a look-alike
- B2DCubicBezier aQuarterCircle; // not exactly, but a look-alike
- B2DCubicBezier aLoop; // identical endpoints, curve goes back to where it started
- B2DCubicBezier aStraightLineDistinctEndPoints; // truly a line
- B2DCubicBezier aStraightLineDistinctEndPoints2; // truly a line, with slightly different control points
- B2DCubicBezier aStraightLineIdenticalEndPoints; // degenerate case of aLoop
- B2DCubicBezier aStraightLineIdenticalEndPoints2;// degenerate case of aLoop, with slightly different control points
- B2DCubicBezier aCrossing; // curve self-intersects somewhere in the middle
- B2DCubicBezier aCusp; // curve has a point of undefined tangency
-
-
-public:
- // initialise your test code values here.
- void setUp()
- {
- const B2DPoint a00(0.0, 0.0);
- const B2DPoint a10(1.0, 0.0);
- const B2DPoint a11(1.0, 1.0);
- const B2DPoint a01(0.0, 1.0);
- const B2DPoint middle( 0.5, 0.5 );
- const B2DPoint quarterDown( 0.25, 0.25 );
- const B2DPoint quarterUp( 0.75, 0.75 );
-
- aHalfCircle = B2DCubicBezier(a00, a01, a11, a10);
-
- // The spline control points become
- //
- // (R * cos(A), R * sin(A))
- // (R * cos(A) - h * sin(A), R * sin(A) + h * cos (A))
- // (R * cos(B) + h * sin(B), R * sin(B) - h * cos (B))
- // (R * cos(B), R * sin(B))
- //
- // where h = 4/3 * R * tan ((B-A)/4)
- //
- // with R being the radius, A start angle and B end angle (A < B).
- //
- // (This calculation courtesy Carl Worth, himself based on
- // Michael Goldapp and Dokken/Daehlen)
-
- // Choosing R=1, A=0, B=pi/2
- const double h( 4.0/3.0 * tan(M_PI/8.0) );
- aQuarterCircle = B2DCubicBezier(a10 + B2DPoint(1.0,0.0),
- B2DPoint(B2DPoint( 1.0, h ) + B2DPoint(1.0,0.0)),
- B2DPoint(B2DPoint( h, 1.0) + B2DPoint(1.0,0.0)),
- a01 + B2DPoint(1.0,0.0));
-
- aCusp = B2DCubicBezier(a00 + B2DPoint(2.0,0.0),
- B2DPoint(a11 + B2DPoint(2.0,0.0)),
- B2DPoint(a01 + B2DPoint(2.0,0.0)),
- a10 + B2DPoint(2.0,0.0));
-
- aLoop = B2DCubicBezier(a00 + B2DPoint(3.0,0.0),
- B2DPoint(a01 + B2DPoint(3.0,0.0)),
- B2DPoint(a10 + B2DPoint(3.0,0.0)),
- a00 + B2DPoint(3.0,0.0));
-
- aStraightLineDistinctEndPoints = B2DCubicBezier(a00 + B2DPoint(4.0,0.0),
- B2DPoint(middle + B2DPoint(4.0,0.0)),
- B2DPoint(middle + B2DPoint(4.0,0.0)),
- a11 + B2DPoint(4.0,0.0));
-
- aStraightLineDistinctEndPoints2 = B2DCubicBezier(a00 + B2DPoint(5.0,0.0),
- B2DPoint(quarterDown + B2DPoint(5.0,0.0)),
- B2DPoint(quarterUp + B2DPoint(5.0,0.0)),
- a11 + B2DPoint(5.0,0.0));
-
- aStraightLineIdenticalEndPoints = B2DCubicBezier(a00 + B2DPoint(6.0,0.0),
- B2DPoint(a11 + B2DPoint(6.0,0.0)),
- B2DPoint(a11 + B2DPoint(6.0,0.0)),
- a00 + B2DPoint(6.0,0.0));
-
- aStraightLineIdenticalEndPoints2 = B2DCubicBezier(a00 + B2DPoint(7.0,0.0),
- B2DPoint(quarterDown + B2DPoint(7.0,0.0)),
- B2DPoint(quarterUp + B2DPoint(7.0,0.0)),
- a00 + B2DPoint(7.0,0.0));
-
- aCrossing = B2DCubicBezier(a00 + B2DPoint(8.0,0.0),
- B2DPoint(B2DPoint(2.0,2.0) + B2DPoint(8.0,0.0)),
- B2DPoint(B2DPoint(-1.0,2.0) + B2DPoint(8.0,0.0)),
- a10 + B2DPoint(8.0,0.0));
-
- ::std::ofstream output("bez_testcases.gnuplot");
- DebugPlotter aPlotter( "Original curves",
- output );
-
- aPlotter.plot( aHalfCircle,
- "half circle" );
- aPlotter.plot( aQuarterCircle,
- "quarter circle" );
- aPlotter.plot( aCusp,
- "cusp" );
- aPlotter.plot( aLoop,
- "loop" );
- aPlotter.plot( aStraightLineDistinctEndPoints,
- "straight line 0" );
- aPlotter.plot( aStraightLineDistinctEndPoints2,
- "straight line 1" );
- aPlotter.plot( aStraightLineIdenticalEndPoints,
- "straight line 2" );
- aPlotter.plot( aStraightLineIdenticalEndPoints2,
- "straight line 3" );
- aPlotter.plot( aCrossing,
- "crossing" );
-
- // break up a complex bezier (loopy, spiky or self intersecting)
- // into simple segments (left to right)
- B2DCubicBezier aSegment = aCrossing;
- double fExtremePos(0.0);
-
- aPlotter.plot( aSegment, "segment" );
- while(aSegment.getMinimumExtremumPosition(fExtremePos))
- {
- aSegment.split(fExtremePos, 0, &aSegment);
- aPlotter.plot( aSegment, "segment" );
- }
- }
-
- void tearDown()
- {
- }
-
- void adaptiveByDistance()
- {
- ::std::ofstream output("bez_adaptiveByDistance.gnuplot");
- DebugPlotter aPlotter( "distance-adaptive subdivision",
- output );
-
- const double fBound( 0.0001 );
- B2DPolygon result;
-
- aHalfCircle.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "half circle"); result.clear();
-
- aQuarterCircle.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "quarter circle"); result.clear();
-
- aLoop.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "loop"); result.clear();
-
- aStraightLineDistinctEndPoints.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "straight line 0"); result.clear();
-
- aStraightLineDistinctEndPoints2.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "straight line 1"); result.clear();
-
- aStraightLineIdenticalEndPoints.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "straight line 2"); result.clear();
-
- aStraightLineIdenticalEndPoints2.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "straight line 3"); result.clear();
-
- aCrossing.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "straight line 4"); result.clear();
-
- aCusp.adaptiveSubdivideByDistance(result, fBound);
- aPlotter.plot(result,
- "straight line 5"); result.clear();
-
- CPPUNIT_ASSERT_MESSAGE("adaptiveByDistance", true );
- }
-
- void adaptiveByAngle()
- {
- const double fBound( 5.0 );
- B2DPolygon result;
-
- ::std::ofstream output("bez_adaptiveByAngle.gnuplot");
- DebugPlotter aPlotter( "angle-adaptive subdivision",
- output );
-
- aHalfCircle.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "half circle"); result.clear();
-
- aQuarterCircle.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "quarter cirle"); result.clear();
-
- aLoop.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "loop"); result.clear();
-
- aStraightLineDistinctEndPoints.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "straight line 0"); result.clear();
-
- aStraightLineDistinctEndPoints2.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "straight line 1"); result.clear();
-
- aStraightLineIdenticalEndPoints.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "straight line 2"); result.clear();
-
- aStraightLineIdenticalEndPoints2.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "straight line 3"); result.clear();
-
- aCrossing.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "straight line 4"); result.clear();
-
- aCusp.adaptiveSubdivideByAngle(result, fBound, true);
- aPlotter.plot(result,
- "straight line 5"); result.clear();
-
- CPPUNIT_ASSERT_MESSAGE("adaptiveByAngle", true );
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- SAL_CPPUNIT_TEST_SUITE(b2dbeziertools);
- CPPUNIT_TEST(adaptiveByDistance); // TODO: add tests for quadratic bezier (subdivide and degree reduction)
- CPPUNIT_TEST(adaptiveByAngle);
- SAL_CPPUNIT_TEST_SUITE_END();
-}; // class b2dcubicbezier
-
-
-class b2dcubicbezier : public CppUnit::TestFixture
-{
-public:
- // initialise your test code values here.
- void setUp()
- {
- }
-
- void tearDown()
- {
- }
-
- // insert your test code here.
- void EmptyMethod()
- {
- // this is demonstration code
- // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- SAL_CPPUNIT_TEST_SUITE(b2dcubicbezier);
- CPPUNIT_TEST(EmptyMethod);
- SAL_CPPUNIT_TEST_SUITE_END();
-}; // class b2dcubicbezier
-
-
class b2dhommatrix : public CppUnit::TestFixture
{
private:
@@ -1193,36 +932,6 @@ public:
SAL_CPPUNIT_TEST_SUITE_END();
}; // class b2dpolypolygon
-
-class b2dquadraticbezier : public CppUnit::TestFixture
-{
-public:
- // initialise your test code values here.
- void setUp()
- {
- }
-
- void tearDown()
- {
- }
-
- // insert your test code here.
- // this is only demonstration code
- void EmptyMethod()
- {
- // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- SAL_CPPUNIT_TEST_SUITE(b2dquadraticbezier);
- CPPUNIT_TEST(EmptyMethod);
- SAL_CPPUNIT_TEST_SUITE_END();
-}; // class b2dquadraticbezier
-
-
class b1Xrange : public CppUnit::TestFixture
{
public:
@@ -1485,33 +1194,6 @@ public:
SAL_CPPUNIT_TEST_SUITE_END();
}; // class b2dtuple
-
-class b2dvector : public CppUnit::TestFixture
-{
-public:
- // initialise your test code values here.
- void setUp()
- {
- }
-
- void tearDown()
- {
- }
-
- // insert your test code here.
- void EmptyMethod()
- {
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- SAL_CPPUNIT_TEST_SUITE(b2dvector);
- CPPUNIT_TEST(EmptyMethod);
- SAL_CPPUNIT_TEST_SUITE_END();
-}; // class b2dvector
-
class bcolor : public CppUnit::TestFixture
{
BColor maWhite;
@@ -1690,20 +1372,17 @@ public:
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dsvgdimpex);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolyrange);
-CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dcubicbezier);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dhommatrix);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dhompoint);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpoint);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygon);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygontools);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolypolygon);
-CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dquadraticbezier);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b1Xrange);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b1ibox);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2Xrange);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2ibox);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dtuple);
-CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dvector);
CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::bcolor);
} // namespace basegfx2d