                      How to write xml file

One model of marker allows the user to define a region using a xml file.  All the grid cells inside this region will be refined recursively until a tolerance is met. 

The root element of the xml file is region. It's a complex type, its children can be the following element types: region, object and op.It describes the set opeartion on objects or regions. Therefor, The structure of region should make sense for set operation expression. For example, if op is binary, it should not appear as the first child of region. Two binary operators should not appear next to each other, etc. The recursive definition of region allow the priority of evaluation.
   
Example 1 for region:
<region>
<region>
...
</region>
<op>...</op>
<object>
...
</object>
</region>

Example 2 for region:
<region>
<object>
...
</object>
<op>...</op>
<region>
...
</region>
<op>...</op>
<object>
...
</object>
</region>

Example 3 for region:
<region>
<object>
...
</object>
</region>

Element op is a simple type, defines the set operations on objects and regions. The content of op can only be string, the value of the string can only be "intersection", "union", "difference" or "complement". Here are some examples:
 Example 1 for element op:
<op>union</op>

Example 2 for element op:
<op>difference</op>

Element object is also a complex type,its children can be element tranform followed by element shape or just an element shape. Here are examples for object:
Example 1 of object:
<object>
<transform>
...
</transform>
<shape>
...
</shape>
</object>

Example 2 for object:
<object>
<shape>
...
</shape>
</object>



Element  transform is a complex type, it defines the tranformation performed on the shape.  Its children can be the following elements: translate, scale, rotateX, rotateY, rotateZ. Each child element type can appear one or more times, and the children can appear in any order. Here are examples for transform:
Example 1 for transform:
<transform>
<translate>
...
</translate>
<scale>
...
</scale>
</transform>

Example 2 for transform:
<transform>
<rotateX>
...
<rotateX>
</transform>


Elements translate, scale, rotateX, rotateY, rotateZ are complex types, their children elements can by x0, y0, and z0, to defne a vector in 3d space, or element theta to define an angle in degree for rotation.  Elements x0, y0 and z0 and theta are simple types, their contents are restrictd to decimal type. Here are some examples:
Example 1 for translate:
<translate>
<x0>10.0</x0>
<y0>-2.0</y0>
<z0>20.0</z0>
</translate>

If one of the children is missing, the default value for it is 0

Example 2 for translate:
<translate>
<y0>-2.0</y0>
</translate>

Example 1 for scale:
<scale>
<x0>2.0</x0>
<y0>2.0</y0>
</scale>
The default value for the children of scale is 1.

Example 1 for rotateX:
<rotateX>
<theta>75.0</theta>
</rotateX>


Element shape is a complex type, its children can only  be one of the following: sphere, cone, cylinder, box, x_plus_plane, x_minus_plane, y_plus_plane, y_minus_plane, z_plus_plane,and  z_minus_plane.
Example 1 of shape:
<shape>
<sphere>
...
</sphere>
</shape>


The children of shape are paratype. A paratype is a complex type, it's used to specify a set of parameters. The parameters include the center of shape:(x0,y0, z0), of which the default value is (0, 0, 0), the radius r, the default value is 1. The bounding box value: (x1, y1, z1), (x1, y2, z2). The default value for (x1, y1, z1) is (0, 0, 0), the default value for (x2, y2, z2) is (1, 1, 1).
 
Element sphere specify a sphere of radius r with origion at (x0, y0, z0). The implicit equation for sphere is: (x-x0)*(x-x0)+(y-y0)*(y-y0)+(z-z0)*(z-z0)<=r*r.
Example 1 for sphere:
<sphere>
<x0>10.0</x0>
<y0>2.0</y0>
<z0>3.0</z0>
<r>5.0</r>
</sphere>
 
Example 2 for sphere:
<sphere>
</sphere>


The definition for cone is:
 (x-x0)*(x-x0) + (y-y0)*(y-y0) <=r*r* (z-z0)*(z-z0); z>=z1; z <=z2
Example 1 for cone:
<cone>
<x0>0.0</x0>
<y0>1.0</y0>
<z0>2.0</z0>
<r> 3.0</r>
<z1>2.0</z1>
<z2>5.0</z2>
</cone>

Example 2 for cone:
<cone>
<z1>-20.0</z1>
<z2>20.0</z2>
</cone>

The definition for cylinder is: (x-x0)*(x-x0) +(y-y0)*(y-y0) <= r*r; z>=z1; z<=z2
Example 1 for cylinder:
<cylinder>
<x0>0.0</x0>
<y0>1.0</y0>
<r> 3.0</r>
<z1>2.0</z1>
<z2>5.0</z2>
</cylinder>

Example 2 for cylinder:
<cylinder>
<r>5.0</r>
<z1>-20.0</z1>
<z2>20.0</z2>
</cylinder>

 
The definition for box is: x >= x1 && x <=x2 && y > y1 && y <=y2 && z> z1 && z <=z2
Example 1 for box:
<box>
<x1>-1.0</x1>
<x2> 3.0</x2>
<y1>-2.0</y1>
<y2>2.0</y2>
<z1>-2.0</z1>
<z2>5.0</z2>
</box>



Example 2 for box:
<box>
<z1>-20.0</z1>
<z2>20.0</z2>
</box>


The definition for x_plus_plane is: x >=x1, default value for x1 is 0
Example 1 for x+plane:
<x_plus_plane>
<x1>1.0</x1>
</x_plus_plane>

Example 2 for x_plus_plane:
<x_plus_plane>
</x_plus_plane>

The definition for x_minus_plane is: x <=x1, default value for x1 is 0
Example 1 for x_minus_plane:
<x_minus_plane>
<x1>1.0</x1>
</x_minus_plane>

Example 2 for x_minus_plane:
<x_minus_plane>
</x_minus_plane>

y_plus_plane, y_minus_plane, z_plus_plane, z_minus_plane are defined in the same way.











 


