use emplace_back instead of push_back where justified

This commit is contained in:
asapelkin
2019-10-25 00:57:12 +03:00
committed by wmayer
parent 079808b816
commit e951094af9
67 changed files with 239 additions and 241 deletions

View File

@@ -460,8 +460,8 @@ private:
float hy = y/2.0f;
std::vector<MeshCore::MeshGeomFacet> TriaList;
TriaList.push_back(MeshCore::MeshGeomFacet(Base::Vector3f(-hx, -hy, 0.0),Base::Vector3f(hx, hy, 0.0),Base::Vector3f(-hx, hy, 0.0)));
TriaList.push_back(MeshCore::MeshGeomFacet(Base::Vector3f(-hx, -hy, 0.0),Base::Vector3f(hx, -hy, 0.0),Base::Vector3f(hx, hy, 0.0)));
TriaList.emplace_back(Base::Vector3f(-hx, -hy, 0.0),Base::Vector3f(hx, hy, 0.0),Base::Vector3f(-hx, hy, 0.0));
TriaList.emplace_back(Base::Vector3f(-hx, -hy, 0.0),Base::Vector3f(hx, -hy, 0.0),Base::Vector3f(hx, hy, 0.0));
std::unique_ptr<MeshObject> mesh(new MeshObject);
mesh->addFacets(TriaList);

View File

@@ -498,7 +498,7 @@ void MeshAlgorithm::GetFacetBorders (const std::vector<unsigned long> &raulInd,
// thus doesn't invalidate the iterator itself, only the referenced object
if ((pEI == aclEdges.end()) || aclEdges.empty() || (ulLast == ulFirst)) {
// no further edge found or closed polyline, respectively
rclBorders.push_back(std::vector<unsigned long>(clBorder.begin(), clBorder.end()));
rclBorders.emplace_back(clBorder.begin(), clBorder.end());
clBorder.clear();
if (aclEdges.size() > 0) {
@@ -1455,7 +1455,7 @@ bool MeshAlgorithm::CutWithPlane (const Base::Vector3f &clBase, const Base::Vect
// Facet schneiden und Schnittstrecke ablegen
if (clF.IntersectWithPlane(clBase, clNormal, clE1, clE2) == true)
clTempPoly.push_back(std::pair<Base::Vector3f, Base::Vector3f>(clE1, clE2));
clTempPoly.emplace_back(clE1, clE2);
}
if(bConnectPolygons)
@@ -1574,7 +1574,7 @@ bool MeshAlgorithm::ConnectLines (std::list<std::pair<Base::Vector3f, Base::Vect
}
while (bFoundLine);
rclPolylines.push_back(std::vector<Base::Vector3f>(clPoly.begin(), clPoly.end()));
rclPolylines.emplace_back(clPoly.begin(), clPoly.end());
}
// remove all polylines with too few length

View File

@@ -373,7 +373,7 @@ bool MeshEvalTopology::Evaluate ()
else {
if (count > 2) {
// Edge that is shared by more than 2 facets
nonManifoldList.push_back(std::make_pair(p0, p1));
nonManifoldList.emplace_back(p0, p1);
nonManifoldFacets.push_back(facets);
}
@@ -681,7 +681,7 @@ void MeshEvalSelfIntersection::GetIntersections(const std::vector<std::pair<unsi
if (box1 && box2) {
int ret = cMF1->IntersectWithFacet(*cMF2, pt1, pt2);
if (ret == 2) {
intersection.push_back(std::make_pair(pt1, pt2));
intersection.emplace_back(pt1, pt2);
}
}
}
@@ -749,7 +749,7 @@ void MeshEvalSelfIntersection::GetIntersections(std::vector<std::pair<unsigned l
facet2 = *cMFI;
int ret = facet1.IntersectWithFacet(facet2, pt1, pt2);
if (ret == 2) {
intersection.push_back(std::make_pair (*it,*jt));
intersection.emplace_back (*it,*jt);
}
}
}

View File

@@ -378,7 +378,7 @@ bool MeshInput::LoadOBJ (std::istream &rstrIn)
}
else if (boost::regex_match(line.c_str(), what, rx_u)) {
if (!materialName.empty()) {
_materialNames.push_back(std::make_pair(materialName, countMaterialFacets));
_materialNames.emplace_back(materialName, countMaterialFacets);
}
materialName = Base::Tools::escapedUnicodeToUtf8(what[1].first);
countMaterialFacets = 0;
@@ -441,7 +441,7 @@ bool MeshInput::LoadOBJ (std::istream &rstrIn)
// Add the last added material name
if (!materialName.empty()) {
_materialNames.push_back(std::make_pair(materialName, countMaterialFacets));
_materialNames.emplace_back(materialName, countMaterialFacets);
}
// now get back the colors from the vertex property
@@ -679,7 +679,7 @@ bool MeshInput::LoadOFF (std::istream &rstrIn)
float fg = static_cast<float>(g)/255.0f;
float fb = static_cast<float>(b)/255.0f;
float fa = static_cast<float>(a)/255.0f;
_material->diffuseColor.push_back(App::Color(fr, fg, fb, fa));
_material->diffuseColor.emplace_back(fr, fg, fb, fa);
}
meshPoints.push_back(MeshPoint(Base::Vector3f(fX, fY, fZ)));
cntPoints++;
@@ -893,7 +893,7 @@ bool MeshInput::LoadPLY (std::istream &inp)
}
// store the property name and type
vertex_props.push_back(std::make_pair(name, number));
vertex_props.emplace_back(name, number);
}
else if (element == "face") {
std::string list, uchr;
@@ -1064,7 +1064,7 @@ bool MeshInput::LoadPLY (std::istream &inp)
float r = (prop_values["red"]) / 255.0f;
float g = (prop_values["green"]) / 255.0f;
float b = (prop_values["blue"]) / 255.0f;
_material->diffuseColor.push_back(App::Color(r, g, b));
_material->diffuseColor.emplace_back(r, g, b);
}
}
@@ -1146,7 +1146,7 @@ bool MeshInput::LoadPLY (std::istream &inp)
float r = (prop_values["red"]) / 255.0f;
float g = (prop_values["green"]) / 255.0f;
float b = (prop_values["blue"]) / 255.0f;
_material->diffuseColor.push_back(App::Color(r, g, b));
_material->diffuseColor.emplace_back(r, g, b);
}
}

View File

@@ -185,23 +185,23 @@ bool MeshProjection::projectLineOnMesh(const MeshFacetGrid& grid,
continue;
}
cutLine.push_back(std::pair<Base::Vector3f, Base::Vector3f>(e1, e2));
cutLine.emplace_back(e1, e2);
}
else {
if (*it == f1) { // start facet
if (((e2 - v1) * dir) > 0.0f)
cutLine.push_back(std::pair<Base::Vector3f, Base::Vector3f>(v1, e2));
cutLine.emplace_back(v1, e2);
else
cutLine.push_back(std::pair<Base::Vector3f, Base::Vector3f>(v1, e1));
cutLine.emplace_back(v1, e1);
//start = it - facets.begin();
}
if (*it == f2) { // end facet
if (((e2 - v2) * -dir) > 0.0f)
cutLine.push_back(std::pair<Base::Vector3f, Base::Vector3f>(v2, e2));
cutLine.emplace_back(v2, e2);
else
cutLine.push_back(std::pair<Base::Vector3f, Base::Vector3f>(v2, e1));
cutLine.emplace_back(v2, e1);
//end = it - facets.begin();
}

View File

@@ -425,7 +425,7 @@ void MeshTopoAlgorithm::AdjustEdgesToCurvatureDirection()
MeshPointIterator cPIt( _rclMesh );
aPnts.reserve(_rclMesh.CountPoints());
for ( cPIt.Init(); cPIt.More(); cPIt.Next() )
aPnts.push_back( Wm4::Vector3<float>( cPIt->x, cPIt->y, cPIt->z ) );
aPnts.emplace_back( cPIt->x, cPIt->y, cPIt->z );
// get all point connections
std::vector<int> aIdx;

View File

@@ -648,7 +648,7 @@ bool DelaunayTriangulator::Triangulate()
std::vector<Wm4::Vector2d> akVertex;
akVertex.reserve(_points.size());
for (std::vector<Base::Vector3f>::iterator it = _points.begin(); it != _points.end(); ++it) {
akVertex.push_back(Wm4::Vector2d(static_cast<double>(it->x), static_cast<double>(it->y)));
akVertex.emplace_back(static_cast<double>(it->x), static_cast<double>(it->y));
}
Wm4::Delaunay2d del(static_cast<int>(akVertex.size()), &(akVertex[0]), 0.001, false, Wm4::Query::QT_INT64);

View File

@@ -458,7 +458,7 @@ void MeshObject::swapKernel(MeshCore::MeshKernel& kernel,
if (prop < it->_ulProp) {
prop = it->_ulProp;
if (!segment.empty()) {
this->_segments.push_back(Segment(this,segment,true));
this->_segments.emplace_back(this,segment,true);
segment.clear();
}
}
@@ -468,7 +468,7 @@ void MeshObject::swapKernel(MeshCore::MeshKernel& kernel,
// if the whole mesh is a single object then don't mark as segment
if (!segment.empty() && (segment.size() < faces.size())) {
this->_segments.push_back(Segment(this,segment,true));
this->_segments.emplace_back(this,segment,true);
}
// apply the group names to the segments
@@ -1213,7 +1213,7 @@ void MeshObject::splitEdges()
if (!pF->IsFlag(MeshCore::MeshFacet::VISIT) && !rFace.IsFlag(MeshCore::MeshFacet::VISIT)) {
pF->SetFlag(MeshCore::MeshFacet::VISIT);
rFace.SetFlag(MeshCore::MeshFacet::VISIT);
adjacentFacet.push_back(std::make_pair(pF-rFacets.begin(), pF->_aulNeighbours[id]));
adjacentFacet.emplace_back(pF-rFacets.begin(), pF->_aulNeighbours[id]);
}
}
}
@@ -1368,7 +1368,7 @@ void MeshObject::removeSelfIntersections(const std::vector<unsigned long>& indic
for (it = indices.begin(); it != indices.end(); ) {
unsigned long id1 = *it; ++it;
unsigned long id2 = *it; ++it;
selfIntersections.push_back(std::make_pair(id1,id2));
selfIntersections.emplace_back(id1,id2);
}
if (!selfIntersections.empty()) {
@@ -1747,7 +1747,7 @@ void MeshObject::addSegment(const std::vector<unsigned long>& inds)
throw Base::IndexError("Index out of range");
}
this->_segments.push_back(Segment(this,inds,true));
this->_segments.emplace_back(this,inds,true);
}
const Segment& MeshObject::getSegment(unsigned long index) const
@@ -1810,7 +1810,7 @@ std::vector<Segment> MeshObject::getSegmentsOfType(MeshObject::GeometryType type
const std::vector<MeshCore::MeshSegment>& data = surf->GetSegments();
for (std::vector<MeshCore::MeshSegment>::const_iterator it = data.begin(); it != data.end(); ++it) {
segm.push_back(Segment(const_cast<MeshObject*>(this), *it, false));
segm.emplace_back(const_cast<MeshObject*>(this), *it, false);
}
}

View File

@@ -248,7 +248,7 @@ PyObject* MeshPy::write(PyObject *args, PyObject *kwds)
float r = (float)Py::Float(t.getItem(0));
float g = (float)Py::Float(t.getItem(1));
float b = (float)Py::Float(t.getItem(2));
mat.diffuseColor.push_back(App::Color(r,g,b));
mat.diffuseColor.emplace_back(r,g,b);
}
if (mat.diffuseColor.size() == getMeshObjectPtr()->countPoints())
@@ -288,7 +288,7 @@ PyObject* MeshPy::write(PyObject *args, PyObject *kwds)
float r = (float)Py::Float(t.getItem(0));
float g = (float)Py::Float(t.getItem(1));
float b = (float)Py::Float(t.getItem(2));
mat->diffuseColor.push_back(App::Color(r,g,b));
mat->diffuseColor.emplace_back(r,g,b);
}
if (mat->diffuseColor.size() == getMeshObjectPtr()->countPoints())
@@ -324,7 +324,7 @@ PyObject* MeshPy::writeInventor(PyObject *args)
std::vector<Base::Vector3f> coords;
coords.reserve(mesh->countPoints());
for (MeshObject::const_point_iterator it = mesh->points_begin(); it != mesh->points_end(); ++it)
coords.push_back(Base::Vector3f((float)it->x,(float)it->y,(float)it->z));
coords.emplace_back((float)it->x,(float)it->y,(float)it->z);
indices.reserve(4*faces.size());
for (MeshCore::MeshFacetArray::_TConstIterator it = faces.begin(); it != faces.end(); ++it) {
indices.push_back(it->_aulPoints[0]);
@@ -710,7 +710,7 @@ PyObject* MeshPy::addFacets(PyObject *args)
for (Py::List::iterator it = list_v.begin(); it != list_v.end(); ++it) {
if ((*it).isType(vType)) {
Base::Vector3d v = static_cast<Base::VectorPy*>((*it).ptr())->value();
vertices.push_back(Base::Vector3f((float)v.x,(float)v.y,(float)v.z));
vertices.emplace_back((float)v.x,(float)v.y,(float)v.z);
}
}

View File

@@ -1006,8 +1006,7 @@ void SoFCIndexedFaceSet::stopSelection(SoAction * action)
GLint index=0;
for (GLint ii=0;ii<hits && index<bufSize;ii++) {
GLint ct = (GLint)selectBuf[index];
hit.push_back(std::pair<double,unsigned int>
(selectBuf[index+1]/4294967295.0,selectBuf[index+3]));
hit.emplace_back(selectBuf[index+1]/4294967295.0,selectBuf[index+3]);
index = index+ct+3;
}

View File

@@ -1046,8 +1046,7 @@ void SoFCMeshObjectShape::stopSelection(SoAction * action, const Mesh::MeshObjec
GLuint index=0;
for (GLint ii=0;ii<hits && index<bufSize;ii++) {
GLint ct = (GLint)selectBuf[index];
hit.push_back(std::pair<double,unsigned int>
(selectBuf[index+1]/4294967295.0,selectBuf[index+3]));
hit.emplace_back(selectBuf[index+1]/4294967295.0,selectBuf[index+3]);
index = index+ct+3;
}

View File

@@ -709,7 +709,7 @@ void ViewProviderMesh::exportMesh(const char* filename, const char* fmt) const
mat.diffuseColor.reserve(numColors);
for (int i=0; i<numColors; i++) {
const SbColor& c = colors[i];
mat.diffuseColor.push_back(App::Color(c[0], c[1], c[2]));
mat.diffuseColor.emplace_back(c[0], c[1], c[2]);
}
Mesh::MeshObject mesh = static_cast<Mesh::Feature*>(getObject())->Mesh.getValue();
@@ -801,12 +801,12 @@ bool ViewProviderMesh::createToolMesh(const std::vector<SbVec2f>& rclPoly, const
if (it+1 < rclPoly.end()) {
pt1.getValue(fX, fY, fZ);
top.push_back( Base::Vector3f(fX, fY, fZ) );
top.emplace_back(fX, fY, fZ );
pt2.getValue(fX, fY, fZ);
bottom.push_back( Base::Vector3f(fX, fY, fZ) );
bottom.emplace_back(fX, fY, fZ );
// polygon we need to triangulate (in x,y-plane)
it->getValue(fX, fY);
polygon.push_back( Base::Vector3f(fX, fY, 0.0f) );
polygon.emplace_back(fX, fY, 0.0f );
}
}

View File

@@ -646,7 +646,7 @@ void ViewProviderMeshSelfIntersections::showDefects(const std::vector<unsigned l
for (it = indices.begin(); it != indices.end(); ) {
unsigned long id1 = *it; ++it;
unsigned long id2 = *it; ++it;
intersection.push_back(std::make_pair(id1,id2));
intersection.emplace_back(id1,id2);
}
std::vector<std::pair<Base::Vector3f, Base::Vector3f> > lines;

View File

@@ -141,7 +141,7 @@ void ViewProviderMeshTransformDemolding::calcNormalVector(void)
const MeshGeomFacet& rFace = *cFIt;
Base::Vector3f norm(rFace.GetNormal());
normalVector.push_back(SbVec3f(norm.x,norm.y,norm.z));
normalVector.emplace_back(norm.x,norm.y,norm.z);
}
}