@@ -633,23 +633,17 @@ double QgsGeometryUtils::circleTangentDirection( const QgsPoint &tangentPoint, c
633
633
void QgsGeometryUtils::segmentizeArc ( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, QgsPointSequence &points, double tolerance, QgsAbstractGeometry::SegmentationToleranceType toleranceType, bool hasZ, bool hasM )
634
634
{
635
635
bool reversed = false ;
636
- bool clockwise = false ;
637
636
int segSide = segmentSide ( p1, p3, p2 );
638
- if ( segSide == -1 )
639
- {
640
- clockwise = true ;
641
- }
642
637
643
638
QgsPoint circlePoint1;
644
639
const QgsPoint circlePoint2 = p2;
645
640
QgsPoint circlePoint3;
646
641
647
- if ( clockwise )
642
+ if ( segSide == - 1 )
648
643
{
649
644
// Reverse !
650
645
circlePoint1 = p3;
651
646
circlePoint3 = p1;
652
- clockwise = false ;
653
647
reversed = true ;
654
648
}
655
649
else
@@ -664,8 +658,8 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
664
658
double centerY = 0 ;
665
659
circleCenterRadius ( circlePoint1, circlePoint2, circlePoint3, radius, centerX, centerY );
666
660
667
- QgsDebugMsg ( QString ( " Center: POINT(%1 %2) - Radius: %3 - Clockwise : %4" )
668
- .arg ( centerX ) .arg ( centerY ) .arg ( radius ) .arg ( clockwise ) );
661
+ QgsDebugMsg ( QString ( " Center: POINT(%1 %2) - Radius: %3 - Reversed : %4" )
662
+ .arg ( centerX ) .arg ( centerY ) .arg ( radius ) .arg ( reversed ) );
669
663
670
664
if ( circlePoint1 != circlePoint3 && ( radius < 0 || qgsDoubleNear ( segSide, 0.0 ) ) ) // points are colinear
671
665
{
@@ -698,7 +692,7 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
698
692
const bool symmetric = true ;
699
693
if ( symmetric )
700
694
{
701
- double angle = clockwise ? a1 - a3 : a3 - a1;
695
+ double angle = a3 - a1;
702
696
if ( angle < 0 ) angle += M_PI * 2 ;
703
697
QgsDebugMsg ( QString ( " total angle: %1 (%2)" )
704
698
.arg ( angle ) .arg ( angle * 180 / M_PI )
@@ -712,23 +706,11 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
712
706
QgsDebugMsg ( QString ( " symmetric adjusted increment:%1" ) .arg ( increment ) );
713
707
}
714
708
715
- if ( clockwise )
716
- {
717
- increment *= -1 ;
718
- /* Adjust a3 down so we can increment from a1 to a3 cleanly */
719
- if ( a3 > a1 )
720
- a3 -= 2.0 * M_PI;
721
- if ( a2 > a1 )
722
- a2 -= 2.0 * M_PI;
723
- }
724
- else
725
- {
726
- /* Adjust a3 up so we can increment from a1 to a3 cleanly */
727
- if ( a3 < a1 )
728
- a3 += 2.0 * M_PI;
729
- if ( a2 < a1 )
730
- a2 += 2.0 * M_PI;
731
- }
709
+ /* Adjust a3 up so we can increment from a1 to a3 cleanly */
710
+ if ( a3 < a1 )
711
+ a3 += 2.0 * M_PI;
712
+ if ( a2 < a1 )
713
+ a2 += 2.0 * M_PI;
732
714
733
715
QgsDebugMsg ( QString ( " ADJUSTED - a1:%1 (%4) a2:%2 (%5) a3:%3 (%6)" )
734
716
.arg ( a1 ).arg ( a2 ).arg ( a3 )
@@ -749,10 +731,10 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
749
731
if ( hasM )
750
732
pointWkbType = QgsWkbTypes::addM ( pointWkbType );
751
733
752
- QgsDebugMsg ( QString ( " a1:%1 (%2), a3:%3 (%4), inc:%5, shi:?, cw:%6 " )
734
+ QgsDebugMsg ( QString ( " a1:%1 (%2), a3:%3 (%4), inc:%5" )
753
735
. arg ( a1 ). arg ( a1 * 180 / M_PI )
754
736
. arg ( a3 ). arg ( a3 * 180 / M_PI )
755
- . arg ( increment ). arg ( clockwise )
737
+ . arg ( increment )
756
738
);
757
739
758
740
// make sure the curve point p2 is part of the segmentized vertices. But only if p1 != p3
@@ -771,27 +753,16 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
771
753
// are more distant than requested. This is at most 1% off
772
754
// from requested MaxAngle and less for MaxError.
773
755
double tolError = increment / 100 ;
774
- double stopAngle = clockwise ? a3 - tolError : a3 - tolError;
756
+ double stopAngle = a3 - tolError;
775
757
QgsDebugMsg ( QString ( " stopAngle: %1 (%2)" ) . arg ( stopAngle ) .arg ( stopAngle * 180 / M_PI ) );
776
- for ( double angle = a1 + increment; clockwise ? angle > stopAngle : angle < stopAngle; angle += increment )
758
+ for ( double angle = a1 + increment; angle < stopAngle; angle += increment )
777
759
{
778
760
if ( addP2 && angle > a2 )
779
761
{
780
- if ( clockwise )
781
- {
782
- if ( stringPoints.empty () || stringPoints.front () != circlePoint2 )
783
- {
784
- QgsDebugMsg ( QString ( " Adding control point, with angle %1 (%2)" ) . arg ( a2 ) .arg ( a2 * 180 / M_PI ) );
785
- stringPoints.insert ( 0 , circlePoint2 );
786
- }
787
- }
788
- else
762
+ if ( stringPoints.empty () || stringPoints.back () != circlePoint2 )
789
763
{
790
- if ( stringPoints.empty () || stringPoints.back () != circlePoint2 )
791
- {
792
- QgsDebugMsg ( QString ( " Adding control point, with angle %1 (%2)" ) . arg ( a2 ) .arg ( a2 * 180 / M_PI ) );
793
- stringPoints.insert ( stringPoints.size (), circlePoint2 );
794
- }
764
+ QgsDebugMsg ( QString ( " Adding control point, with angle %1 (%2)" ) . arg ( a2 ) .arg ( a2 * 180 / M_PI ) );
765
+ stringPoints.insert ( stringPoints.size (), circlePoint2 );
795
766
}
796
767
addP2 = false ;
797
768
}
0 commit comments