Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounding when saving/reading an obj #1119

Closed
ManuGraiph opened this issue May 15, 2024 · 5 comments
Closed

Rounding when saving/reading an obj #1119

ManuGraiph opened this issue May 15, 2024 · 5 comments

Comments

@ManuGraiph
Copy link

Hi Marco!

I'm having an issue when saving/reading a mesh as an obj file..

When i create a mesh and i save it as a .obj file and then i read it again, at some point, the vertices coordinates are getting "internally" converted to scientific notation and rounded to the 4th decimal place (I'm not entirely sure if this behaviour is in numpy, vedo, or both). I've tried converting the points to int32, int64, etc. before saving the obj, but the result is the same.

This causes some issues when the order of coordinates is more than 4-5, like, when working with UTM coordinates.

Any idea how to prevent this?

Thanks in advance!
Manu

@marcomusy
Copy link
Owner

Hi - I just increased the precision in the dev version.

@ManuGraiph
Copy link
Author

Thanks a lot!

I ended up "patching" it myself writing a new write function for .obj. I'm gonna leave it here in case it's useful for anyone.

def writeObj(mesh,filename):
    with open(filename, 'w') as f:
        for k in range(len(mesh.points())):
            a = list(mesh.points()[k,:])
            line = "v "+str(a[0])+" "+str(a[1])+" "+str(a[2])
            f.write(line+'\n')
        for k in range(len(mesh.cells)):
            a = list(mesh.cells[k])
            line = "f "+str(a[0])+" "+str(a[1])+" "+str(a[2])
            f.write(line+'\n')

So it just writes the array values as text.

Thanks again!

@ManuGraiph
Copy link
Author

Sorry, i'm gonna use this post and ask another thing, so i don't open another one. I'm not sure if i asked this before, i apologize if i did, but, it's possible to create quad elements in vedo? (an element with 4 verts. instead of 3)

@marcomusy
Copy link
Owner

Yes sure in fact any polygon. You need to mind about coplanatity.

@ManuGraiph
Copy link
Author

ManuGraiph commented May 17, 2024

Great! Thanks a lot! I think at some point i tried but failed and after that i basically kept making quads combining 2 triangles.

Thanks!

Closing with this to not spam anymore :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants