<!-- ******************************************************** -->
<!--                                                          -->
<!--  [History]                                               -->
<!--    Converted to DocBook: Katsuya Amako, Aug-2006         -->
<!--    Changed by: Gabriele Cosmo, 18-Apr-2005               -->
<!--                                                          -->
<!-- ******************************************************** -->


<!-- ******************* Section (Level#2) ****************** -->
<sect2 id="sect.Geom.Solids">
<title>
Solids
</title>

<para>
The STEP standard supports multiple solid representations.
Constructive Solid Geometry (CSG) representations and Boundary
Represented Solids (BREPs) are available. Different representations
are suitable for different purposes, applications, required
complexity, and levels of detail. CSG representations are easy to
use and normally give superior performance, but they cannot
reproduce complex solids such as those used in CAD systems. BREP
representations can handle more extended topologies and reproduce
the most complex solids.
</para>

<para>
All constructed solids can stream out their contents via
appropriate methods and streaming operators.
</para>

<para>
For all solids it is possible to estimate the geometrical volume and the
surface area by invoking the methods:

<informalexample>
<programlisting>
   G4double GetCubicVolume()
   G4double GetSurfaceArea()
</programlisting>
</informalexample>

which return an estimate of the solid volume and total area in internal
units respectively. For elementary solids the functions compute the exact
geometrical quantities, while for composite or complex solids an estimate
is made using Monte Carlo techniques.
</para>

<para>
For all solids it is also possible to generate pseudo-random
points lying on their surfaces, by invoking the method

<informalexample>
<programlisting>
   G4ThreeVector GetPointOnSurface() const
</programlisting>
</informalexample>

which returns the generated point in local coordinates relative to
the solid.
</para>


<!-- ******************* Section (Level#3) ****************** -->
<sect3 id="sect.Geom.Solids.CSG">
<title>
Constructed Solid Geometry (CSG) Solids
</title>

<para>
CSG solids are defined directly as three-dimensional primitives.
They are described by a minimal set of parameters necessary to
define the shape and size of the solid. CSG solids are Boxes, Tubes
and their sections, Cones and their sections, Spheres, Wedges, and
Toruses.
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Box:
</bridgehead>

<para>  
To create a <emphasis role="bold">box</emphasis> one can use the constructor:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>
   G4Box(const G4String&amp; pName,                         
               G4double  pX,
               G4double  pY,
               G4double  pZ)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aBox.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aBox.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic1.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    pX = 30, pY = 40, pZ = 60                                                       
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
by giving the box a name and its half-lengths along the X, Y and
Z axis:
<informaltable pgwide="0">
<tgroup cols="6">
<tbody>
<row>
  <entry>
    <literal>pX</literal>
  </entry>
  <entry>
    half length in X
  </entry>
  <entry>
    <literal>pY</literal>
  </entry>
  <entry>
    half length in Y
  </entry>
  <entry>
    <literal>pZ</literal>
  </entry>
  <entry>
    half length in Z
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<para>
This will create a box that extends from <literal>-pX</literal> to
<literal>+pX</literal> in X, from <literal>-pY</literal> to 
<literal>+pY</literal> in Y, and from
<literal>-pZ</literal> to <literal>+pZ</literal> in Z.
</para>

<para>
For example to create a box that is 2 by 6 by 10 centimeters in
full length, and called <literal>BoxA</literal> one should use the following
code:
<informalexample>
<programlisting>  
   G4Box* aBox = new G4Box("BoxA", 1.0*cm, 3.0*cm, 5.0*cm);
</programlisting>
</informalexample>
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Cylindrical Section or Tube:
</bridgehead>

<para>  
Similarly to create a <emphasis role="bold">cylindrical section</emphasis> 
or <emphasis role="bold">tube</emphasis>, one would use the constructor:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Tubs(const G4String&amp; pName,                        
                G4double  pRMin,
                G4double  pRMax,
                G4double  pDz,
                G4double  pSPhi,
                G4double  pDPhi)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTubs.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTubs.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic2.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    pRMin = 10, pRMax = 15, pDz = 20
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
giving its name <literal>pName</literal> and its parameters which are:
<informaltable pgwide="0">
<tgroup cols="4">
<tbody>
<row>
  <entry>
    <literal>pRMin</literal>
  </entry>
  <entry>
    Inner radius
  </entry>
  <entry>
    <literal>pRMax</literal>
  </entry>
  <entry>
    Outer radius
  </entry>
</row>
<row>
  <entry>
    <literal>pDz</literal>
  </entry>
  <entry>
    half length in z
  </entry>
  <entry>
    <literal>pSPhi</literal>
  </entry>
  <entry>
    the starting phi angle in radians
  </entry>
</row>
<row>
  <entry>
    <literal>pDPhi</literal>
  </entry>
  <entry>
    the angle of the segment in radians
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Cone or Conical section:
</bridgehead>

<para>  
Similarly to create a <emphasis role="bold">cone</emphasis>, or
<emphasis role="bold">conical section</emphasis>, one would use the constructor

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Cons(const G4String&amp; pName,                        
                G4double  pRmin1,
                G4double  pRmax1,
                G4double  pRmin2,
                G4double  pRmax2,
                G4double  pDz,
                G4double  pSPhi,
                G4double  pDPhi)
    </programlisting>
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aCons.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aCons.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic3.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    pRmin1 = 5, pRmax1 = 10,
    pRmin2 = 20, pRmax2 = 25,
    pDz = 40, pSPhi = 0, pDPhi = 4/3*Pi
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
giving its name <literal>pName</literal>, and its parameters which are:
<informaltable pgwide="0">
<tgroup cols="4">
<tbody>
<row>
  <entry>
    <literal>pRmin1</literal>
  </entry>
  <entry>
    inside radius at <literal>-pDz</literal>
  </entry>
  <entry>
    <literal>pRmax1</literal>
  </entry>
  <entry>
    outside radius at <literal>-pDz</literal>
  </entry>
</row>
<row>
  <entry>
    <literal>pRmin2</literal>
  </entry>
  <entry>
    inside radius at <literal>+pDz</literal>
  </entry>
  <entry>
    <literal>pRmax2</literal>
  </entry>
  <entry>
    outside radius at <literal>+pDz</literal>
  </entry>
</row>
<row>
  <entry>
    <literal>pDz</literal>
  </entry>
  <entry>
    half length in z
  </entry>
  <entry>
    <literal>pSPhi</literal>
  </entry>
  <entry>
    starting angle of the segment in radians
  </entry>
</row>
<row>
  <entry>
    <literal>pDPhi</literal>
  </entry>
  <entry>
    the angle of the segment in radians
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Parallelepiped:
</bridgehead>

<para>  
A <emphasis role="bold">parallelepiped</emphasis> is constructed
using:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Para(const G4String&amp; pName,                                  
                G4double   dx,
                G4double   dy,
                G4double   dz,
                G4double   alpha,
                G4double   theta,
                G4double   phi)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aPara.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aPara.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic4.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    dx = 30, dy = 40, dz = 60
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
giving its name <literal>pName</literal> and its parameters which are:
<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>dx,dy,dz</literal>    
  </entry>
  <entry>
    Half-length in x,y,z
  </entry>
</row>
<row>
  <entry>
    <literal>alpha</literal>
  </entry>
  <entry>
    Angle formed by the y axis and by the plane joining the centre
    of the faces <emphasis>parallel</emphasis> to the z-x plane at -dy and +dy
  </entry>
</row>
<row>
  <entry>
    <literal>theta</literal>
  </entry>
  <entry>
    Polar angle of the line joining the centres of the faces at -dz
    and +dz in z
  </entry>
</row>
<row>
  <entry>
    <literal>phi</literal>
  </entry>
  <entry>
    Azimuthal angle of the line joining the centres of the faces at
    -dz and +dz in z
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Trapezoid:
</bridgehead>

<para>  
To construct a <emphasis role="bold">trapezoid</emphasis> use:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Trd(const G4String&amp; pName,                            
               G4double  dx1,
               G4double  dx2,
               G4double  dy1,
               G4double  dy2,
               G4double  dz)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTrd.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTrd.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic5.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    dx1 = 30, dx2 = 10, 
    dy1 = 40, dy2 = 15, 
    dz = 60
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
to obtain a solid with name <literal>pName</literal> and parameters

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>dx1</literal>
  </entry>
  <entry>
    Half-length along x at the surface positioned at <literal>-dz</literal>
  </entry>
</row>
<row>
  <entry>
    <literal>dx2</literal>
  </entry>
  <entry>
    Half-length along x at the surface positioned at <literal>+dz</literal>
  </entry>
</row>
<row>
  <entry>
    <literal>dy1</literal>
  </entry>
  <entry>
    Half-length along y at the surface positioned at <literal>-dz</literal>
  </entry>
</row>
<row>
  <entry>
    <literal>dy2</literal>
  </entry>
  <entry>
    Half-length along y at the surface positioned at <literal>+dz</literal>
  </entry>
</row>
<row>
  <entry>
    <literal>dz</literal>
  </entry>
  <entry>
    Half-length along z axis
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Generic Trapezoid:
</bridgehead>

<para>  
To build a <emphasis role="bold">generic trapezoid</emphasis>,
the <literal>G4Trap</literal> class is provided. Here are the two costructors
for a Right Angular Wedge and for the general trapezoid for it:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
 G4Trap(const G4String&amp; pName,                        
              G4double   pZ,
              G4double   pY,
              G4double   pX,
              G4double   pLTX)

 G4Trap(const G4String&amp; pName,                         
              G4double   pDz,   G4double   pTheta,
              G4double   pPhi,  G4double   pDy1,
              G4double   pDx1,  G4double   pDx2,
              G4double   pAlp1, G4double   pDy2,
              G4double   pDx3,  G4double   pDx4,
              G4double   pAlp2)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTrap.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTrap.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic6.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    pDx1 = 30, pDx2 = 40, pDy1 = 40,
    pDx3 = 10, pDx4 = 14, pDy2 = 16,
    pDz = 60, pTheta = 20*Degree,
    pPhi = 5*Degree, pAlp1 = pAlp2 = 10*Degree
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
to obtain a Right Angular Wedge with name <literal>pName</literal> and
parameters:
<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>pZ</literal>
  </entry>
  <entry>
    Length along z
  </entry>
</row>
<row>
  <entry>
    <literal>pY</literal>
  </entry>
  <entry>
    Length along y
  </entry>
</row>
<row>
  <entry>
    <literal>pX</literal>
  </entry>
  <entry>
    Length along x at the wider side
  </entry>
</row>
<row>
  <entry>
    <literal>pLTX</literal>
  </entry>
  <entry>
    Length along x at the narrower side (<literal>plTX&lt;=pX</literal>)
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
or to obtain the general trapezoid (see the Software Reference
Manual):
</para>
   
<para>
<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
   <literal>pDx1</literal> 
  </entry>
  <entry>
    Half x length of the side at y=-pDy1 of the face at -pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pDx2</literal>
  </entry>
  <entry>
    Half x length of the side at y=+pDy1 of the face at -pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pDz</literal>
  </entry>
  <entry>
    Half z length
  </entry>
</row>
<row>
  <entry>
    <literal>pTheta</literal>
  </entry>
  <entry>
    Polar angle of the line joining the centres of the faces at -/+pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pPhi</literal>
  </entry>
  <entry>
    Azimuthal angle of the line joining the centre of the face at -pDz to the centre of the face at +pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pDy1</literal>
  </entry>
  <entry>
    Half y length at -pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pDy2</literal>
  </entry>
  <entry>
    Half y length at +pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pDx3</literal>
  </entry>
  <entry>
    Half x length of the side at y=-pDy2 of the face at +pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pDx4</literal>
  </entry>
  <entry>
    Half x length of the side at y=+pDy2 of the face at +pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pAlp1</literal>
  </entry>
  <entry>
    Angle with respect to the y axis from the centre of the side
    (lower endcap)
  </entry>
</row>
<row>
  <entry>
    <literal>pAlp2</literal>
  </entry>
  <entry>
    Angle with respect to the y axis from the centre of the side
    (upper endcap)
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<para>
<emphasis role="bold">Note on <literal>pAlph1/2</literal></emphasis>: the
two angles have to be the
same due to the planarity condition.
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Sphere or Spherical Shell Section:
</bridgehead>

<para>  
To build a <emphasis role="bold">sphere</emphasis>, or a
<emphasis role="bold">spherical shell section</emphasis>, use:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Sphere(const G4String&amp; pName,                      
                  G4double   pRmin,
                  G4double   pRmax,
                  G4double   pSPhi,
                  G4double   pDPhi,
                  G4double   pSTheta,
                  G4double   pDTheta )
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aSphere.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aSphere.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic7.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
      pRmin = 100, pRmax = 120, 
      pSPhi = 0*Degree, pDPhi = 180*Degree,
      pSTheta = 0 Degree, pDTheta = 180*Degree
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
to obtain a solid with name <literal>pName</literal> and parameters:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    pRmin
  </entry>
  <entry>
    Inner radius
  </entry>
</row>
<row>
  <entry>
    pRmax
  </entry>
  <entry>
    Outer radius
  </entry>
</row>
<row>
  <entry>
    pSPhi
  </entry>
  <entry>
    Starting Phi angle of the segment in radians
  </entry>
</row>
<row>
  <entry>
    pDPhi
  </entry>
  <entry>
    Delta Phi angle of the segment in radians
  </entry>
</row>
<row>
  <entry>
    pSTheta
  </entry>
  <entry>
    Starting Theta angle of the segment in radians
  </entry>
</row>
<row>
  <entry>
    pDTheta
  </entry>
  <entry>
    Delta Theta angle of the segment in radians
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Full Solid Sphere:
</bridgehead>

<para>  
To build a <emphasis role="bold">full solid sphere</emphasis>
use:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Orb(const G4String&amp; pName,                                   
               G4double  pRmax)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aOrb.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aOrb.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic8.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
      pRmax = 100
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
The Orb can be obtained from a Sphere with:
<literal>pRmin</literal> = 0, <literal>pSPhi</literal> = 0, 
<literal>pDPhi</literal> = 2*Pi,
<literal>pSTheta</literal> = 0, <literal>pDTheta</literal> = Pi

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    pRmax
  </entry>
  <entry>
    Outer radius
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Torus:
</bridgehead>

<para>  
To build a <emphasis role="bold">torus</emphasis> use:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Torus(const G4String&amp; pName,                       
                 G4double   pRmin,
                 G4double   pRmax,
                 G4double   pRtor,
                 G4double   pSPhi,
                 G4double   pDPhi)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTorus.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTorus.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic9.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
      pRmin = 40, pRmax = 60, pRtor = 200,
      pSPhi = 0, pDPhi = 90*Degree
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
to obtain a solid with name <literal>pName</literal> and parameters:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    pRmin
  </entry>
  <entry>
    Inside radius
  </entry>
</row>
<row>
  <entry>
    pRmax
  </entry>
  <entry>
    Outside radius
  </entry>
</row>
<row>
  <entry>
    pRtor
  </entry>
  <entry>
    Swept radius of torus
  </entry>
</row>
<row>
  <entry>
    pSPhi
  </entry>
  <entry>
    Starting Phi angle in radians (<literal>fSPhi+fDPhi&lt;=2PI</literal>,
    <literal>fSPhi&gt;-2PI</literal>)
  </entry>
</row>
<row>
  <entry>
    pDPhi
  </entry>
  <entry>
    Delta angle of the segment in radians
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<para>
In addition, the Geant4 Design Documentation shows in the Solids
Class Diagram the complete list of CSG classes, and the STEP
documentation contains a detailed EXPRESS description of each CSG
solid.
</para>



<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect3'>
Specific CSG Solids
</bridgehead>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Polycons:
</bridgehead>

<para>  
<emphasis role="bold">Polycons</emphasis> (PCON) are implemented in Geant4 through the
<literal>G4Polycon</literal> class:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Polycone(const G4String&amp; pName,                    
                    G4double   phiStart,
                    G4double   phiTotal,
                    G4int      numZPlanes,
                    const G4double   zPlane[],
                    const G4double   rInner[],
                    const G4double   rOuter[])

   G4Polycone(const G4String&amp; pName,                      
                    G4double   phiStart,
                    G4double   phiTotal,
                    G4int      numRZ,
                    const G4double  r[],
                    const G4double  z[])
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aBREPSolidPCone.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aBREPSolidPCone.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic10.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
      phiStart = 1/4*Pi, phiTotal = 3/2*Pi, numZPlanes = 9,
      rInner = { 0, 0, 0, 0, 0, 0, 0, 0, 0},
      rOuter = { 0, 10, 10, 5 , 5, 10 , 10 , 2, 2},
      z = { 5, 7, 9, 11, 25, 27, 29, 31, 35 }
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
where:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    phiStart
  </entry>
  <entry>
    Initial Phi starting angle
  </entry>
</row>
<row>
  <entry>
    phiTotal
  </entry>
  <entry>
    Total Phi angle
  </entry>
</row>
<row>
  <entry>
    numZPlanes
  </entry>
  <entry>
    Number of z planes
  </entry>
</row>
<row>
  <entry>
    numRZ
  </entry>
  <entry>
    Number of corners in r,z space
  </entry>
</row>
<row>
  <entry>
    zPlane
  </entry>
  <entry>
    Position of z planes
  </entry>
</row>
<row>
  <entry>
    rInner
  </entry>
  <entry>
    Tangent distance to inner surface
  </entry>
</row>
<row>
  <entry>
    rOuter
  </entry>
  <entry>
    Tangent distance to outer surface
  </entry>
</row>
<row>
  <entry>
    r
  </entry>
  <entry>
    r coordinate of corners
  </entry>
</row>
<row>
  <entry>
    z
  </entry>
  <entry>
    z coordinate of corners
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Polyhedra (PGON):
</bridgehead>

<para>  
<emphasis role="bold">Polyhedra</emphasis> (PGON) are implemented through 
<literal>G4Polyhedra</literal>:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Polyhedra(const G4String&amp; pName,                   
                     G4double  phiStart,
                     G4double  phiTotal,
                     G4int     numSide,
                     G4int     numZPlanes,
               const G4double  zPlane[],
               const G4double  rInner[],
               const G4double  rOuter[] )

   G4Polyhedra(const G4String&amp; pName,
                     G4double  phiStart,
                     G4double  phiTotal,
                     G4int     numSide,
                     G4int     numRZ,
               const G4double  r[],
               const G4double  z[] )
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aBREPSolidPolyhedra.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aBREPSolidPolyhedra.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic11.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    phiStart = -1/4*Pi, phiTotal= 5/4*Pi, 
    numSide = 3, nunZPlanes = 7,
    rInner = { 0, 0, 0, 0, 0, 0, 0 },
    rOuter = { 0, 15, 15, 4, 4, 10, 10 },
    z = { 0, 5, 8, 13 , 30, 32, 35 }
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
where:
<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>phiStart</literal>
  </entry>
  <entry>
    Initial Phi starting angle
  </entry>
</row>
<row>
  <entry>
    <literal>phiTotal</literal>
  </entry>
  <entry>
    Total Phi angle
  </entry>
</row>
<row>
  <entry>
    <literal>numSide</literal>
  </entry>
  <entry>
    Number of sides
  </entry>
</row>
<row>
  <entry>
    <literal>numZPlanes</literal>
  </entry>
  <entry>
    Number of z planes
  </entry>
</row>
<row>
  <entry>
    <literal>numRZ</literal>
  </entry>
  <entry>
    Number of corners in r,z space
  </entry>
</row>
<row>
  <entry>
    zPlane
  </entry>
  <entry>
    Position of z planes
  </entry>
</row>
<row>
  <entry>
    <literal>rInner</literal>
  </entry>
  <entry>
    Tangent distance to inner surface
  </entry>
</row>
<row>
  <entry>
    rOuter
  </entry>
  <entry>
    Tangent distance to outer surface
  </entry>
</row>
<row>
  <entry>
    <literal>r</literal>
  </entry>
  <entry>
    r coordinate of corners
  </entry>
</row>
<row>
  <entry>
    <literal>z</literal>
  </entry>
  <entry>
    z coordinate of corners
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Tube with an elliptical cross section:
</bridgehead>

<para>  
A <emphasis role="bold">tube with an elliptical cross
section</emphasis> (ELTU) can be defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4EllipticalTube(const G4String&amp; pName,                   
                          G4double  Dx,
                          G4double  Dy,
                          G4double  Dz)
    </programlisting>  
    </informalexample>

    The equation of the surface in x/y is <literal>1.0 = (x/dx)**2 +(y/dy)**2</literal>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aEllipticalTube.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aEllipticalTube.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic12.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    Dx = 5, Dy = 10, Dz = 20
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
<informaltable pgwide="0">
<tgroup cols="6">
<tbody>
<row>
  <entry>
    Dx
  </entry>
  <entry>
    Half length X
  </entry>
  <entry>
    Dy
  </entry>
  <entry>
    Half length Y
  </entry>
  <entry>
    Dz
  </entry>
  <entry>
    Half length Z
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
General Ellipsoid:
</bridgehead>

<para>  
The general <emphasis role="bold">ellipsoid</emphasis> with
possible cut in <literal>Z</literal> can be defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Ellipsoid(const G4String&amp; pName,                   
                     G4double  pxSemiAxis,
                     G4double  pySemiAxis,
                     G4double  pzSemiAxis,
                     G4double  pzBottomCut=0,
                     G4double  pzTopCut=0)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aEllipsoid.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aEllipsoid.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic13.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    pxSemiAxis = 10, pySemiAxis = 20, pzSemiAxis = 50, 
    pzBottomCut = -10, pzTopCut = 40
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
A general (or triaxial) ellipsoid is a quadratic surface which is
given in Cartesian coordinates by:

<informalexample>
<programlisting>
   1.0 = (x/pxSemiAxis)**2 + (y/pySemiAxis)**2 + (z/pzSemiAxis)**2
</programlisting>
</informalexample>

where:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>pxSemiAxis</literal>
  </entry>
  <entry>
    Semiaxis in X
  </entry>
</row>
<row>
  <entry>
    pySemiAxis
  </entry>
  <entry>
    Semiaxis in Y
  </entry>
</row>
<row>
  <entry>
    pzSemiAxis
  </entry>
  <entry>
    Semiaxis in Z
  </entry>
</row>
<row>
  <entry>
    pzBottomCut
  </entry>
  <entry>
    lower cut plane level, z
  </entry>
</row>
<row>
  <entry>
    pzTopCut
  </entry>
  <entry>
    upper cut plane level, z
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Cone with Elliptical Cross Section:
</bridgehead>

<para>  
A <emphasis role="bold">cone with an elliptical cross section</emphasis> 
can be defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4EllipticalCone(const G4String&amp; pName,              
                          G4double  pxSemiAxis,
                          G4double  pySemiAxis,
                          G4double  zMax,
                          G4double  pzTopCut)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aEllipticalCone.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aEllipticalCone.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic14.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    pxSemiAxis = 30/75, pySemiAxis = 60/75, zMax = 50, pzTopCut = 25
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
where:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    pxSemiAxis
  </entry>
  <entry>
    Semiaxis in X
  </entry>
</row>
<row>
  <entry>
    pySemiAxis
  </entry>
  <entry>
    Semiaxis in Y
  </entry>
</row>
<row>
  <entry>
    zMax
  </entry>
  <entry>
    Height of elliptical cone
  </entry>
</row>
<row>
  <entry>
    pzTopCut
  </entry>
  <entry>
    upper cut plane level
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<para>
An elliptical cone of height <literal>zMax</literal>, semiaxis
<literal>pxSemiAxis</literal>, and semiaxis <literal>pySemiAxis</literal> 
is given by the parametric equations:

<informalexample>
<programlisting>  
   x = pxSemiAxis * ( zMax - u ) / u * Cos(v)
   y = pySemiAxis * ( zMax - u ) / u * Sin(v)
   z = u
</programlisting>
</informalexample>  

Where <literal>v</literal> is between <literal>0</literal> and 
<literal>2*Pi</literal>, and
<literal>u</literal> between <literal>0</literal> and 
<literal>h</literal> respectively.
</para>


<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Paraboloid, a solid with parabolic profile:
</bridgehead>

<para>  
A <emphasis role="bold">solid with parabolic profile</emphasis> and possible cuts along
the <literal>Z</literal> axis can be defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Paraboloid(const G4String&amp; pName,                   
                     G4double  Dz,
                     G4double  R1,
                     G4double  R2)
    </programlisting>  
    </informalexample>

    The equation for the solid is:
<informalexample>
<programlisting>  
   rho**2 &lt;= k1 * z + k2;
       -dz &lt;= z &lt;= dz
   r1**2 = k1 * (-dz) + k2
   r2**2 = k1 * ( dz) + k2
</programlisting>
</informalexample>  

  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aParaboloid.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aParaboloid.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic21.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    R1 = 20, R2 = 35, Dz = 20
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
<informaltable pgwide="0">
<tgroup cols="6">
<tbody>
<row>
  <entry>
    Dz
  </entry>
  <entry>
    Half length Z
  </entry>
  <entry>
    R1
  </entry>
  <entry>
    Radius at -Dz
  </entry>
  <entry>
    R2
  </entry>
  <entry>
    Radius at +Dz greater than R1
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Tube with Hyperbolic Profile:
</bridgehead>

<para>  
A <emphasis role="bold">tube with a hyperbolic
profile</emphasis> (HYPE) can be defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Hype(const G4String&amp; pName,                        
                G4double  innerRadius,
                G4double  outerRadius,
                G4double  innerStereo,
                G4double  outerStereo,
                G4double  halfLenZ)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aHyperboloid.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aHyperboloid.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic15.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    innerStereo = 0.7, outerStereo = 0.7,
    halfLenZ = 50,
    innerRadius = 20, outerRadius = 30
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
<literal>G4Hype</literal> is shaped with curved sides parallel to the
<literal>z</literal>-axis, has a specified half-length along the <literal>z</literal>
axis about which it is centred, and a given minimum and maximum
radius.
</para>

<para>
A minimum radius of <literal>0</literal> defines a filled Hype (with
hyperbolic inner surface), i.e. inner radius = 0 AND inner stereo
angle = 0.
</para>

<para>
The inner and outer hyperbolic surfaces can have different stereo
angles. A stereo angle of <literal>0</literal> gives a cylindrical
surface:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>innerRadius</literal>
  </entry>
  <entry>
    Inner radius
  </entry>
</row>
<row>
  <entry>
    <literal>outerRadius</literal>
  </entry>
  <entry>
    Outer radius
  </entry>
</row>
<row>
  <entry>
    <literal>innerStereo</literal>
  </entry>
  <entry>
    Inner stereo angle in radians
  </entry>
</row>
<row>
  <entry>
    <literal>outerStereo</literal>
  </entry>
  <entry>
    Outer stereo angle in radians
  </entry>
</row>
<row>
  <entry>
    <literal>halfLenZ</literal>
  </entry>
  <entry>
    Half length in Z
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Tetrahedra:
</bridgehead>

<para>  
A <emphasis role="bold">tetrahedra</emphasis> solid can be
defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4Tet(const G4String&amp; pName,                         
               G4ThreeVector  anchor,
               G4ThreeVector  p2,
               G4ThreeVector  p3,
               G4ThreeVector  p4,
               G4bool         *degeneracyFlag=0)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTet.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTet.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic16.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    anchor = {0, 0, sqrt(3)},
    p2 = { 0, 2*sqrt(2/3), -1/sqrt(3) },
    p3 = { -sqrt(2), -sqrt(2/3),-1/sqrt(3) },
    p4 = { sqrt(2), -sqrt(2/3) , -1/sqrt(3) }
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
The solid is defined by 4 points in space:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>anchor</literal>
  </entry>
  <entry>
    Anchor point
  </entry>
</row>
<row>
  <entry>
    <literal>p2</literal>
  </entry>
  <entry>
    Point 2
  </entry>
</row>
<row>
  <entry>
    <literal>p3</literal>
  </entry>
  <entry>
    Point 3
  </entry>
</row>
<row>
  <entry>
    <literal>p4</literal>
  </entry>
  <entry>
    Point 4
  </entry>
</row>
<row>
  <entry>
    degeneracyFlag
  </entry>
  <entry>
    Flag indicating degeneracy of points
  </entry>
</row>
<row>
  <entry>
    
  </entry>
  <entry>
    
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>


<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Extruded Polygon:
</bridgehead>

<para>
The extrusion of an arbitrary polygon
(<emphasis role="bold">extruded solid</emphasis>) with fixed outline
in the defined <literal>Z</literal> sections can be defined as follows
(in a general way, or as special construct with two <literal>Z</literal>
sections):

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4ExtrudedSolid(const G4String&amp;                pName,
                         std::vector&lt;G4TwoVector&gt; polygon,
                         std::vector&lt;ZSection&gt;    zsections)

   G4ExtrudedSolid(const G4String&amp;                pName,
                         std::vector&lt;G4TwoVector&gt; polygon,
                         G4double                 hz,
                         G4TwoVector off1, G4double scale1,
                         G4TwoVector off2, G4double scale2)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aExtrudedSolid.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aExtrudedSolid.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic22.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    poligon = {-30,-30},{-30,30},{30,30},{30,-30},
              {15,-30},{15,15},{-15,15},{-15,-30}</para>
    <para>
    zsections = [-60,{0,30},0.8], [-15, {0,-30},1.],
                [10,{0,0},0.6], [60,{0,30},1.2]</para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
The z-sides of the solid are the scaled versions of the same polygon.

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>polygon</literal>
  </entry>
  <entry>
    the vertices of the outlined polygon defined in clock-wise order
  </entry>
</row>
<row>
  <entry>
    <literal>zsections</literal>
  </entry>
  <entry>
     the z-sections defined by z position in increasing order
  </entry>
</row>
<row>
  <entry>
    <literal>hz</literal>
  </entry>
  <entry>
    Half length in Z
  </entry>
</row>
<row>
  <entry>
    <literal>off1, off2</literal>
  </entry>
  <entry>
    Offset of the side in -hz and +hz respectively
  </entry>
</row>
<row>
  <entry>
    <literal>scale1, scale2</literal>
  </entry>
  <entry>
    Scale of the side in -hz and +hz respectively
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>


<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Box Twisted:
</bridgehead>

<para>  
A <emphasis role="bold">box twisted</emphasis> along one axis
can be defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4TwistedBox(const G4String&amp; pName,                  
                      G4double  twistedangle,
                      G4double  pDx,
                      G4double  pDy,
                      G4double  pDz)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTwistedBox.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTwistedBox.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic17.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    twistedangle = 30*Degree, pDx = 30, pDy =40, pDz = 60
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
<literal>G4TwistedBox</literal> is a box twisted along the z-axis. The
twist angle cannot be greater than 90 degrees:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>twistedangle</literal>
  </entry>
  <entry>
    Twist angle
  </entry>
</row>
<row>
  <entry>
    <literal>pDx</literal>
  </entry>
  <entry>
    Half x length
  </entry>
</row>
<row>
  <entry>
    <literal>pDy</literal>
  </entry>
  <entry>
    Half y length
  </entry>
</row>
<row>
  <entry>
    <literal>pDz</literal>
  </entry>
  <entry>
    Half z length
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Trapezoid Twisted along One Axis:
</bridgehead>

<para>  
<emphasis>trapezoid twisted</emphasis> along one axis can be defined as
follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4TwistedTrap(const G4String&amp; pName,                 
                       G4double  twistedangle,
                       G4double  pDxx1, 
                       G4double  pDxx2,
                       G4double  pDy, 
                       G4double   pDz)
  
   G4TwistedTrap(const G4String&amp; pName,
                       G4double  twistedangle,
                       G4double  pDz,
                       G4double  pTheta, 
                       G4double  pPhi,
                       G4double  pDy1, 
                       G4double  pDx1,
                       G4double  pDx2, 
                       G4double  pDy2,
                       G4double  pDx3, 
                       G4double  pDx4,
                       G4double  pAlph)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTwistedTrap.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTwistedTrap.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic18.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    pDx1 = 30, pDx2 = 40, pDy1 = 40,
    pDx3 = 10, pDx4 = 14, pDy2 = 16,
    pDz = 60,
    pTheta = 20*Degree, pDphi = 5*Degree,
    pAlph = 10*Degree, twistedangle = 30*Degree
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
The first constructor of <literal>G4TwistedTrap</literal> produces a
regular trapezoid twisted along the <literal>z</literal>-axis, where the caps
of the trapezoid are of the same shape and size.
</para>

<para>
The second constructor produces a generic trapezoid with polar,
azimuthal and tilt angles.
</para>

<para>
The twist angle cannot be greater than 90 degrees:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>twistedangle</literal>
  </entry>
  <entry>
    Twisted angle
  </entry>
</row>
<row>
  <entry>
    <literal>pDx1</literal>
  </entry>
  <entry>
    Half x length at y=-pDy
  </entry>
</row>
<row>
  <entry>
    <literal>pDx2</literal>
  </entry>
  <entry>
    Half x length at y=+pDy
  </entry>
</row>
<row>
  <entry>
    <literal>pDy</literal>
  </entry>
  <entry>
    Half y length
  </entry>
</row>
<row>
  <entry>
    <literal>pDz</literal>
  </entry>
  <entry>
    Half z length
  </entry>
</row>
<row>
  <entry>
    <literal>pTheta</literal>
  </entry>
  <entry>
    Polar angle of the line joining the centres of the faces at -/+pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pDy1</literal>
  </entry>
  <entry>
    Half y length at -pDz
  </entry>
</row>
<row>
  <entry>
    <literal>pDx1</literal>
  </entry>
  <entry>
    Half x length at -pDz, y=-pDy1
  </entry>
</row>
<row>
  <entry>
    <literal>pDx2</literal>
  </entry>
  <entry>
    Half x length at -pDz, y=+pDy1
  </entry>
</row>
<row>
  <entry>
    <literal>pDy2</literal>
  </entry>
  <entry>
    Half y length at +pDz

  </entry>
</row>
<row>
  <entry>
    <literal>pDx3</literal>
  </entry>
  <entry>
    Half x length at +pDz, y=-pDy2
  </entry>
</row>
<row>
  <entry>
    <literal>pDx4</literal>
  </entry>
  <entry>
    Half x length at +pDz, y=+pDy2
  </entry>
</row>
<row>
  <entry>
    <literal>pAlph</literal>
  </entry>
  <entry>
    Angle with respect to the y axis from the centre of the side
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Twisted Trapezoid with <literal>x</literal> and <literal>y</literal> dimensions 
varying along <literal>z</literal>:
</bridgehead>

<para>  
A <emphasis role="bold">twisted trapezoid</emphasis> with the
<literal>x</literal> and <literal>y</literal> dimensions 
<emphasis role="bold">varying along <literal>z</literal></emphasis> can be
defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4TwistedTrd(const G4String&amp; pName,                  
                      G4double  pDx1,
                      G4double  pDx2,
                      G4double  pDy1,
                      G4double  pDy2,
                      G4double  pDz,
                      G4double  twistedangle)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTwistedTrd.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTwistedTrd.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic19.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    dx1 = 30, dx2 = 10,
    dy1 = 40, dy2 = 15,
    dz = 60, twistedangle = 30*Degree
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
where:
<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>pDx1</literal>
  </entry>
  <entry>
    Half x length at the surface positioned at -dz
  </entry>
</row>
<row>
  <entry>
    <literal>pDx2</literal>
  </entry>
  <entry>
    Half x length at the surface positioned at +dz
  </entry>
</row>
<row>
  <entry>
    <literal>pDy1</literal>
  </entry>
  <entry>
    Half y length at the surface positioned at -dz
  </entry>
</row>
<row>
  <entry>
    <literal>pDy2</literal>
  </entry>
  <entry>
    Half y length at the surface positioned at +dz
  </entry>
</row>
<row>
  <entry>
    <literal>pDz</literal>
  </entry>
  <entry>
    Half z length
  </entry>
</row>
<row>
  <entry>
    <literal>twistedangle</literal>
  </entry>
  <entry>
    Twisted angle
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Tube Section Twisted along Its Axis:
</bridgehead>

<para>  
A <emphasis role="bold">tube section twisted</emphasis> along
its axis can be defined as follows:

<informaltable frame="none" pgwide="0">
<tgroup cols="2" colsep="0">
<tbody>
<row>
  <entry valign="top" align="left">
    <informalexample>
    <programlisting>  
   G4TwistedTubs(const G4String&amp; pName,                 
                       G4double  twistedangle,
                       G4double  endinnerrad,
                       G4double  endouterrad,
                       G4double  halfzlen,
                       G4double  dphi)
    </programlisting>  
    </informalexample>
  </entry>
  <entry valign="top" align="center">
    <mediaobject>
    <imageobject  role="fo">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTwistedTubs.jpg"
                 format="JPG" contentwidth="3.5cm" />
    </imageobject>
    <imageobject  role="html">
      <imagedata fileref="./AllResources/Detector/geometry.src/aTwistedTubs.jpg"
                 format="JPG" />
    </imageobject>
    </mediaobject>

    <?JavaScript pic20.html ?>
    <emphasis role="underline">In the picture</emphasis>:
    <literal>
    <para>
    endinnerrad = 10, endouterrad = 15,
    halfzlen = 20, dphi = 90*Degree,
    twistedangle = 60*Degree
    </para>
    </literal>
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
<literal>G4TwistedTubs</literal> is a sort of twisted cylinder which,
placed along the <literal>z</literal>-axis and divided into
<literal>phi</literal>-segments is shaped like an hyperboloid, where each of
its segmented pieces can be tilted with a stereo angle.
</para>

<para>
It can have inner and outer surfaces with the same stereo angle:
<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>twistedangle</literal>
  </entry>
  <entry>
    Twisted angle
  </entry>
</row>
<row>
  <entry>
    <literal>endinnerrad</literal>
  </entry>
  <entry>
    Inner radius at endcap
  </entry>
</row>
<row>
  <entry>
    <literal>endouterrad</literal>
  </entry>
  <entry>
    Outer radius at endcap
  </entry>
</row>
<row>
  <entry>
    <literal>halfzlen</literal>
  </entry>
  <entry>
    Half z length
  </entry>
</row>
<row>
  <entry>
    <literal>dphi</literal>
  </entry>
  <entry>
    Phi angle of a segment
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<para>
Additional constructors are provided, allowing the shape to be
specified either as:

<itemizedlist spacing="compact">
  <listitem><para>
    the number of segments in <literal>phi</literal> and the total angle for
    all segments, or
  </para></listitem>
  <listitem><para>
    a combination of the above constructors providing instead the
    inner and outer radii at <literal>z=0</literal> with different
    <literal>z</literal>-lengths along negative and positive
    <literal>z</literal>-axis.
  </para></listitem>
</itemizedlist>
</para>

</sect3>


<!-- ******************* Section (Level#3) ****************** -->
<sect3 id="sect.Geom.Solids.BoolOp">
<title>
Solids made by Boolean operations
</title>

<para>
Simple solids can be combined using Boolean operations. For
example, a cylinder and a half-sphere can be combined with the
union Boolean operation.
</para>

<para>
Creating such a new <emphasis>Boolean</emphasis> solid, requires:

<itemizedlist spacing="compact">
  <listitem><para>
    Two solids
  </para></listitem>
  <listitem><para>
    A Boolean operation: union, intersection or subtraction.
  </para></listitem>
  <listitem><para>
    Optionally a transformation for the second solid.
  </para></listitem>
</itemizedlist>
</para>

<para>
The solids used should be either CSG solids (for examples a box,
a spherical shell, or a tube) or another Boolean solid: the product
of a previous Boolean operation. An important purpose of Boolean
solids is to allow the description of solids with peculiar shapes
in a simple and intuitive way, still allowing an efficient
geometrical navigation inside them.
</para>

<note><title></title>
<para>
The solids used can actually be of any type. However, in
order to fully support the export of a Geant4 solid model via STEP
to CAD systems, we restrict the use of Boolean operations to this
subset of solids. But this subset contains all the most interesting
use cases.
</para>
</note>

<note><title></title>
<para>
The tracking cost for navigating in a Boolean solid in the
current implementation, is proportional to the number of
constituent solids. So care must be taken to avoid extensive,
unecessary use of Boolean solids in performance-critical areas of a
geometry description, where each solid is created from Boolean
combinations of many other solids.
</para>
</note>

<para>
Examples of the creation of the simplest Boolean solids are
given below:

<informalexample>
<programlisting>
  G4Box*  box =
    new G4Box("Box",20*mm,30*mm,40*mm);
  G4Tubs* cyl =
    new G4Tubs("Cylinder",0,50*mm,50*mm,0,twopi);  // r:     0 mm -&gt; 50 mm
                                                   // z:   -50 mm -&gt; 50 mm
                                                   // phi:   0 -&gt;  2 pi
  G4UnionSolid* union =
    new G4UnionSolid("Box+Cylinder", box, cyl); 
  G4IntersectionSolid* intersection =
    new G4IntersectionSolid("Box*Cylinder", box, cyl); 
  G4SubtractionSolid* subtraction =
    new G4SubtractionSolid("Box-Cylinder", box, cyl);
 </programlisting>
</informalexample>

where the union, intersection and subtraction of a box and cylinder
are constructed.
</para>

<para>
The more useful case where one of the solids is displaced from
the origin of coordinates also exists. In this case the second
solid is positioned relative to the coordinate system (and thus
relative to the first). This can be done in two ways:

<itemizedlist spacing="compact">
  <listitem><para>
    Either by giving a rotation matrix and translation vector that
    are used to transform the coordinate system of the second solid to
    the coordinate system of the first solid. This is called the
    <emphasis>passive</emphasis> method.
  </para></listitem>
  <listitem><para>
    Or by creating a transformation that moves the second solid
    from its desired position to its standard position, e.g., a box's
    standard position is with its centre at the origin and sides
    parallel to the three axes. This is called the 
    <emphasis>active</emphasis> method.
  </para></listitem>
</itemizedlist>
</para>

<para>
In the first case, the translation is applied first to move the
origin of coordinates. Then the rotation is used to rotate the
coordinate system of the second solid to the coordinate system of
the first.

<informalexample>
<programlisting>
    G4RotationMatrix* yRot = new G4RotationMatrix;  // Rotates X and Z axes only
    yRot-&gt;rotateY(M_PI/4.*rad);                     // Rotates 45 degrees
    G4ThreeVector zTrans(0, 0, 50);

    G4UnionSolid* unionMoved =
      new G4UnionSolid("Box+CylinderMoved", box, cyl, yRot, zTrans);
    //
    // The new coordinate system of the cylinder is translated so that
    // its centre is at +50 on the original Z axis, and it is rotated
    // with its X axis halfway between the original X and Z axes.

    // Now we build the same solid using the alternative method
    //
    G4RotationMatrix invRot = *(yRot-&gt;invert());
    G4Transform3D transform(invRot, zTrans);  
    G4UnionSolid* unionMoved =
      new G4UnionSolid("Box+CylinderMoved", box, cyl, transform);
</programlisting>
</informalexample>
</para>

<para>
Note that the first constructor that takes a pointer to the
rotation-matrix (<literal>G4RotationMatrix*</literal>), does NOT copy it.
Therefore once used a rotation-matrix to construct a Boolean solid,
it must NOT be modified.
</para>

<para>
In contrast, with the alternative method shown, a
<literal>G4Transform3D</literal> is provided to the constructor by value, and
its transformation is stored by the Boolean solid. The user may
modify the <literal>G4Transform3D</literal> and eventually use it again.
</para>

<para>
When positioning a volume associated to a Boolean solid, the
relative center of coordinates considered for the positioning is
the one related to the <emphasis>first</emphasis> of the two constituent
solids.
</para>

</sect3>


<!-- ******************* Section (Level#3) ****************** -->
<sect3 id="sect.Geom.Solids.BREPS">
<title>
Boundary Represented (BREPS) Solids
</title>

<para>
BREP solids are defined via the description of their boundaries.
The boundaries can be made of planar and second order surfaces.
Eventually these can be trimmed and have holes. The resulting
solids, such as polygonal, polyconical solids are known as
Elementary BREPS.
</para>

<para>
In addition, the boundary surfaces can be made of Bezier
surfaces and B-Splines, or of NURBS
(Non-Uniform-Rational-B-Splines) surfaces. The resulting solids are
Advanced BREPS.
</para>

<para>

<note><title></title>
<para>
Currently, the implementation for surfaces
generated by Beziers, B-Splines or NURBS is only at the level of
prototype and not fully functional.
</para>

<para>
Extensions in this area are foreseen in future.
</para>
</note>

<para>
We have defined a few simple Elementary BREPS, that can be
instantiated simply by a user in a manner similar to the
construction of Constructed Solids (CSGs). We summarize their
capabilities in the following section.
</para>

<para>
Most BREPS Solids are however defined by creating each surface
separately and tying them together.
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Specific BREP Solids:
</bridgehead>

<para>
We have defined one polygonal and one polyconical shape using
BREPS. The polycone provides a shape defined by a series of conical
sections with the same axis, contiguous along it.
</para>

<para>
The polyconical solid <literal>G4BREPSolidPCone</literal> is a shape
defined by a set of inner and outer conical or cylindrical surface
sections and two planes perpendicular to the Z axis. Each conical
surface is defined by its radius at two different planes
perpendicular to the Z-axis. Inner and outer conical surfaces are
defined using common Z planes.
</para>

<informalexample>
<programlisting>  
  G4BREPSolidPCone( const G4String&amp; pName,
                          G4double  start_angle,
                          G4double  opening_angle,                   
                          G4int     num_z_planes,    // sections,
                          G4double  z_start,                   
                    const G4double  z_values[],
                    const G4double  RMIN[],
                    const G4double  RMAX[]  )
</programlisting>
</informalexample>  

<para>
The conical sections do not need to fill 360 degrees, but can have
a common start and opening angle.
</para>

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>start_angle</literal>
  </entry>
  <entry>
    starting angle
  </entry>
</row>
<row>
  <entry>
    <literal>opening_angle</literal>
  </entry>
  <entry>
    opening angle
  </entry>
</row>
<row>
  <entry>
    <literal>num_z_planes</literal>
  </entry>
  <entry>
    number of planes perpendicular to the z-axis used.
  </entry>
</row>
<row>
  <entry>
    <literal>z_start</literal>
  </entry>
  <entry>
    starting value of z
  </entry>
</row>
<row>
  <entry>
    <literal>z_values</literal>
  </entry>
  <entry>
    z coordinates of each plane
  </entry>
</row>
<row>
  <entry>
    <literal>RMIN</literal>
  </entry>
  <entry>
    radius of inner cone at each plane
  </entry>
</row>
<row>
  <entry>
    <literal>RMAX</literal>
  </entry>
  <entry>
    radius of outer cone at each plane
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
   
<para>
The polygonal solid <literal>G4BREPSolidPolyhedra</literal> is a shape
defined by an inner and outer polygonal surface and two planes
perpendicular to the Z axis. Each polygonal surface is created by
linking a series of polygons created at different planes
perpendicular to the Z-axis. All these polygons all have the same
number of sides (<literal>sides</literal>) and are defined at the same Z
planes for both inner and outer polygonal surfaces.
</para>

<para>
The polygons do not need to fill 360 degrees, but have a start
and opening angle.
</para>

<para>
The constructor takes the following parameters:

<informalexample>
<programlisting>  
  G4BREPSolidPolyhedra( const G4String&amp; pName,
                              G4double  start_angle,
                              G4double  opening_angle,
                              G4int     sides,
                              G4int     num_z_planes,      
                              G4double  z_start,
                        const G4double  z_values[],
                        const G4double  RMIN[],
                        const G4double  RMAX[]  )
</programlisting>
</informalexample>  

which in addition to its name have the following meaning:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>start_angle</literal>
  </entry>
  <entry>
    starting angle
  </entry>
</row>
<row>
  <entry>
    <literal>opening_angle</literal>
  </entry>
  <entry>
    opening angle
  </entry>
</row>
<row>
  <entry>
    <literal>sides</literal>
  </entry>
  <entry>
    number of sides of each polygon in the x-y plane
  </entry>
</row>
<row>
  <entry>
    <literal>num_z_planes</literal>
  </entry>
  <entry>
    number of planes perpendicular to the z-axis used.
  </entry>
</row>
<row>
  <entry>
    <literal>z_start</literal>
  </entry>
  <entry>
    starting value of z
  </entry>
</row>
<row>
  <entry>
    <literal>z_values</literal>
  </entry>
  <entry>
    z coordinates of each plane
  </entry>
</row>
<row>
  <entry>
    <literal>RMIN</literal>
  </entry>
  <entry>
    radius of inner polygon at each corner
  </entry>
</row>
<row>
  <entry>
    <literal>RMAX</literal>
  </entry>
  <entry>
    radius of outer polygon at each corner
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
   
the shape is defined by the number of sides <literal>sides</literal> of
the polygon in the plane perpendicular to the z-axis.
</para>

</sect3>


<!-- ******************* Section (Level#3) ****************** -->
<sect3 id="sect.Geom.Solids.Tessel">
<title>
Tessellated Solids
</title>

<para>
In Geant4 it is also implemented a class
<literal>G4TessellatedSolid</literal> which can be used to generate a generic
solid defined by a number of facets (<literal>G4VFacet</literal>). Such
constructs are especially important for conversion of complex
geometrical shapes imported from CAD systems bounded with generic
surfaces into an approximate description with facets of defined
dimension (see <xref linkend="fig.Geom.Solid_1" />).

<figure id="fig.Geom.Solid_1">
<title>
  Example of geometries imported from CAD system and converted to
  tessellated solids.
</title>

<mediaobject>
  <imageobject role="fo">
    <imagedata fileref="./AllResources/Detector/geometry.src/cad-tess-combined.jpg" 
               format="JPG" width="12.0cm" align="center" />
  </imageobject>
  <imageobject role="html">
    <imagedata fileref="./AllResources/Detector/geometry.src/cad-tess-combined.jpg" 
               format="JPG" align="center" />
  </imageobject>
</mediaobject>
</figure>
</para>

<para>
They can also be used to generate a solid bounded with a generic
surface made of planar facets. It is important that the supplied
facets shall form a fully enclose space to represent the solid.
</para>

<para>
Two types of facet can be used for the construction of a
<literal>G4TessellatedSolid</literal>: a triangular facet
(<literal>G4TriangularFacet</literal>) and a quadrangular facet
(<literal>G4QuadrangularFacet</literal>).
</para>

<para>
An example on how to generate a simple tessellated shape is
given below.

<example id="programlist_Geom_1">
<title>
An example of a simple tessellated solid with
<literal>G4TessellatedSolid</literal>.
</title>

<programlisting>
        // First declare a tessellated solid
        //
        G4TessellatedSolid solidTarget = new G4TessellatedSolid("Solid_name");

        // Define the facets which form the solid
        //
        G4double targetSize = 10*cm ;
        G4TriangularFacet *facet1 = new
        G4TriangularFacet (G4ThreeVector(-targetSize,-targetSize,        0.0),
                           G4ThreeVector(+targetSize,-targetSize,        0.0),
                           G4ThreeVector(        0.0,        0.0,+targetSize),
                           ABSOLUTE);
        G4TriangularFacet *facet2 = new
        G4TriangularFacet (G4ThreeVector(+targetSize,-targetSize,        0.0),
                           G4ThreeVector(+targetSize,+targetSize,        0.0),
                           G4ThreeVector(        0.0,        0.0,+targetSize),
                           ABSOLUTE);
        G4TriangularFacet *facet3 = new
        G4TriangularFacet (G4ThreeVector(+targetSize,+targetSize,        0.0),
                           G4ThreeVector(-targetSize,+targetSize,        0.0),
                           G4ThreeVector(        0.0,        0.0,+targetSize),
                           ABSOLUTE);
        G4TriangularFacet *facet4 = new
        G4TriangularFacet (G4ThreeVector(-targetSize,+targetSize,        0.0),
                           G4ThreeVector(-targetSize,-targetSize,        0.0),
                           G4ThreeVector(        0.0,        0.0,+targetSize),
                           ABSOLUTE);
        G4QuadrangularFacet *facet5 = new
        G4QuadrangularFacet (G4ThreeVector(-targetSize,-targetSize,        0.0),
                             G4ThreeVector(-targetSize,+targetSize,        0.0),
                             G4ThreeVector(+targetSize,+targetSize,        0.0),
                             G4ThreeVector(+targetSize,-targetSize,        0.0),
                             ABSOLUTE);

        // Now add the facets to the solid
        //
        solidTarget-&gt;AddFacet((G4VFacet*) facet1);
        solidTarget-&gt;AddFacet((G4VFacet*) facet2);
        solidTarget-&gt;AddFacet((G4VFacet*) facet3);
        solidTarget-&gt;AddFacet((G4VFacet*) facet4);
        solidTarget-&gt;AddFacet((G4VFacet*) facet5);

        Finally declare the solid is complete
        //
        solidTarget-&gt;SetSolidClosed(true);
</programlisting>
</example>
</para>

<para>
The <literal>G4TriangularFacet</literal> class is used for the contruction
of <literal>G4TessellatedSolid</literal>. It is defined by three vertices,
which shall be supplied in <emphasis>anti-clockwise order</emphasis> looking from
the outside of the solid where it belongs. Its constructor looks
like:

<informalexample>
<programlisting>
        G4TriangularFacet ( const G4ThreeVector     Pt0,
                            const G4ThreeVector     vt1,
                            const G4ThreeVector     vt2,
                                  G4FacetVertexType fType )
</programlisting>
</informalexample> 

i.e., it takes 4 parameters to define the three vertices:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>G4FacetVertexType</literal>
  </entry>
  <entry>
    <literal>ABSOLUTE</literal> in which case <literal>Pt0</literal>, 
    <literal>vt1</literal> and <literal>vt2</literal> 
    are the three vertices in anti-clockwise order looking from the outside.
  </entry>
</row>
<row>
  <entry>
    <literal>G4FacetVertexType</literal>
  </entry>
  <entry>
    <literal>RELATIVE</literal> in which case the first vertex is
    <literal>Pt0</literal>, the second vertex is <literal>Pt0+vt1</literal> and 
    the third vertex is <literal>Pt0+vt2</literal>, all in anti-clockwise order 
    when looking from the outside.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<para>
The <literal>G4QuadrangularFacet</literal> class can be used for the
contruction of <literal>G4TessellatedSolid</literal> as well. It is defined
by four vertices, which shall be in the same plane and be supplied
in <emphasis>anti-clockwise order</emphasis> looking from the outside of the
solid where it belongs. Its constructor looks like:

<informalexample>
<programlisting>
        G4QuadrangularFacet ( const G4ThreeVector     Pt0,
                              const G4ThreeVector     vt1,
                              const G4ThreeVector     vt2,
                              const G4ThreeVector     vt3,
                                    G4FacetVertexType fType )
</programlisting>
</informalexample>

i.e., it takes 5 parameters to define the four vertices:

<informaltable pgwide="0">
<tgroup cols="2">
<tbody>
<row>
  <entry>
    <literal>G4FacetVertexType</literal>
  </entry>
  <entry>
    <literal>ABSOLUTE</literal> in which case <literal>Pt0</literal>, 
    <literal>vt1</literal>, <literal>vt2</literal> and <literal>vt3</literal> 
    are the four vertices required in anti-clockwise order when looking 
    from the outside.
  </entry>
</row>
<row>
  <entry>
    <literal>G4FacetVertexType</literal>
  </entry>
  <entry>
    <literal>RELATIVE</literal> in which case the first vertex is
    <literal>Pt0</literal>, the second vertex is <literal>Pt0+vt</literal>, 
    the third vertex is <literal>Pt0+vt2</literal> and the fourth vertex is
    <literal>Pt0+vt3</literal>, in anti-clockwise order when looking from the
    outside.
  </entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>

<!-- ******* Bridgehead ******* -->
<bridgehead renderas='sect4'>
Importing CAD models as tessellated shapes
</bridgehead>

<para>
Tessellated solids can also be used to import geometrical models from CAD
systems (see <xref linkend="fig.Geom.Solid_1" />). In order to do this, it
is required to convert first the CAD shapes into tessellated surfaces. A
way to do this is to save the shapes in the geometrical model as STEP files
and convert them using a tool like
<ulink url="http://www.steptools.com/products/stviewer/">STViewer</ulink> or
<ulink url="http://www.trad.fr/en/">FASTRAD</ulink> to
tessellated (faceted surfaces) solids. This strategy allows to import any shape
with some degree of approximation; the converted CAD models can then be
imported through <ulink url="http://cern.ch/gdml/">GDML (Geometry Description
Markup Language)</ulink> into Geant4 and be represented as
<literal>G4TessellatedSolid</literal> shapes.
</para>

</sect3>
</sect2>
