MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / wn_PnPoly

Method wn_PnPoly

annotation/AnnotationToMask.cpp:139–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139int AnnotationToMask::wn_PnPoly(const Point& P, const std::vector<Point>& V) const {
140 int wn = 0; // the winding number counter
141
142 // loop through all edges of the polygon
143 for (int i = 0; i<V.size() - 1; i++) { // edge from V[i] to V[i+1]
144 if (V[i].getY() <= P.getY()) { // start y <= P.y
145 if (V[i + 1].getY() > P.getY()) // an upward crossing
146 if (isLeft(V[i], V[i + 1], P) > 0) // P left of edge
147 ++wn; // have a valid up intersect
148 }
149 else { // start y > P.y (no test needed)
150 if (V[i + 1].getY() <= P.getY()) // a downward crossing
151 if (isLeft(V[i], V[i + 1], P) < 0) // P right of edge
152 --wn; // have a valid down intersect
153 }
154 }
155 return wn;
156}

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected