@@ -269,11 +269,10 @@ void Triangulation::calculate_boundaries()
269
269
auto it = boundary_edges.cbegin ();
270
270
int tri = it->tri ;
271
271
int edge = it->edge ;
272
- _boundaries.push_back (Boundary ());
273
- Boundary& boundary = _boundaries.back ();
272
+ Boundary& boundary = _boundaries.emplace_back ();
274
273
275
274
while (true ) {
276
- boundary.push_back ( TriEdge ( tri, edge) );
275
+ boundary.emplace_back ( tri, edge);
277
276
boundary_edges.erase (it);
278
277
_tri_edge_to_boundary_map[TriEdge (tri, edge)] =
279
278
BoundaryEdge (_boundaries.size ()-1 , boundary.size ()-1 );
@@ -624,7 +623,7 @@ void TriContourGenerator::clear_visited_flags(bool include_boundaries)
624
623
// Initialise _boundaries_visited.
625
624
_boundaries_visited.reserve (boundaries.size ());
626
625
for (const auto & boundary : boundaries) {
627
- _boundaries_visited.push_back ( BoundaryVisited ( boundary.size () ));
626
+ _boundaries_visited.emplace_back ( boundary.size ());
628
627
}
629
628
630
629
// Initialise _boundaries_used.
@@ -798,8 +797,7 @@ void TriContourGenerator::find_boundary_lines(Contour& contour,
798
797
if (startAbove && !endAbove) {
799
798
// This boundary edge is the start point for a contour line,
800
799
// so follow the line.
801
- contour.push_back (ContourLine ());
802
- ContourLine& contour_line = contour.back ();
800
+ ContourLine& contour_line = contour.emplace_back ();
803
801
TriEdge tri_edge = *itb;
804
802
follow_interior (contour_line, tri_edge, true , level, false );
805
803
}
@@ -832,8 +830,7 @@ void TriContourGenerator::find_boundary_lines_filled(Contour& contour,
832
830
833
831
if (decr_lower || incr_upper) {
834
832
// Start point for contour line, so follow it.
835
- contour.push_back (ContourLine ());
836
- ContourLine& contour_line = contour.back ();
833
+ ContourLine& contour_line = contour.emplace_back ();
837
834
TriEdge start_tri_edge = boundary[j];
838
835
TriEdge tri_edge = start_tri_edge;
839
836
@@ -861,8 +858,7 @@ void TriContourGenerator::find_boundary_lines_filled(Contour& contour,
861
858
const Boundary& boundary = boundaries[i];
862
859
double z = get_z (triang.get_triangle_point (boundary[0 ]));
863
860
if (z >= lower_level && z < upper_level) {
864
- contour.push_back (ContourLine ());
865
- ContourLine& contour_line = contour.back ();
861
+ ContourLine& contour_line = contour.emplace_back ();
866
862
for (auto edge : boundary) {
867
863
contour_line.push_back (triang.get_point_coords (
868
864
triang.get_triangle_point (edge)));
@@ -896,8 +892,7 @@ void TriContourGenerator::find_interior_lines(Contour& contour,
896
892
continue ; // Contour does not pass through this triangle.
897
893
898
894
// Found start of new contour line loop.
899
- contour.push_back (ContourLine ());
900
- ContourLine& contour_line = contour.back ();
895
+ ContourLine& contour_line = contour.emplace_back ();
901
896
TriEdge tri_edge = triang.get_neighbor_edge (tri, edge);
902
897
follow_interior (contour_line, tri_edge, false , level, on_upper);
903
898
@@ -1436,10 +1431,10 @@ TrapezoidMapTriFinder::initialize()
1436
1431
1437
1432
// Set up edges array.
1438
1433
// First the bottom and top edges of the enclosing rectangle.
1439
- _edges.push_back ( Edge (&_points[npoints], &_points[npoints+1 ], -1 , -1 ,
1440
- nullptr , nullptr ) );
1441
- _edges.push_back ( Edge (&_points[npoints+2 ], &_points[npoints+3 ], -1 , -1 ,
1442
- nullptr , nullptr ) );
1434
+ _edges.emplace_back (&_points[npoints], &_points[npoints+1 ], -1 , -1 ,
1435
+ nullptr , nullptr );
1436
+ _edges.emplace_back (&_points[npoints+2 ], &_points[npoints+3 ], -1 , -1 ,
1437
+ nullptr , nullptr );
1443
1438
1444
1439
// Add all edges in the triangulation that point to the right. Do not
1445
1440
// explicitly include edges that point to the left as the neighboring
@@ -1458,11 +1453,12 @@ TrapezoidMapTriFinder::initialize()
1458
1453
const Point* neighbor_point_below = (neighbor.tri == -1 ) ?
1459
1454
nullptr : _points + triang.get_triangle_point (
1460
1455
neighbor.tri , (neighbor.edge +2 )%3 );
1461
- _edges.push_back (Edge (start, end, neighbor.tri , tri,
1462
- neighbor_point_below, other));
1456
+ _edges.emplace_back (start, end, neighbor.tri , tri,
1457
+ neighbor_point_below, other);
1458
+ }
1459
+ else if (neighbor.tri == -1 ) {
1460
+ _edges.emplace_back (end, start, tri, -1 , other, nullptr );
1463
1461
}
1464
- else if (neighbor.tri == -1 )
1465
- _edges.push_back (Edge (end, start, tri, -1 , other, nullptr ));
1466
1462
1467
1463
// Set triangle associated with start point if not already set.
1468
1464
if (start->tri == -1 )
0 commit comments