778{
779#ifdef use_lines
780 if (!Closed && PolyTyp ==
ptClip)
781 throw clipperException("AddPath: Open paths must be subject.");
782#else
783 if (!Closed)
784 throw clipperException("AddPath: Open paths have been disabled.");
785#endif
786
787 assert(highI >= 0 && highI < pg.size());
788
789
790 try
791 {
792 edges[1].Curr = pg[1];
793#ifdef CLIPPERLIB_INT32
796#else
799#endif
800 InitEdge(&edges[0], &edges[1], &edges[highI], pg[0]);
801 InitEdge(&edges[highI], &edges[0], &edges[highI-1], pg[highI]);
802 for (int i = highI - 1; i >= 1; --i)
803 {
804#ifdef CLIPPERLIB_INT32
806#else
808#endif
809 InitEdge(&edges[i], &edges[i+1], &edges[i-1], pg[i]);
810 }
811 }
812 catch(...)
813 {
814 throw;
815 }
816 TEdge *eStart = &
edges[0];
817
818
819 TEdge *
E = eStart, *eLoopStop = eStart;
820 for (;;)
821 {
822
823 if (
E->Curr ==
E->Next->Curr && (Closed ||
E->Next != eStart))
824 {
825 if (E ==
E->Next)
break;
826 if (E == eStart) eStart =
E->Next;
829 continue;
830 }
831 if (
E->Prev ==
E->Next)
832 break;
833 else if (Closed &&
837 {
838
839
840
841
842 if (E == eStart) eStart =
E->Next;
846 continue;
847 }
849 if ((E == eLoopStop) || (!Closed &&
E->Next == eStart))
break;
850 }
851
852 if ((!Closed && (E ==
E->Next)) || (Closed && (
E->Prev ==
E->Next)))
853 {
854 return false;
855 }
856
857 if (!Closed)
858 {
860 eStart->Prev->OutIdx =
Skip;
861 }
862
863
864
865 bool IsFlat = true;
867 do
868 {
871 if (IsFlat &&
E->Curr.y() != eStart->Curr.y()) IsFlat =
false;
872 }
873 while (E != eStart);
874
875
876
877
878
879 if (IsFlat)
880 {
881 if (Closed)
882 {
883 return false;
884 }
885 E->Prev->OutIdx =
Skip;
886 LocalMinimum locMin;
887 locMin.Y =
E->Bot.y();
888 locMin.LeftBound = 0;
889 locMin.RightBound =
E;
890 locMin.RightBound->Side =
esRight;
891 locMin.RightBound->WindDelta = 0;
892 for (;;)
893 {
895 if (
E->Next->OutIdx ==
Skip)
break;
896 E->NextInLML =
E->Next;
898 }
900 return true;
901 }
902
903 bool leftBoundIsForward;
904 TEdge* EMin = 0;
905
906
907
908 if (
E->Prev->Bot ==
E->Prev->Top)
E =
E->Next;
909
910
911
912 for (;;)
913 {
915 if (E == EMin) break;
916 else if (!EMin) EMin =
E;
917
918
919
920 LocalMinimum locMin;
921 locMin.Y =
E->Bot.y();
922 if (
E->Dx <
E->Prev->Dx)
923 {
924 locMin.LeftBound =
E->Prev;
925 locMin.RightBound =
E;
926 leftBoundIsForward = false;
927 } else
928 {
929 locMin.LeftBound =
E;
930 locMin.RightBound =
E->Prev;
931 leftBoundIsForward = true;
932 }
933 locMin.LeftBound->Side =
esLeft;
934 locMin.RightBound->Side =
esRight;
935
936 if (!Closed) locMin.LeftBound->WindDelta = 0;
937 else if (locMin.LeftBound->Next == locMin.RightBound)
938 locMin.LeftBound->WindDelta = -1;
939 else locMin.LeftBound->WindDelta = 1;
940 locMin.RightBound->WindDelta = -locMin.LeftBound->WindDelta;
941
944
945 TEdge* E2 =
ProcessBound(locMin.RightBound, !leftBoundIsForward);
947
948 if (locMin.LeftBound->OutIdx ==
Skip)
949 locMin.LeftBound = 0;
950 else if (locMin.RightBound->OutIdx ==
Skip)
951 locMin.RightBound = 0;
953 if (!leftBoundIsForward)
E = E2;
954 }
955 return true;
956}
TEdge * ProcessBound(TEdge *E, bool IsClockwise)
Definition clipper.cpp:637
bool m_PreserveCollinear
Definition clipper.hpp:413
std::vector< LocalMinimum, Allocator< LocalMinimum > > m_MinimaList
Definition clipper.hpp:399
@ esLeft
Definition clipper.hpp:226
@ esRight
Definition clipper.hpp:226
void InitEdge(TEdge *e, TEdge *eNext, TEdge *ePrev, const IntPoint &Pt)
Definition clipper.cpp:425
bool Pt2IsBetweenPt1AndPt3(const IntPoint &pt1, const IntPoint &pt2, const IntPoint &pt3)
Definition clipper.cpp:567
void ReverseHorizontal(TEdge &e)
Definition clipper.cpp:469
static void RangeTest(const IntPoint &pt)
Definition clipper.cpp:591
bool SlopesEqual(const cInt dx1, const cInt dy1, const cInt dx2, const cInt dy2, bool)
Definition clipper.cpp:296
@ ptClip
Definition clipper.hpp:76
TEdge * RemoveEdge(TEdge *e)
Definition clipper.cpp:458
TEdge * FindNextLocMin(TEdge *E)
Definition clipper.cpp:619
static int const Skip
Definition clipper.cpp:70
void InitEdge2(TEdge &e, PolyType Pt)
Definition clipper.cpp:435
@ E
Definition libslic3r.h:101