Skip to content

2026 10 farhi mcdisplay cad more outputs - #2824

Open
farhi wants to merge 9 commits into
mainfrom
2026-10-farhi-mcdisplay-cad-more-outputs
Open

farhi wants to merge 9 commits into
mainfrom
2026-10-farhi-mcdisplay-cad-more-outputs

Conversation

@farhi

@farhi farhi commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Rewrite of mcdisplay-cad: more formats, no cadquery/opencascade dependency

This is a full rewrite of the mcdisplay-cad 3D model export tool.

Why ? The existing tool requires python-cadquery and opencascade, which makes its installation more complex on some systems. The wish for this PR was to bring a fully standalone implementation, with more output formats.

It now provides export in the following formats:

  • STEP, STL, VRML, GLTF, GLB, OBJ, PLY, XML/X3D, VTK and VTKJS

The old cad export supported 'step', 'stl', 'xml/x3d', 'vrml', 'gltf', 'vtkjs'. So we have added GLB, VTK, PLY, VTK and OBJ.

All formats include color cycling except STL and legacy VTK (which do not support it).
The PLY format may fail showing colors with some viewers. The GLB format is selected as default (compact format).

All exports have been tested with castle-model-viewer (replaces view3dscene) and Blender, except STEP, which format is not supported by usual viewers (f3d, meshlab, blender, etc).

The code is larger than before, but I think this is a valuable investment in terms of portability (no depends) and usability (more formats).


Declaration of use of AI-tools

  • Please add a checkmark here if you used AI-tools during the work for this contribution
  • Furter, please describe how / where and for what the tools were used:

Development OS / boundary conditions

Please describe what OS you developed and tested your additions on, and if any special dependencies are required:

Developped under Debian 13 trixie/arm64.


PR Checklist for contributing to McStas/McXtrace

For a coherent and useful contribution to McStas/McXtrace, please fill in relevant parts of the checklist:

  • My contribution contains something else

    • Explanation is added in free form text above or below the checklist

@farhi
farhi force-pushed the 2026-10-farhi-mcdisplay-cad-more-outputs branch from ec403f1 to f3aa126 Compare October 18, 2026 14:00
Emmanuel FARHI and others added 5 commits October 18, 2026 23:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t, add --tubes

- run mcrun with --trace=2 so solid primitives (box/cylinder/cone/sphere/polyhedron) are emitted
- parse the MCDISPLAY polyhedron JSON (vertices + faces) instead of failing on it
- STEP: write #-references, CARTESIAN_POINT POLY_LOOPs in FACE_SURFACEs, complex SI units,
  REALs with decimal point, 7-field FILE_NAME (now reads cleanly in OpenCASCADE/FreeCAD)
- --tubes: draw lines as cylinders with corner spheres, as in the mcdisplay-plopp 3D view

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- with -n > 0, read the traced rays and export them as one grey 'rays' part
  (instrument coordinates) in every output format; --tubes applies to them too
- STEP: write REALs with 12 significant digits; at 6, short ray segments far
  from the origin collapsed into degenerate faces and OpenCASCADE dropped them
- --tubes help: note that tubed rays can make files very large

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willend

willend commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

@farhi I have

  • Removed the test-import of cadquery in the shellscript wrapper
  • Added support for --trace=2 (solids and meshes)
  • Fixed the STEP output
  • Added possibility of including rays (with n>0)
  • Allowed to draw lines as 'tubes' (some of the output formats have issues with lines)

@willend

willend commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

@g5t since the original tool is your contribution, can you have a look / test?

willend and others added 4 commits October 18, 2026 18:38
--trace=1 gives the legacy wireframe drawing; the help notes that STL may then
be empty and that many viewers ignore lines in OBJ/PLY (use --tubes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…heck

column_stack on the 2-D meshgrid arrays interleaved x/y/z across points, so
every sphere (e.g. the Text.comp stroke joints) came out as spikes in all
output formats. Flatten the grids first.

test_mcdisplay.py: assert-based check of the tessellated primitives (radii,
extents, closed surfaces, polyhedron JSON, tubes), as test_mcdisplopp.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ves)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants