@@ -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.
@@ -796,8 +795,7 @@ void TriContourGenerator::find_boundary_lines(Contour& contour,
796
795
if (startAbove && !endAbove) {
797
796
// This boundary edge is the start point for a contour line,
798
797
// so follow the line.
799
- contour.push_back (ContourLine ());
800
- ContourLine& contour_line = contour.back ();
798
+ ContourLine& contour_line = contour.emplace_back ();
801
799
TriEdge tri_edge = *itb;
802
800
follow_interior (contour_line, tri_edge, true , level, false );
803
801
}
@@ -830,8 +828,7 @@ void TriContourGenerator::find_boundary_lines_filled(Contour& contour,
830
828
831
829
if (decr_lower || incr_upper) {
832
830
// Start point for contour line, so follow it.
833
- contour.push_back (ContourLine ());
834
- ContourLine& contour_line = contour.back ();
831
+ ContourLine& contour_line = contour.emplace_back ();
835
832
TriEdge start_tri_edge = boundary[j];
836
833
TriEdge tri_edge = start_tri_edge;
837
834
@@ -859,8 +856,7 @@ void TriContourGenerator::find_boundary_lines_filled(Contour& contour,
859
856
const Boundary& boundary = boundaries[i];
860
857
double z = get_z (triang.get_triangle_point (boundary[0 ]));
861
858
if (z >= lower_level && z < upper_level) {
862
- contour.push_back (ContourLine ());
863
- ContourLine& contour_line = contour.back ();
859
+ ContourLine& contour_line = contour.emplace_back ();
864
860
for (auto edge : boundary) {
865
861
contour_line.push_back (triang.get_point_coords (
866
862
triang.get_triangle_point (edge)));
@@ -894,8 +890,7 @@ void TriContourGenerator::find_interior_lines(Contour& contour,
894
890
continue ; // Contour does not pass through this triangle.
895
891
896
892
// Found start of new contour line loop.
897
- contour.push_back (ContourLine ());
898
- ContourLine& contour_line = contour.back ();
893
+ ContourLine& contour_line = contour.emplace_back ();
899
894
TriEdge tri_edge = triang.get_neighbor_edge (tri, edge);
900
895
follow_interior (contour_line, tri_edge, false , level, on_upper);
901
896
@@ -1434,10 +1429,10 @@ TrapezoidMapTriFinder::initialize()
1434
1429
1435
1430
// Set up edges array.
1436
1431
// First the bottom and top edges of the enclosing rectangle.
1437
- _edges.push_back ( Edge (&_points[npoints], &_points[npoints+1 ], -1 , -1 ,
1438
- nullptr , nullptr ) );
1439
- _edges.push_back ( Edge (&_points[npoints+2 ], &_points[npoints+3 ], -1 , -1 ,
1440
- nullptr , nullptr ) );
1432
+ _edges.emplace_back (&_points[npoints], &_points[npoints+1 ], -1 , -1 ,
1433
+ nullptr , nullptr );
1434
+ _edges.emplace_back (&_points[npoints+2 ], &_points[npoints+3 ], -1 , -1 ,
1435
+ nullptr , nullptr );
1441
1436
1442
1437
// Add all edges in the triangulation that point to the right. Do not
1443
1438
// explicitly include edges that point to the left as the neighboring
@@ -1456,11 +1451,12 @@ TrapezoidMapTriFinder::initialize()
1456
1451
const Point* neighbor_point_below = (neighbor.tri == -1 ) ?
1457
1452
nullptr : _points + triang.get_triangle_point (
1458
1453
neighbor.tri , (neighbor.edge +2 )%3 );
1459
- _edges.push_back (Edge (start, end, neighbor.tri , tri,
1460
- neighbor_point_below, other));
1454
+ _edges.emplace_back (start, end, neighbor.tri , tri,
1455
+ neighbor_point_below, other);
1456
+ }
1457
+ else if (neighbor.tri == -1 ) {
1458
+ _edges.emplace_back (end, start, tri, -1 , other, nullptr );
1461
1459
}
1462
- else if (neighbor.tri == -1 )
1463
- _edges.push_back (Edge (end, start, tri, -1 , other, nullptr ));
1464
1460
1465
1461
// Set triangle associated with start point if not already set.
1466
1462
if (start->tri == -1 )
0 commit comments