Skip to content

Commit

Permalink
Fix #4972 Shape center and size not reflective of actual (#5143)
Browse files Browse the repository at this point in the history
* Fix #4848 - added svg for button

* Fix #4968 Allow importing binary STL files to Radia

Co-authored-by: mkeilman <mkeilman@radiasoft.net>
Co-authored-by: git-user <git-email>
Co-authored-by: Paul Moeller <moeller@radiasoft.net>
  • Loading branch information
3 people authored Nov 22, 2022
1 parent 24fe5c4 commit 6ecdf34
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
7 changes: 7 additions & 0 deletions sirepo/package_data/static/js/radia.js
Original file line number Diff line number Diff line change
Expand Up @@ -3894,9 +3894,16 @@ SIREPO.viewLogic('geomObjectView', function(appState, panelState, radiaService,
panelState.showField('geomObject', 'materialFile', o.material === 'custom');

panelState.enableField('geomObject', 'size', true);

if (o.type === 'stl') {
panelState.enableField('geomObject', 'size', false);
//TODO(BG): Only disables 'size' field, need to build shape to get sizes to update values (likely will need to send request since python)
}

if (o.type !== 'extrudedPoints') {
return;
}

for (const dim of [o.widthAxis, o.heightAxis]) {
panelState.enableArrayField(
'geomObject',
Expand Down
10 changes: 5 additions & 5 deletions sirepo/package_data/template/radia/geometryReport.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ def _add_object(o, radia_objs, id_map):
if t == _MODEL_STL:
g_id = radia_util.build_stl(
filename = o.get('file'),
#TODO(BG) Not currently reflective
center=ctr,
#TODO(BG) Not currently reflective
center=o.center,
centroid=o.stlCentroid,
size=sz,
vertices=o.stlVertices,
faces=o.stlFaces,
magnetization=m,
material=o.material,
rem_mag=o.remanentMag,
segments=segs, #TODO: Not implemented
segments=segs,
h_m_curve=o.h_m_curve,
#slices=o.stlSlices TODO: Not implemented
#TODO: Not implemented
#slices=o.stlSlices
)
if t in _OBJ_MODELS:
for b in o.get('bevels', []):
Expand Down
3 changes: 3 additions & 0 deletions sirepo/template/radia.py
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,7 @@ def _poly_area(pts):
size=[1.0, 1.0, 1.0],
stlVertices=[],
stlFaces=[],
stlCentroid=[],
# TODO(BG) Not implemented
# stlSlices = [],
)
Expand Down Expand Up @@ -1699,6 +1700,8 @@ def _poly_area(pts):
d.stlFaces.append(list(f))
o.stlVertices = d.stlVertices
o.stlFaces = d.stlFaces
o.size = list(mesh.bounding_box.primitive.extents)
o.stlCentroid = mesh.centroid.tolist()

# TODO(BG) Mesh slicing implementation, option for meshes with 400+ faces although will be approximation
"""
Expand Down
3 changes: 3 additions & 0 deletions sirepo/template/radia_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ def build_stl(**kwargs):
g_id = radia.ObjPolyhdr(
d.vertices, (numpy.array(d.faces) + 1).tolist(), d.magnetization
)
center = [x - d.centroid[i] for i, x in enumerate(d.center)]
radia.TrfOrnt(g_id, radia.TrfTrsl([center[0], center[1], center[2]]))
_apply_segments(g_id, d.segments)
radia.MatApl(g_id, _radia_material(d.material, d.rem_mag, d.h_m_curve))
return g_id

Expand Down

0 comments on commit 6ecdf34

Please sign in to comment.