marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
2.06k stars 267 forks source link

Reading point and connectivity information from iges files #294

Closed DeepaMahm closed 3 years ago

DeepaMahm commented 3 years ago

Hi @marcomusy

I'd like to extract the points and connectivity information stored in an iges file. In gmsh I could read the geometry entities by importing the mesh file (example). I'd like to do something similar in vedo to parse the node coordinates and links. Could you please suggest how external mesh files can be imported in vedo?

marcomusy commented 3 years ago

Hi you can access the information of points an connectivity of a mesh with mesh.point() , mesh.faces() and mesh.lines(), I'm not sure if that answers the question..

DeepaMahm commented 3 years ago

Hi @marcomusy I'm sorry, I think I wasn't clear

I tried saving the mesh information in iges file with .msh (I couldn't find .gmsh in the save options) extension in gmsh and loaded the file in vedo to read the point and line data.

from vedo import io
f = io.loadGmesh("test2_gmsh.msh")

unfortunately, I am facing some issue here

    nnodes = int(lines[index_nodes])
ValueError: invalid literal for int() with base 10: '14 32 1 32\n'

test2_gmsh.msh

Could you please help me with this?

marcomusy commented 3 years ago

I see.. it looks it's a different format from what vedoknows.. but it's readable in meshio

import meshio

mesh = meshio.read('test2_gmsh.msh')
print(mesh.points)
print(mesh.cells)

print(mesh.cells[10][0])
print(mesh.cells[10][1])

then you can build the vedo.Lines object

DeepaMahm commented 3 years ago

Hi @marcomusy

That was of great help!

I would like to ask for another suggestion

For instance in gmsh,

image

I could specify min/max element size to mesh the original network created from points and lines. I do this to add additional nodes in each edge (or Line). I'd like to know if such meshing option is available in vedo for adding nodes to the geometry created using vedo Points and Lines. Right now I do this externally, save in msh format, get all new points and elements, and recreate in vedo.

Thanks a lot, Deepa

marcomusy commented 3 years ago

Uhm, I'm not sure - you can use the function densify - see advanced/densifycloud.py- to add extra points in space or use delaunay2D to make a mesh out of a cloud of points if it's 2d. You can also subdivide a mesh (increase the triangulation density) with mesh.subdivide() I don't know if this is useful..