47 if (self->
getShapeXML().find(
"infinite") != std::string::npos) {
48 throw std::runtime_error(
"Cannot plot Shapes of infinite extent.");
52 const auto &vertices = localTriangulator.getTriangleVertices();
53 const auto &triangles = localTriangulator.getTriangleFaces();
54 const size_t &numberTriangles = localTriangulator.numTriangleFaces();
55 npy_intp dims[3] = {
static_cast<npy_intp
>(numberTriangles), 3, 3};
57 if (numberTriangles == 0 || vertices.empty() || triangles.empty()) {
61 size_t totalSize = dims[0] * dims[1] * dims[2];
62 auto *meshCoords =
new double[totalSize];
63 std::fill(meshCoords, meshCoords + totalSize, 0.0);
66 for (
size_t corner_index = 0; corner_index < triangles.size() && corner_index < totalSize; ++corner_index) {
67 for (
size_t xyz = 0; xyz < 3; xyz++) {
68 size_t vertex_idx = triangles[corner_index];
69 if (vertex_idx * 3 + xyz < vertices.size()) {
70 meshCoords[3 * corner_index + xyz] = vertices[3 * vertex_idx + xyz];
74 PyObject *ndarray =
Impl::wrapWithNDArray(meshCoords, 3, dims, NumpyWrapMode::ReadOnly, OwnershipMode::Python);
75 return object(handle<>(ndarray));
77 }
catch (
const std::exception &e) {
79 g_log.
error(e.what());
PyObject * wrapWithNDArray(const ElementType *, const int ndims, Py_intptr_t *dims, const NumpyWrapMode mode, const OwnershipMode oMode=OwnershipMode::Cpp)
Defines the wrapWithNDArray specialization for C array types.