Set stricter warning rules for gcc
This commit is contained in:
@@ -7,7 +7,7 @@ using namespace std;
|
||||
|
||||
static void help()
|
||||
{
|
||||
cout << "\nThis program demostrates iterative construction of\n"
|
||||
cout << "\nThis program demostrates iterative construction of\n"
|
||||
"delaunay triangulation and voronoi tesselation.\n"
|
||||
"It draws a random set of points in an image and then delaunay triangulates them.\n"
|
||||
"Usage: \n"
|
||||
@@ -27,7 +27,7 @@ static void draw_subdiv( Mat& img, Subdiv2D& subdiv, Scalar delaunay_color )
|
||||
vector<Vec6f> triangleList;
|
||||
subdiv.getTriangleList(triangleList);
|
||||
vector<Point> pt(3);
|
||||
|
||||
|
||||
for( size_t i = 0; i < triangleList.size(); i++ )
|
||||
{
|
||||
Vec6f t = triangleList[i];
|
||||
@@ -54,9 +54,9 @@ static void draw_subdiv( Mat& img, Subdiv2D& subdiv, Scalar delaunay_color )
|
||||
static void locate_point( Mat& img, Subdiv2D& subdiv, Point2f fp, Scalar active_color )
|
||||
{
|
||||
int e0=0, vertex=0;
|
||||
|
||||
|
||||
subdiv.locate(fp, e0, vertex);
|
||||
|
||||
|
||||
if( e0 > 0 )
|
||||
{
|
||||
int e = e0;
|
||||
@@ -65,37 +65,37 @@ static void locate_point( Mat& img, Subdiv2D& subdiv, Point2f fp, Scalar active_
|
||||
Point2f org, dst;
|
||||
if( subdiv.edgeOrg(e, &org) > 0 && subdiv.edgeDst(e, &dst) > 0 )
|
||||
line( img, org, dst, active_color, 3, CV_AA, 0 );
|
||||
|
||||
|
||||
e = subdiv.getEdge(e, Subdiv2D::NEXT_AROUND_LEFT);
|
||||
}
|
||||
while( e != e0 );
|
||||
}
|
||||
|
||||
|
||||
draw_subdiv_point( img, fp, active_color );
|
||||
}
|
||||
|
||||
|
||||
void paint_voronoi( Mat& img, Subdiv2D& subdiv )
|
||||
static void paint_voronoi( Mat& img, Subdiv2D& subdiv )
|
||||
{
|
||||
vector<vector<Point2f> > facets;
|
||||
vector<Point2f> centers;
|
||||
subdiv.getVoronoiFacetList(vector<int>(), facets, centers);
|
||||
|
||||
|
||||
vector<Point> ifacet;
|
||||
vector<vector<Point> > ifacets(1);
|
||||
|
||||
|
||||
for( size_t i = 0; i < facets.size(); i++ )
|
||||
{
|
||||
ifacet.resize(facets[i].size());
|
||||
for( size_t j = 0; j < facets[i].size(); j++ )
|
||||
ifacet[j] = facets[i][j];
|
||||
|
||||
|
||||
Scalar color;
|
||||
color[0] = rand() & 255;
|
||||
color[1] = rand() & 255;
|
||||
color[2] = rand() & 255;
|
||||
fillConvexPoly(img, ifacet, color, 8, 0);
|
||||
|
||||
|
||||
ifacets[0] = ifacet;
|
||||
polylines(img, ifacets, true, Scalar(), 1, CV_AA, 0);
|
||||
circle(img, centers[i], 3, Scalar(), -1, CV_AA, 0);
|
||||
@@ -106,43 +106,43 @@ void paint_voronoi( Mat& img, Subdiv2D& subdiv )
|
||||
int main( int, char** )
|
||||
{
|
||||
help();
|
||||
|
||||
|
||||
Scalar active_facet_color(0, 0, 255), delaunay_color(255,255,255);
|
||||
Rect rect(0, 0, 600, 600);
|
||||
|
||||
|
||||
Subdiv2D subdiv(rect);
|
||||
Mat img(rect.size(), CV_8UC3);
|
||||
|
||||
|
||||
img = Scalar::all(0);
|
||||
string win = "Delaunay Demo";
|
||||
imshow(win, img);
|
||||
|
||||
|
||||
for( int i = 0; i < 200; i++ )
|
||||
{
|
||||
Point2f fp( (float)(rand()%(rect.width-10)+5),
|
||||
(float)(rand()%(rect.height-10)+5));
|
||||
|
||||
|
||||
locate_point( img, subdiv, fp, active_facet_color );
|
||||
imshow( win, img );
|
||||
|
||||
|
||||
if( waitKey( 100 ) >= 0 )
|
||||
break;
|
||||
|
||||
|
||||
subdiv.insert(fp);
|
||||
|
||||
|
||||
img = Scalar::all(0);
|
||||
draw_subdiv( img, subdiv, delaunay_color );
|
||||
imshow( win, img );
|
||||
|
||||
|
||||
if( waitKey( 100 ) >= 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
img = Scalar::all(0);
|
||||
paint_voronoi( img, subdiv );
|
||||
imshow( win, img );
|
||||
|
||||
|
||||
waitKey(0);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user