MCPcopy Create free account
hub / github.com/creatale/node-dv / FillConvexPoly

Function FillConvexPoly

deps/opencv/modules/core/src/drawing.cpp:1079–1233  ·  view source on GitHub ↗

filling convex polygon. v - array of vertices, ntps - number of points */

Source from the content-addressed store, hash-verified

1077
1078/* filling convex polygon. v - array of vertices, ntps - number of points */
1079static void
1080FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int line_type, int shift )
1081{
1082 struct
1083 {
1084 int idx, di;
1085 int64 x, dx;
1086 int ye;
1087 }
1088 edge[2];
1089
1090 int delta = 1 << shift >> 1;
1091 int i, y, imin = 0, left = 0, right = 1;
1092 int edges = npts;
1093 int64 xmin, xmax, ymin, ymax;
1094 uchar* ptr = img.data;
1095 Size size = img.size();
1096 int pix_size = (int)img.elemSize();
1097 Point2l p0;
1098 int delta1, delta2;
1099
1100 if( line_type < CV_AA )
1101 delta1 = delta2 = XY_ONE >> 1;
1102 else
1103 delta1 = XY_ONE - 1, delta2 = 0;
1104
1105 p0 = v[npts - 1];
1106 p0.x <<= XY_SHIFT - shift;
1107 p0.y <<= XY_SHIFT - shift;
1108
1109 assert( 0 <= shift && shift <= XY_SHIFT );
1110 xmin = xmax = v[0].x;
1111 ymin = ymax = v[0].y;
1112
1113 for( i = 0; i < npts; i++ )
1114 {
1115 Point2l p = v[i];
1116 if( p.y < ymin )
1117 {
1118 ymin = p.y;
1119 imin = i;
1120 }
1121
1122 ymax = std::max( ymax, p.y );
1123 xmax = std::max( xmax, p.x );
1124 xmin = MIN( xmin, p.x );
1125
1126 p.x <<= XY_SHIFT - shift;
1127 p.y <<= XY_SHIFT - shift;
1128
1129 if( line_type <= 8 )
1130 {
1131 if( shift == 0 )
1132 {
1133 Point pt0, pt1;
1134 pt0.x = (int)(p0.x >> XY_SHIFT);
1135 pt0.y = (int)(p0.y >> XY_SHIFT);
1136 pt1.x = (int)(p.x >> XY_SHIFT);

Callers 4

EllipseExFunction · 0.85
ThickLineFunction · 0.85
rectangleFunction · 0.85
fillConvexPolyFunction · 0.85

Calls 6

Line2Function · 0.85
LineAAFunction · 0.85
maxFunction · 0.70
LineFunction · 0.70
sizeMethod · 0.45
elemSizeMethod · 0.45

Tested by

no test coverage detected