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

STL import #3270

Closed
4 tasks done
mkeilman opened this issue Dec 30, 2020 · 8 comments
Closed
4 tasks done

STL import #3270

mkeilman opened this issue Dec 30, 2020 · 8 comments
Labels
Milestone

Comments

@mkeilman
Copy link
Contributor

mkeilman commented Dec 30, 2020

This may end up being part of the Phase 2a but the initial steps are not too complicated so I'll make this issue for it. The plan is to copy the warpvnd interface

(edited to mention that approach won't work here, because we have to let Radia create the object and then display it, not feed an arbitrary stl file to Radia)

@mkeilman mkeilman added this to the mpmd milestone Dec 30, 2020
@mkeilman mkeilman self-assigned this Dec 30, 2020
@robnagler robnagler changed the title mpmd: STL import STL import Feb 22, 2022
@mkeilman
Copy link
Contributor Author

This issue should include using STL imports as individual magnet components, not just an entire simulation

@mkeilman
Copy link
Contributor Author

mkeilman commented Sep 12, 2022

I don't see a specific "import stl" function in Radia - the most generic thing is RadObjMltExtPgn which builds an object up from stacked convex polygons. Actually RadObjPolyhdr is a better fit for this problem

@mkeilman
Copy link
Contributor Author

We have had problems getting ObjPolyhdr to work. For example here is some code to test the simplest possible polyhedron (a tetrahedron):

import radia
import numpy
p = [[0, 0, 0], [1, 1, 0], [0, 1, 0], [0.5, 0.5, 1]]
f = [[0, 1, 2], [0, 1, 3], [0, 3, 2], [3, 1, 2]]
g_id = radia.ObjPolyhdr(p, f)
d = radia.ObjDrwVTK(g_id, "Axes->No")
numpy.array([round(x, 6) for x in d["polygons"]["vertices"]]).reshape(-1, 3).tolist()
[
    [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [1.0, 1.0, 0.0],
    [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [1.0, 0.0, 0.0],
    [1.0, 1.0, 0.0], [0.0, 1.0, 0.0], [1.0, 0.0, 0.0],
    [1.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0]
]

The generated vertices are missing points supplied to the function and include points not supplied. They are also all in the same plane. The function also sometimes causes a segfault. We are exploring using ObjMltExtPgn - which would be an approximation - as an alternative.

@cchall or @j-edelen, have you had success using ObjPolyhdr?

@cchall
Copy link
Member

cchall commented Oct 18, 2022

I've been able to use ObjPolyhdr in the past to do very similar things.
I'll take a look at this example and see what I can find.

@cchall
Copy link
Member

cchall commented Oct 18, 2022

I think it was just the face indexing. Radia uses 1-based indexing.

import radia
import numpy
p = [[0, 0, 0], [1, 1, 0], [0, 1, 0], [0.5, 0.5, 1]]
f = numpy.array([[0, 1, 2], [0, 1, 3], [0, 3, 2], [3, 1, 2]]) + 1
g_id = radia.ObjPolyhdr(p, f.tolist())
d = radia.ObjDrwVTK(g_id, "Axes->No")
numpy.array([round(x, 6) for x in d["polygons"]["vertices"]]).reshape(-1, 3).tolist()
[[0.0, 1.0, 0.0],
 [1.0, 1.0, 0.0],
 [0.0, 0.0, 0.0],
 [0.0, 0.0, 0.0],
 [1.0, 1.0, 0.0],
 [0.5, 0.5, 1.0],
 [0.0, 0.0, 0.0],
 [0.5, 0.5, 1.0],
 [0.0, 1.0, 0.0],
 [0.5, 0.5, 1.0],
 [1.0, 1.0, 0.0],
 [0.0, 1.0, 0.0]]

@mkeilman
Copy link
Contributor Author

Oh, for goodness sake. @Benbenbenin0 does that info help?

@Benbenbenin0
Copy link
Contributor

Yup, feature works...
Thank you @cchall

@mkeilman
Copy link
Contributor Author

All sub-tasks completed

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

No branches or pull requests

4 participants