| 16 | | * Object File Format intersection header for McStas. |
| | 16 | * Object File Format intersection header for McStas. Requires the qsort function. |
| | 17 | * |
| | 18 | * Such files may be obtained with e.g. |
| | 19 | * qhull < points.xyz Qx Qv Tv o > points.off |
| | 20 | * where points.xyz has format: |
| | 21 | * 3 |
| | 22 | * <nb_points> |
| | 23 | * <x> <y> <z> |
| | 24 | * ... |
| | 25 | * The resulting file should have its first line being changed from '3' into 'OFF'. |
| | 26 | * It can then be displayed with geomview. |
| | 27 | * A similar, but somewhat older solution is to use 'powercrust' with e.g. |
| | 28 | * powercrust -i points.xyz |
| | 29 | * which will generate a 'pc.off' file to be renamed as suited. |
| 63 | | #define F(x,y,z,A,B,C,D) ( (A)*(x) + (B)*(y) + (C)*(z) + (D) ) |
| 64 | | #ifndef sign |
| 65 | | #define sign(a) ( ((a)<0)?-1:((a)!=0) ) |
| 66 | | #endif |
| | 67 | /******************************************************************************* |
| | 68 | * long off_init( char *offfile, double xwidth, double yheight, double zdepth, off_struct* data) |
| | 69 | * ACTION: read an OFF file, optionally center object and rescale, initialize OFF data structure |
| | 70 | * INPUT: 'offfile' OFF file to read |
| | 71 | * 'xwidth,yheight,zdepth' if given as non-zero, apply bounding box. |
| | 72 | * Specifying only one of these will also use the same ratio on all axes |
| | 73 | * 'center' center the object to the (0,0,0) position in local frame when set to non-zero |
| | 74 | * RETURN: number of polyhedra and 'data' OFF structure |
| | 75 | *******************************************************************************/ |
| | 76 | long off_init( char *offfile, double xwidth, double yheight, double zdepth, |
| | 77 | int center, off_struct* data); |
| 68 | | long off_init(char*, double, double, double, off_struct*); |
| | 79 | /******************************************************************************* |
| | 80 | * int off_intersect(double* t0, double* t3, |
| | 81 | Coords *n0, Coords *n3, |
| | 82 | double x, double y, double z, |
| | 83 | double vx, double vy, double vz, |
| | 84 | off_struct data ) |
| | 85 | * ACTION: computes intersection of neutron trajectory with an object. |
| | 86 | * INPUT: x,y,z and vx,vy,vz are the position and velocity of the neutron |
| | 87 | * data points to the OFF data structure |
| | 88 | * RETURN: the number of polyhedra which trajectory intersects |
| | 89 | * t0 and t3 are the smallest incoming and outgoing intersection times |
| | 90 | * n0 and n3 are the corresponding normal vectors to the surface |
| | 91 | *******************************************************************************/ |
| | 92 | int off_intersect(double* t0, double* t3, |
| | 93 | Coords *n0, Coords *n3, |
| | 94 | double x, double y, double z, |
| | 95 | double vx, double vy, double vz, |
| | 96 | off_struct data ); |
| 70 | | int off_intersect(double*, double*, double, double, double, double, double, double, off_struct); |
| 71 | | |
| | 98 | /******************************************************************************* |
| | 99 | * void off_display(off_struct data) |
| | 100 | * ACTION: display up to N_VERTEX_DISPLAYED points from the object |
| | 101 | *******************************************************************************/ |