Fechar menu lateral

Install Pymesh

Instalando o pymesh

Para instalar o pacote pymesh v0.2.0 no anaconda em fiz o seguinte procedimento:

  • Primeiro baixei o correspondente wheel (pymesh2-0.2.0-cp27-cp36mu-linux_x86_64.whl) no meu caso. Link

  • Segundo :
    pip install pymesh2-0.2.0-cp36-cp27mu-linux_x86_64.whl

  • Test:
    python -c "import pymesh; pymesh.test()"

  • Este foi o resultado: 

Running unit tests for pymesh
NumPy version 1.14.3
NumPy relaxed strides checking option: True
NumPy is installed in /home/radias-s20/anaconda3/lib/python3.6/site-packages/numpy
Python version 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) [GCC 7.2.0]
nose version 1.3.7
………………………………………………………………………………………………………………………………S……
———————————————————————-
Ran 151 tests in 27.367s

OK (SKIP=1)

Primeiro programa.

Para maiores detalhes veja aqui: https://pymesh.readthedocs.io/en/latest/

Vou assumir que tenha o freeCAD instalado.

Abra o freeCAD, vá em part design e crie um cubo e exporte este como “cube.obj”

Crie um arquivo com o nome “pymesh0.py” e cole o seguinte texto dentro:

 

import pymesh
mesh = pymesh.load_mesh(“cube.obj”);

print(“mesh.vertices”)
print(mesh.vertices)

print(“type(mesh.vertices)”)
print(type(mesh.vertices))

# A scalar field representing the Gaussian curvature field of the mesh.
atribute=”vertex_gaussian_curvature”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A vector field representing surface normals. Zero vectors are assigned to vertices in the interior.
atribute=”vertex_normal”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

#A scalar field representing the lumped volume of each vertex (e.g. 1/4 of the total volume of all neighboring tets for tetrahedron mesh.).
atribute=”vertex_volume”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A scalar field representing the lumped surface area of each vertex (e.g. 1/3 of the total face area of its 1-ring neighborhood).
atribute=”vertex_area”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A vector field representing the discretized Laplacian vector.
atribute=”vertex_laplacian”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

#: A scalar field representing the mean curvature field of the mesh.
atribute=”vertex_mean_curvature”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

#: A scalar field representing the index of each vertex.
atribute=”vertex_index”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

#: A scalar field representing the valance of each vertex.
atribute=”vertex_valance”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

#: A scalar field representing the max dihedral angle of all edges adjacent to this vertex.
atribute=”vertex_dihedral_angle”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A scalar field representing face areas.
atribute=”face_area”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A vector field representing the face centroids (i.e. average of all corners).
atribute=”face_centroid”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

#A vector field representing the face circumcenters (defined for triangle faces only).
atribute=”face_circumcenter”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A scalar field representing the index of each face.
atribute=”face_index”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A vector field representing the normal vector of each face.
atribute=”face_normal”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A vector field representing the voronoi area of each corner of the face.
atribute=”face_voronoi_area”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A scalar field representing the index of each voxel.
atribute=”voxel_index”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

#: A scalar field representing the volume of each voxel.
atribute=”voxel_volume”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

# A scalar field representing the centroid of each voxel (i.e. average
atribute=”voxel_centroid”
print(atribute)
mesh.add_attribute(atribute)
print(mesh.get_attribute(atribute))

#The following formats are supported for saving meshes: .obj, .off, .ply, .mesh, .node, .poly, .stl and .msh.
#However, saving in .stl format is strongly discouraged because STL files use more disk space and stores less information.
#To save a mesh:

pymesh.save_mesh(“filename.obj”, mesh)

#For certain formats (e.g. .ply, .msh, .stl), it is possible to save either as an ASCII file or a binary file.
#By default, PyMesh will always use the binary format. To save in ASCII, just set the ascii argument:

pymesh.save_mesh(“filename.obj”, mesh, ascii=True)

 

 

Vá para o terminal e digite:

python pymesh0.py