Path.Area: minor optimization

This commit is contained in:
Zheng, Lei
2018-11-06 17:14:12 +08:00
committed by Yorik van Havre
parent a345669b38
commit f2ddb64fa1
4 changed files with 14 additions and 8 deletions

View File

@@ -448,7 +448,7 @@ void Area::addWire(CArea &area, const TopoDS_Wire& wire,
AREA_WARN("ccurve not closed");
ccurve.append(ccurve.m_vertices.front());
}
area.append(ccurve);
area.move(std::move(ccurve));
}
}

View File

@@ -47,6 +47,11 @@ void CArea::append(const CCurve& curve)
m_curves.push_back(curve);
}
void CArea::move(CCurve&& curve)
{
m_curves.push_back(std::move(curve));
}
void CArea::FitArcs(){
for(std::list<CCurve>::iterator It = m_curves.begin(); It != m_curves.end(); It++)
{

View File

@@ -59,6 +59,7 @@ public:
static double m_clipper_scale;
void append(const CCurve& curve);
void move(CCurve&& curve);
void Subtract(const CArea& a2);
void Intersect(const CArea& a2);
void Union(const CArea& a2);

View File

@@ -269,9 +269,9 @@ void CCurve::FitArcs(bool retry)
if(arc_added)
{
m_vertices.clear();
for(std::list<CVertex>::iterator It = new_vertices.begin(); It != new_vertices.end(); It++)m_vertices.push_back(*It);
for(std::list<const CVertex*>::iterator It = might_be_an_arc.begin(); It != might_be_an_arc.end(); It++)m_vertices.push_back(*(*It));
for(auto *v : might_be_an_arc)
new_vertices.push_back(*v);
m_vertices.swap(new_vertices);
}
}
@@ -466,7 +466,7 @@ void CCurve::Reverse()
prev_v = &v;
}
m_vertices = new_vertices;
m_vertices.swap(new_vertices);
}
double CCurve::GetArea()const
@@ -556,7 +556,7 @@ void CCurve::ChangeStart(const Point &p) {
if(started)
{
*this = new_curve;
m_vertices.swap(new_curve.m_vertices);
}
}
@@ -656,7 +656,7 @@ void CCurve::RemoveTinySpans() {
new_curve.m_vertices.push_back(vertex);
}
}
*this = new_curve;
m_vertices.swap(new_curve.m_vertices);
}
void CCurve::ChangeEnd(const Point &p) {
@@ -691,7 +691,7 @@ void CCurve::ChangeEnd(const Point &p) {
prev_p = &(vertex.m_p);
}
*this = new_curve;
m_vertices.swap(new_curve.m_vertices);
}
Point CCurve::NearestPoint(const Span& p, double *d)const