View Javadoc

1   /*
2    * PolyhedraRegular.java
3    *
4    * Created on August 24, 2005, 10:34 PM
5    *
6    */
7   
8   package org.lcsim.geometry.compact.converter.lcdd.util;
9   
10  /**
11   *
12   * @author jeremym
13   *
14   * This class represents a regular polyhedra solid, e.g. one without any slope to the sides.
15   * Thus, it does not require user definition of any zplanes, unlike Polycone.
16   */
17  public class PolyhedraRegular extends Solid
18  {
19      double rmin;
20      double rmax;
21      
22      public PolyhedraRegular(String name, int nsides, double rmin, double rmax, double zlength)
23      {
24          super("polyhedra", name);
25          
26          setAttribute("startphi", String.valueOf(0));
27          setAttribute("deltaphi", String.valueOf(Math.PI * 2) );
28          setAttribute("numsides", String.valueOf(nsides));
29          
30          if ( rmin < 0 || rmin > rmax )
31          {
32              throw new IllegalArgumentException("rmin <" + rmin + "> is invalid.");
33          }
34          
35          if ( rmax < 0 )
36          {
37              throw new IllegalArgumentException("rmax <" + rmax + "> is invalid.");
38          }
39          
40          ZPlane zplane1 = new ZPlane(rmin,  rmax, -zlength/2);
41          ZPlane zplane2 = new ZPlane(rmin, rmax, zlength/2);
42          
43          addContent(zplane1);
44          addContent(zplane2);
45      }
46  }