Perform the 3D projection for this object.
(self)
| 1410 | self.stale = True |
| 1411 | |
| 1412 | def do_3d_projection(self): |
| 1413 | """ |
| 1414 | Perform the 3D projection for this object. |
| 1415 | """ |
| 1416 | if self._A is not None: |
| 1417 | # force update of color mapping because we re-order them |
| 1418 | # below. If we do not do this here, the 2D draw will call |
| 1419 | # this, but we will never port the color mapped values back |
| 1420 | # to the 3D versions. |
| 1421 | # |
| 1422 | # We hold the 3D versions in a fixed order (the order the user |
| 1423 | # passed in) and sort the 2D version by view depth. |
| 1424 | self.update_scalarmappable() |
| 1425 | if self._face_is_mapped: |
| 1426 | self._facecolor3d = self._facecolors |
| 1427 | if self._edge_is_mapped: |
| 1428 | self._edgecolor3d = self._edgecolors |
| 1429 | |
| 1430 | num_faces = len(self._faces) |
| 1431 | mask = self._invalid_vertices | _scale_invalid_mask( |
| 1432 | self._faces[..., 0], self._faces[..., 1], |
| 1433 | self._faces[..., 2], self.axes) |
| 1434 | needs_masking = np.any(mask) |
| 1435 | |
| 1436 | # Some faces might contain masked vertices, so we want to ignore any |
| 1437 | # errors that those might cause |
| 1438 | with np.errstate(invalid='ignore', divide='ignore'): |
| 1439 | pfaces = proj3d._scale_proj_transform_vectors(self._faces, self.axes) |
| 1440 | |
| 1441 | if self._axlim_clip: |
| 1442 | viewlim_mask = _viewlim_mask(self._faces[..., 0], self._faces[..., 1], |
| 1443 | self._faces[..., 2], self.axes) |
| 1444 | if np.any(viewlim_mask): |
| 1445 | needs_masking = True |
| 1446 | mask = mask | viewlim_mask |
| 1447 | |
| 1448 | pzs = pfaces[..., 2] |
| 1449 | if needs_masking: |
| 1450 | pzs = np.ma.MaskedArray(pzs, mask=mask) |
| 1451 | |
| 1452 | # This extra fuss is to re-order face / edge colors |
| 1453 | cface = self._facecolor3d |
| 1454 | cedge = self._edgecolor3d |
| 1455 | if len(cface) != num_faces: |
| 1456 | cface = cface.repeat(num_faces, axis=0) |
| 1457 | if len(cedge) != num_faces: |
| 1458 | if len(cedge) == 0: |
| 1459 | cedge = cface |
| 1460 | else: |
| 1461 | cedge = cedge.repeat(num_faces, axis=0) |
| 1462 | |
| 1463 | if len(pzs) > 0: |
| 1464 | face_z = self._zsortfunc(pzs, axis=-1) |
| 1465 | else: |
| 1466 | face_z = pzs |
| 1467 | if needs_masking: |
| 1468 | face_z = face_z.data |
| 1469 | face_order = np.argsort(face_z, axis=-1)[::-1] |
no test coverage detected