From 7f819d92ee762bfeb33035bdfe8cfcb3a5f7b85f Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 31 Oct 2026 20:27:52 +0100 Subject: [PATCH] mcdisplay: filled surfaces at --trace=2 for Monochromator components Replace closed multiline/rectangle outlines with polygon() facets, so --trace=2 shows surfaces; --trace=1 keeps outlines. Monochromator_flat, Monochromator_curved, Monochromator_2foc, Monochromator_pol (slab quads), Monochromator_bent and Monochromator_bent_complex (inner/outer/top/bottom faces per arc segment plus end caps; draw_as_rectangles keeps box()). Display only, no change to simulation results. Co-Authored-By: Claude Opus 5.5 --- mcstas-comps/contrib/Monochromator_2foc.comp | 3 +-- mcstas-comps/contrib/Monochromator_bent.comp | 21 ++++++++----------- .../contrib/Monochromator_bent_complex.comp | 21 ++++++++----------- mcstas-comps/optics/Monochromator_curved.comp | 3 +-- mcstas-comps/optics/Monochromator_flat.comp | 3 +-- mcstas-comps/optics/Monochromator_pol.comp | 2 +- 6 files changed, 22 insertions(+), 31 deletions(-) diff --git a/mcstas-comps/contrib/Monochromator_2foc.comp b/mcstas-comps/contrib/Monochromator_2foc.comp index 5fdcb60f7b..9013ecf5c5 100644 --- a/mcstas-comps/contrib/Monochromator_2foc.comp +++ b/mcstas-comps/contrib/Monochromator_2foc.comp @@ -321,8 +321,7 @@ MCDISPLAY yt = 0; yt1 = 0; } - multiline (5, xt + yt, (double)ymin, (double)zmin, xt + yt1, (double)ymax, (double)zmin, xt1 + yt1, (double)ymax, (double)zmax, xt1 + yt, (double)ymin, - (double)zmax, xt + yt, (double)ymin, (double)zmin); + polygon (4, xt + yt, (double)ymin, (double)zmin, xt + yt1, (double)ymax, (double)zmin, xt1 + yt1, (double)ymax, (double)zmax, xt1 + yt, (double)ymin, (double)zmax); } } %} diff --git a/mcstas-comps/contrib/Monochromator_bent.comp b/mcstas-comps/contrib/Monochromator_bent.comp index 9a1e12a30f..72bf0bcbee 100755 --- a/mcstas-comps/contrib/Monochromator_bent.comp +++ b/mcstas-comps/contrib/Monochromator_bent.comp @@ -1640,19 +1640,16 @@ MCDISPLAY // These 8 coordinates define 8 points. Coordinate transform these // to the current crystal rotate_all_points (&x_inner[0], &x_outer[0], &x_inner[1], &x_outer[1], &y_top, &y_bottom, &z_inner[0], &z_outer[0], &z_inner[1], &z_outer[1], points, mono); - // Draw a box in th xy plane - multiline (5, points[0][0], points[0][1], points[0][2], points[2][0], points[2][1], points[2][2], points[3][0], points[3][1], points[3][2], points[1][0], - points[1][1], points[1][2], points[0][0], points[0][1], points[0][2]); - - // Draw curving parts of crystal in the zx plane - line (points[0][0], points[0][1], points[0][2], points[4][0], points[4][1], points[4][2]); - line (points[1][0], points[1][1], points[1][2], points[5][0], points[5][1], points[5][2]); - line (points[2][0], points[2][1], points[2][2], points[6][0], points[6][1], points[6][2]); - line (points[3][0], points[3][1], points[3][2], points[7][0], points[7][1], points[7][2]); + // Start cap, then inner, outer, top and bottom faces of this segment + if (i == 0) + polygon (4, points[0][0], points[0][1], points[0][2], points[2][0], points[2][1], points[2][2], points[3][0], points[3][1], points[3][2], points[1][0], points[1][1], points[1][2]); + polygon (4, points[0][0], points[0][1], points[0][2], points[1][0], points[1][1], points[1][2], points[5][0], points[5][1], points[5][2], points[4][0], points[4][1], points[4][2]); + polygon (4, points[2][0], points[2][1], points[2][2], points[3][0], points[3][1], points[3][2], points[7][0], points[7][1], points[7][2], points[6][0], points[6][1], points[6][2]); + polygon (4, points[0][0], points[0][1], points[0][2], points[2][0], points[2][1], points[2][2], points[6][0], points[6][1], points[6][2], points[4][0], points[4][1], points[4][2]); + polygon (4, points[1][0], points[1][1], points[1][2], points[3][0], points[3][1], points[3][2], points[7][0], points[7][1], points[7][2], points[5][0], points[5][1], points[5][2]); } - // Draw a final box in the xy plane - multiline (5, points[4][0], points[4][1], points[4][2], points[6][0], points[6][1], points[6][2], points[7][0], points[7][1], points[7][2], points[5][0], - points[5][1], points[5][2], points[4][0], points[4][1], points[4][2]); + // End cap + polygon (4, points[4][0], points[4][1], points[4][2], points[6][0], points[6][1], points[6][2], points[7][0], points[7][1], points[7][2], points[5][0], points[5][1], points[5][2]); } // line(0,0,0, diff --git a/mcstas-comps/contrib/Monochromator_bent_complex.comp b/mcstas-comps/contrib/Monochromator_bent_complex.comp index 4cee0f1fa0..1d9af0ae61 100755 --- a/mcstas-comps/contrib/Monochromator_bent_complex.comp +++ b/mcstas-comps/contrib/Monochromator_bent_complex.comp @@ -341,19 +341,16 @@ MCDISPLAY // These 8 coordinates define 8 points. Coordinate transform these // to the current crystal rotate_all_points (&x_inner[0], &x_outer[0], &x_inner[1], &x_outer[1], &y_top, &y_bottom, &z_inner[0], &z_outer[0], &z_inner[1], &z_outer[1], points, mono); - // Draw a box in th xy plane - multiline (5, points[0][0], points[0][1], points[0][2], points[2][0], points[2][1], points[2][2], points[3][0], points[3][1], points[3][2], points[1][0], - points[1][1], points[1][2], points[0][0], points[0][1], points[0][2]); - - // Draw curving parts of crystal in the zx plane - line (points[0][0], points[0][1], points[0][2], points[4][0], points[4][1], points[4][2]); - line (points[1][0], points[1][1], points[1][2], points[5][0], points[5][1], points[5][2]); - line (points[2][0], points[2][1], points[2][2], points[6][0], points[6][1], points[6][2]); - line (points[3][0], points[3][1], points[3][2], points[7][0], points[7][1], points[7][2]); + // Start cap, then inner, outer, top and bottom faces of this segment + if (i == 0) + polygon (4, points[0][0], points[0][1], points[0][2], points[2][0], points[2][1], points[2][2], points[3][0], points[3][1], points[3][2], points[1][0], points[1][1], points[1][2]); + polygon (4, points[0][0], points[0][1], points[0][2], points[1][0], points[1][1], points[1][2], points[5][0], points[5][1], points[5][2], points[4][0], points[4][1], points[4][2]); + polygon (4, points[2][0], points[2][1], points[2][2], points[3][0], points[3][1], points[3][2], points[7][0], points[7][1], points[7][2], points[6][0], points[6][1], points[6][2]); + polygon (4, points[0][0], points[0][1], points[0][2], points[2][0], points[2][1], points[2][2], points[6][0], points[6][1], points[6][2], points[4][0], points[4][1], points[4][2]); + polygon (4, points[1][0], points[1][1], points[1][2], points[3][0], points[3][1], points[3][2], points[7][0], points[7][1], points[7][2], points[5][0], points[5][1], points[5][2]); } - // Draw a final box in the xy plane - multiline (5, points[4][0], points[4][1], points[4][2], points[6][0], points[6][1], points[6][2], points[7][0], points[7][1], points[7][2], points[5][0], - points[5][1], points[5][2], points[4][0], points[4][1], points[4][2]); + // End cap + polygon (4, points[4][0], points[4][1], points[4][2], points[6][0], points[6][1], points[6][2], points[7][0], points[7][1], points[7][2], points[5][0], points[5][1], points[5][2]); } // line(0,0,0, diff --git a/mcstas-comps/optics/Monochromator_curved.comp b/mcstas-comps/optics/Monochromator_curved.comp index ca915a02af..caa4d51ea9 100644 --- a/mcstas-comps/optics/Monochromator_curved.comp +++ b/mcstas-comps/optics/Monochromator_curved.comp @@ -531,8 +531,7 @@ MCDISPLAY yt = -(ymax * ymax - ymin * ymin) / RV / 2; else yt = 0; - multiline (5, xt + yt, (double)ymin, (double)zmin, xt - yt, (double)ymax, (double)zmin, -xt - yt, (double)ymax, (double)zmax, -xt + yt, (double)ymin, - (double)zmax, xt + yt, (double)ymin, (double)zmin); + polygon (4, xt + yt, (double)ymin, (double)zmin, xt - yt, (double)ymax, (double)zmin, -xt - yt, (double)ymax, (double)zmax, -xt + yt, (double)ymin, (double)zmax); } } %} diff --git a/mcstas-comps/optics/Monochromator_flat.comp b/mcstas-comps/optics/Monochromator_flat.comp index 9bcf77bb5e..636d817c39 100644 --- a/mcstas-comps/optics/Monochromator_flat.comp +++ b/mcstas-comps/optics/Monochromator_flat.comp @@ -251,8 +251,7 @@ TRACE MCDISPLAY %{ - multiline (5, 0.0, (double)ymin, (double)zmin, 0.0, (double)ymax, (double)zmin, 0.0, (double)ymax, (double)zmax, 0.0, (double)ymin, (double)zmax, 0.0, - (double)ymin, (double)zmin); + polygon (4, 0.0, (double)ymin, (double)zmin, 0.0, (double)ymax, (double)zmin, 0.0, (double)ymax, (double)zmax, 0.0, (double)ymin, (double)zmax); %} END diff --git a/mcstas-comps/optics/Monochromator_pol.comp b/mcstas-comps/optics/Monochromator_pol.comp index e9bba37897..eb28cd251a 100644 --- a/mcstas-comps/optics/Monochromator_pol.comp +++ b/mcstas-comps/optics/Monochromator_pol.comp @@ -200,7 +200,7 @@ TRACE MCDISPLAY %{ - rectangle ("yz", 0, 0, 0, zwidth, yheight); + polygon (4, 0.0, -yheight / 2, -zwidth / 2, 0.0, -yheight / 2, zwidth / 2, 0.0, yheight / 2, zwidth / 2, 0.0, yheight / 2, -zwidth / 2); %} END