1
2
3
4
5
6
7 package org.lcsim.geometry.compact.converter.lcdd.util;
8
9 import java.util.Iterator;
10 import java.util.List;
11
12 import org.jdom.Element;
13 import org.jdom.DataConversionException;
14 import org.jdom.JDOMException;
15
16
17
18
19
20 public class Polycone extends Solid
21 {
22
23 public Polycone(String name)
24 {
25 super("polycone", name);
26 setStartPhi(0);
27 setDeltaPhi(2.*Math.PI);
28 }
29
30
31 public Polycone(String name, double startPhi, double deltaPhi, Element zplanesNode) throws JDOMException
32 {
33 super("polycone", name);
34 setStartPhi(startPhi);
35 setDeltaPhi(deltaPhi);
36 addZPlanes(zplanesNode);
37 }
38
39 void addZPlanes(Element zplanesNode) throws JDOMException, DataConversionException
40 {
41
42
43 int num_zplanes = 0;
44 for ( Iterator i = zplanesNode.getChildren("zplane").iterator(); i.hasNext(); num_zplanes++)
45 {
46 Element e = (Element) i.next();
47
48 ZPlane zp = new ZPlane(e.getAttribute("rmin").getDoubleValue(),
49 e.getAttribute("rmax").getDoubleValue(),
50 e.getAttribute("z").getDoubleValue() );
51 addZPlane(zp);
52 }
53
54 if ( num_zplanes < 2)
55 {
56 throw new JDOMException("Not enough zplanes -- minimum is 2.");
57 }
58
59
60 }
61
62 final void setStartPhi(double startPhi)
63 {
64 setAttribute("startphi", String.valueOf(startPhi) );
65 }
66
67 final void setDeltaPhi(double deltaPhi)
68 {
69 setAttribute("deltaphi", String.valueOf(deltaPhi) );
70 }
71
72 public void addZPlane(ZPlane zplane)
73 {
74 addContent(zplane);
75 }
76
77 public void addZPlane(double rmin, double rmax, double z)
78 {
79 addZPlane( new ZPlane(rmin, rmax, z) );
80 }
81 }