MCPcopy Create free account
hub / github.com/PaddlePaddle/PaddleOCR / AddPath

Method AddPath

deploy/android_demo/app/src/main/cpp/ocr_clipper.cpp:990–1168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

988//------------------------------------------------------------------------------
989
990bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed) {
991#ifdef use_lines
992 if (!Closed && PolyTyp == ptClip)
993 throw clipperException("AddPath: Open paths must be subject.");
994#else
995 if (!Closed)
996 throw clipperException("AddPath: Open paths have been disabled.");
997#endif
998
999 int highI = (int)pg.size() - 1;
1000 if (Closed)
1001 while (highI > 0 && (pg[highI] == pg[0]))
1002 --highI;
1003 while (highI > 0 && (pg[highI] == pg[highI - 1]))
1004 --highI;
1005 if ((Closed && highI < 2) || (!Closed && highI < 1))
1006 return false;
1007
1008 // create a new edge array ...
1009 TEdge *edges = new TEdge[highI + 1];
1010
1011 bool IsFlat = true;
1012 // 1. Basic (first) edge initialization ...
1013 try {
1014 edges[1].Curr = pg[1];
1015 RangeTest(pg[0], m_UseFullRange);
1016 RangeTest(pg[highI], m_UseFullRange);
1017 InitEdge(&edges[0], &edges[1], &edges[highI], pg[0]);
1018 InitEdge(&edges[highI], &edges[0], &edges[highI - 1], pg[highI]);
1019 for (int i = highI - 1; i >= 1; --i) {
1020 RangeTest(pg[i], m_UseFullRange);
1021 InitEdge(&edges[i], &edges[i + 1], &edges[i - 1], pg[i]);
1022 }
1023 } catch (...) {
1024 delete[] edges;
1025 throw; // range test fails
1026 }
1027 TEdge *eStart = &edges[0];
1028
1029 // 2. Remove duplicate vertices, and (when closed) collinear edges ...
1030 TEdge *E = eStart, *eLoopStop = eStart;
1031 for (;;) {
1032 // nb: allows matching start and end points when not Closed ...
1033 if (E->Curr == E->Next->Curr && (Closed || E->Next != eStart)) {
1034 if (E == E->Next)
1035 break;
1036 if (E == eStart)
1037 eStart = E->Next;
1038 E = RemoveEdge(E);
1039 eLoopStop = E;
1040 continue;
1041 }
1042 if (E->Prev == E->Next)
1043 break; // only two vertices
1044 else if (Closed &&
1045 SlopesEqual(E->Prev->Curr, E->Curr, E->Next->Curr,
1046 m_UseFullRange) &&
1047 (!m_PreserveCollinear ||

Callers 15

draw_border_mapMethod · 0.45
shrinkMethod · 0.45
__call__Method · 0.45
generate_kernelMethod · 0.45
unclipMethod · 0.45
UnclipFunction · 0.45
ExecuteMethod · 0.45
SimplifyPolygonFunction · 0.45
MinkowskiSumFunction · 0.45
unclipFunction · 0.45
UnclipMethod · 0.45
IoUMethod · 0.45

Calls 14

clipperExceptionClass · 0.70
RangeTestFunction · 0.70
InitEdgeFunction · 0.70
RemoveEdgeFunction · 0.70
SlopesEqualFunction · 0.70
Pt2IsBetweenPt1AndPt3Function · 0.70
InitEdge2Function · 0.70
ReverseHorizontalFunction · 0.70
FindNextLocMinFunction · 0.70
IntPointClass · 0.70
sizeMethod · 0.65
push_backMethod · 0.65

Tested by

no test coverage detected