Normalize line endings and whitespace

This commit is contained in:
OpenCV Buildbot
2012-10-17 11:12:04 +04:00
committed by Andrey Kamaev
parent 0442bca235
commit 81f826db2b
1511 changed files with 258678 additions and 258624 deletions

View File

@@ -42,7 +42,7 @@
namespace cv
{
int Subdiv2D::nextEdge(int edge) const
{
CV_DbgAssert((size_t)(edge >> 2) < qedges.size());
@@ -114,7 +114,7 @@ Subdiv2D::Subdiv2D(Rect rect)
freeQEdge = 0;
freePoint = 0;
recentEdge = 0;
initDelaunay(rect);
}
@@ -132,7 +132,7 @@ Subdiv2D::QuadEdge::QuadEdge(int edgeidx)
next[1] = edgeidx+3;
next[2] = edgeidx+2;
next[3] = edgeidx+1;
pt[0] = pt[1] = pt[2] = pt[3] = 0;
}
@@ -187,10 +187,10 @@ void Subdiv2D::setEdgePoints(int edge, int orgPt, int dstPt)
int Subdiv2D::connectEdges( int edgeA, int edgeB )
{
int edge = newEdge();
splice(edge, getEdge(edgeA, NEXT_AROUND_LEFT));
splice(symEdge(edge), edgeB);
setEdgePoints(edge, edgeDst(edgeA), edgeOrg(edgeB));
return edge;
}
@@ -200,12 +200,12 @@ void Subdiv2D::swapEdges( int edge )
int sedge = symEdge(edge);
int a = getEdge(edge, PREV_AROUND_ORG);
int b = getEdge(sedge, PREV_AROUND_ORG);
splice(edge, a);
splice(sedge, b);
setEdgePoints(edge, edgeDst(a), edgeDst(b));
splice(edge, getEdge(a, NEXT_AROUND_LEFT));
splice(sedge, getEdge(b, NEXT_AROUND_LEFT));
}
@@ -213,15 +213,15 @@ void Subdiv2D::swapEdges( int edge )
static double triangleArea( Point2f a, Point2f b, Point2f c )
{
return ((double)b.x - a.x) * ((double)c.y - a.y) - ((double)b.y - a.y) * ((double)c.x - a.x);
}
}
int Subdiv2D::isRightOf(Point2f pt, int edge) const
{
Point2f org, dst;
edgeOrg(edge, &org);
edgeDst(edge, &dst);
double cw_area = triangleArea( pt, dst, org );
return (cw_area > 0) - (cw_area < 0);
}
@@ -244,7 +244,7 @@ void Subdiv2D::deleteEdge(int edge)
splice( edge, getEdge(edge, PREV_AROUND_ORG) );
int sedge = symEdge(edge);
splice(sedge, getEdge(sedge, PREV_AROUND_ORG) );
edge >>= 2;
qedges[edge].next[0] = 0;
qedges[edge].next[1] = freeQEdge;
@@ -261,7 +261,7 @@ int Subdiv2D::newPoint(Point2f pt, bool isvirtual, int firstEdge)
int vidx = freePoint;
freePoint = vtx[vidx].firstEdge;
vtx[vidx] = Vertex(pt, isvirtual, firstEdge);
return vidx;
}
@@ -276,35 +276,35 @@ void Subdiv2D::deletePoint(int vidx)
int Subdiv2D::locate(Point2f pt, int& _edge, int& _vertex)
{
int vertex = 0;
int i, maxEdges = (int)(qedges.size() * 4);
if( qedges.size() < (size_t)4 )
CV_Error( CV_StsError, "Subdivision is empty" );
if( pt.x < topLeft.x || pt.y < topLeft.y || pt.x >= bottomRight.x || pt.y >= bottomRight.y )
CV_Error( CV_StsOutOfRange, "" );
int edge = recentEdge;
CV_Assert(edge > 0);
int location = PTLOC_ERROR;
int right_of_curr = isRightOf(pt, edge);
if( right_of_curr > 0 )
{
edge = symEdge(edge);
right_of_curr = -right_of_curr;
}
for( i = 0; i < maxEdges; i++ )
{
int onext_edge = nextEdge( edge );
int dprev_edge = getEdge( edge, PREV_AROUND_DST );
int right_of_onext = isRightOf( pt, onext_edge );
int right_of_dprev = isRightOf( pt, dprev_edge );
if( right_of_dprev > 0 )
{
if( right_of_onext > 0 || (right_of_onext == 0 && right_of_curr == 0) )
@@ -345,22 +345,22 @@ int Subdiv2D::locate(Point2f pt, int& _edge, int& _vertex)
}
}
}
recentEdge = edge;
if( location == PTLOC_INSIDE )
{
Point2f org_pt, dst_pt;
edgeOrg(edge, &org_pt);
edgeDst(edge, &dst_pt);
double t1 = fabs( pt.x - org_pt.x );
t1 += fabs( pt.y - org_pt.y );
double t2 = fabs( pt.x - dst_pt.x );
t2 += fabs( pt.y - dst_pt.y );
double t3 = fabs( org_pt.x - dst_pt.x );
t3 += fabs( org_pt.y - dst_pt.y );
if( t1 < FLT_EPSILON )
{
location = PTLOC_VERTEX;
@@ -380,16 +380,16 @@ int Subdiv2D::locate(Point2f pt, int& _edge, int& _vertex)
vertex = 0;
}
}
if( location == PTLOC_ERROR )
{
edge = 0;
vertex = 0;
}
_edge = edge;
_vertex = vertex;
return location;
}
@@ -402,7 +402,7 @@ isPtInCircle3( Point2f pt, Point2f a, Point2f b, Point2f c)
val -= ((double)b.x * b.x + (double)b.y * b.y) * triangleArea( a, c, pt );
val += ((double)c.x * c.x + (double)c.y * c.y) * triangleArea( a, b, pt );
val -= ((double)pt.x * pt.x + (double)pt.y * pt.y) * triangleArea( a, b, c );
return val > eps ? 1 : val < -eps ? -1 : 0;
}
@@ -411,16 +411,16 @@ int Subdiv2D::insert(Point2f pt)
{
int curr_point = 0, curr_edge = 0, deleted_edge = 0;
int location = locate( pt, curr_edge, curr_point );
if( location == PTLOC_ERROR )
CV_Error( CV_StsBadSize, "" );
if( location == PTLOC_OUTSIDE_RECT )
CV_Error( CV_StsOutOfRange, "" );
if( location == PTLOC_VERTEX )
return curr_point;
if( location == PTLOC_ON_EDGE )
{
deleted_edge = curr_edge;
@@ -431,36 +431,36 @@ int Subdiv2D::insert(Point2f pt)
;
else
CV_Error_(CV_StsError, ("Subdiv2D::locate returned invalid location = %d", location) );
assert( curr_edge != 0 );
validGeometry = false;
curr_point = newPoint(pt, false);
int base_edge = newEdge();
int first_point = edgeOrg(curr_edge);
setEdgePoints(base_edge, first_point, curr_point);
splice(base_edge, curr_edge);
do
{
base_edge = connectEdges( curr_edge, symEdge(base_edge) );
curr_edge = getEdge(base_edge, PREV_AROUND_ORG);
}
while( edgeDst(curr_edge) != first_point );
curr_edge = getEdge( base_edge, PREV_AROUND_ORG );
int i, max_edges = (int)(qedges.size()*4);
for( i = 0; i < max_edges; i++ )
{
int temp_dst = 0, curr_org = 0, curr_dst = 0;
int temp_edge = getEdge( curr_edge, PREV_AROUND_ORG );
temp_dst = edgeDst( temp_edge );
curr_org = edgeOrg( curr_edge );
curr_dst = edgeDst( curr_edge );
if( isRightOf( vtx[temp_dst].pt, curr_edge ) > 0 &&
isPtInCircle3( vtx[curr_org].pt, vtx[temp_dst].pt,
vtx[curr_dst].pt, vtx[curr_point].pt ) < 0 )
@@ -473,7 +473,7 @@ int Subdiv2D::insert(Point2f pt)
else
curr_edge = getEdge( nextEdge( curr_edge ), PREV_AROUND_LEFT );
}
return curr_point;
}
@@ -488,42 +488,42 @@ void Subdiv2D::initDelaunay( Rect rect )
float big_coord = 3.f * MAX( rect.width, rect.height );
float rx = (float)rect.x;
float ry = (float)rect.y;
vtx.clear();
qedges.clear();
recentEdge = 0;
validGeometry = false;
topLeft = Point2f( rx, ry );
bottomRight = Point2f( rx + rect.width, ry + rect.height );
Point2f ppA( rx + big_coord, ry );
Point2f ppB( rx, ry + big_coord );
Point2f ppC( rx - big_coord, ry - big_coord );
vtx.push_back(Vertex());
qedges.push_back(QuadEdge());
freeQEdge = 0;
freePoint = 0;
int pA = newPoint(ppA, false);
int pB = newPoint(ppB, false);
int pC = newPoint(ppC, false);
int edge_AB = newEdge();
int edge_BC = newEdge();
int edge_CA = newEdge();
setEdgePoints( edge_AB, pA, pB );
setEdgePoints( edge_BC, pB, pC );
setEdgePoints( edge_CA, pC, pA );
splice( edge_AB, symEdge( edge_CA ));
splice( edge_BC, symEdge( edge_AB ));
splice( edge_CA, symEdge( edge_BC ));
recentEdge = edge_AB;
}
@@ -531,17 +531,17 @@ void Subdiv2D::initDelaunay( Rect rect )
void Subdiv2D::clearVoronoi()
{
size_t i, total = qedges.size();
for( i = 0; i < total; i++ )
qedges[i].pt[1] = qedges[i].pt[3] = 0;
total = vtx.size();
for( i = 0; i < total; i++ )
{
if( vtx[i].isvirtual() )
deletePoint((int)i);
}
validGeometry = false;
}
@@ -551,20 +551,20 @@ static Point2f computeVoronoiPoint(Point2f org0, Point2f dst0, Point2f org1, Poi
double a0 = dst0.x - org0.x;
double b0 = dst0.y - org0.y;
double c0 = -0.5*(a0 * (dst0.x + org0.x) + b0 * (dst0.y + org0.y));
double a1 = dst1.x - org1.x;
double b1 = dst1.y - org1.y;
double c1 = -0.5*(a1 * (dst1.x + org1.x) + b1 * (dst1.y + org1.y));
double det = a0 * b1 - a1 * b0;
if( det != 0 )
{
det = 1. / det;
return Point2f((float) ((b0 * c1 - b1 * c0) * det),
(float) ((a1 * c0 - a0 * c1) * det));
}
return Point2f(FLT_MAX, FLT_MAX);
}
@@ -574,33 +574,33 @@ void Subdiv2D::calcVoronoi()
// check if it is already calculated
if( validGeometry )
return;
clearVoronoi();
int i, total = (int)qedges.size();
// loop through all quad-edges, except for the first 3 (#1, #2, #3 - 0 is reserved for "NULL" pointer)
for( i = 4; i < total; i++ )
{
QuadEdge& quadedge = qedges[i];
if( quadedge.isfree() )
continue;
int edge0 = (int)(i*4);
Point2f org0, dst0, org1, dst1;
if( !quadedge.pt[3] )
{
int edge1 = getEdge( edge0, NEXT_AROUND_LEFT );
int edge2 = getEdge( edge1, NEXT_AROUND_LEFT );
edgeOrg(edge0, &org0);
edgeDst(edge0, &dst0);
edgeOrg(edge1, &org1);
edgeDst(edge1, &dst1);
Point2f virt_point = computeVoronoiPoint(org0, dst0, org1, dst1);
if( fabs( virt_point.x ) < FLT_MAX * 0.5 &&
fabs( virt_point.y ) < FLT_MAX * 0.5 )
{
@@ -608,28 +608,28 @@ void Subdiv2D::calcVoronoi()
qedges[edge2 >> 2].pt[3 - (edge2 & 2)] = newPoint(virt_point, true);
}
}
if( !quadedge.pt[1] )
{
int edge1 = getEdge( edge0, NEXT_AROUND_RIGHT );
int edge2 = getEdge( edge1, NEXT_AROUND_RIGHT );
edgeOrg(edge0, &org0);
edgeDst(edge0, &dst0);
edgeOrg(edge1, &org1);
edgeDst(edge1, &dst1);
Point2f virt_point = computeVoronoiPoint(org0, dst0, org1, dst1);
if( fabs( virt_point.x ) < FLT_MAX * 0.5 &&
fabs( virt_point.y ) < FLT_MAX * 0.5 )
{
quadedge.pt[1] = qedges[edge1 >> 2].pt[1 + (edge1 & 2)] =
quadedge.pt[1] = qedges[edge1 >> 2].pt[1 + (edge1 & 2)] =
qedges[edge2 >> 2].pt[1 + (edge2 & 2)] = newPoint(virt_point, true);
}
}
}
validGeometry = true;
}
@@ -646,70 +646,70 @@ int Subdiv2D::findNearest(Point2f pt, Point2f* nearestPt)
{
if( !validGeometry )
calcVoronoi();
int vertex = 0, edge = 0;
int loc = locate( pt, edge, vertex );
if( loc != PTLOC_ON_EDGE && loc != PTLOC_INSIDE )
return vertex;
vertex = 0;
Point2f start;
edgeOrg(edge, &start);
Point2f diff = pt - start;
edge = rotateEdge(edge, 1);
int i, total = (int)vtx.size();
for( i = 0; i < total; i++ )
{
Point2f t;
for(;;)
{
CV_Assert( edgeDst(edge, &t) > 0 );
if( isRightOf2( t, start, diff ) >= 0 )
break;
edge = getEdge( edge, NEXT_AROUND_LEFT );
}
for(;;)
{
CV_Assert( edgeOrg( edge, &t ) > 0 );
if( isRightOf2( t, start, diff ) < 0 )
break;
edge = getEdge( edge, PREV_AROUND_LEFT );
}
Point2f tempDiff;
edgeDst(edge, &tempDiff);
edgeOrg(edge, &t);
tempDiff -= t;
if( isRightOf2( pt, t, tempDiff ) >= 0 )
{
vertex = edgeOrg(rotateEdge( edge, 3 ));
break;
}
edge = symEdge( edge );
}
if( nearestPt && vertex > 0 )
*nearestPt = vtx[vertex].pt;
return vertex;
}
void Subdiv2D::getEdgeList(vector<Vec4f>& edgeList) const
{
edgeList.clear();
for( size_t i = 4; i < qedges.size(); i++ )
{
if( qedges[i].isfree() )
@@ -728,7 +728,7 @@ void Subdiv2D::getTriangleList(vector<Vec6f>& triangleList) const
triangleList.clear();
int i, total = (int)(qedges.size()*4);
vector<bool> edgemask(total, false);
for( i = 4; i < total; i += 2 )
{
if( edgemask[i] )
@@ -754,23 +754,23 @@ void Subdiv2D::getVoronoiFacetList(const vector<int>& idx,
calcVoronoi();
facetList.clear();
facetCenters.clear();
vector<Point2f> buf;
size_t i, total;
if( idx.empty() )
i = 4, total = vtx.size();
else
i = 0, total = idx.size();
for( ; i < total; i++ )
{
int k = idx.empty() ? (int)i : idx[i];
if( vtx[k].isfree() || vtx[k].isvirtual() )
continue;
int edge = rotateEdge(vtx[k].firstEdge, 1), t = edge;
int edge = rotateEdge(vtx[k].firstEdge, 1), t = edge;
// gather points
buf.clear();
do
@@ -779,7 +779,7 @@ void Subdiv2D::getVoronoiFacetList(const vector<int>& idx,
t = getEdge( t, NEXT_AROUND_LEFT );
}
while( t != edge );
facetList.push_back(buf);
facetCenters.push_back(vtx[k].pt);
}
@@ -789,14 +789,14 @@ void Subdiv2D::getVoronoiFacetList(const vector<int>& idx,
void Subdiv2D::checkSubdiv() const
{
int i, j, total = (int)qedges.size();
for( i = 0; i < total; i++ )
{
const QuadEdge& qe = qedges[i];
if( qe.isfree() )
continue;
for( j = 0; j < 4; j++ )
{
int e = (int)(i*4 + j);
@@ -804,13 +804,13 @@ void Subdiv2D::checkSubdiv() const
int o_prev = getEdge(e, PREV_AROUND_ORG );
int d_prev = getEdge(e, PREV_AROUND_DST );
int d_next = getEdge(e, NEXT_AROUND_DST );
// check points
CV_Assert( edgeOrg(e) == edgeOrg(o_next));
CV_Assert( edgeOrg(e) == edgeOrg(o_prev));
CV_Assert( edgeDst(e) == edgeDst(d_next));
CV_Assert( edgeDst(e) == edgeDst(d_prev));
if( j % 2 == 0 )
{
CV_Assert( edgeDst(o_next) == edgeOrg(d_prev));
@@ -820,8 +820,8 @@ void Subdiv2D::checkSubdiv() const
}
}
}
}
}
}
/* End of file. */