Refactoring: prefix inc/dec operators for iterators
This commit is contained in:
parent
06913cc8b8
commit
f2c4a66e45
5 changed files with 30 additions and 30 deletions
|
@ -2594,14 +2594,14 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge)
|
||||||
if (dir == dLeftToRight)
|
if (dir == dLeftToRight)
|
||||||
{
|
{
|
||||||
maxIt = m_Maxima.begin();
|
maxIt = m_Maxima.begin();
|
||||||
while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.X) maxIt++;
|
while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.X) ++maxIt;
|
||||||
if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.X)
|
if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.X)
|
||||||
maxIt = m_Maxima.end();
|
maxIt = m_Maxima.end();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
maxRit = m_Maxima.rbegin();
|
maxRit = m_Maxima.rbegin();
|
||||||
while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.X) maxRit++;
|
while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.X) ++maxRit;
|
||||||
if (maxRit != m_Maxima.rend() && *maxRit <= eLastHorz->Top.X)
|
if (maxRit != m_Maxima.rend() && *maxRit <= eLastHorz->Top.X)
|
||||||
maxRit = m_Maxima.rend();
|
maxRit = m_Maxima.rend();
|
||||||
}
|
}
|
||||||
|
@ -2628,7 +2628,7 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge)
|
||||||
{
|
{
|
||||||
if (horzEdge->OutIdx >= 0 && !IsOpen)
|
if (horzEdge->OutIdx >= 0 && !IsOpen)
|
||||||
AddOutPt(horzEdge, IntPoint(*maxIt, horzEdge->Bot.Y));
|
AddOutPt(horzEdge, IntPoint(*maxIt, horzEdge->Bot.Y));
|
||||||
maxIt++;
|
++maxIt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2637,7 +2637,7 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge)
|
||||||
{
|
{
|
||||||
if (horzEdge->OutIdx >= 0 && !IsOpen)
|
if (horzEdge->OutIdx >= 0 && !IsOpen)
|
||||||
AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.Y));
|
AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.Y));
|
||||||
maxRit++;
|
++maxRit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -362,7 +362,7 @@ MotionPlannerGraph::shortest_path(size_t from, size_t to)
|
||||||
const std::vector<neighbor> &neighbors = this->adjacency_list[u];
|
const std::vector<neighbor> &neighbors = this->adjacency_list[u];
|
||||||
for (std::vector<neighbor>::const_iterator neighbor_iter = neighbors.begin();
|
for (std::vector<neighbor>::const_iterator neighbor_iter = neighbors.begin();
|
||||||
neighbor_iter != neighbors.end();
|
neighbor_iter != neighbors.end();
|
||||||
neighbor_iter++)
|
++neighbor_iter)
|
||||||
{
|
{
|
||||||
// neighbor node is v
|
// neighbor node is v
|
||||||
node_t v = neighbor_iter->target;
|
node_t v = neighbor_iter->target;
|
||||||
|
|
|
@ -119,7 +119,7 @@ Polyline::equally_spaced_points(double distance) const
|
||||||
double take = segment_length - (len - distance); // how much we take of this segment
|
double take = segment_length - (len - distance); // how much we take of this segment
|
||||||
Line segment(*(it-1), *it);
|
Line segment(*(it-1), *it);
|
||||||
points.push_back(segment.point_at(take));
|
points.push_back(segment.point_at(take));
|
||||||
it--;
|
--it;
|
||||||
len = -take;
|
len = -take;
|
||||||
}
|
}
|
||||||
return points;
|
return points;
|
||||||
|
|
|
@ -316,7 +316,7 @@ TriangleMesh::split() const
|
||||||
stl_allocate(&mesh->stl);
|
stl_allocate(&mesh->stl);
|
||||||
|
|
||||||
int first = 1;
|
int first = 1;
|
||||||
for (std::deque<int>::const_iterator facet = facets.begin(); facet != facets.end(); facet++) {
|
for (std::deque<int>::const_iterator facet = facets.begin(); facet != facets.end(); ++facet) {
|
||||||
mesh->stl.facet_start[facet - facets.begin()] = this->stl.facet_start[*facet];
|
mesh->stl.facet_start[facet - facets.begin()] = this->stl.facet_start[*facet];
|
||||||
stl_facet_stats(&mesh->stl, this->stl.facet_start[*facet], first);
|
stl_facet_stats(&mesh->stl, this->stl.facet_start[*facet], first);
|
||||||
first = 0;
|
first = 0;
|
||||||
|
|
|
@ -181,14 +181,14 @@ int TPPLPartition::RemoveHoles(list<TPPLPoly> *inpolys, list<TPPLPoly> *outpolys
|
||||||
|
|
||||||
//check for trivial case (no holes)
|
//check for trivial case (no holes)
|
||||||
hasholes = false;
|
hasholes = false;
|
||||||
for(iter = inpolys->begin(); iter!=inpolys->end(); iter++) {
|
for(iter = inpolys->begin(); iter!=inpolys->end(); ++iter) {
|
||||||
if(iter->IsHole()) {
|
if(iter->IsHole()) {
|
||||||
hasholes = true;
|
hasholes = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!hasholes) {
|
if(!hasholes) {
|
||||||
for(iter = inpolys->begin(); iter!=inpolys->end(); iter++) {
|
for(iter = inpolys->begin(); iter!=inpolys->end(); ++iter) {
|
||||||
outpolys->push_back(*iter);
|
outpolys->push_back(*iter);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -199,7 +199,7 @@ int TPPLPartition::RemoveHoles(list<TPPLPoly> *inpolys, list<TPPLPoly> *outpolys
|
||||||
while(1) {
|
while(1) {
|
||||||
//find the hole point with the largest x
|
//find the hole point with the largest x
|
||||||
hasholes = false;
|
hasholes = false;
|
||||||
for(iter = polys.begin(); iter!=polys.end(); iter++) {
|
for(iter = polys.begin(); iter!=polys.end(); ++iter) {
|
||||||
if(!iter->IsHole()) continue;
|
if(!iter->IsHole()) continue;
|
||||||
|
|
||||||
if(!hasholes) {
|
if(!hasholes) {
|
||||||
|
@ -219,7 +219,7 @@ int TPPLPartition::RemoveHoles(list<TPPLPoly> *inpolys, list<TPPLPoly> *outpolys
|
||||||
holepoint = holeiter->GetPoint(holepointindex);
|
holepoint = holeiter->GetPoint(holepointindex);
|
||||||
|
|
||||||
pointfound = false;
|
pointfound = false;
|
||||||
for(iter = polys.begin(); iter!=polys.end(); iter++) {
|
for(iter = polys.begin(); iter!=polys.end(); ++iter) {
|
||||||
if(iter->IsHole()) continue;
|
if(iter->IsHole()) continue;
|
||||||
for(i=0; i < iter->GetNumPoints(); i++) {
|
for(i=0; i < iter->GetNumPoints(); i++) {
|
||||||
if(iter->GetPoint(i).x <= holepoint.x) continue;
|
if(iter->GetPoint(i).x <= holepoint.x) continue;
|
||||||
|
@ -235,7 +235,7 @@ int TPPLPartition::RemoveHoles(list<TPPLPoly> *inpolys, list<TPPLPoly> *outpolys
|
||||||
if(v2.x > v1.x) continue;
|
if(v2.x > v1.x) continue;
|
||||||
}
|
}
|
||||||
pointvisible = true;
|
pointvisible = true;
|
||||||
for(iter2 = polys.begin(); iter2!=polys.end(); iter2++) {
|
for(iter2 = polys.begin(); iter2!=polys.end(); ++iter2) {
|
||||||
if(iter2->IsHole()) continue;
|
if(iter2->IsHole()) continue;
|
||||||
for(i2=0; i2 < iter2->GetNumPoints(); i2++) {
|
for(i2=0; i2 < iter2->GetNumPoints(); i2++) {
|
||||||
linep1 = iter2->GetPoint(i2);
|
linep1 = iter2->GetPoint(i2);
|
||||||
|
@ -278,7 +278,7 @@ int TPPLPartition::RemoveHoles(list<TPPLPoly> *inpolys, list<TPPLPoly> *outpolys
|
||||||
polys.push_back(newpoly);
|
polys.push_back(newpoly);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(iter = polys.begin(); iter!=polys.end(); iter++) {
|
for(iter = polys.begin(); iter!=polys.end(); ++iter) {
|
||||||
outpolys->push_back(*iter);
|
outpolys->push_back(*iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ int TPPLPartition::Triangulate_EC(list<TPPLPoly> *inpolys, list<TPPLPoly> *trian
|
||||||
list<TPPLPoly>::iterator iter;
|
list<TPPLPoly>::iterator iter;
|
||||||
|
|
||||||
if(!RemoveHoles(inpolys,&outpolys)) return 0;
|
if(!RemoveHoles(inpolys,&outpolys)) return 0;
|
||||||
for(iter=outpolys.begin();iter!=outpolys.end();iter++) {
|
for(iter=outpolys.begin();iter!=outpolys.end();++iter) {
|
||||||
if(!Triangulate_EC(&(*iter),triangles)) return 0;
|
if(!Triangulate_EC(&(*iter),triangles)) return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -484,7 +484,7 @@ int TPPLPartition::ConvexPartition_HM(TPPLPoly *poly, list<TPPLPoly> *parts) {
|
||||||
|
|
||||||
if(!Triangulate_EC(poly,&triangles)) return 0;
|
if(!Triangulate_EC(poly,&triangles)) return 0;
|
||||||
|
|
||||||
for(iter1 = triangles.begin(); iter1 != triangles.end(); iter1++) {
|
for(iter1 = triangles.begin(); iter1 != triangles.end(); ++iter1) {
|
||||||
poly1 = &(*iter1);
|
poly1 = &(*iter1);
|
||||||
for(i11=0;i11<poly1->GetNumPoints();i11++) {
|
for(i11=0;i11<poly1->GetNumPoints();i11++) {
|
||||||
d1 = poly1->GetPoint(i11);
|
d1 = poly1->GetPoint(i11);
|
||||||
|
@ -492,7 +492,7 @@ int TPPLPartition::ConvexPartition_HM(TPPLPoly *poly, list<TPPLPoly> *parts) {
|
||||||
d2 = poly1->GetPoint(i12);
|
d2 = poly1->GetPoint(i12);
|
||||||
|
|
||||||
isdiagonal = false;
|
isdiagonal = false;
|
||||||
for(iter2 = iter1; iter2 != triangles.end(); iter2++) {
|
for(iter2 = iter1; iter2 != triangles.end(); ++iter2) {
|
||||||
if(iter1 == iter2) continue;
|
if(iter1 == iter2) continue;
|
||||||
poly2 = &(*iter2);
|
poly2 = &(*iter2);
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ int TPPLPartition::ConvexPartition_HM(TPPLPoly *poly, list<TPPLPoly> *parts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(iter1 = triangles.begin(); iter1 != triangles.end(); iter1++) {
|
for(iter1 = triangles.begin(); iter1 != triangles.end(); ++iter1) {
|
||||||
parts->push_back(*iter1);
|
parts->push_back(*iter1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ int TPPLPartition::ConvexPartition_HM(list<TPPLPoly> *inpolys, list<TPPLPoly> *p
|
||||||
list<TPPLPoly>::iterator iter;
|
list<TPPLPoly>::iterator iter;
|
||||||
|
|
||||||
if(!RemoveHoles(inpolys,&outpolys)) return 0;
|
if(!RemoveHoles(inpolys,&outpolys)) return 0;
|
||||||
for(iter=outpolys.begin();iter!=outpolys.end();iter++) {
|
for(iter=outpolys.begin();iter!=outpolys.end();++iter) {
|
||||||
if(!ConvexPartition_HM(&(*iter),parts)) return 0;
|
if(!ConvexPartition_HM(&(*iter),parts)) return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -740,7 +740,7 @@ void TPPLPartition::TypeA(long i, long j, long k, PartitionVertex *vertices, DPS
|
||||||
iter = pairs->end();
|
iter = pairs->end();
|
||||||
lastiter = pairs->end();
|
lastiter = pairs->end();
|
||||||
while(iter!=pairs->begin()) {
|
while(iter!=pairs->begin()) {
|
||||||
iter--;
|
--iter;
|
||||||
if(!IsReflex(vertices[iter->index2].p,vertices[j].p,vertices[k].p)) lastiter = iter;
|
if(!IsReflex(vertices[iter->index2].p,vertices[j].p,vertices[k].p)) lastiter = iter;
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
@ -776,7 +776,7 @@ void TPPLPartition::TypeB(long i, long j, long k, PartitionVertex *vertices, DPS
|
||||||
while(iter!=pairs->end()) {
|
while(iter!=pairs->end()) {
|
||||||
if(!IsReflex(vertices[i].p,vertices[j].p,vertices[iter->index1].p)) {
|
if(!IsReflex(vertices[i].p,vertices[j].p,vertices[iter->index1].p)) {
|
||||||
lastiter = iter;
|
lastiter = iter;
|
||||||
iter++;
|
++iter;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
@ -917,7 +917,7 @@ int TPPLPartition::ConvexPartition_OPT(TPPLPoly *poly, list<TPPLPoly> *parts) {
|
||||||
}
|
}
|
||||||
if(!vertices[diagonal.index1].isConvex) {
|
if(!vertices[diagonal.index1].isConvex) {
|
||||||
iter = pairs->end();
|
iter = pairs->end();
|
||||||
iter--;
|
--iter;
|
||||||
j = iter->index2;
|
j = iter->index2;
|
||||||
newdiagonal.index1 = j;
|
newdiagonal.index1 = j;
|
||||||
newdiagonal.index2 = diagonal.index2;
|
newdiagonal.index2 = diagonal.index2;
|
||||||
|
@ -931,7 +931,7 @@ int TPPLPartition::ConvexPartition_OPT(TPPLPoly *poly, list<TPPLPoly> *parts) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
iter2 = pairs2->end();
|
iter2 = pairs2->end();
|
||||||
iter2--;
|
--iter2;
|
||||||
if(iter->index1 != iter2->index1) pairs2->pop_back();
|
if(iter->index1 != iter2->index1) pairs2->pop_back();
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
@ -1001,7 +1001,7 @@ int TPPLPartition::ConvexPartition_OPT(TPPLPoly *poly, list<TPPLPoly> *parts) {
|
||||||
pairs = &(dpstates[diagonal.index1][diagonal.index2].pairs);
|
pairs = &(dpstates[diagonal.index1][diagonal.index2].pairs);
|
||||||
if(!vertices[diagonal.index1].isConvex) {
|
if(!vertices[diagonal.index1].isConvex) {
|
||||||
iter = pairs->end();
|
iter = pairs->end();
|
||||||
iter--;
|
--iter;
|
||||||
j = iter->index2;
|
j = iter->index2;
|
||||||
if(iter->index1 != iter->index2) ijreal = false;
|
if(iter->index1 != iter->index2) ijreal = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1032,7 +1032,7 @@ int TPPLPartition::ConvexPartition_OPT(TPPLPoly *poly, list<TPPLPoly> *parts) {
|
||||||
indices.sort();
|
indices.sort();
|
||||||
newpoly.Init((long)indices.size());
|
newpoly.Init((long)indices.size());
|
||||||
k=0;
|
k=0;
|
||||||
for(iiter = indices.begin();iiter!=indices.end();iiter++) {
|
for(iiter = indices.begin();iiter!=indices.end(); ++iiter) {
|
||||||
newpoly[k] = vertices[*iiter].p;
|
newpoly[k] = vertices[*iiter].p;
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
@ -1064,7 +1064,7 @@ int TPPLPartition::MonotonePartition(list<TPPLPoly> *inpolys, list<TPPLPoly> *mo
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
numvertices = 0;
|
numvertices = 0;
|
||||||
for(iter = inpolys->begin(); iter != inpolys->end(); iter++) {
|
for(iter = inpolys->begin(); iter != inpolys->end(); ++iter) {
|
||||||
numvertices += iter->GetNumPoints();
|
numvertices += iter->GetNumPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1073,7 +1073,7 @@ int TPPLPartition::MonotonePartition(list<TPPLPoly> *inpolys, list<TPPLPoly> *mo
|
||||||
newnumvertices = numvertices;
|
newnumvertices = numvertices;
|
||||||
|
|
||||||
polystartindex = 0;
|
polystartindex = 0;
|
||||||
for(iter = inpolys->begin(); iter != inpolys->end(); iter++) {
|
for(iter = inpolys->begin(); iter != inpolys->end(); ++iter) {
|
||||||
poly = &(*iter);
|
poly = &(*iter);
|
||||||
polyendindex = polystartindex + poly->GetNumPoints()-1;
|
polyendindex = polystartindex + poly->GetNumPoints()-1;
|
||||||
for(i=0;i<poly->GetNumPoints();i++) {
|
for(i=0;i<poly->GetNumPoints();i++) {
|
||||||
|
@ -1174,7 +1174,7 @@ int TPPLPartition::MonotonePartition(list<TPPLPoly> *inpolys, list<TPPLPoly> *mo
|
||||||
error = true;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
edgeIter--;
|
--edgeIter;
|
||||||
//Insert the diagonal connecting vi to helper(ej) in D.
|
//Insert the diagonal connecting vi to helper(ej) in D.
|
||||||
AddDiagonal(vertices,&newnumvertices,vindex,helpers[edgeIter->index]);
|
AddDiagonal(vertices,&newnumvertices,vindex,helpers[edgeIter->index]);
|
||||||
vertextypes[newnumvertices-2] = vertextypes[vindex];
|
vertextypes[newnumvertices-2] = vertextypes[vindex];
|
||||||
|
@ -1220,7 +1220,7 @@ int TPPLPartition::MonotonePartition(list<TPPLPoly> *inpolys, list<TPPLPoly> *mo
|
||||||
error = true;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
edgeIter--;
|
--edgeIter;
|
||||||
//if helper(ej) is a merge vertex
|
//if helper(ej) is a merge vertex
|
||||||
if(vertextypes[helpers[edgeIter->index]]==TPPL_VERTEXTYPE_MERGE) {
|
if(vertextypes[helpers[edgeIter->index]]==TPPL_VERTEXTYPE_MERGE) {
|
||||||
//Insert the diagonal connecting vi to helper(e j) in D.
|
//Insert the diagonal connecting vi to helper(e j) in D.
|
||||||
|
@ -1270,7 +1270,7 @@ int TPPLPartition::MonotonePartition(list<TPPLPoly> *inpolys, list<TPPLPoly> *mo
|
||||||
error = true;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
edgeIter--;
|
--edgeIter;
|
||||||
//if helper(ej) is a merge vertex
|
//if helper(ej) is a merge vertex
|
||||||
if(vertextypes[helpers[edgeIter->index]]==TPPL_VERTEXTYPE_MERGE) {
|
if(vertextypes[helpers[edgeIter->index]]==TPPL_VERTEXTYPE_MERGE) {
|
||||||
//Insert the diagonal connecting vi to helper(e j) in D.
|
//Insert the diagonal connecting vi to helper(e j) in D.
|
||||||
|
@ -1547,7 +1547,7 @@ int TPPLPartition::Triangulate_MONO(list<TPPLPoly> *inpolys, list<TPPLPoly> *tri
|
||||||
list<TPPLPoly>::iterator iter;
|
list<TPPLPoly>::iterator iter;
|
||||||
|
|
||||||
if(!MonotonePartition(inpolys,&monotone)) return 0;
|
if(!MonotonePartition(inpolys,&monotone)) return 0;
|
||||||
for(iter = monotone.begin(); iter!=monotone.end();iter++) {
|
for(iter = monotone.begin(); iter!=monotone.end(); ++iter) {
|
||||||
if(!TriangulateMonotone(&(*iter),triangles)) return 0;
|
if(!TriangulateMonotone(&(*iter),triangles)) return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue