Skip to content

Commit

Permalink
Merge pull request #1623 from willend/main
Browse files Browse the repository at this point in the history
More work on visualisation
  • Loading branch information
willend authored Jun 6, 2024
2 parents 92a8b3f + d3620ad commit befc545
Show file tree
Hide file tree
Showing 60 changed files with 94 additions and 134 deletions.
38 changes: 24 additions & 14 deletions common/lib/share/mccode-r.c
Original file line number Diff line number Diff line change
Expand Up @@ -2601,18 +2601,10 @@ void mcdis_Circle(double x, double y, double z, double r, double nx, double ny,
}
}

/* NEW 3D IMPLEMENTATION OF BOX SUPPORTS HOLLOW ALSO
draws a box with center at (x, y, z) and
width (deltax), height (deltay), length (deltaz) */
void mcdis_new_box(double x, double y, double z,
double width, double height, double length, double thickness){
printf("MCDISPLAY: box(%g,%g,%g,%g,%g,%g,%g)\n", x, y, z, width, height, length, thickness);
}

/* OLD IMPLEMENTATION
draws a box with center at (x, y, z) and
width (deltax), height (deltay), length (deltaz) */
void mcdis_box(double x, double y, double z,
void mcdis_legacy_box(double x, double y, double z,
double width, double height, double length){

mcdis_rectangle("xy", x, y, z-length/2, width, height);
Expand All @@ -2627,12 +2619,25 @@ void mcdis_box(double x, double y, double z,
x+width/2, y+height/2, z+length/2);
}

/* NEW 3D IMPLEMENTATION OF BOX SUPPORTS HOLLOW ALSO
draws a box with center at (x, y, z) and
width (deltax), height (deltay), length (deltaz) */
void mcdis_box(double x, double y, double z,
double width, double height, double length, double thickness){
if (mcdotrace==2) {
printf("MCDISPLAY: box(%g,%g,%g,%g,%g,%g,%g)\n", x, y, z, width, height, length, thickness);
} else {
mcdis_legacy_box(x, y, z, width, height, length);
if (thickness)
mcdis_legacy_box(x, y, z, width-thickness, height-thickness, length);
}
}


/* OLD IMPLEMENTATION
Draws a cylinder with center at (x,y,z) with extent (r,height).
* The cylinder axis is along the vector nx,ny,nz.
* After converting comps to 3D implementation remove this*/
void mcdis_cylinder( double x, double y, double z,
* The cylinder axis is along the vector nx,ny,nz. */
void mcdis_legacy_cylinder( double x, double y, double z,
double r, double height, int N, double nx, double ny, double nz){
int i;
/*no lines make little sense - so trigger the default*/
Expand Down Expand Up @@ -2663,10 +2668,15 @@ void mcdis_cylinder( double x, double y, double z,
/* NEW 3D IMPLEMENTATION ALSO SUPPORTING HOLLOW
Draws a cylinder with center at (x,y,z) with extent (r,height).
* The cylinder axis is along the vector nx,ny,nz.*/
void mcdis_new_cylinder( double x, double y, double z,
double r, double height, double thickness, double t, double nx, double ny, double nz){
void mcdis_cylinder( double x, double y, double z,
double r, double height, double thickness, double nx, double ny, double nz){
if (mcdotrace==2) {
printf("MCDISPLAY: cylinder(%g, %g, %g, %g, %g, %g, %g, %g, %g)\n",
x, y, z, r, height, thickness, nx, ny, nz);
} else {
mcdis_legacy_cylinder(x, y, z,
r, height, 12, nx, ny, nz);
}
}

/* Draws a cone with center at (x,y,z) with extent (r,height).
Expand Down
4 changes: 2 additions & 2 deletions common/lib/share/mccode-r.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,11 @@ void mcdis_multiline(int count, ...);
void mcdis_rectangle(char* plane, double x, double y, double z,
double width, double height);
void mcdis_box(double x, double y, double z,
double width, double height, double length);
double width, double height, double length, double thickness);
void mcdis_circle(char *plane, double x, double y, double z, double r);
void mcdis_Circle(double x, double y, double z, double r, double nx, double ny, double nz);
void mcdis_cylinder( double x, double y, double z,
double r, double height, int N, double nx, double ny, double nz);
double r, double height, double thickness, double nx, double ny, double nz);
void mcdis_cone( double x, double y, double z,
double r, double height, double nx, double ny, double nz);
void mcdis_sphere(double x, double y, double z, double r);
Expand Down
4 changes: 2 additions & 2 deletions mcstas-comps/contrib/Foil_flipper_magnet.comp
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ MCDISPLAY
%{
double y=atan(phi)*zdepth/2.0;

box(0.0,0.0,0.0,Bxwidth,Byheight,Bzdepth);
box(0.0,0.0,0.0,Bxwidth,Byheight,Bzdepth,0);
if (Bxwidth!=xwidth || Byheight!=yheight || Bzdepth!=zdepth){
box(0,0,0,xwidth,yheight,zdepth);
box(0,0,0,xwidth,yheight,zdepth,0);
}
/*draw the foil plane*/
multiline(5,-xwidth/2.0,-y,-zdepth/2.0, xwidth/2.0,-y,-zdepth/2.0, xwidth/2.0,y,zdepth/2.0, -xwidth/2.0,y,zdepth/2.0, -xwidth/2.0,-y,-zdepth/2.0);
Expand Down
9 changes: 0 additions & 9 deletions mcstas-comps/contrib/Guide_anyshape_r.comp
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,6 @@ MCDISPLAY
%{
/* display the object */
r_off_display(offdata);
/* and its bounding box */
/*
mcdis_box(( offdata.xmin+offdata.xmax)/2,
( offdata.ymin+offdata.ymax)/2,
( offdata.zmin+offdata.zmax)/2,
(-offdata.xmin+offdata.xmax),
(-offdata.ymin+offdata.ymax),
(-offdata.zmin+offdata.zmax));
*/
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/Multilayer_Sample.comp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,6 @@ TRACE

MCDISPLAY
%{
box(0.0, (double)-ythick/2.0, 0.0, (double)xwidth, (double)ythick, (double)zlength);
box(0.0, (double)-ythick/2.0, 0.0, (double)xwidth, (double)ythick, (double)zlength,0);
%}
END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/NCrystal_sample.comp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ MCDISPLAY
mcdis_line(0, -geoparams.dy/2.0, +geoparams.rradius, 0, +geoparams.dy/2.0, +geoparams.rradius);
break;
case NC_BOX:
mcdis_box(0., 0., 0., geoparams.dx, geoparams.dy, geoparams.dz);
mcdis_box(0., 0., 0., geoparams.dx, geoparams.dy, geoparams.dz,0);
break;
case NC_SPHERE:
mcdis_circle("xy", 0., 0., 0., geoparams.rradius);
Expand Down
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/Pol_pi_2_rotator.comp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TRACE
MCDISPLAY
%{
box((double) 0.0,(double) 0.0,(double) 0.0,
(double)xwidth,(double)yheight,(double)zdepth);
(double)xwidth,(double)yheight,(double)zdepth,0);

%}
END
4 changes: 2 additions & 2 deletions mcstas-comps/contrib/Pol_triafield.comp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ MCDISPLAY
%{


box(0, 0, 0, xwidth, yheight, zdepth);
%}
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SANSCurve.comp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ TRACE

MCDISPLAY
%{
box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SANSCylinders.comp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ TRACE

MCDISPLAY
%{
box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SANSEllipticCylinders.comp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ TRACE

MCDISPLAY
%{
box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SANSLiposomes.comp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ TRACE

MCDISPLAY
%{
box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SANSNanodiscs.comp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ TRACE
MCDISPLAY
%{

box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
3 changes: 1 addition & 2 deletions mcstas-comps/contrib/SANSNanodiscsFast.comp
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ TRACE

MCDISPLAY
%{

box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SANSNanodiscsWithTags.comp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ TRACE
MCDISPLAY
%{

box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
3 changes: 1 addition & 2 deletions mcstas-comps/contrib/SANSNanodiscsWithTagsFast.comp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ TRACE

MCDISPLAY
%{

box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
3 changes: 1 addition & 2 deletions mcstas-comps/contrib/SANSPDB.comp
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,7 @@ TRACE

MCDISPLAY
%{

box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SANSPDBFast.comp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ TRACE
MCDISPLAY
%{

box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SANSShells.comp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ TRACE
MCDISPLAY
%{

box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
3 changes: 1 addition & 2 deletions mcstas-comps/contrib/SANSSpheres.comp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ TRACE

MCDISPLAY
%{

box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
3 changes: 1 addition & 2 deletions mcstas-comps/contrib/SANSSpheresPolydisperse.comp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ TRACE

MCDISPLAY
%{
magnify("xyz");
box(0, 0, 0, xwidth, yheight, zdepth);
box(0, 0, 0, xwidth, yheight, zdepth,0);
%}

END
5 changes: 2 additions & 3 deletions mcstas-comps/misc/Shape_simple.comp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ MCDISPLAY
off_display(offdata);
}
else if (radius > 0 && yheight) { /* cylinder */
cylinder(0,0,0,radius,yheight,0, 0,1,0);
cylinder(0,0,0,radius-thickness,yheight,0, 0,1,0);
cylinder(0,0,0,radius,yheight,thickness, 0,1,0);
}
else if (xwidth && yheight) { /* box/rectangle XY */
box(0,0,0,xwidth, yheight, zdepth);
box(0,0,0,xwidth, yheight, zdepth,0);
}
else if (radius > 0 && !yheight) { /* sphere */
sphere(0,0,0,radius);
Expand Down
2 changes: 1 addition & 1 deletion mcstas-comps/obsolete/Virtual_input.comp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ FINALLY
MCDISPLAY
%{
if (verbose) {
mcdis_box(mean_x, mean_y, mean_z, max_x-min_x, max_y-min_y, max_z-min_z);
box(mean_x, mean_y, mean_z, max_x-min_x, max_y-min_y, max_z-min_z,0);
/* a line in the main beam direction */
line(mean_x, mean_y, mean_z,mean_dx,mean_dy,mean_dz);
}
Expand Down
2 changes: 1 addition & 1 deletion mcstas-comps/obsolete/Virtual_mcnp_input.comp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ MCDISPLAY
if (do_translate) nx=ny=nz=0;
if (do_rotate) { dx=dy=0; dz=.1; }

mcdis_box(nx,ny,nz, max_x-min_x, max_y-min_y, max_z-min_z);
box(nx,ny,nz, max_x-min_x, max_y-min_y, max_z-min_z,0);
line( nx,ny,nz, dx,dy,dz);

%}
Expand Down
3 changes: 1 addition & 2 deletions mcstas-comps/optics/Absorber.comp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ TRACE

MCDISPLAY
%{

box(xm, ym, zm, xw, yh, zt);
box(xm, ym, zm, xw, yh, zt,0);
%}

END
9 changes: 0 additions & 9 deletions mcstas-comps/optics/Guide_anyshape.comp
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,6 @@ MCDISPLAY
%{
/* display the object */
off_display(offdata);
/* and its bounding box */
/*
mcdis_box(( offdata.xmin+offdata.xmax)/2,
( offdata.ymin+offdata.ymax)/2,
( offdata.zmin+offdata.zmax)/2,
(-offdata.xmin+offdata.xmax),
(-offdata.ymin+offdata.ymax),
(-offdata.zmin+offdata.zmax));
*/
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/optics/Pol_Bfield.comp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ MCDISPLAY
enum shapes {NONE=0, BOX, WINDOW, CYLINDER, SPHERE, ANY};
switch (shape){
case BOX:
box(0,0,0,xwidth,yheight,zdepth);
box(0,0,0,xwidth,yheight,zdepth,0);
break;
case CYLINDER:
circle("xz",0, yheight/2.0,0,radius);
Expand Down
6 changes: 3 additions & 3 deletions mcstas-comps/optics/Pol_SF_ideal.comp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ TRACE

MCDISPLAY
%{
double dx=xwidth/16;
double dy=yheight/8;
double dx=xwidth/16;
double dy=yheight/8;

box(0,0,0,xwidth,yheight,zdepth);
box(0,0,0,xwidth,yheight,zdepth,0);

line(dx,-dy,0,dx,-dy+yheight/2.0,0);
line(-dx,dy,0,-dx,dy-yheight/2.0,0);
Expand Down
2 changes: 1 addition & 1 deletion mcstas-comps/optics/Pol_constBfield.comp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ TRACE

MCDISPLAY
%{
box(0, 0, zdepth/2, xwidth, yheight, zdepth);
box(0, 0, zdepth/2, xwidth, yheight, zdepth,0);
%}

END
2 changes: 1 addition & 1 deletion mcstas-comps/optics/Pol_guide_mirror.comp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ MCDISPLAY
%{
int i, j;
// draw box
box(0, 0, length/2.0, xwidth, yheight, length);
box(0, 0, length/2.0, xwidth, yheight, length,0);

for(j = -1; j<=1; j+=2){
line(-xwidth/2.0, j*yheight/2, 0, xwidth/2.0, j*yheight/2, length);
Expand Down
2 changes: 1 addition & 1 deletion mcstas-comps/optics/Pol_guide_vmirror.comp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ MCDISPLAY
double dx = xwidth/(2*nvs);

// draw box
box(0, 0, length/2.0, xwidth, yheight, length);
box(0, 0, length/2.0, xwidth, yheight, length,0);

for(i = -nvs; i<=nvs; i+=2)
for(j = -1; j<=1; j+=2) {
Expand Down
Loading

0 comments on commit befc545

Please sign in to comment.