Skip to content

Latest commit

 

History

History
91 lines (66 loc) · 1.96 KB

README.md

File metadata and controls

91 lines (66 loc) · 1.96 KB

PyMesh3D

Basic Installation

This project for mesh render in data science.

pip install --upgrade pip
pip install pymesh3d

If you need mayavi backend.

pip install mayavi
pip install pyqt

Quick Start

import pymesh
import numpy as np
import matplotlib.pyplot as plt

Look at the directory example for full example.

##########################################
############ Rotate Mesh Data ############
##########################################

wkdir = "../../Render"

ey = np.load(wkdir + "/Ez.npy")[::2, ::50]

m, n = ey.shape[0], ey.shape[1]
res = np.zeros([m, n, n])
pymesh.rotate(ey, res, ifhalf = False)

fig = plt.figure(figsize=(4, 3))
plt.contourf(res[:, int(n/2), :].T)
cbar = plt.colorbar()

png

##########################################
############# Save Mesh Data #############
##########################################

mesh = pymesh.get_iso_surf(res, contours_number = 4, cmap = "jet")
color = pymesh.interp_color(mesh.iso_vals, cmap = "jet")
mesh.export(wkdir + "test", "obj")
##########################################
############# Load Mesh Data #############
##########################################

mesh = pymesh.Mesh.load(wkdir + "test", "obj")
##########################################
############# Plot Mesh Data #############
##########################################
from mayavi import mlab

mlab_mesh = pymesh.iso_surface(mesh, colormap = "RdBu")
mlab.colorbar()
mlab.show()

png

################ plt example #################

surf = mesh.plt_trisurf(cmap = "jet")
plt.colorbar(surf, orientation = 'horizontal')
plt.tight_layout()

png