<jupyter_start><jupyter_text>1.<jupyter_code>plt.figure(figsize=(10,5))
ax=plt.subplot(111,projection='3d')
ax.scatter(vertices[:,0],vertices[:,1],vertices[:,2])
# ax.plot_surface(vertices[:,0],vertices[:,1],vertices[:,2])
ax.plot(vertices[:,0],vertices[:,1],vertices[:,2])
# srf = Poly3DCollection(verts[:], alpha=0.1, facecolor='b')
# plt.gca().add_collection3d(srf)

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.view_init(30,90)<jupyter_output><empty_output><jupyter_text>2.<jupyter_code>import pygame as pg
from pygame.locals import *

from OpenGL.GL import *
from OpenGL.GLU import *

def Read(verticies,surfaces):
    glBegin(GL_TRIANGLES)
    for surface in surfaces:
        x=0
        for vertex in surface:
            x+=1
            glColor3fv(colors[x])
            glVertex3fv(verticies[vertex])
    glEnd()
surfaces = mesh.cells[0].data
verticies = mesh.points
colors = (
    (1,0,0),
    (0,1,0),
    (0,0,1),
    (0,1,0),
    (1,1,1),
    (0,1,1),
    (1,0,0),
    (0,1,0),
    (0,0,1),
    (1,0,0),
    (1,1,1),
    (0,1,1),
    )
pg.init()
display = (1680, 1050)
pg.display.set_mode(display, DOUBLEBUF|OPENGL)

gluPerspective(45, (display[0]/display[1]), 1, 500)

glTranslatef(0.0, 0.0, -100)

while True:
    for event in pg.event.get():
        if event.type == pg.QUIT:
            pg.quit()
            quit()

    glRotatef(1, 1, 1, 1)
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    Read(verticies,surfaces)
    pg.display.flip()
    pg.time.wait(10)<jupyter_output><empty_output><jupyter_text>3.<jupyter_code>import pyvista as pv
mesh = pv.PolyData(vertices)
mesh.length
mesh.plot(point_size=10)
p = pv.Plotter()
path = "/home/yui/Documents/data/ModelNet10/chair/train/chair_0001.off"
mesh = meshio.read(path,file_format="off")
p.add_mesh(mesh,show_edges=True,color='white')
p.show()
mesh
voxels = pv.voxelize(mesh, density=84.54609526122422/50
                     , check_surface=False)
voxels["density"] = np.full(voxels.n_cells, 3.65) # g/cc
voxels
voxels.plot(scalars="density")
pts = np.array(voxels.points)
plt.figure(figsize=(10,5))
ax=plt.subplot(111,projection='3d')
ax.scatter(pts[:,0],pts[:,1],pts[:,2],alpha=.05)
ax.view_init(60,40)
print(pts.shape)
# sphinx_gallery_thumbnail_number = 2
from pyvista import examples
import pyvista as pv
import numpy as np

# Load a surface to voxelize
surface = examples.download_foot_bones()
surface
cpos = [(7.656346967151718, -9.802071079151158, -11.021236183314311),
 (0.2224512272564101, -0.4594554282112895, 0.5549738359311297),
 (-0.6279216753504941, -0.7513057097368635, 0.20311105371647392)]

surface.plot(cpos=cpos, opacity=0.75)
surface.points.shape
surface.length
voxels = pv.voxelize(surface, density=surface.length/50)

p = pv.Plotter()
p.add_mesh(voxels, color=True, show_edges=True, opacity=0.5)
p.show()
pts = np.array(voxels.points)
len(voxels.cells)
len(pts)
plt.figure(figsize=(10,5))
ax=plt.subplot(111,projection='3d')
ax.scatter(pts[:,0],pts[:,1],pts[:,2],alpha=.1)
ax.view_init(30,90)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17873601053324556, 'fraction_numerical': 0.1043449637919684, 'mean_word_length': 4.866795366795367, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '390679', 'license': 'MIT', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1312, 'n_words': 178, 'path': 'resources/vis_mesh.ipynb', 'repo_name': 'zcemycl/zcemycl.github.io', 'size': '3038'}