@@ -1064,7 +1064,6 @@ XY TriContourGenerator::interp(int point1,
1064
1064
1065
1065
TrapezoidMapTriFinder::TrapezoidMapTriFinder (Triangulation& triangulation)
1066
1066
: _triangulation(triangulation),
1067
- _points(nullptr ),
1068
1067
_tree(nullptr )
1069
1068
{}
1070
1069
@@ -1291,8 +1290,7 @@ TrapezoidMapTriFinder::add_edge_to_tree(const Edge& edge)
1291
1290
void
1292
1291
TrapezoidMapTriFinder::clear ()
1293
1292
{
1294
- delete [] _points;
1295
- _points = nullptr ;
1293
+ _points.clear ();
1296
1294
1297
1295
_edges.clear ();
1298
1296
@@ -1399,7 +1397,7 @@ TrapezoidMapTriFinder::initialize()
1399
1397
// Set up points array, which contains all of the points in the
1400
1398
// triangulation plus the 4 corners of the enclosing rectangle.
1401
1399
int npoints = triang.get_npoints ();
1402
- _points = new Point[ npoints + 4 ] ;
1400
+ _points. reserve ( npoints + 4 ) ;
1403
1401
BoundingBox bbox;
1404
1402
for (int i = 0 ; i < npoints; ++i) {
1405
1403
XY xy = triang.get_point_coords (i);
@@ -1408,7 +1406,7 @@ TrapezoidMapTriFinder::initialize()
1408
1406
xy.x = 0.0 ;
1409
1407
if (xy.y == -0.0 )
1410
1408
xy.y = 0.0 ;
1411
- _points[i] = Point (xy);
1409
+ _points. emplace_back (xy);
1412
1410
bbox.add (xy);
1413
1411
}
1414
1412
@@ -1423,10 +1421,10 @@ TrapezoidMapTriFinder::initialize()
1423
1421
const double small = 0.1 ; // Any value > 0.0
1424
1422
bbox.expand ( (bbox.upper - bbox.lower )*small );
1425
1423
}
1426
- _points[npoints ] = Point (bbox.lower ); // SW point.
1427
- _points[npoints+ 1 ] = Point (bbox.upper .x , bbox.lower .y ); // SE point.
1428
- _points[npoints+ 2 ] = Point (bbox.lower .x , bbox.upper .y ); // NW point.
1429
- _points[npoints+ 3 ] = Point (bbox.upper ); // NE point.
1424
+ _points. emplace_back (bbox.lower ); // SW point.
1425
+ _points. emplace_back (bbox.upper .x , bbox.lower .y ); // SE point.
1426
+ _points. emplace_back (bbox.lower .x , bbox.upper .y ); // NW point.
1427
+ _points. emplace_back (bbox.upper ); // NE point.
1430
1428
1431
1429
// Set up edges array.
1432
1430
// First the bottom and top edges of the enclosing rectangle.
@@ -1442,16 +1440,14 @@ TrapezoidMapTriFinder::initialize()
1442
1440
for (int tri = 0 ; tri < ntri; ++tri) {
1443
1441
if (!triang.is_masked (tri)) {
1444
1442
for (int edge = 0 ; edge < 3 ; ++edge) {
1445
- Point* start = _points + triang.get_triangle_point (tri,edge);
1446
- Point* end = _points +
1447
- triang.get_triangle_point (tri,(edge+1 )%3 );
1448
- Point* other = _points +
1449
- triang.get_triangle_point (tri,(edge+2 )%3 );
1443
+ Point* start = &_points[triang.get_triangle_point (tri, edge)];
1444
+ Point* end = &_points[triang.get_triangle_point (tri,(edge+1 )%3 )];
1445
+ Point* other = &_points[triang.get_triangle_point (tri,(edge+2 )%3 )];
1450
1446
TriEdge neighbor = triang.get_neighbor_edge (tri,edge);
1451
1447
if (end->is_right_of (*start)) {
1452
1448
const Point* neighbor_point_below = (neighbor.tri == -1 ) ?
1453
- nullptr : _points + triang. get_triangle_point (
1454
- neighbor.tri , (neighbor.edge +2 )%3 );
1449
+ nullptr :
1450
+ &_points[triang. get_triangle_point ( neighbor.tri , (neighbor.edge +2 )%3 )] ;
1455
1451
_edges.emplace_back (start, end, neighbor.tri , tri,
1456
1452
neighbor_point_below, other);
1457
1453
}
0 commit comments