1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <basegfx/polygon/b2dpolygonclipper.hxx>
21 #include <basegfx/polygon/b2dpolygontools.hxx>
22 #include <basegfx/numeric/ftools.hxx>
23 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
24 #include <basegfx/polygon/b2dpolygoncutandtouch.hxx>
25 #include <basegfx/polygon/b2dpolypolygontools.hxx>
26 #include <basegfx/curve/b2dcubicbezier.hxx>
27 #include <basegfx/utils/rectcliptools.hxx>
33 B2DPolyPolygon
clipPolygonOnParallelAxis(const B2DPolygon
& rCandidate
, bool bParallelToXAxis
, bool bAboveAxis
, double fValueOnOtherAxis
, bool bStroke
)
35 B2DPolyPolygon aRetval
;
37 if(rCandidate
.count())
39 const B2DRange
aCandidateRange(getRange(rCandidate
));
41 if(bParallelToXAxis
&& fTools::moreOrEqual(aCandidateRange
.getMinY(), fValueOnOtherAxis
))
43 // completely above and on the clip line. also true for curves.
47 aRetval
.append(rCandidate
);
50 else if(bParallelToXAxis
&& fTools::lessOrEqual(aCandidateRange
.getMaxY(), fValueOnOtherAxis
))
52 // completely below and on the clip line. also true for curves.
56 aRetval
.append(rCandidate
);
59 else if(!bParallelToXAxis
&& fTools::moreOrEqual(aCandidateRange
.getMinX(), fValueOnOtherAxis
))
61 // completely right of and on the clip line. also true for curves.
65 aRetval
.append(rCandidate
);
68 else if(!bParallelToXAxis
&& fTools::lessOrEqual(aCandidateRange
.getMaxX(), fValueOnOtherAxis
))
70 // completely left of and on the clip line. also true for curves.
74 aRetval
.append(rCandidate
);
79 // add cuts with axis to polygon, including bezier segments
80 // Build edge to cut with. Make it a little big longer than needed for
81 // numerical stability. We want to cut against the edge seen as endless
82 // ray here, but addPointsAtCuts() will limit itself to the
83 // edge's range ]0.0 .. 1.0[.
84 const double fSmallExtension((aCandidateRange
.getWidth() + aCandidateRange
.getHeight()) * (0.5 * 0.1));
85 const B2DPoint
aStart(
86 bParallelToXAxis
? aCandidateRange
.getMinX() - fSmallExtension
: fValueOnOtherAxis
,
87 bParallelToXAxis
? fValueOnOtherAxis
: aCandidateRange
.getMinY() - fSmallExtension
);
89 bParallelToXAxis
? aCandidateRange
.getMaxX() + fSmallExtension
: fValueOnOtherAxis
,
90 bParallelToXAxis
? fValueOnOtherAxis
: aCandidateRange
.getMaxY() + fSmallExtension
);
91 const B2DPolygon
aCandidate(addPointsAtCuts(rCandidate
, aStart
, aEnd
));
92 const sal_uInt32
nPointCount(aCandidate
.count());
93 const sal_uInt32
nEdgeCount(aCandidate
.isClosed() ? nPointCount
: nPointCount
- 1);
97 for(sal_uInt32
a(0); a
< nEdgeCount
; a
++)
99 aCandidate
.getBezierSegment(a
, aEdge
);
100 const B2DPoint
aTestPoint(aEdge
.interpolatePoint(0.5));
101 const bool bInside(bParallelToXAxis
?
102 fTools::moreOrEqual(aTestPoint
.getY(), fValueOnOtherAxis
) == bAboveAxis
:
103 fTools::moreOrEqual(aTestPoint
.getX(), fValueOnOtherAxis
) == bAboveAxis
);
107 if(!aRun
.count() || !aRun
.getB2DPoint(aRun
.count() - 1).equal(aEdge
.getStartPoint()))
109 aRun
.append(aEdge
.getStartPoint());
114 aRun
.appendBezierSegment(aEdge
.getControlPointA(), aEdge
.getControlPointB(), aEdge
.getEndPoint());
118 aRun
.append(aEdge
.getEndPoint());
123 if(bStroke
&& aRun
.count())
125 aRetval
.append(aRun
);
135 // try to merge this last and first polygon; they may have been
136 // the former polygon's start/end point
139 const B2DPolygon
aStartPolygon(aRetval
.getB2DPolygon(0));
141 if(aStartPolygon
.count() && aStartPolygon
.getB2DPoint(0).equal(aRun
.getB2DPoint(aRun
.count() - 1)))
143 // append start polygon to aRun, remove from result set
144 aRun
.append(aStartPolygon
); aRun
.removeDoublePoints();
149 aRetval
.append(aRun
);
153 // set closed flag and correct last point (which is added double now).
154 closeWithGeometryChange(aRun
);
155 aRetval
.append(aRun
);
164 B2DPolyPolygon
clipPolyPolygonOnParallelAxis(const B2DPolyPolygon
& rCandidate
, bool bParallelToXAxis
, bool bAboveAxis
, double fValueOnOtherAxis
, bool bStroke
)
166 const sal_uInt32
nPolygonCount(rCandidate
.count());
167 B2DPolyPolygon aRetval
;
169 for(sal_uInt32
a(0); a
< nPolygonCount
; a
++)
171 const B2DPolyPolygon
aClippedPolyPolygon(clipPolygonOnParallelAxis(rCandidate
.getB2DPolygon(a
), bParallelToXAxis
, bAboveAxis
, fValueOnOtherAxis
, bStroke
));
173 if(aClippedPolyPolygon
.count())
175 aRetval
.append(aClippedPolyPolygon
);
182 B2DPolyPolygon
clipPolygonOnRange(const B2DPolygon
& rCandidate
, const B2DRange
& rRange
, bool bInside
, bool bStroke
)
184 const sal_uInt32
nCount(rCandidate
.count());
185 B2DPolyPolygon aRetval
;
197 // nothing is inside an empty range
202 // everything is outside an empty range
203 return B2DPolyPolygon(rCandidate
);
207 const B2DRange
aCandidateRange(getRange(rCandidate
));
209 if(rRange
.isInside(aCandidateRange
))
211 // candidate is completely inside given range
215 return B2DPolyPolygon(rCandidate
);
219 // nothing is outside, then
226 // cutting off the outer parts of filled polygons at parallel
227 // lines to the axes is only possible for the inner part, not for
228 // the outer part which means cutting a hole into the original polygon.
229 // This is because the inner part is a logical AND-operation of
230 // the four implied half-planes, but the outer part is not.
231 // It is possible for strokes, but with creating unnecessary extra
232 // cuts, so using clipPolygonOnPolyPolygon is better there, too.
233 // This needs to be done with the topology knowledge and is unfortunately
234 // more expensive, too.
235 const B2DPolygon
aClip(createPolygonFromRect(rRange
));
237 return clipPolygonOnPolyPolygon(rCandidate
, B2DPolyPolygon(aClip
), bInside
, bStroke
);
240 // clip against the four axes of the range
241 // against X-Axis, lower value
242 aRetval
= clipPolygonOnParallelAxis(rCandidate
, true, bInside
, rRange
.getMinY(), bStroke
);
246 // against Y-Axis, lower value
247 if(aRetval
.count() == 1)
249 aRetval
= clipPolygonOnParallelAxis(aRetval
.getB2DPolygon(0), false, bInside
, rRange
.getMinX(), bStroke
);
253 aRetval
= clipPolyPolygonOnParallelAxis(aRetval
, false, bInside
, rRange
.getMinX(), bStroke
);
258 // against X-Axis, higher value
259 if(aRetval
.count() == 1)
261 aRetval
= clipPolygonOnParallelAxis(aRetval
.getB2DPolygon(0), true, false, rRange
.getMaxY(), bStroke
);
265 aRetval
= clipPolyPolygonOnParallelAxis(aRetval
, true, false, rRange
.getMaxY(), bStroke
);
270 // against Y-Axis, higher value
271 if(aRetval
.count() == 1)
273 aRetval
= clipPolygonOnParallelAxis(aRetval
.getB2DPolygon(0), false, false, rRange
.getMaxX(), bStroke
);
277 aRetval
= clipPolyPolygonOnParallelAxis(aRetval
, false, false, rRange
.getMaxX(), bStroke
);
286 B2DPolyPolygon
clipPolyPolygonOnRange(const B2DPolyPolygon
& rCandidate
, const B2DRange
& rRange
, bool bInside
, bool bStroke
)
288 const sal_uInt32
nPolygonCount(rCandidate
.count());
289 B2DPolyPolygon aRetval
;
301 // nothing is inside an empty range
306 // everything is outside an empty range
313 for(sal_uInt32
a(0); a
< nPolygonCount
; a
++)
315 const B2DPolyPolygon
aClippedPolyPolygon(clipPolygonOnRange(rCandidate
.getB2DPolygon(a
), rRange
, bInside
, bStroke
));
317 if(aClippedPolyPolygon
.count())
319 aRetval
.append(aClippedPolyPolygon
);
325 // for details, see comment in clipPolygonOnRange for the "cutting off
326 // the outer parts of filled polygons at parallel lines" explanations
327 const B2DPolygon
aClip(createPolygonFromRect(rRange
));
329 return clipPolyPolygonOnPolyPolygon(rCandidate
, B2DPolyPolygon(aClip
), bInside
, bStroke
);
335 B2DPolyPolygon
clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon
& rCandidate
, const B2DPolyPolygon
& rClip
, bool bInside
, bool bStroke
)
337 B2DPolyPolygon aRetval
;
339 if(rCandidate
.count() && rClip
.count())
341 // one or both are no rectangle - go the hard way and clip PolyPolygon
342 // against PolyPolygon...
345 // line clipping, create line snippets by first adding all cut points and
346 // then marching along the edges and detecting if they are inside or outside
348 for(sal_uInt32
a(0); a
< rCandidate
.count(); a
++)
350 // add cuts with clip to polygon, including bezier segments
351 const B2DPolygon
aCandidate(addPointsAtCuts(rCandidate
.getB2DPolygon(a
), rClip
));
352 const sal_uInt32
nPointCount(aCandidate
.count());
353 const sal_uInt32
nEdgeCount(aCandidate
.isClosed() ? nPointCount
: nPointCount
- 1);
354 B2DCubicBezier aEdge
;
357 for(sal_uInt32
b(0); b
< nEdgeCount
; b
++)
359 aCandidate
.getBezierSegment(b
, aEdge
);
360 const B2DPoint
aTestPoint(aEdge
.interpolatePoint(0.5));
361 const bool bIsInside(utils::isInside(rClip
, aTestPoint
) == bInside
);
367 aRun
.append(aEdge
.getStartPoint());
372 aRun
.appendBezierSegment(aEdge
.getControlPointA(), aEdge
.getControlPointB(), aEdge
.getEndPoint());
376 aRun
.append(aEdge
.getEndPoint());
383 aRetval
.append(aRun
);
391 // try to merge this last and first polygon; they may have been
392 // the former polygon's start/end point
395 const B2DPolygon
aStartPolygon(aRetval
.getB2DPolygon(0));
397 if(aStartPolygon
.count() && aStartPolygon
.getB2DPoint(0).equal(aRun
.getB2DPoint(aRun
.count() - 1)))
399 // append start polygon to aRun, remove from result set
400 aRun
.append(aStartPolygon
); aRun
.removeDoublePoints();
405 aRetval
.append(aRun
);
411 // check for simplification with ranges if !bStroke (handling as stroke is more simple),
412 // but also only when bInside, else the simplification may lead to recursive calls (see
413 // calls to clipPolyPolygonOnPolyPolygon in clipPolyPolygonOnRange and clipPolygonOnRange)
414 if (bInside
&& basegfx::utils::isRectangle(rClip
))
416 // #i125349# detect if both given PolyPolygons are indeed ranges
417 if (basegfx::utils::isRectangle(rCandidate
))
419 // both are rectangle
420 if(rCandidate
.getB2DRange().equal(rClip
.getB2DRange()))
422 // if both are equal -> no change
427 // not equal -> create new intersection from both ranges,
428 // but much cheaper based on the ranges
429 basegfx::B2DRange
aIntersectionRange(rCandidate
.getB2DRange());
431 aIntersectionRange
.intersect(rClip
.getB2DRange());
433 if(aIntersectionRange
.isEmpty())
435 // no common IntersectionRange -> the clip will be empty
436 return B2DPolyPolygon();
440 // use common aIntersectionRange as result, convert
441 // to expected utils::PolyPolygon form
442 return basegfx::B2DPolyPolygon(
443 basegfx::utils::createPolygonFromRect(aIntersectionRange
));
449 // rClip is rectangle -> clip rCandidate on rRectangle, use the much
450 // cheaper and numerically more stable clipping against a range
451 return clipPolyPolygonOnRange(rCandidate
, rClip
.getB2DRange(), bInside
, bStroke
);
457 // First solve all polygon-self and polygon-polygon intersections.
458 // Also get rid of some not-needed polygons (neutral, no area -> when
459 // no intersections, these are tubes).
460 // Now it is possible to correct the orientations in the cut-free
461 // polygons to values corresponding to painting the utils::PolyPolygon with
462 // a XOR-WindingRule.
463 B2DPolyPolygon aMergePolyPolygonA
= solveCrossovers(rClip
);
464 aMergePolyPolygonA
= stripNeutralPolygons(aMergePolyPolygonA
);
465 aMergePolyPolygonA
= correctOrientations(aMergePolyPolygonA
);
469 // if we want to get the outside of the clip polygon, make
470 // it a 'Hole' in topological sense
471 aMergePolyPolygonA
.flip();
475 // prepare 2nd source polygon in same way
476 B2DPolyPolygon aMergePolyPolygonB
= solveCrossovers(rCandidate
);
477 aMergePolyPolygonB
= stripNeutralPolygons(aMergePolyPolygonB
);
478 aMergePolyPolygonB
= correctOrientations(aMergePolyPolygonB
);
480 // to clip against each other, concatenate and solve all
481 // polygon-polygon crossovers. polygon-self do not need to
482 // be solved again, they were solved in the preparation.
483 aRetval
.append(aMergePolyPolygonA
);
484 aRetval
.append(aMergePolyPolygonB
);
485 aRetval
= solveCrossovers(aRetval
);
487 // now remove neutral polygons (closed, but no area). In a last
488 // step throw away all polygons which have a depth of less than 1
489 // which means there was no logical AND at their position. For the
490 // not-inside solution, the clip was flipped to define it as 'Hole',
491 // so the removal rule is different here; remove all with a depth
492 // of less than 0 (aka holes).
493 aRetval
= stripNeutralPolygons(aRetval
);
494 aRetval
= stripDispensablePolygons(aRetval
, bInside
);
501 B2DPolyPolygon
clipPolygonOnPolyPolygon(const B2DPolygon
& rCandidate
, const B2DPolyPolygon
& rClip
, bool bInside
, bool bStroke
)
503 B2DPolyPolygon aRetval
;
505 if(rCandidate
.count() && rClip
.count())
507 aRetval
= clipPolyPolygonOnPolyPolygon(B2DPolyPolygon(rCandidate
), rClip
, bInside
, bStroke
);
514 * let a plane be defined as
518 * and a ray be defined as
522 * substitute and rearranging yields
524 * t = -(a.n+d)/(n.(b-a))
526 * if the denominator is zero, the line is either
527 * contained in the plane or parallel to the plane.
528 * in either case, there is no intersection.
529 * if numerator and denominator are both zero, the
530 * ray is contained in the plane.
533 struct scissor_plane
{
534 double nx
,ny
; // plane normal
535 double d
; // [-] minimum distance from origin
536 sal_uInt32 clipmask
; // clipping mask, e.g. 1000 1000
541 * polygon clipping rules (straight out of Foley and Van Dam)
542 * ===========================================================
543 * current |next |emit
544 * ____________________________________
545 * inside |inside |next
546 * inside |outside |intersect with clip plane
547 * outside |outside |nothing
548 * outside |inside |intersect with clip plane follwed by next
551 static sal_uInt32
scissorLineSegment( ::basegfx::B2DPoint
*in_vertex
, // input buffer
552 sal_uInt32 in_count
, // number of verts in input buffer
553 ::basegfx::B2DPoint
*out_vertex
, // output buffer
554 scissor_plane
const *pPlane
, // scissoring plane
555 const ::basegfx::B2DRectangle
&rR
) // clipping rectangle
558 sal_uInt32 out_count
=0;
560 // process all the verts
561 for(sal_uInt32 i
=0; i
<in_count
; i
++) {
563 // vertices are relative to the coordinate
564 // system defined by the rectangle.
565 ::basegfx::B2DPoint
*curr
= &in_vertex
[i
];
566 ::basegfx::B2DPoint
*next
= &in_vertex
[(i
+1)%in_count
];
568 // perform clipping judgement & mask against current plane.
569 sal_uInt32 clip
= pPlane
->clipmask
& ((getCohenSutherlandClipFlags(*curr
,rR
)<<4)|getCohenSutherlandClipFlags(*next
,rR
));
571 if(clip
==0) { // both verts are inside
572 out_vertex
[out_count
++] = *next
;
574 else if((clip
&0x0f) && (clip
&0xf0)) { // both verts are outside
576 else if((clip
&0x0f) && (clip
&0xf0)==0) { // curr is inside, next is outside
578 // direction vector from 'current' to 'next', *not* normalized
579 // to bring 't' into the [0<=x<=1] interval.
580 ::basegfx::B2DPoint
dir((*next
)-(*curr
));
582 double denominator
= pPlane
->nx
*dir
.getX() +
583 pPlane
->ny
*dir
.getY();
584 double numerator
= pPlane
->nx
*curr
->getX() +
585 pPlane
->ny
*curr
->getY() +
587 double t
= -numerator
/denominator
;
589 // calculate the actual point of intersection
590 ::basegfx::B2DPoint
intersection( curr
->getX()+t
*dir
.getX(),
591 curr
->getY()+t
*dir
.getY() );
593 out_vertex
[out_count
++] = intersection
;
595 else if((clip
&0x0f)==0 && (clip
&0xf0)) { // curr is outside, next is inside
597 // direction vector from 'current' to 'next', *not* normalized
598 // to bring 't' into the [0<=x<=1] interval.
599 ::basegfx::B2DPoint
dir((*next
)-(*curr
));
601 double denominator
= pPlane
->nx
*dir
.getX() +
602 pPlane
->ny
*dir
.getY();
603 double numerator
= pPlane
->nx
*curr
->getX() +
604 pPlane
->ny
*curr
->getY() +
606 double t
= -numerator
/denominator
;
608 // calculate the actual point of intersection
609 ::basegfx::B2DPoint
intersection( curr
->getX()+t
*dir
.getX(),
610 curr
->getY()+t
*dir
.getY() );
612 out_vertex
[out_count
++] = intersection
;
613 out_vertex
[out_count
++] = *next
;
620 B2DPolygon
clipTriangleListOnRange( const B2DPolygon
& rCandidate
,
621 const B2DRange
& rRange
)
625 if( !(rCandidate
.count()%3) )
627 const int scissor_plane_count
= 4;
629 scissor_plane sp
[scissor_plane_count
];
633 sp
[0].d
= -(rRange
.getMinX());
634 sp
[0].clipmask
= (RectClipFlags::LEFT
<< 4) | RectClipFlags::LEFT
; // 0001 0001
637 sp
[1].d
= +(rRange
.getMaxX());
638 sp
[1].clipmask
= (RectClipFlags::RIGHT
<< 4) | RectClipFlags::RIGHT
; // 0010 0010
641 sp
[2].d
= -(rRange
.getMinY());
642 sp
[2].clipmask
= (RectClipFlags::TOP
<< 4) | RectClipFlags::TOP
; // 0100 0100
645 sp
[3].d
= +(rRange
.getMaxY());
646 sp
[3].clipmask
= (RectClipFlags::BOTTOM
<< 4) | RectClipFlags::BOTTOM
; // 1000 1000
648 // retrieve the number of vertices of the triangulated polygon
649 const sal_uInt32 nVertexCount
= rCandidate
.count();
653 // Upper bound for the maximal number of vertices when intersecting an
654 // axis-aligned rectangle with a triangle in E2
656 // The rectangle and the triangle are in general position, and have 4 and 3
657 // vertices, respectively.
659 // Lemma: Since the rectangle is a convex polygon ( see
660 // http://mathworld.wolfram.com/ConvexPolygon.html for a definition), and
661 // has no holes, it follows that any straight line will intersect the
662 // rectangle's border line at utmost two times (with the usual
663 // tie-breaking rule, if the intersection exactly hits an already existing
664 // rectangle vertex, that this intersection is only attributed to one of
665 // the adjoining edges). Thus, having a rectangle intersected with
666 // a half-plane (one side of a straight line denotes 'inside', the
667 // other 'outside') will at utmost add _one_ vertex to the resulting
668 // intersection polygon (adding two intersection vertices, and removing at
669 // least one rectangle vertex):
672 // +--+-----------------+
678 // +--------------------+
680 // Proof: If the straight line intersects the rectangle two
681 // times, it does so for distinct edges, i.e. the intersection has
682 // minimally one of the rectangle's vertices on either side of the straight
683 // line (but maybe more). Thus, the intersection with a half-plane has
684 // minimally _one_ rectangle vertex removed from the resulting clip
685 // polygon, and therefore, a clip against a half-plane has the net effect
686 // of adding at utmost _one_ vertex to the resulting clip polygon.
688 // Theorem: The intersection of a rectangle and a triangle results in a
689 // polygon with at utmost 7 vertices.
691 // Proof: The inside of the triangle can be described as the consecutive
692 // intersection with three half-planes. Together with the lemma above, this
693 // results in at utmost 3 additional vertices added to the already existing 4
694 // rectangle vertices.
696 // This upper bound is attained with the following example configuration:
720 // As we need to scissor all triangles against the
721 // output rectangle we employ an output buffer for the
722 // resulting vertices. the question is how large this
723 // buffer needs to be compared to the number of
724 // incoming vertices. this buffer needs to hold at
725 // most the number of original vertices times '7'. see
726 // figure above for an example. scissoring triangles
727 // with the cohen-sutherland line clipping algorithm
728 // as implemented here will result in a triangle fan
729 // which will be rendered as separate triangles to
730 // avoid pipeline stalls for each scissored
731 // triangle. creating separate triangles from a
732 // triangle fan produces (n-2)*3 vertices where n is
733 // the number of vertices of the original triangle
734 // fan. for the maximum number of 7 vertices of
735 // resulting triangle fans we therefore need 15 times
736 // the number of original vertices.
738 //const size_t nBufferSize = sizeof(vertex)*(nVertexCount*16);
739 //vertex *pVertices = (vertex*)alloca(nBufferSize);
740 //sal_uInt32 nNumOutput = 0;
742 // we need to clip this triangle against the output rectangle
743 // to ensure that the resulting texture coordinates are in
744 // the valid range from [0<=st<=1]. under normal circumstances
745 // we could use the BORDERCOLOR renderstate but some cards
746 // seem to ignore this feature.
747 ::basegfx::B2DPoint stack
[3];
748 unsigned int clipflag
= 0;
750 for(sal_uInt32 nIndex
=0; nIndex
<nVertexCount
; ++nIndex
)
755 stack
[2] = rCandidate
.getB2DPoint(nIndex
);
757 // clipping judgement
758 clipflag
|= unsigned(!(rRange
.isInside(stack
[2])));
762 // consume vertices until a single separate triangle has been visited.
765 // if any of the last three vertices was outside
766 // we need to scissor against the destination rectangle
769 ::basegfx::B2DPoint buf0
[16];
770 ::basegfx::B2DPoint buf1
[16];
772 sal_uInt32 vertex_count
= 3;
774 // clip against all 4 planes passing the result of
775 // each plane as the input to the next using a double buffer
776 vertex_count
= scissorLineSegment(stack
,vertex_count
,buf1
,&sp
[0],rRange
);
777 vertex_count
= scissorLineSegment(buf1
,vertex_count
,buf0
,&sp
[1],rRange
);
778 vertex_count
= scissorLineSegment(buf0
,vertex_count
,buf1
,&sp
[2],rRange
);
779 vertex_count
= scissorLineSegment(buf1
,vertex_count
,buf0
,&sp
[3],rRange
);
781 if(vertex_count
>= 3)
783 // convert triangle fan back to triangle list.
784 ::basegfx::B2DPoint
v0(buf0
[0]);
785 ::basegfx::B2DPoint
v1(buf0
[1]);
786 for(sal_uInt32 i
=2; i
<vertex_count
; ++i
)
788 ::basegfx::B2DPoint
v2(buf0
[i
]);
798 // the last triangle has not been altered, simply copy to result
799 for(const basegfx::B2DPoint
& i
: stack
)
813 } // end of namespace utils
814 } // end of namespace basegfx
816 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */