4

for a project I'm writing I need a library for python to process ".off" files (3d models mesh files), so I would be able to visualize them and save an image of several views of the model . (the visualization is for that purpose, I just didn't find a lib with such option)

I found the following libraries, and they seem fine but I'm not sure what to chose:

Can you recommend on another library or which of the ones here is preferred?

1 Answer 1

0

Can't comment on those, sorry. Meshio reads / writes many different formats; an example --

""" meshio loopback test """
import numpy as np
import meshio  # https://github.com/nschloe/meshio
import meshzoo  # https://github.com/nschloe/meshzoo

def pr( txt, x ):
    print( "%s: %s \n%s .T" % (
            txt, x.shape, x.T ))

np.set_printoptions( threshold=20, edgeitems=10, linewidth=120,
        formatter = dict( float = lambda x: "%.2g" % x ))  # float arrays %.2g
print( 80 * "▄" )

#...............................................................................
points, cells = meshzoo.tube( n=10 )
pr( "points", points )
pr( "cells", cells )

cellsdict = {"triangle": cells}  # line triangle tetra
mesh = meshio.Mesh( points, cellsdict )

    # loopback test, write read --
mesh.write( "tmp-tube.off" )

print( "\nmeshio.read should be the same --" )  # reordered ?
meshin = meshio.read( "tmp-tube.off" )
points = meshin.points
pr( "points", points )
for typ, data in meshin.cells_dict.items():
    pr( typ, data )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.