MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / initialize

Method initialize

site-packages/matplotlib/tri/_tri.cpp:1317–1406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1315}
1316
1317void
1318TrapezoidMapTriFinder::initialize()
1319{
1320 clear();
1321 const Triangulation& triang = _triangulation;
1322
1323 // Set up points array, which contains all of the points in the
1324 // triangulation plus the 4 corners of the enclosing rectangle.
1325 int npoints = triang.get_npoints();
1326 _points = new Point[npoints + 4];
1327 BoundingBox bbox;
1328 for (int i = 0; i < npoints; ++i) {
1329 XY xy = triang.get_point_coords(i);
1330 // Avoid problems with -0.0 values different from 0.0
1331 if (xy.x == -0.0)
1332 xy.x = 0.0;
1333 if (xy.y == -0.0)
1334 xy.y = 0.0;
1335 _points[i] = Point(xy);
1336 bbox.add(xy);
1337 }
1338
1339 // Last 4 points are corner points of enclosing rectangle. Enclosing
1340 // rectangle made slightly larger in case corner points are already in the
1341 // triangulation.
1342 if (bbox.empty) {
1343 bbox.add(XY(0.0, 0.0));
1344 bbox.add(XY(1.0, 1.0));
1345 }
1346 else {
1347 const double small = 0.1; // Any value > 0.0
1348 bbox.expand( (bbox.upper - bbox.lower)*small );
1349 }
1350 _points[npoints ] = Point(bbox.lower); // SW point.
1351 _points[npoints+1] = Point(bbox.upper.x, bbox.lower.y); // SE point.
1352 _points[npoints+2] = Point(bbox.lower.x, bbox.upper.y); // NW point.
1353 _points[npoints+3] = Point(bbox.upper); // NE point.
1354
1355 // Set up edges array.
1356 // First the bottom and top edges of the enclosing rectangle.
1357 _edges.push_back(Edge(&_points[npoints], &_points[npoints+1],-1,-1,0,0));
1358 _edges.push_back(Edge(&_points[npoints+2],&_points[npoints+3],-1,-1,0,0));
1359
1360 // Add all edges in the triangulation that point to the right. Do not
1361 // explicitly include edges that point to the left as the neighboring
1362 // triangle will supply that, unless there is no such neighbor.
1363 int ntri = triang.get_ntri();
1364 for (int tri = 0; tri < ntri; ++tri) {
1365 if (!triang.is_masked(tri)) {
1366 for (int edge = 0; edge < 3; ++edge) {
1367 Point* start = _points + triang.get_triangle_point(tri,edge);
1368 Point* end = _points +
1369 triang.get_triangle_point(tri,(edge+1)%3);
1370 Point* other = _points +
1371 triang.get_triangle_point(tri,(edge+2)%3);
1372 TriEdge neighbor = triang.get_neighbor_edge(tri,edge);
1373 if (end->is_right_of(*start)) {
1374 const Point* neighbor_point_below = (neighbor.tri == -1) ?

Callers 2

_initializeMethod · 0.45

Calls 15

clearFunction · 0.85
PointClass · 0.85
XYClass · 0.85
get_npointsMethod · 0.80
get_point_coordsMethod · 0.80
get_ntriMethod · 0.80
is_maskedMethod · 0.80
get_triangle_pointMethod · 0.80
get_neighbor_edgeMethod · 0.80
is_right_ofMethod · 0.80
assert_validMethod · 0.80
EdgeClass · 0.70

Tested by

no test coverage detected