summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2003-11-06 15:30:30 +0000
committerArmin Weiss <aw@openoffice.org>2003-11-06 15:30:30 +0000
commitfef23aeb65bed8951a90ed71beb1552b62cfce71 (patch)
treed2ee4fe2d735d77de4f1618ea6664042269a67fa
parent8db4a5314c1b74eba07f4f4e383fafa24239e1f1 (diff)
Added tooling for PolyPolygon cutting and some more tooling at B2DPolygon and B2DPolyPolygon
-rw-r--r--basegfx/inc/basegfx/curve/b2dcubicbezier.hxx34
-rw-r--r--basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx28
-rw-r--r--basegfx/inc/basegfx/point/b2dhompoint.hxx6
-rw-r--r--basegfx/inc/basegfx/point/b2dpoint.hxx14
-rw-r--r--basegfx/inc/basegfx/point/b3dhompoint.hxx6
-rw-r--r--basegfx/inc/basegfx/point/b3dpoint.hxx12
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolygon.hxx31
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolygontools.hxx62
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx12
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx21
-rw-r--r--basegfx/inc/basegfx/range/b1drange.hxx9
-rw-r--r--basegfx/inc/basegfx/range/b2drange.hxx12
-rw-r--r--basegfx/inc/basegfx/range/b3drange.hxx13
-rw-r--r--basegfx/inc/basegfx/vector/b2dvector.hxx10
-rw-r--r--basegfx/inc/basegfx/vector/b3dvector.hxx12
-rw-r--r--basegfx/prj/d.lst1
-rw-r--r--basegfx/source/curve/b2dcubicbezier.cxx10
-rw-r--r--basegfx/source/curve/b2dquadraticbezier.cxx8
-rw-r--r--basegfx/source/point/b2dpoint.cxx8
-rw-r--r--basegfx/source/point/makefile.mk6
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx102
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx345
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx20
-rw-r--r--basegfx/source/polygon/b2dpolypolygontools.cxx91
-rw-r--r--basegfx/source/polygon/makefile.mk13
-rw-r--r--basegfx/source/vector/b2dvector.cxx8
26 files changed, 680 insertions, 214 deletions
diff --git a/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx b/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx
index 66f70223a14f..9761367bdd1b 100644
--- a/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx
+++ b/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dcubicbezier.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:35 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,17 +74,17 @@ namespace basegfx
{
class B2DCubicBezier
{
- point::B2DPoint maStartPoint;
- point::B2DPoint maEndPoint;
- point::B2DPoint maControlPointA;
- point::B2DPoint maControlPointB;
+ ::basegfx::point::B2DPoint maStartPoint;
+ ::basegfx::point::B2DPoint maEndPoint;
+ ::basegfx::point::B2DPoint maControlPointA;
+ ::basegfx::point::B2DPoint maControlPointB;
public:
B2DCubicBezier();
B2DCubicBezier(const B2DCubicBezier& rBezier);
- B2DCubicBezier(const point::B2DPoint& rStart, const point::B2DPoint& rEnd);
- B2DCubicBezier(const point::B2DPoint& rStart, const point::B2DPoint& rControlPointA,
- const point::B2DPoint& rControlPointB, const point::B2DPoint& rEnd);
+ B2DCubicBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rEnd);
+ B2DCubicBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rControlPointA,
+ const ::basegfx::point::B2DPoint& rControlPointB, const ::basegfx::point::B2DPoint& rEnd);
~B2DCubicBezier();
// assignment operator
@@ -101,17 +101,17 @@ namespace basegfx
void testAndSolveTrivialBezier();
// data interface
- point::B2DPoint getStartPoint() const { return maStartPoint; }
- void setStartPoint(const point::B2DPoint& rValue) { maStartPoint = rValue; }
+ ::basegfx::point::B2DPoint getStartPoint() const { return maStartPoint; }
+ void setStartPoint(const ::basegfx::point::B2DPoint& rValue) { maStartPoint = rValue; }
- point::B2DPoint getEndPoint() const { return maEndPoint; }
- void setEndPoint(const point::B2DPoint& rValue) { maEndPoint = rValue; }
+ ::basegfx::point::B2DPoint getEndPoint() const { return maEndPoint; }
+ void setEndPoint(const ::basegfx::point::B2DPoint& rValue) { maEndPoint = rValue; }
- point::B2DPoint getControlPointA() const { return maControlPointA; }
- void setControlPointA(const point::B2DPoint& rValue) { maControlPointA = rValue; }
+ ::basegfx::point::B2DPoint getControlPointA() const { return maControlPointA; }
+ void setControlPointA(const ::basegfx::point::B2DPoint& rValue) { maControlPointA = rValue; }
- point::B2DPoint getControlPointB() const { return maControlPointB; }
- void setControlPointB(const point::B2DPoint& rValue) { maControlPointB = rValue; }
+ ::basegfx::point::B2DPoint getControlPointB() const { return maControlPointB; }
+ void setControlPointB(const ::basegfx::point::B2DPoint& rValue) { maControlPointB = rValue; }
};
} // end of namespace curve
} // end of namespace basegfx
diff --git a/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx b/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx
index 72c4df358c74..95f7eeda845a 100644
--- a/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx
+++ b/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dquadraticbezier.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:35 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,16 +74,16 @@ namespace basegfx
{
class B2DQuadraticBezier
{
- point::B2DPoint maStartPoint;
- point::B2DPoint maEndPoint;
- point::B2DPoint maControlPoint;
+ ::basegfx::point::B2DPoint maStartPoint;
+ ::basegfx::point::B2DPoint maEndPoint;
+ ::basegfx::point::B2DPoint maControlPoint;
public:
B2DQuadraticBezier();
B2DQuadraticBezier(const B2DQuadraticBezier& rBezier);
- B2DQuadraticBezier(const point::B2DPoint& rStart, const point::B2DPoint& rEnd);
- B2DQuadraticBezier(const point::B2DPoint& rStart,
- const point::B2DPoint& rControlPoint, const point::B2DPoint& rEnd);
+ B2DQuadraticBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rEnd);
+ B2DQuadraticBezier(const ::basegfx::point::B2DPoint& rStart,
+ const ::basegfx::point::B2DPoint& rControlPoint, const ::basegfx::point::B2DPoint& rEnd);
~B2DQuadraticBezier();
// assignment operator
@@ -97,14 +97,14 @@ namespace basegfx
sal_Bool isBezier() const;
// data interface
- point::B2DPoint getStartPoint() const { return maStartPoint; }
- void setStartPoint(const point::B2DPoint& rValue) { maStartPoint = rValue; }
+ ::basegfx::point::B2DPoint getStartPoint() const { return maStartPoint; }
+ void setStartPoint(const ::basegfx::point::B2DPoint& rValue) { maStartPoint = rValue; }
- point::B2DPoint getEndPoint() const { return maEndPoint; }
- void setEndPoint(const point::B2DPoint& rValue) { maEndPoint = rValue; }
+ ::basegfx::point::B2DPoint getEndPoint() const { return maEndPoint; }
+ void setEndPoint(const ::basegfx::point::B2DPoint& rValue) { maEndPoint = rValue; }
- point::B2DPoint getControlPoint() const { return maControlPoint; }
- void setControlPoint(const point::B2DPoint& rValue) { maControlPoint = rValue; }
+ ::basegfx::point::B2DPoint getControlPoint() const { return maControlPoint; }
+ void setControlPoint(const ::basegfx::point::B2DPoint& rValue) { maControlPoint = rValue; }
};
} // end of namespace curve
} // end of namespace basegfx
diff --git a/basegfx/inc/basegfx/point/b2dhompoint.hxx b/basegfx/inc/basegfx/point/b2dhompoint.hxx
index 5407b2653029..3b145bf4e444 100644
--- a/basegfx/inc/basegfx/point/b2dhompoint.hxx
+++ b/basegfx/inc/basegfx/point/b2dhompoint.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dhompoint.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:38 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,7 +87,7 @@ namespace basegfx
{
protected:
/// This member contains the coordinate part of the point
- tuple::B2DTuple maTuple;
+ ::basegfx::tuple::B2DTuple maTuple;
/// This Member holds the homogenous part of the point
double mfW;
diff --git a/basegfx/inc/basegfx/point/b2dpoint.hxx b/basegfx/inc/basegfx/point/b2dpoint.hxx
index 723e734abce9..297bada3ba56 100644
--- a/basegfx/inc/basegfx/point/b2dpoint.hxx
+++ b/basegfx/inc/basegfx/point/b2dpoint.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpoint.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-10-31 10:12:49 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,7 +84,7 @@ namespace basegfx
@see B2DTuple
*/
- class B2DPoint : public tuple::B2DTuple
+ class B2DPoint : public ::basegfx::tuple::B2DTuple
{
public:
/** Create a 2D Point
@@ -123,7 +123,7 @@ namespace basegfx
/** constructor with tuple to allow copy-constructing
from B2DTuple-based classes
*/
- B2DPoint(const B2DTuple& rTuple)
+ B2DPoint(const ::basegfx::tuple::B2DTuple& rTuple)
: B2DTuple(rTuple)
{}
@@ -133,18 +133,18 @@ namespace basegfx
/** assignment operator to allow assigning the results
of B2DTuple calculations
*/
- B2DPoint& operator=( const B2DTuple& rPoint );
+ B2DPoint& operator=( const ::basegfx::tuple::B2DTuple& rPoint );
/** Transform point by given transformation matrix.
The translational components of the matrix are, in
contrast to B2DVector, applied.
*/
- B2DPoint& operator*=( const matrix::B2DHomMatrix& rMat );
+ B2DPoint& operator*=( const ::basegfx::matrix::B2DHomMatrix& rMat );
static const B2DPoint& getEmptyPoint()
{
- return (const B2DPoint&) tuple::B2DTuple::getEmptyTuple();
+ return (const B2DPoint&) ::basegfx::tuple::B2DTuple::getEmptyTuple();
}
};
} // end of namespace point
diff --git a/basegfx/inc/basegfx/point/b3dhompoint.hxx b/basegfx/inc/basegfx/point/b3dhompoint.hxx
index dc470d1c7ebd..d661d2f500dc 100644
--- a/basegfx/inc/basegfx/point/b3dhompoint.hxx
+++ b/basegfx/inc/basegfx/point/b3dhompoint.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dhompoint.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:38 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,7 +87,7 @@ namespace basegfx
{
protected:
/// This member contains the coordinate part of the point
- tuple::B3DTuple maTuple;
+ ::basegfx::tuple::B3DTuple maTuple;
/// This Member holds the homogenous part of the point
double mfW;
diff --git a/basegfx/inc/basegfx/point/b3dpoint.hxx b/basegfx/inc/basegfx/point/b3dpoint.hxx
index d142b0bfe726..65047e6c26cf 100644
--- a/basegfx/inc/basegfx/point/b3dpoint.hxx
+++ b/basegfx/inc/basegfx/point/b3dpoint.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dpoint.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-10-31 10:12:50 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,7 +78,7 @@ namespace basegfx
@see B3DTuple
*/
- class B3DPoint : public tuple::B3DTuple
+ class B3DPoint : public ::basegfx::tuple::B3DTuple
{
public:
/** Create a 3D Point
@@ -121,7 +121,7 @@ namespace basegfx
/** constructor with tuple to allow copy-constructing
from B3DTuple-based classes
*/
- B3DPoint(const B3DTuple& rTuple)
+ B3DPoint(const ::basegfx::tuple::B3DTuple& rTuple)
: B3DTuple(rTuple)
{}
@@ -131,7 +131,7 @@ namespace basegfx
/** assignment operator to allow assigning the results
of B3DTuple calculations
*/
- B3DPoint& operator=( const B3DTuple& rVec )
+ B3DPoint& operator=( const ::basegfx::tuple::B3DTuple& rVec )
{
mfX = rVec.getX();
mfY = rVec.getY();
@@ -141,7 +141,7 @@ namespace basegfx
static const B3DPoint& getEmptyPoint()
{
- return (const B3DPoint&) tuple::B3DTuple::getEmptyTuple();
+ return (const B3DPoint&) ::basegfx::tuple::B3DTuple::getEmptyTuple();
}
};
} // end of namespace point
diff --git a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
index 60d1219d431a..40a45c800a4f 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygon.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:39 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,6 +81,11 @@ namespace basegfx
{
class B2DPoint;
} // end of namespace point
+
+ namespace vector
+ {
+ class B2DVector;
+ } // end of namespace vector
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
@@ -116,18 +121,18 @@ namespace basegfx
sal_uInt32 count() const;
// Coordinate interface
- point::B2DPoint getB2DPoint(sal_uInt32 nIndex) const;
- void setB2DPoint(sal_uInt32 nIndex, const point::B2DPoint& rValue);
+ ::basegfx::point::B2DPoint getB2DPoint(sal_uInt32 nIndex) const;
+ void setB2DPoint(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue);
// Coordinate insert/append
- void insert(sal_uInt32 nIndex, const point::B2DPoint& rPoint, sal_uInt32 nCount = 1);
- void append(const point::B2DPoint& rPoint, sal_uInt32 nCount = 1);
-
- // ControlPoint interface
- point::B2DPoint getControlPointA(sal_uInt32 nIndex) const;
- void setControlPointA(sal_uInt32 nIndex, const point::B2DPoint& rValue);
- point::B2DPoint getControlPointB(sal_uInt32 nIndex) const;
- void setControlPointB(sal_uInt32 nIndex, const point::B2DPoint& rValue);
+ void insert(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount = 1);
+ void append(const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount = 1);
+
+ // ControlVector interface
+ ::basegfx::vector::B2DVector getControlVectorA(sal_uInt32 nIndex) const;
+ void setControlVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue);
+ ::basegfx::vector::B2DVector getControlVectorB(sal_uInt32 nIndex) const;
+ void setControlVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue);
sal_Bool areControlPointsUsed() const;
// insert/append other 2D polygons
@@ -154,7 +159,7 @@ namespace basegfx
void removeDoublePoints();
// isInside tests for B2dPoint and other B2dPolygon. On border is not inside.
- sal_Bool isInside(const point::B2DPoint& rPoint);
+ sal_Bool isInside(const ::basegfx::point::B2DPoint& rPoint);
sal_Bool isInside(const B2DPolygon& rPolygon);
};
} // end of namespace polygon
diff --git a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx
index f3a7601f0f78..740d82060283 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygontools.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:40 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -105,17 +105,17 @@ namespace basegfx
void checkClosed(polygon::B2DPolygon& rCandidate);
// Get index of outmost point (e.g. biggest X and biggest Y)
- sal_uInt32 getIndexOfOutmostPoint(const polygon::B2DPolygon& rCandidate);
+ sal_uInt32 getIndexOfOutmostPoint(const ::basegfx::polygon::B2DPolygon& rCandidate);
// Get successor and predecessor indices. Returning the same index means there
// is none. Same for successor.
- sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const polygon::B2DPolygon& rCandidate);
- sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const polygon::B2DPolygon& rCandidate);
+ sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate);
+ sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate);
// Get index of first different predecessor. Returning the same index means there
// is none. Same for successor.
- sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const polygon::B2DPolygon& rCandidate);
- sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const polygon::B2DPolygon& rCandidate);
+ sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate);
+ sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate);
// Get orientation of Polygon
::basegfx::vector::B2DVectorOrientation getOrientation(const ::basegfx::polygon::B2DPolygon& rCandidate);
@@ -149,6 +149,54 @@ namespace basegfx
// get orientation at given polygon point
::basegfx::vector::B2DVectorOrientation getPointOrientation(const ::basegfx::polygon::B2DPolygon& rCandidate, sal_uInt32 nIndex);
+ // Definitions for the cut flags used from the findCut methods
+ typedef sal_uInt16 CutFlagValue;
+
+ #define CUTFLAG_NONE (0x0000)
+ #define CUTFLAG_LINE (0x0001)
+ #define CUTFLAG_START1 (0x0002)
+ #define CUTFLAG_START2 (0x0004)
+ #define CUTFLAG_END1 (0x0008)
+ #define CUTFLAG_END2 (0x0010)
+ #define CUTFLAG_ALL (CUTFLAG_LINE|CUTFLAG_START1|CUTFLAG_START2|CUTFLAG_END1|CUTFLAG_END2)
+ #define CUTFLAG_DEFAULT (CUTFLAG_LINE|CUTFLAG_START2|CUTFLAG_END2)
+
+ // Calculate cut between the points given by the two indices. pCut1
+ // and pCut2 will contain the cut coordinate on each edge in ]0.0, 1.0]
+ // (if given) and the return value will contain a cut description.
+ CutFlagValue findCut(
+ const ::basegfx::polygon::B2DPolygon& rCandidate,
+ sal_uInt32 nIndex1, sal_uInt32 nIndex2,
+ CutFlagValue aCutFlags = CUTFLAG_DEFAULT,
+ double* pCut1 = 0L, double* pCut2 = 0L);
+
+ // This version is working with two indexed edges from different
+ // polygons.
+ CutFlagValue findCut(
+ const ::basegfx::polygon::B2DPolygon& rCandidate1, sal_uInt32 nIndex1,
+ const ::basegfx::polygon::B2DPolygon& rCandidate2, sal_uInt32 nIndex2,
+ CutFlagValue aCutFlags = CUTFLAG_DEFAULT,
+ double* pCut1 = 0L, double* pCut2 = 0L);
+
+ // This version works with two points and vectors to define the
+ // edges for the cut test.
+ CutFlagValue findCut(
+ const ::basegfx::point::B2DPoint& rEdge1Start, const ::basegfx::vector::B2DVector& rEdge1Delta,
+ const ::basegfx::point::B2DPoint& rEdge2Start, const ::basegfx::vector::B2DVector& rEdge2Delta,
+ CutFlagValue aCutFlags = CUTFLAG_DEFAULT,
+ double* pCut1 = 0L, double* pCut2 = 0L);
+
+ // test if point is on the given edge in range ]0.0..1.0[ without
+ // the start/end points. If so, return sal_True and put the parameter
+ // value in pCut (if provided)
+ sal_Bool isPointOnEdge(
+ const ::basegfx::point::B2DPoint& rPoint,
+ const ::basegfx::point::B2DPoint& rEdgeStart,
+ const ::basegfx::vector::B2DVector& rEdgeDelta,
+ double* pCut = 0L);
+
+
+
/* Still missing:
void transform(const Matrix4D& rTfMatrix);
Polygon3D getExpandedPolygon(sal_uInt32 nNum);
diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
index b54d067ec78c..658f9b33d6b3 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygon.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:41 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,11 +75,6 @@ namespace basegfx
{
class B2DPolygon;
} // end of namespace polygon
-
- namespace vector
- {
- enum B2DVectorOrientation;
- } // end of namespace vector
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
@@ -133,9 +128,6 @@ namespace basegfx
sal_Bool isClosed() const;
void setClosed(sal_Bool bNew);
- // Check and evtl. correct orientations of contained Polygons
- ::basegfx::vector::B2DVectorOrientation checkOrientations();
-
// flip polygon direction
void flip();
diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx
index e6c6793186a2..e640dbb9f295 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygontools.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:24:04 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -90,9 +90,22 @@ namespace basegfx
{
// B2DPolyPolygon tools
- // Check and evtl. correct orientations of contained Polygons
- ::basegfx::vector::B2DVectorOrientation checkOrientations(::basegfx::polygon::B2DPolyPolygon& rCandidate);
+ // Check and evtl. correct orientations of all contained Polygons so that
+ // the orientations of contained polygons will variate to express areas and
+ // holes
+ void correctOrientations(::basegfx::polygon::B2DPolyPolygon& rCandidate);
+ // Remove all intersections, the self intersections and the in-between
+ // polygon intersections. After this operation there are no more intersections
+ // in the given PolyPolygon. Only closed polygons are handled. The non-closed
+ // polygons or the ones with less than 3 points are preserved, but not
+ // computed.
+ // bForceOrientation: If sal_True, the orientations of all contained polygons
+ // is changed to ORIENTATION_POSITIVE before computing.
+ // bInvertRemove: if sal_True, created polygons which are inside others and
+ // have the same orientation are removed (cleanup).
+ void removeIntersections(::basegfx::polygon::B2DPolyPolygon& rCandidate,
+ sal_Bool bForceOrientation = sal_True, sal_Bool bInvertRemove = sal_False);
} // end of namespace tools
} // end of namespace polygon
diff --git a/basegfx/inc/basegfx/range/b1drange.hxx b/basegfx/inc/basegfx/range/b1drange.hxx
index eedb4bc5911b..3acab7da4a20 100644
--- a/basegfx/inc/basegfx/range/b1drange.hxx
+++ b/basegfx/inc/basegfx/range/b1drange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b1drange.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:43 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -129,6 +129,11 @@ namespace basegfx
return maRange.isInside(rRange.maRange);
}
+ sal_Bool overlaps(const B1DRange& rRange) const
+ {
+ return maRange.overlaps(rRange.maRange);
+ }
+
void expand(double fValue)
{
maRange.expand(fValue);
diff --git a/basegfx/inc/basegfx/range/b2drange.hxx b/basegfx/inc/basegfx/range/b2drange.hxx
index f3a8ac8bbba2..85002f6c8956 100644
--- a/basegfx/inc/basegfx/range/b2drange.hxx
+++ b/basegfx/inc/basegfx/range/b2drange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2drange.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:43 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -156,6 +156,14 @@ namespace basegfx
);
}
+ sal_Bool overlaps(const B2DRange& rRange) const
+ {
+ return (
+ maRangeX.overlaps(rRange.maRangeX)
+ && maRangeY.overlaps(rRange.maRangeY)
+ );
+ }
+
void expand(const tuple::B2DTuple& rTuple)
{
maRangeX.expand(rTuple.getX());
diff --git a/basegfx/inc/basegfx/range/b3drange.hxx b/basegfx/inc/basegfx/range/b3drange.hxx
index a62f61208b5d..2da5e2c3e1af 100644
--- a/basegfx/inc/basegfx/range/b3drange.hxx
+++ b/basegfx/inc/basegfx/range/b3drange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3drange.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:43 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -167,6 +167,15 @@ namespace basegfx
);
}
+ sal_Bool overlaps(const B3DRange& rRange) const
+ {
+ return (
+ maRangeX.overlaps(rRange.maRangeX)
+ && maRangeY.overlaps(rRange.maRangeY)
+ && maRangeZ.overlaps(rRange.maRangeZ)
+ );
+ }
+
void expand(const tuple::B3DTuple& rTuple)
{
maRangeX.expand(rTuple.getX());
diff --git a/basegfx/inc/basegfx/vector/b2dvector.hxx b/basegfx/inc/basegfx/vector/b2dvector.hxx
index 1766a3d4ca0e..8a7127d42ab3 100644
--- a/basegfx/inc/basegfx/vector/b2dvector.hxx
+++ b/basegfx/inc/basegfx/vector/b2dvector.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dvector.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:46 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -98,7 +98,7 @@ namespace basegfx
@see B2DTuple
*/
- class B2DVector : public tuple::B2DTuple
+ class B2DVector : public ::basegfx::tuple::B2DTuple
{
public:
/** Create a 2D Vector
@@ -137,7 +137,7 @@ namespace basegfx
/** constructor with tuple to allow copy-constructing
from B2DTuple-based classes
*/
- B2DVector(const B2DTuple& rTuple)
+ B2DVector(const ::basegfx::tuple::B2DTuple& rTuple)
: B2DTuple(rTuple)
{}
@@ -147,7 +147,7 @@ namespace basegfx
/** assignment operator to allow assigning the results
of B2DTuple calculations
*/
- B2DVector& operator=( const B2DTuple& rVec );
+ B2DVector& operator=( const ::basegfx::tuple::B2DTuple& rVec );
/** Calculate the length of this 2D Vector
diff --git a/basegfx/inc/basegfx/vector/b3dvector.hxx b/basegfx/inc/basegfx/vector/b3dvector.hxx
index ec153104981e..bd118592ec96 100644
--- a/basegfx/inc/basegfx/vector/b3dvector.hxx
+++ b/basegfx/inc/basegfx/vector/b3dvector.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dvector.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:47 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,7 +78,7 @@ namespace basegfx
@see B3DTuple
*/
- class B3DVector : public tuple::B3DTuple
+ class B3DVector : public ::basegfx::tuple::B3DTuple
{
public:
/** Create a 3D Vector
@@ -121,7 +121,7 @@ namespace basegfx
/** constructor with tuple to allow copy-constructing
from B3DTuple-based classes
*/
- B3DVector(const B3DTuple& rTuple)
+ B3DVector(const ::basegfx::tuple::B3DTuple& rTuple)
: B3DTuple(rTuple)
{}
@@ -131,7 +131,7 @@ namespace basegfx
/** assignment operator to allow assigning the results
of B3DTuple calculations
*/
- B3DVector& operator=( const B3DTuple& rVec )
+ B3DVector& operator=( const ::basegfx::tuple::B3DTuple& rVec )
{
mfX = rVec.getX();
mfY = rVec.getY();
@@ -277,7 +277,7 @@ namespace basegfx
static const B3DVector& getEmptyVector()
{
- return (const B3DVector&) B3DTuple::getEmptyTuple();
+ return (const B3DVector&) ::basegfx::tuple::B3DTuple::getEmptyTuple();
}
};
diff --git a/basegfx/prj/d.lst b/basegfx/prj/d.lst
index ade6da3e54b7..54fb7f67a511 100644
--- a/basegfx/prj/d.lst
+++ b/basegfx/prj/d.lst
@@ -37,6 +37,7 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\polygon
..\inc\basegfx\polygon\b2dpolygon.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolygon.hxx
..\inc\basegfx\polygon\b2dpolypolygon.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolypolygon.hxx
..\inc\basegfx\polygon\b2dpolygontools.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolygontools.hxx
+..\inc\basegfx\polygon\b2dpolypolygontools.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolypolygontools.hxx
mkdir: %_DEST%\inc%_EXT%\basegfx\tuple
..\inc\basegfx\tuple\b2dtuple.hxx %_DEST%\inc%_EXT%\basegfx\tuple\b2dtuple.hxx
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx
index 05ac36f5bb86..19eadc8dab49 100644
--- a/basegfx/source/curve/b2dcubicbezier.cxx
+++ b/basegfx/source/curve/b2dcubicbezier.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dcubicbezier.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:47 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,7 +85,7 @@ namespace basegfx
{
}
- B2DCubicBezier::B2DCubicBezier(const point::B2DPoint& rStart, const point::B2DPoint& rEnd)
+ B2DCubicBezier::B2DCubicBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rEnd)
: maStartPoint(rStart),
maEndPoint(rEnd),
maControlPointA(rStart),
@@ -93,8 +93,8 @@ namespace basegfx
{
}
- B2DCubicBezier::B2DCubicBezier(const point::B2DPoint& rStart, const point::B2DPoint& rControlPointA,
- const point::B2DPoint& rControlPointB, const point::B2DPoint& rEnd)
+ B2DCubicBezier::B2DCubicBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rControlPointA,
+ const ::basegfx::point::B2DPoint& rControlPointB, const ::basegfx::point::B2DPoint& rEnd)
: maStartPoint(rStart),
maEndPoint(rEnd),
maControlPointA(rControlPointA),
diff --git a/basegfx/source/curve/b2dquadraticbezier.cxx b/basegfx/source/curve/b2dquadraticbezier.cxx
index a22fc9778090..5db6c1d42775 100644
--- a/basegfx/source/curve/b2dquadraticbezier.cxx
+++ b/basegfx/source/curve/b2dquadraticbezier.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dquadraticbezier.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:48 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -88,13 +88,13 @@ namespace basegfx
{
}
- B2DQuadraticBezier::B2DQuadraticBezier(const point::B2DPoint& rStart, const point::B2DPoint& rEnd)
+ B2DQuadraticBezier::B2DQuadraticBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rEnd)
: maStartPoint(rStart),
maEndPoint(rEnd)
{
}
- B2DQuadraticBezier::B2DQuadraticBezier(const point::B2DPoint& rStart, const point::B2DPoint& rControl, const point::B2DPoint& rEnd)
+ B2DQuadraticBezier::B2DQuadraticBezier(const ::basegfx::point::B2DPoint& rStart, const ::basegfx::point::B2DPoint& rControl, const ::basegfx::point::B2DPoint& rEnd)
: maStartPoint(rStart),
maEndPoint(rEnd),
maControlPoint(rControl)
diff --git a/basegfx/source/point/b2dpoint.cxx b/basegfx/source/point/b2dpoint.cxx
index 82e4b30c689c..34c14f89bdac 100644
--- a/basegfx/source/point/b2dpoint.cxx
+++ b/basegfx/source/point/b2dpoint.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpoint.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: aw $ $Date: 2003-10-31 10:13:57 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,14 +71,14 @@ namespace basegfx
{
namespace point
{
- B2DPoint& B2DPoint::operator=( const B2DTuple& rPoint )
+ B2DPoint& B2DPoint::operator=( const ::basegfx::tuple::B2DTuple& rPoint )
{
mfX = rPoint.getX();
mfY = rPoint.getY();
return *this;
}
- B2DPoint& B2DPoint::operator*=( const matrix::B2DHomMatrix& rMat )
+ B2DPoint& B2DPoint::operator*=( const ::basegfx::matrix::B2DHomMatrix& rMat )
{
const double fTempX( rMat.get(0,0)*mfX +
rMat.get(0,1)*mfY +
diff --git a/basegfx/source/point/makefile.mk b/basegfx/source/point/makefile.mk
index 6be5eace0c9c..639b03621b13 100644
--- a/basegfx/source/point/makefile.mk
+++ b/basegfx/source/point/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: aw $ $Date: 2003-10-28 11:26:15 $
+# last change: $Author: aw $ $Date: 2003-11-06 16:30:28 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -75,7 +75,7 @@ TARGET=point
# --- Files -------------------------------------
SLOFILES= \
- $(SLO)$/b3dpoint.obj \
+ $(SLO)$/b2dpoint.obj \
$(SLO)$/b2dhompoint.obj \
$(SLO)$/b3dpoint.obj \
$(SLO)$/b3dhompoint.obj
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index 3d532cdf478d..e5bcd66a2e04 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygon.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:54 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,15 +82,15 @@
class CoordinateData2D
{
- basegfx::point::B2DPoint maPoint;
+ ::basegfx::point::B2DPoint maPoint;
public:
CoordinateData2D() {}
- CoordinateData2D(const basegfx::point::B2DPoint& rData) : maPoint(rData) {}
+ CoordinateData2D(const ::basegfx::point::B2DPoint& rData) : maPoint(rData) {}
~CoordinateData2D() {}
- const basegfx::point::B2DPoint& getCoordinate() const { return maPoint; }
- void setCoordinate(const basegfx::point::B2DPoint& rValue) { if(rValue != maPoint) maPoint = rValue; }
+ const ::basegfx::point::B2DPoint& getCoordinate() const { return maPoint; }
+ void setCoordinate(const ::basegfx::point::B2DPoint& rValue) { if(rValue != maPoint) maPoint = rValue; }
sal_Bool operator==(const CoordinateData2D& rData ) const { return (maPoint == rData.getCoordinate()); }
};
@@ -128,12 +128,12 @@ public:
return (maVector == rCandidate.maVector);
}
- const basegfx::point::B2DPoint& getCoordinate(sal_uInt32 nIndex) const
+ const ::basegfx::point::B2DPoint& getCoordinate(sal_uInt32 nIndex) const
{
return maVector[nIndex].getCoordinate();
}
- void setCoordinate(sal_uInt32 nIndex, const basegfx::point::B2DPoint& rValue)
+ void setCoordinate(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue)
{
maVector[nIndex].setCoordinate(rValue);
}
@@ -229,18 +229,18 @@ public:
class ControlVectorPair2D
{
- basegfx::vector::B2DVector maVectorA;
- basegfx::vector::B2DVector maVectorB;
+ ::basegfx::vector::B2DVector maVectorA;
+ ::basegfx::vector::B2DVector maVectorB;
public:
ControlVectorPair2D() {}
~ControlVectorPair2D() {}
- const basegfx::vector::B2DVector& getVectorA() const { return maVectorA; }
- void setVectorA(const basegfx::vector::B2DVector& rValue) { if(rValue != maVectorA) maVectorA = rValue; }
+ const ::basegfx::vector::B2DVector& getVectorA() const { return maVectorA; }
+ void setVectorA(const ::basegfx::vector::B2DVector& rValue) { if(rValue != maVectorA) maVectorA = rValue; }
- const basegfx::vector::B2DVector& getVectorB() const { return maVectorB; }
- void setVectorB(const basegfx::vector::B2DVector& rValue) { if(rValue != maVectorB) maVectorB = rValue; }
+ const ::basegfx::vector::B2DVector& getVectorB() const { return maVectorB; }
+ void setVectorB(const ::basegfx::vector::B2DVector& rValue) { if(rValue != maVectorB) maVectorB = rValue; }
sal_Bool operator==(const ControlVectorPair2D& rData ) const
{ return (maVectorA == rData.getVectorA() && maVectorB == rData.getVectorB()); }
@@ -305,12 +305,12 @@ public:
return (0L != mnUsedVectors);
}
- const basegfx::vector::B2DVector& getVectorA(sal_uInt32 nIndex) const
+ const ::basegfx::vector::B2DVector& getVectorA(sal_uInt32 nIndex) const
{
return maVector[nIndex].getVectorA();
}
- void setVectorA(sal_uInt32 nIndex, const basegfx::vector::B2DVector& rValue)
+ void setVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
{
sal_Bool bWasUsed(mnUsedVectors && !maVector[nIndex].getVectorA().equalZero());
sal_Bool bIsUsed(!rValue.equalZero());
@@ -323,7 +323,7 @@ public:
}
else
{
- maVector[nIndex].setVectorA(basegfx::vector::B2DVector::getEmptyVector());
+ maVector[nIndex].setVectorA(::basegfx::vector::B2DVector::getEmptyVector());
mnUsedVectors--;
}
}
@@ -337,12 +337,12 @@ public:
}
}
- const basegfx::vector::B2DVector& getVectorB(sal_uInt32 nIndex) const
+ const ::basegfx::vector::B2DVector& getVectorB(sal_uInt32 nIndex) const
{
return maVector[nIndex].getVectorB();
}
- void setVectorB(sal_uInt32 nIndex, const basegfx::vector::B2DVector& rValue)
+ void setVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
{
sal_Bool bWasUsed(mnUsedVectors && !maVector[nIndex].getVectorB().equalZero());
sal_Bool bIsUsed(!rValue.equalZero());
@@ -355,7 +355,7 @@ public:
}
else
{
- maVector[nIndex].setVectorB(basegfx::vector::B2DVector::getEmptyVector());
+ maVector[nIndex].setVectorB(::basegfx::vector::B2DVector::getEmptyVector());
mnUsedVectors--;
}
}
@@ -577,17 +577,17 @@ public:
return sal_False;
}
- const basegfx::point::B2DPoint& getPoint(sal_uInt32 nIndex) const
+ const ::basegfx::point::B2DPoint& getPoint(sal_uInt32 nIndex) const
{
return maPoints.getCoordinate(nIndex);
}
- void setPoint(sal_uInt32 nIndex, const basegfx::point::B2DPoint& rValue)
+ void setPoint(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue)
{
maPoints.setCoordinate(nIndex, rValue);
}
- void insert(sal_uInt32 nIndex, const basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount)
+ void insert(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount)
{
if(nCount)
{
@@ -602,7 +602,7 @@ public:
}
}
- const basegfx::point::B2DPoint& getControlPointA(sal_uInt32 nIndex) const
+ const ::basegfx::vector::B2DVector& getControlVectorA(sal_uInt32 nIndex) const
{
if(mpControlVector)
{
@@ -610,11 +610,11 @@ public:
}
else
{
- return basegfx::point::B2DPoint::getEmptyPoint();
+ return ::basegfx::vector::B2DVector::getEmptyVector();
}
}
- void setControlPointA(sal_uInt32 nIndex, const basegfx::point::B2DPoint& rValue)
+ void setControlVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
{
if(!mpControlVector)
{
@@ -641,7 +641,7 @@ public:
return (mpControlVector && mpControlVector->isUsed());
}
- const basegfx::point::B2DPoint& getControlPointB(sal_uInt32 nIndex) const
+ const ::basegfx::vector::B2DVector& getControlVectorB(sal_uInt32 nIndex) const
{
if(mpControlVector)
{
@@ -649,11 +649,11 @@ public:
}
else
{
- return basegfx::point::B2DPoint::getEmptyPoint();
+ return ::basegfx::vector::B2DVector::getEmptyVector();
}
}
- void setControlPointB(sal_uInt32 nIndex, const basegfx::point::B2DPoint& rValue)
+ void setControlVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
{
if(!mpControlVector)
{
@@ -751,10 +751,10 @@ public:
const sal_uInt32 nVectorSource(nCoorSource ? nCoorSource - 1L : nCount - 1L);
// get source data
- const basegfx::point::B2DPoint& rSourceCoor = pCoordinateCopy->getCoordinate(nCoorSource);
- const basegfx::point::B2DPoint& rVectorSourceCoor = pCoordinateCopy->getCoordinate(nVectorSource);
- const basegfx::vector::B2DVector& rVectorSourceA = pVectorCopy->getVectorA(nVectorSource);
- const basegfx::vector::B2DVector& rVectorSourceB = pVectorCopy->getVectorB(nVectorSource);
+ const ::basegfx::point::B2DPoint& rSourceCoor = pCoordinateCopy->getCoordinate(nCoorSource);
+ const ::basegfx::point::B2DPoint& rVectorSourceCoor = pCoordinateCopy->getCoordinate(nVectorSource);
+ const ::basegfx::vector::B2DVector& rVectorSourceA = pVectorCopy->getVectorA(nVectorSource);
+ const ::basegfx::vector::B2DVector& rVectorSourceB = pVectorCopy->getVectorB(nVectorSource);
// copy point data
maPoints.setCoordinate(a, rSourceCoor);
@@ -763,12 +763,12 @@ public:
if(rVectorSourceA.equalZero())
{
// unused, use zero vector
- mpControlVector->setVectorB(a, basegfx::vector::B2DVector::getEmptyVector());
+ mpControlVector->setVectorB(a, ::basegfx::vector::B2DVector::getEmptyVector());
}
else
{
// calculate new vector relative to new point
- basegfx::vector::B2DVector aNewVectorB((rVectorSourceA + rVectorSourceCoor) - rSourceCoor);
+ ::basegfx::vector::B2DVector aNewVectorB((rVectorSourceA + rVectorSourceCoor) - rSourceCoor);
mpControlVector->setVectorB(a, aNewVectorB);
}
@@ -776,12 +776,12 @@ public:
if(rVectorSourceB.equalZero())
{
// unused, use zero vector
- mpControlVector->setVectorA(a, basegfx::vector::B2DVector::getEmptyVector());
+ mpControlVector->setVectorA(a, ::basegfx::vector::B2DVector::getEmptyVector());
}
else
{
// calculate new vector relative to new point
- basegfx::vector::B2DVector aNewVectorA((rVectorSourceB + rVectorSourceCoor) - rSourceCoor);
+ ::basegfx::vector::B2DVector aNewVectorA((rVectorSourceB + rVectorSourceCoor) - rSourceCoor);
mpControlVector->setVectorA(a, aNewVectorA);
}
}
@@ -1006,14 +1006,14 @@ namespace basegfx
return mpPolygon->count();
}
- point::B2DPoint B2DPolygon::getB2DPoint(sal_uInt32 nIndex) const
+ ::basegfx::point::B2DPoint B2DPolygon::getB2DPoint(sal_uInt32 nIndex) const
{
DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
return mpPolygon->getPoint(nIndex);
}
- void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const point::B2DPoint& rValue)
+ void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rValue)
{
DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
@@ -1024,7 +1024,7 @@ namespace basegfx
}
}
- void B2DPolygon::insert(sal_uInt32 nIndex, const point::B2DPoint& rPoint, sal_uInt32 nCount)
+ void B2DPolygon::insert(sal_uInt32 nIndex, const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount)
{
DBG_ASSERT(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)");
@@ -1035,7 +1035,7 @@ namespace basegfx
}
}
- void B2DPolygon::append(const point::B2DPoint& rPoint, sal_uInt32 nCount)
+ void B2DPolygon::append(const ::basegfx::point::B2DPoint& rPoint, sal_uInt32 nCount)
{
if(nCount)
{
@@ -1044,39 +1044,39 @@ namespace basegfx
}
}
- point::B2DPoint B2DPolygon::getControlPointA(sal_uInt32 nIndex) const
+ ::basegfx::vector::B2DVector B2DPolygon::getControlVectorA(sal_uInt32 nIndex) const
{
DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- return mpPolygon->getControlPointA(nIndex);
+ return mpPolygon->getControlVectorA(nIndex);
}
- void B2DPolygon::setControlPointA(sal_uInt32 nIndex, const point::B2DPoint& rValue)
+ void B2DPolygon::setControlVectorA(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
{
DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- if(mpPolygon->getControlPointA(nIndex) != rValue)
+ if(mpPolygon->getControlVectorA(nIndex) != rValue)
{
implForceUniqueCopy();
- mpPolygon->setControlPointA(nIndex, rValue);
+ mpPolygon->setControlVectorA(nIndex, rValue);
}
}
- point::B2DPoint B2DPolygon::getControlPointB(sal_uInt32 nIndex) const
+ ::basegfx::vector::B2DVector B2DPolygon::getControlVectorB(sal_uInt32 nIndex) const
{
DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- return mpPolygon->getControlPointB(nIndex);
+ return mpPolygon->getControlVectorB(nIndex);
}
- void B2DPolygon::setControlPointB(sal_uInt32 nIndex, const point::B2DPoint& rValue)
+ void B2DPolygon::setControlVectorB(sal_uInt32 nIndex, const ::basegfx::vector::B2DVector& rValue)
{
DBG_ASSERT(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)");
- if(mpPolygon->getControlPointB(nIndex) != rValue)
+ if(mpPolygon->getControlVectorB(nIndex) != rValue)
{
implForceUniqueCopy();
- mpPolygon->setControlPointB(nIndex, rValue);
+ mpPolygon->setControlVectorB(nIndex, rValue);
}
}
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index c5b56dd72e31..c7211c12bd07 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygontools.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:54 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,7 +99,7 @@ namespace basegfx
}
// Get index of outmost point (e.g. biggest X and biggest Y)
- sal_uInt32 getIndexOfOutmostPoint(const polygon::B2DPolygon& rCandidate)
+ sal_uInt32 getIndexOfOutmostPoint(const ::basegfx::polygon::B2DPolygon& rCandidate)
{
sal_uInt32 nRetval(0L);
@@ -132,7 +132,7 @@ namespace basegfx
// Get successor and predecessor indices. Returning the same index means there
// is none. Same for successor.
- sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const polygon::B2DPolygon& rCandidate)
+ sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate)
{
if(nIndex)
{
@@ -148,7 +148,7 @@ namespace basegfx
}
}
- sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const polygon::B2DPolygon& rCandidate)
+ sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate)
{
if(nIndex + 1L < rCandidate.count())
{
@@ -160,7 +160,7 @@ namespace basegfx
}
}
- sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const polygon::B2DPolygon& rCandidate)
+ sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate)
{
if(rCandidate.count() > 1)
{
@@ -177,7 +177,7 @@ namespace basegfx
return nIndex;
}
- sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const polygon::B2DPolygon& rCandidate)
+ sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rCandidate)
{
if(rCandidate.count() > 1)
{
@@ -214,8 +214,8 @@ namespace basegfx
for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- const basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
- const basegfx::point::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
+ const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
+ const ::basegfx::point::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
// cross-over in Y?
const sal_Bool bCompYA(::basegfx::numeric::fTools::more(aPreviousPoint.getY(), rPoint.getY()));
@@ -291,8 +291,8 @@ namespace basegfx
{
for(sal_uInt32 a(0L); a < nPointCount; a++)
{
- const basegfx::point::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
- const basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
+ const ::basegfx::point::B2DPoint aPreviousPoint(rCandidate.getB2DPoint((!a) ? nPointCount - 1L : a - 1L));
+ const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
fRetval += aPreviousPoint.getX() * aCurrentPoint.getY();
fRetval -= aPreviousPoint.getY() * aCurrentPoint.getX();
@@ -321,9 +321,9 @@ namespace basegfx
if(rCandidate.isClosed() || nIndex + 1 != nPointCount)
{
const sal_uInt32 nNextIndex(nIndex + 1 == nPointCount ? 0L : nIndex + 1L);
- const basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(nIndex));
- const basegfx::point::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
- const basegfx::vector::B2DVector aVector(aNextPoint - aCurrentPoint);
+ const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(nIndex));
+ const ::basegfx::point::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
+ const ::basegfx::vector::B2DVector aVector(aNextPoint - aCurrentPoint);
fRetval = aVector.getLength();
}
}
@@ -343,9 +343,9 @@ namespace basegfx
for(sal_uInt32 a(0L); a < nLoopCount; a++)
{
const sal_uInt32 nNextIndex(a + 1 == nPointCount ? 0L : a + 1L);
- const basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
- const basegfx::point::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
- const basegfx::vector::B2DVector aVector(aNextPoint - aCurrentPoint);
+ const ::basegfx::point::B2DPoint aCurrentPoint(rCandidate.getB2DPoint(a));
+ const ::basegfx::point::B2DPoint aNextPoint(rCandidate.getB2DPoint(nNextIndex));
+ const ::basegfx::vector::B2DVector aVector(aNextPoint - aCurrentPoint);
fRetval += aVector.scalar(aVector);
}
@@ -498,6 +498,317 @@ namespace basegfx
return eRetval;
}
+
+ CutFlagValue findCut(
+ const ::basegfx::polygon::B2DPolygon& rCandidate,
+ sal_uInt32 nIndex1, sal_uInt32 nIndex2,
+ CutFlagValue aCutFlags,
+ double* pCut1, double* pCut2)
+ {
+ CutFlagValue aRetval(CUTFLAG_NONE);
+ const sal_uInt32 nPointCount(rCandidate.count());
+
+ if(nIndex1 < nPointCount && nIndex2 < nPointCount && nIndex1 != nIndex2)
+ {
+ sal_uInt32 nEnd1(getIndexOfSuccessor(nIndex1, rCandidate));
+ sal_uInt32 nEnd2(getIndexOfSuccessor(nIndex2, rCandidate));
+
+ const ::basegfx::point::B2DPoint aStart1(rCandidate.getB2DPoint(nIndex1));
+ const ::basegfx::point::B2DPoint aEnd1(rCandidate.getB2DPoint(nEnd1));
+ const ::basegfx::vector::B2DVector aVector1(aEnd1 - aStart1);
+
+ const ::basegfx::point::B2DPoint aStart2(rCandidate.getB2DPoint(nIndex2));
+ const ::basegfx::point::B2DPoint aEnd2(rCandidate.getB2DPoint(nEnd2));
+ const ::basegfx::vector::B2DVector aVector2(aEnd2 - aStart2);
+
+ aRetval = findCut(
+ aStart1, aVector1, aStart2, aVector2,
+ aCutFlags, pCut1, pCut2);
+ }
+
+ return aRetval;
+ }
+
+ CutFlagValue findCut(
+ const ::basegfx::polygon::B2DPolygon& rCandidate1, sal_uInt32 nIndex1,
+ const ::basegfx::polygon::B2DPolygon& rCandidate2, sal_uInt32 nIndex2,
+ CutFlagValue aCutFlags,
+ double* pCut1, double* pCut2)
+ {
+ CutFlagValue aRetval(CUTFLAG_NONE);
+ const sal_uInt32 nPointCount1(rCandidate1.count());
+ const sal_uInt32 nPointCount2(rCandidate2.count());
+
+ if(nIndex1 < nPointCount1 && nIndex2 < nPointCount2)
+ {
+ sal_uInt32 nEnd1(getIndexOfSuccessor(nIndex1, rCandidate1));
+ sal_uInt32 nEnd2(getIndexOfSuccessor(nIndex2, rCandidate2));
+
+ const ::basegfx::point::B2DPoint aStart1(rCandidate1.getB2DPoint(nIndex1));
+ const ::basegfx::point::B2DPoint aEnd1(rCandidate1.getB2DPoint(nEnd1));
+ const ::basegfx::vector::B2DVector aVector1(aEnd1 - aStart1);
+
+ const ::basegfx::point::B2DPoint aStart2(rCandidate2.getB2DPoint(nIndex2));
+ const ::basegfx::point::B2DPoint aEnd2(rCandidate2.getB2DPoint(nEnd2));
+ const ::basegfx::vector::B2DVector aVector2(aEnd2 - aStart2);
+
+ aRetval = findCut(
+ aStart1, aVector1, aStart2, aVector2,
+ aCutFlags, pCut1, pCut2);
+ }
+
+ return aRetval;
+ }
+
+ CutFlagValue findCut(
+ const ::basegfx::point::B2DPoint& rEdge1Start, const ::basegfx::vector::B2DVector& rEdge1Delta,
+ const ::basegfx::point::B2DPoint& rEdge2Start, const ::basegfx::vector::B2DVector& rEdge2Delta,
+ CutFlagValue aCutFlags,
+ double* pCut1, double* pCut2)
+ {
+ CutFlagValue aRetval(CUTFLAG_NONE);
+ double fCut1(0.0);
+ double fCut2(0.0);
+ sal_Bool bFinished(!((sal_Bool)(aCutFlags & CUTFLAG_ALL)));
+
+ // test for same points?
+ if(!bFinished
+ && (aCutFlags & (CUTFLAG_START1|CUTFLAG_END1))
+ && (aCutFlags & (CUTFLAG_START2|CUTFLAG_END2)))
+ {
+ // same startpoint?
+ if(!bFinished && (aCutFlags & (CUTFLAG_START1|CUTFLAG_START2)) == (CUTFLAG_START1|CUTFLAG_START2))
+ {
+ if(rEdge1Start.equal(rEdge2Start))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_START1|CUTFLAG_START2);
+ }
+ }
+
+ // same endpoint?
+ if(!bFinished && (aCutFlags & (CUTFLAG_END1|CUTFLAG_END2)) == (CUTFLAG_END1|CUTFLAG_END2))
+ {
+ const ::basegfx::point::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
+ const ::basegfx::point::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
+
+ if(aEnd1.equal(aEnd2))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_END1|CUTFLAG_END2);
+ fCut1 = fCut2 = 1.0;
+ }
+ }
+
+ // startpoint1 == endpoint2?
+ if(!bFinished && (aCutFlags & (CUTFLAG_START1|CUTFLAG_END2)) == (CUTFLAG_START1|CUTFLAG_END2))
+ {
+ const ::basegfx::point::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
+
+ if(rEdge1Start.equal(aEnd2))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_START1|CUTFLAG_END2);
+ fCut1 = 0.0;
+ fCut2 = 1.0;
+ }
+ }
+
+ // startpoint2 == endpoint1?
+ if(!bFinished&& (aCutFlags & (CUTFLAG_START2|CUTFLAG_END1)) == (CUTFLAG_START2|CUTFLAG_END1))
+ {
+ const ::basegfx::point::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
+
+ if(rEdge2Start.equal(aEnd1))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_START2|CUTFLAG_END1);
+ fCut1 = 1.0;
+ fCut2 = 0.0;
+ }
+ }
+ }
+
+ if(!bFinished && (aCutFlags & CUTFLAG_LINE))
+ {
+ if(!bFinished && (aCutFlags & CUTFLAG_START1))
+ {
+ // start1 on line 2 ?
+ if(isPointOnEdge(rEdge1Start, rEdge2Start, rEdge2Delta, &fCut2))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_LINE|CUTFLAG_START1);
+ }
+ }
+
+ if(!bFinished && (aCutFlags & CUTFLAG_START2))
+ {
+ // start2 on line 1 ?
+ if(isPointOnEdge(rEdge2Start, rEdge1Start, rEdge1Delta, &fCut1))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_LINE|CUTFLAG_START2);
+ }
+ }
+
+ if(!bFinished && (aCutFlags & CUTFLAG_END1))
+ {
+ // end1 on line 2 ?
+ const ::basegfx::point::B2DPoint aEnd1(rEdge1Start + rEdge1Delta);
+
+ if(isPointOnEdge(aEnd1, rEdge2Start, rEdge2Delta, &fCut2))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_LINE|CUTFLAG_END1);
+ }
+ }
+
+ if(!bFinished && (aCutFlags & CUTFLAG_END2))
+ {
+ // end2 on line 1 ?
+ const ::basegfx::point::B2DPoint aEnd2(rEdge2Start + rEdge2Delta);
+
+ if(isPointOnEdge(aEnd2, rEdge1Start, rEdge1Delta, &fCut1))
+ {
+ bFinished = sal_True;
+ aRetval = (CUTFLAG_LINE|CUTFLAG_END2);
+ }
+ }
+
+ if(!bFinished)
+ {
+ // cut in line1, line2 ?
+ fCut1 = (rEdge1Delta.getX() * rEdge2Delta.getY()) - (rEdge1Delta.getY() * rEdge2Delta.getX());
+
+ if(!::basegfx::numeric::fTools::equalZero(fCut1))
+ {
+ fCut1 = (rEdge2Delta.getY() * (rEdge2Start.getX() - rEdge1Start.getX())
+ + rEdge2Delta.getX() * (rEdge1Start.getY() - rEdge2Start.getY())) / fCut1;
+
+ const double fZero(0.0);
+ const double fOne(1.0);
+
+ // inside parameter range edge1 AND fCut2 is calcable
+ if(::basegfx::numeric::fTools::more(fCut1, fZero) && ::basegfx::numeric::fTools::less(fCut1, fOne)
+ && (!::basegfx::numeric::fTools::equalZero(rEdge2Delta.getX()) || !::basegfx::numeric::fTools::equalZero(rEdge2Delta.getY())))
+ {
+ // take the mopre precise calculation of the two possible
+ if(fabs(rEdge2Delta.getX()) > fabs(rEdge2Delta.getY()))
+ {
+ fCut2 = (rEdge1Start.getX() + fCut1
+ * rEdge1Delta.getX() - rEdge2Start.getX()) / rEdge2Delta.getX();
+ }
+ else
+ {
+ fCut2 = (rEdge1Start.getY() + fCut1
+ * rEdge1Delta.getY() - rEdge2Start.getY()) / rEdge2Delta.getY();
+ }
+
+ // inside parameter range edge2, too
+ if(::basegfx::numeric::fTools::more(fCut2, fZero) && ::basegfx::numeric::fTools::less(fCut2, fOne))
+ {
+ bFinished = sal_True;
+ aRetval = CUTFLAG_LINE;
+ }
+ }
+ }
+ }
+ }
+
+ // copy values if wanted
+ if(pCut1)
+ {
+ *pCut1 = fCut1;
+ }
+
+ if(pCut2)
+ {
+ *pCut2 = fCut2;
+ }
+
+ return aRetval;
+ }
+
+ sal_Bool isPointOnEdge(
+ const ::basegfx::point::B2DPoint& rPoint,
+ const ::basegfx::point::B2DPoint& rEdgeStart,
+ const ::basegfx::vector::B2DVector& rEdgeDelta,
+ double* pCut)
+ {
+ sal_Bool bDeltaXIsZero(::basegfx::numeric::fTools::equalZero(rEdgeDelta.getX()));
+ sal_Bool bDeltaYIsZero(::basegfx::numeric::fTools::equalZero(rEdgeDelta.getY()));
+ const double fZero(0.0);
+ const double fOne(1.0);
+
+ if(bDeltaXIsZero && bDeltaYIsZero)
+ {
+ // no line, just a point
+ return sal_False;
+ }
+ else if(bDeltaXIsZero)
+ {
+ // vertical line
+ if(::basegfx::numeric::fTools::equal(rPoint.getX(), rEdgeStart.getX()))
+ {
+ double fValue = (rPoint.getY() - rEdgeStart.getY()) / rEdgeDelta.getY();
+
+ if(::basegfx::numeric::fTools::more(fValue, fZero) && ::basegfx::numeric::fTools::less(fValue, fOne))
+ {
+ if(pCut)
+ {
+ *pCut = fValue;
+ }
+
+ return sal_True;
+ }
+ }
+ }
+ else if(bDeltaYIsZero)
+ {
+ // horizontal line
+ if(::basegfx::numeric::fTools::equal(rPoint.getY(), rEdgeStart.getY()))
+ {
+ double fValue = (rPoint.getX() - rEdgeStart.getX()) / rEdgeDelta.getX();
+
+ if(::basegfx::numeric::fTools::more(fValue, fZero)
+ && ::basegfx::numeric::fTools::less(fValue, fOne))
+ {
+ if(pCut)
+ {
+ *pCut = fValue;
+ }
+
+ return sal_True;
+ }
+ }
+ }
+ else
+ {
+ // any angle line
+ double fTOne = (rPoint.getX() - rEdgeStart.getX()) / rEdgeDelta.getX();
+ double fTTwo = (rPoint.getY() - rEdgeStart.getY()) / rEdgeDelta.getY();
+
+ if(::basegfx::numeric::fTools::equal(fTOne, fTTwo))
+ {
+ // same parameter representation, point is on line. Take
+ // middle value for better results
+ double fValue = (fTOne + fTTwo) / 2.0;
+
+ if(::basegfx::numeric::fTools::more(fValue, fZero) && ::basegfx::numeric::fTools::less(fValue, fOne))
+ {
+ // point is inside line bounds, too
+ if(pCut)
+ {
+ *pCut = fValue;
+ }
+
+ return sal_True;
+ }
+ }
+ }
+
+ return sal_False;
+ }
} // end of namespace tools
} // end of namespace polygon
} // end of namespace basegfx
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx
index b1183a6cf052..7b15b1282a71 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygon.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:54 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,7 +81,7 @@
class ImplB2DPolyPolygon
{
- typedef ::std::vector< basegfx::polygon::B2DPolygon > PolygonVector;
+ typedef ::std::vector< ::basegfx::polygon::B2DPolygon > PolygonVector;
PolygonVector maPolygons;
sal_uInt32 mnRefCount;
@@ -127,17 +127,17 @@ public:
return sal_True;
}
- const basegfx::polygon::B2DPolygon& getPolygon(sal_uInt32 nIndex) const
+ const ::basegfx::polygon::B2DPolygon& getPolygon(sal_uInt32 nIndex) const
{
return maPolygons[nIndex];
}
- void setPolygon(sal_uInt32 nIndex, const basegfx::polygon::B2DPolygon& rPolygon)
+ void setPolygon(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rPolygon)
{
maPolygons[nIndex] = rPolygon;
}
- void insert(sal_uInt32 nIndex, const basegfx::polygon::B2DPolygon& rPolygon, sal_uInt32 nCount)
+ void insert(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolygon& rPolygon, sal_uInt32 nCount)
{
if(nCount)
{
@@ -148,7 +148,7 @@ public:
}
}
- void insert(sal_uInt32 nIndex, const basegfx::polygon::B2DPolyPolygon& rPolyPolygon)
+ void insert(sal_uInt32 nIndex, const ::basegfx::polygon::B2DPolyPolygon& rPolyPolygon)
{
const sal_uInt32 nCount = rPolyPolygon.count();
@@ -404,12 +404,6 @@ namespace basegfx
}
}
- ::basegfx::vector::B2DVectorOrientation B2DPolyPolygon::checkOrientations()
- {
- implForceUniqueCopy();
- return ::basegfx::polygon::tools::checkOrientations(*this);
- }
-
void B2DPolyPolygon::flip()
{
implForceUniqueCopy();
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx
index 016bad760cd4..07ada131585d 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygontools.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:24:43 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,10 +67,22 @@
#include <basegfx/polygon/b2dpolypolygon.hxx>
#endif
+#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
+#include <basegfx/polygon/b2dpolygon.hxx>
+#endif
+
+#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#endif
+
#ifndef _BGFX_NUMERIC_FTOOLS_HXX
#include <basegfx/numeric/ftools.hxx>
#endif
+#ifndef _BGFX_POLYGON_B2DPOLYPOLYGONCUTTER_HXX
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#endif
+
//////////////////////////////////////////////////////////////////////////////
namespace basegfx
@@ -81,17 +93,84 @@ namespace basegfx
{
// B2DPolyPolygon tools
- // Check and evtl. correct orientations of contained Polygons
- ::basegfx::vector::B2DVectorOrientation checkOrientations(::basegfx::polygon::B2DPolyPolygon& rCandidate)
+ void correctOrientations(::basegfx::polygon::B2DPolyPolygon& rCandidate)
{
- ::basegfx::vector::B2DVectorOrientation eRetval(::basegfx::vector::ORIENTATION_NEUTRAL);
+ const sal_uInt32 nPolygonCount(rCandidate.count());
+ sal_uInt32 nIndexOfOutmostPolygon(0L);
+ sal_Bool bIndexOfOutmostPolygonSet(sal_False);
+
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
+ {
+ ::basegfx::polygon::B2DPolygon aCandidate = rCandidate.getPolygon(a);
+ if(aCandidate.count() > 2L)
+ {
+ ::basegfx::vector::B2DVectorOrientation aOrientation =
+ ::basegfx::polygon::tools::getOrientation(aCandidate);
+ sal_Bool bDoFlip(::basegfx::vector::ORIENTATION_POSITIVE != aOrientation);
+ // init values for depth and compare point for
+ // inside test. Since the ordering makes only sense when assuming
+ // that there are no intersections, the inside test is done with
+ // any point of the candidate, so teke the first one.
+ sal_uInt32 nDepth(0L);
+ const ::basegfx::point::B2DPoint aTestPoint(aCandidate.getB2DPoint(0L));
+ // loop over other polygons and calculate depth
+ for(sal_uInt32 b(0L); b < nPolygonCount; b++)
+ {
+ if(b != a)
+ {
+ ::basegfx::polygon::B2DPolygon aComparePolygon = rCandidate.getPolygon(b);
+ if(::basegfx::polygon::tools::isInside(aComparePolygon, aTestPoint))
+ {
+ nDepth++;
+ }
+ }
+ }
+ // if nDepth is odd it is a hole
+ sal_Bool bIsHole(1L == (nDepth & 0x00000001));
+
+ // does polygon need to be flipped?
+ if((bDoFlip && !bIsHole) || (!bDoFlip && bIsHole))
+ {
+ aCandidate.flip();
+
+ // write back changed polygon
+ rCandidate.setPolygon(a, aCandidate);
+ }
+
+ // remember the index if it's the outmost polygon
+ if(!bIndexOfOutmostPolygonSet && 0L == nDepth)
+ {
+ bIndexOfOutmostPolygonSet = sal_True;
+ nIndexOfOutmostPolygon = a;
+ }
+ }
+ }
+
+ // if the outmost polygon is not the first, move it in front
+ if(bIndexOfOutmostPolygonSet && nIndexOfOutmostPolygon > 0L)
+ {
+ ::basegfx::polygon::B2DPolygon aOutmostPolygon = rCandidate.getPolygon(nIndexOfOutmostPolygon);
+ rCandidate.remove(nIndexOfOutmostPolygon);
+ rCandidate.insert(0L, aOutmostPolygon);
+ }
+ }
+
+ void removeIntersections(::basegfx::polygon::B2DPolyPolygon& rCandidate,
+ sal_Bool bForceOrientation, sal_Bool bInvertRemove)
+ {
+ ::basegfx::polygon::B2DPolyPolygonCutter aCutter;
- return eRetval;
+ aCutter.addPolyPolygon(rCandidate, bForceOrientation);
+ aCutter.removeSelfIntersections();
+ aCutter.removeDoubleIntersections();
+ aCutter.removeIncludedPolygons(!bInvertRemove);
+ rCandidate.clear();
+ aCutter.getPolyPolygon(rCandidate);
}
} // end of namespace tools
} // end of namespace polygon
diff --git a/basegfx/source/polygon/makefile.mk b/basegfx/source/polygon/makefile.mk
index 7e6e3384c48e..6cf70f361d67 100644
--- a/basegfx/source/polygon/makefile.mk
+++ b/basegfx/source/polygon/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: aw $ $Date: 2003-11-05 12:25:55 $
+# last change: $Author: aw $ $Date: 2003-11-06 16:30:29 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -75,10 +75,11 @@ TARGET=polygon
# --- Files -------------------------------------
SLOFILES= \
- $(SLO)$/b2dpolygon.obj \
- $(SLO)$/b2dpolygontools.obj \
- $(SLO)$/b2dpolypolygon.obj \
- $(SLO)$/b2dpolypolygontools.obj
+ $(SLO)$/b2dpolygon.obj \
+ $(SLO)$/b2dpolygontools.obj \
+ $(SLO)$/b2dpolypolygon.obj \
+ $(SLO)$/b2dpolypolygontools.obj \
+ $(SLO)$/b2dpolypolygoncutter.obj
# --- Targets ----------------------------------
diff --git a/basegfx/source/vector/b2dvector.cxx b/basegfx/source/vector/b2dvector.cxx
index ea3abe72be3a..92931c563125 100644
--- a/basegfx/source/vector/b2dvector.cxx
+++ b/basegfx/source/vector/b2dvector.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dvector.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: aw $ $Date: 2003-11-05 12:25:56 $
+ * last change: $Author: aw $ $Date: 2003-11-06 16:30:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -98,7 +98,7 @@ namespace basegfx
return *this;
}
- B2DVector& B2DVector::operator=( const B2DTuple& rVec )
+ B2DVector& B2DVector::operator=( const ::basegfx::tuple::B2DTuple& rVec )
{
mfX = rVec.getX();
mfY = rVec.getY();
@@ -118,7 +118,7 @@ namespace basegfx
const B2DVector& B2DVector::getEmptyVector()
{
- return (const B2DVector&) B2DTuple::getEmptyTuple();
+ return (const B2DVector&) ::basegfx::tuple::B2DTuple::getEmptyTuple();
}
B2DVector& B2DVector::operator*=( const matrix::B2DHomMatrix& rMat )