Apply modernize-use-emplace clang-tidy rule

This commit is contained in:
Aaron Gokaslan
2022-08-23 11:41:49 -04:00
parent 04997ccbf3
commit 27edb43600
48 changed files with 302 additions and 302 deletions

View File

@@ -310,7 +310,7 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const
if (IfcVector2(diff.x, diff.y).SquareLength() < 1e-10)
continue;
}
intersect_results.push_back(std::make_pair(i, e0));
intersect_results.emplace_back(i, e0);
continue;
}
@@ -324,7 +324,7 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const
if (IfcVector2(diff.x, diff.y).SquareLength() < 1e-10)
continue;
}
intersect_results.push_back(std::make_pair(i, p));
intersect_results.emplace_back(i, p);
}
}
@@ -504,7 +504,7 @@ void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const Schema_2x3::IfcPoly
}
// now add them to the list of intersections
for (size_t b = 0; b < intersected_boundary.size(); ++b)
intersections.push_back(std::make_tuple(a, proj_inv * intersected_boundary[b].second, intersected_boundary[b].first));
intersections.emplace_back(a, proj_inv * intersected_boundary[b].second, intersected_boundary[b].first);
// and calculate our new inside/outside state
if (intersected_boundary.size() & 1)

View File

@@ -224,7 +224,7 @@ public:
IFCImporter::LogVerboseDebug("ignoring transition code on composite curve segment, only continuous transitions are supported");
}
curves.push_back( CurveEntry(bc,IsTrue(curveSegment.SameSense)) );
curves.emplace_back(bc,IsTrue(curveSegment.SameSense) );
total += bc->GetParametricRangeDelta();
}

View File

@@ -170,7 +170,7 @@ void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t m
continue;
}
fake_openings.push_back(TempOpening());
fake_openings.emplace_back();
TempOpening& opening = fake_openings.back();
opening.extrusionDir = master_normal;
@@ -612,7 +612,7 @@ void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const Te
TempMesh& bounds = *t.profileMesh.get();
if( bounds.mVerts.size() <= 2 ) {
nors.push_back(IfcVector3());
nors.emplace_back();
continue;
}
auto nor = ((bounds.mVerts[2] - bounds.mVerts[0]) ^ (bounds.mVerts[1] - bounds.mVerts[0])).Normalize();

View File

@@ -114,9 +114,9 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField&
if (!found) {
// the rectangle [pmin,pend] is opaque, fill it
out.push_back(pmin);
out.push_back(IfcVector2(pmin.x,pmax.y));
out.emplace_back(pmin.x,pmax.y);
out.push_back(pmax);
out.push_back(IfcVector2(pmax.x,pmin.y));
out.emplace_back(pmax.x,pmin.y);
return;
}
@@ -126,9 +126,9 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField&
// see if there's an offset to fill at the top of our quad
if (xs - pmin.x) {
out.push_back(pmin);
out.push_back(IfcVector2(pmin.x,pmax.y));
out.push_back(IfcVector2(xs,pmax.y));
out.push_back(IfcVector2(xs,pmin.y));
out.emplace_back(pmin.x,pmax.y);
out.emplace_back(xs,pmax.y);
out.emplace_back(xs,pmin.y);
}
// search along the y-axis for all openings that overlap xs and our quad
@@ -159,10 +159,10 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField&
}
if (!found) {
// the rectangle [pmin,pend] is opaque, fill it
out.push_back(IfcVector2(xs,pmin.y));
out.push_back(IfcVector2(xs,pmax.y));
out.push_back(IfcVector2(xe,pmax.y));
out.push_back(IfcVector2(xe,pmin.y));
out.emplace_back(xs,pmin.y);
out.emplace_back(xs,pmax.y);
out.emplace_back(xe,pmax.y);
out.emplace_back(xe,pmin.y);
return;
}
if (ylast < pmax.y) {
@@ -342,7 +342,7 @@ void InsertWindowContours(const ContourVector& contours,
if ((contour[a] - edge).SquareLength() > diag*diag*0.7) {
continue;
}
curmesh.mVerts.push_back(IfcVector3(contour[a].x, contour[a].y, 0.0f));
curmesh.mVerts.emplace_back(contour[a].x, contour[a].y, 0.0f);
}
if (edge != contour[last_hit]) {
@@ -363,7 +363,7 @@ void InsertWindowContours(const ContourVector& contours,
corner.y = bb.second.y;
}
curmesh.mVerts.push_back(IfcVector3(corner.x, corner.y, 0.0f));
curmesh.mVerts.emplace_back(corner.x, corner.y, 0.0f);
}
else if (cnt == 1) {
// avoid degenerate polygons (also known as lines or points)
@@ -558,10 +558,10 @@ void CleanupOuterContour(const std::vector<IfcVector2>& contour_flat, TempMesh&
for(const ClipperLib::ExPolygon& ex : clipped) {
iold.push_back(static_cast<unsigned int>(ex.outer.size()));
for(const ClipperLib::IntPoint& point : ex.outer) {
vold.push_back(IfcVector3(
vold.emplace_back(
from_int64(point.X),
from_int64(point.Y),
0.0f));
0.0f);
}
}
@@ -1039,7 +1039,7 @@ void Quadrify(const std::vector< BoundingBox >& bbs, TempMesh& curmesh)
curmesh.mVertcnt.resize(quads.size()/4,4);
curmesh.mVerts.reserve(quads.size());
for(const IfcVector2& v2 : quads) {
curmesh.mVerts.push_back(IfcVector3(v2.x, v2.y, static_cast<IfcFloat>(0.0)));
curmesh.mVerts.emplace_back(v2.x, v2.y, static_cast<IfcFloat>(0.0));
}
}
@@ -1095,7 +1095,7 @@ IfcMatrix4 ProjectOntoPlane(std::vector<IfcVector2>& out_contour, const TempMesh
vmin = std::min(vv, vmin);
vmax = std::max(vv, vmax);
out_contour.push_back(IfcVector2(vv.x,vv.y));
out_contour.emplace_back(vv.x,vv.y);
}
zcoord /= in_verts.size();
@@ -1128,7 +1128,7 @@ IfcMatrix4 ProjectOntoPlane(std::vector<IfcVector2>& out_contour, const TempMesh
for(const IfcVector3& x : in_verts) {
const IfcVector3& vv = m * x;
out_contour2.push_back(IfcVector2(vv.x,vv.y));
out_contour2.emplace_back(vv.x,vv.y);
ai_assert(std::fabs(vv.z) < vmax.z + 1e-8);
}
@@ -1469,7 +1469,7 @@ std::vector<IfcVector2> GetContourInPlane2D(const std::shared_ptr<TempMesh>& mes
// XXX should not be necessary - but it is. Why? For precision reasons?
vv = is_extruded_side ? vv_extr : vv;
contour.push_back(IfcVector2(vv.x,vv.y));
contour.emplace_back(vv.x,vv.y);
}
ok = true;
@@ -1758,7 +1758,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,
vmin = std::min(IfcVector2(vv.x, vv.y), vmin);
vmax = std::max(IfcVector2(vv.x, vv.y), vmax);
contour_flat.push_back(IfcVector2(vv.x,vv.y));
contour_flat.emplace_back(vv.x,vv.y);
}
// With the current code in DerivePlaneCoordinateSpace,
@@ -1891,7 +1891,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,
// Build the poly2tri inner contours for all holes we got from ClipperLib
for(ClipperLib::Polygon& opening : clip.holes) {
contours.push_back(std::vector<p2t::Point*>());
contours.emplace_back();
std::vector<p2t::Point*>& contour = contours.back();
for(ClipperLib::IntPoint& point : opening) {

View File

@@ -108,10 +108,10 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f;
meshout.mVerts.reserve(meshout.mVerts.size()+4);
meshout.mVerts.push_back( IfcVector3( x, y, 0.f ));
meshout.mVerts.push_back( IfcVector3(-x, y, 0.f ));
meshout.mVerts.push_back( IfcVector3(-x,-y, 0.f ));
meshout.mVerts.push_back( IfcVector3( x,-y, 0.f ));
meshout.mVerts.emplace_back( x, y, 0.f );
meshout.mVerts.emplace_back(-x, y, 0.f );
meshout.mVerts.emplace_back(-x,-y, 0.f );
meshout.mVerts.emplace_back( x,-y, 0.f );
meshout.mVertcnt.push_back(4);
}
else if( const Schema_2x3::IfcCircleProfileDef* const circle = def.ToPtr<Schema_2x3::IfcCircleProfileDef>()) {
@@ -125,7 +125,7 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
IfcFloat angle = 0.f;
for(size_t i = 0; i < segments; ++i, angle += delta) {
meshout.mVerts.push_back( IfcVector3( std::cos(angle)*radius, std::sin(angle)*radius, 0.f ));
meshout.mVerts.emplace_back( std::cos(angle)*radius, std::sin(angle)*radius, 0.f );
}
meshout.mVertcnt.push_back(static_cast<unsigned int>(segments));
@@ -136,18 +136,18 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
const IfcFloat inner_height = ishape->OverallDepth - ishape->FlangeThickness * 2;
meshout.mVerts.reserve(12);
meshout.mVerts.push_back(IfcVector3(0,0,0));
meshout.mVerts.push_back(IfcVector3(0,ishape->FlangeThickness,0));
meshout.mVerts.push_back(IfcVector3(offset,ishape->FlangeThickness,0));
meshout.mVerts.push_back(IfcVector3(offset,ishape->FlangeThickness + inner_height,0));
meshout.mVerts.push_back(IfcVector3(0,ishape->FlangeThickness + inner_height,0));
meshout.mVerts.push_back(IfcVector3(0,ishape->OverallDepth,0));
meshout.mVerts.push_back(IfcVector3(ishape->OverallWidth,ishape->OverallDepth,0));
meshout.mVerts.push_back(IfcVector3(ishape->OverallWidth,ishape->FlangeThickness + inner_height,0));
meshout.mVerts.push_back(IfcVector3(offset+ishape->WebThickness,ishape->FlangeThickness + inner_height,0));
meshout.mVerts.push_back(IfcVector3(offset+ishape->WebThickness,ishape->FlangeThickness,0));
meshout.mVerts.push_back(IfcVector3(ishape->OverallWidth,ishape->FlangeThickness,0));
meshout.mVerts.push_back(IfcVector3(ishape->OverallWidth,0,0));
meshout.mVerts.emplace_back(0,0,0);
meshout.mVerts.emplace_back(0,ishape->FlangeThickness,0);
meshout.mVerts.emplace_back(offset,ishape->FlangeThickness,0);
meshout.mVerts.emplace_back(offset,ishape->FlangeThickness + inner_height,0);
meshout.mVerts.emplace_back(0,ishape->FlangeThickness + inner_height,0);
meshout.mVerts.emplace_back(0,ishape->OverallDepth,0);
meshout.mVerts.emplace_back(ishape->OverallWidth,ishape->OverallDepth,0);
meshout.mVerts.emplace_back(ishape->OverallWidth,ishape->FlangeThickness + inner_height,0);
meshout.mVerts.emplace_back(offset+ishape->WebThickness,ishape->FlangeThickness + inner_height,0);
meshout.mVerts.emplace_back(offset+ishape->WebThickness,ishape->FlangeThickness,0);
meshout.mVerts.emplace_back(ishape->OverallWidth,ishape->FlangeThickness,0);
meshout.mVerts.emplace_back(ishape->OverallWidth,0,0);
meshout.mVertcnt.push_back(12);
}

View File

@@ -201,7 +201,7 @@ void TempMesh::ComputePolygonNormals(std::vector<IfcVector3>& normals,
size_t vidx = std::accumulate(mVertcnt.begin(),begin,0);
for(iit = begin; iit != end; vidx += *iit++) {
if (!*iit) {
normals.push_back(IfcVector3());
normals.emplace_back();
continue;
}
for(size_t vofs = 0, cnt = 0; vofs < *iit; ++vofs) {
@@ -215,7 +215,7 @@ void TempMesh::ComputePolygonNormals(std::vector<IfcVector3>& normals,
++cnt;
}
normals.push_back(IfcVector3());
normals.emplace_back();
NewellNormal<4,4,4>(normals.back(),*iit,&temp[0],&temp[1],&temp[2]);
}