b2dpolygonclipper.cxx (07a3d7f1) b2dpolygonclipper.cxx (54d1d3e3)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 403 unchanged lines hidden (view full) ---

412 //////////////////////////////////////////////////////////////////////////////
413
414 B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon& rCandidate, const B2DPolyPolygon& rClip, bool bInside, bool bStroke)
415 {
416 B2DPolyPolygon aRetval;
417
418 if(rCandidate.count() && rClip.count())
419 {
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 403 unchanged lines hidden (view full) ---

412 //////////////////////////////////////////////////////////////////////////////
413
414 B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon& rCandidate, const B2DPolyPolygon& rClip, bool bInside, bool bStroke)
415 {
416 B2DPolyPolygon aRetval;
417
418 if(rCandidate.count() && rClip.count())
419 {
420 // #125349# detect if both given PolyPolygons are indeed ranges
421 bool bBothRectangle(false);
422
423 if(basegfx::tools::isRectangle(rCandidate))
424 {
425 if(basegfx::tools::isRectangle(rClip))
426 {
427 // both are ranges
428 bBothRectangle = true;
429 }
430 else
431 {
432 // rCandidate is rectangle -> clip rClip on rRectangle, use the much
433 // cheaper and numerically more stable clipping against a range
434 // This simplification (exchanging content and clip) is valid
435 // since we do a logical AND operation
436 return clipPolyPolygonOnRange(rClip, rCandidate.getB2DRange(), bInside, bStroke);
437 }
438 }
439 else if(basegfx::tools::isRectangle(rClip))
440 {
441 if(basegfx::tools::isRectangle(rCandidate))
442 {
443 // both are ranges
444 bBothRectangle = true;
445 }
446 else
447 {
448 // rClip is rectangle -> clip rCandidate on rRectangle, use the much
449 // cheaper and numerically more stable clipping against a range
450 return clipPolyPolygonOnRange(rCandidate, rClip.getB2DRange(), bInside, bStroke);
451 }
452 }
453
454 if(bBothRectangle)
455 {
456 // both are rectangle
457 if(rCandidate.getB2DRange().equal(rClip.getB2DRange()))
458 {
459 // if both are equal -> no change
460 return rCandidate;
461 }
462 else
463 {
464 // not equal -> create new intersection from both ranges,
465 // but much cheaper based on the ranges
466 basegfx::B2DRange aIntersectionRange(rCandidate.getB2DRange());
467
468 aIntersectionRange.intersect(rClip.getB2DRange());
469
470 if(aIntersectionRange.isEmpty())
471 {
472 // no common IntersectionRange -> the clip will be empty
473 return B2DPolyPolygon();
474 }
475 else
476 {
477 // use common aIntersectionRange as result, convert
478 // to expected PolyPolygon form
479 return basegfx::B2DPolyPolygon(
480 basegfx::tools::createPolygonFromRect(aIntersectionRange));
481 }
482 }
483 }
484
485 // one or both are no rectangle - go the hard way and clip PolyPolygon
486 // against PolyPolygon...
420 if(bStroke)
421 {
422 // line clipping, create line snippets by first adding all cut points and
423 // then marching along the edges and detecting if they are inside or outside
424 // the clip polygon
425 for(sal_uInt32 a(0); a < rCandidate.count(); a++)
426 {
427 // add cuts with clip to polygon, including bezier segments

--- 442 unchanged lines hidden ---
487 if(bStroke)
488 {
489 // line clipping, create line snippets by first adding all cut points and
490 // then marching along the edges and detecting if they are inside or outside
491 // the clip polygon
492 for(sal_uInt32 a(0); a < rCandidate.count(); a++)
493 {
494 // add cuts with clip to polygon, including bezier segments

--- 442 unchanged lines hidden ---