File: Shape.comp

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (109 lines) | stat: -rw-r--r-- 3,562 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*******************************************************************************
*
* McXtrace, x-ray tracing package
*         Copyright, All rights reserved
*         DTU Physics, Kgs. Lyngby, Denmark
*         Synchrotron SOLEIL, Saint-Aubin, France
*
* Component: Shape
*
* %Identification
* Written by: E. Farhi
* Date: June 23rd 2009
* Origin: ILL
* Modified by: E. Farhi, based on Incoherent
*
* A geometric shape without effect on X-raysX, for instrument display purpose.
*
* %Description
* An inactive geometrical shape, for drawing purposes only.
* It does not propagate X-rays, nor interact.
* <b>Shape:</b>
* Geometric shape may be a cylinder, a sphere, a box or any other shape
*   box/plate:       xwidth x yheight x zdepth (thickness=0)
*   hollow box/plate:xwidth x yheight x zdepth and thickness>0
*   cylinder:        radius x yheight (thickness=0)
*   hollow cylinder: radius x yheight and thickness>0
*   sphere:          radius (yheight=0 thickness=0)
*   hollow sphere:   radius and thickness>0 (yheight=0)
*   any shape:       geometry=OFF file
*
*   The complex geometry option handles any closed non-convex polyhedra.
*   It computes the intersection points of the X ray with the object
*   transparently, so that it can be used like a regular sample object.
*   It supports the OFF and NOFF file format but not COFF (colored faces).
*   Such files may be generated from XYZ data using qhull/powercrust, and
*   viewed with geomview
*   The default size of the object depends of the OFF file data, but its
*   bounding box may be resized using xwidth,yheight and zdepth.
*
* Example: Shape(radius=0.05, yheight=0.1)
*          Shape(geometry="socket.off")
*
* %Parameters
* INPUT PARAMETERS:
* radius: [m]      Outer radius of sample in (x,z) plane 
* xwidth: [m]      Horiz. dimension of sample (bounding box if off file), as a width 
* yheight: [m]     Vert.  dimension of sample (bounding box if off file), as a height. A sphere shape is used when 0 and radius is set 
* zdepth: [m]      Depth of sample (bounding box if off file) 
* thickness: [m]   Thickness of hollow sample 
* geometry: [str]  Name of an Object File Format (OFF) file for complex geometry. The OFF file may be generated from XYZ coordinates using qhull/powercrust 
* center: [1]      Flag to determine if OFF object is centered on its centre of mass.
*
* %Link
* Geomview and Object File Format (OFF) <http|://www.geomview.org>
* %Link
* Powercrust/qhull <http://www.cs.utexas.edu/users/amenta/powercrust>
*
* %End
*******************************************************************************/

DEFINE COMPONENT Shape

SETTING PARAMETERS (string geometry=0, radius=0, xwidth=0, yheight=0, zdepth=0, thickness=0, int center=1)


SHARE
%{
%include "read_table-lib"
%include "interoff-lib"

#ifndef SHAPES_T
#define SHAPES_T
enum shapes_t {NONE=-1,SPHERE, CYLINDER, CUBE, ELLIPSOID, ANY};
#endif
%}

DECLARE
%{
off_struct offdata;
int shape;
%}

INITIALIZE
%{
/*if geometry is specified - try to read the off/ply file and set shape*/
  if (geometry && strlen(geometry) && strcmp(geometry, "NULL") && strcmp(geometry, "0")) {
    if (off_init(geometry, xwidth, yheight, zdepth, 0, &(offdata)))
      shape=ANY; 
  } else if (radius && yheight){
    shape=CYLINDER;
  } else if (radius){
    shape=SPHERE;
  } else if (xwidth && yheight && zdepth){
    shape=CUBE;
  } else {
    fprintf(stderr,"Error (%s): Filter has zero effective volume\n",NAME_CURRENT_COMP);
    exit(-1);
  }
  
%}


TRACE %{
  /* component Shape does nothing */
%}

MCDISPLAY COPY Filter

END