Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd/util on MAIN | |||
PhysVol.java | +84 | -62 | 1.4 -> 1.5 |
Trapezoid.java | +64 | -54 | 1.2 -> 1.3 |
Tube.java | +39 | -33 | 1.3 -> 1.4 |
Volume.java | +29 | -11 | 1.6 -> 1.7 |
+216 | -160 |
JM: add convenience ctors
diff -u -r1.4 -r1.5 --- PhysVol.java 19 Jan 2006 01:57:38 -0000 1.4 +++ PhysVol.java 25 Oct 2007 20:06:01 -0000 1.5 @@ -8,66 +8,88 @@
*/ public class PhysVol extends Element {
- private static int n = 0; - /** Creates a new instance of Physvol */ - public PhysVol() - { - this(null); - } - public PhysVol(Volume volume) - { - super("physvol"); - Element volumeref = new Element("volumeref"); - if (volume != null) volumeref.setAttribute("ref",volume.getRefName()); - addContent(volumeref); - - Element positionref = new Element("positionref"); - positionref.setAttribute("ref","identity_pos"); - addContent(positionref); - - Element rotationref = new Element("rotationref"); - rotationref.setAttribute("ref","identity_rot"); - addContent(rotationref); - } - public void setVolume(Volume volume) - { - getChild("volumeref").setAttribute("ref",volume.getRefName()); - } - - public void setZ(double z) - { - Element positionref = getChild("positionref"); - if (positionref != null) this.removeContent(positionref); - Position position = (Position) getChild("position"); - if (position == null) - { - position = new Position("volpos_"+(n++)); - addContent(1,position); - } - position.setZ(z); - } - - public void setPosition(Position pos) - { - Element positionRef = getChild("positionref"); - positionRef.setAttribute("ref", pos.getRefName()); - } - - public void setRotation(Rotation rot) - { - Element rotationRef = getChild("rotationref"); - rotationRef.setAttribute("ref",rot.getRefName()); - } - public void addPhysVolID(String name, int value) - { - Element element = new Element("physvolid"); - element.setAttribute("field_name",name); - element.setAttribute("value",String.valueOf(value)); - addContent(element); - } - - public void addPhysVolID(PhysVolID id) - { - addContent(id); - }
+ private static int n = 0; + /** Creates a new instance of Physvol */ + public PhysVol(Volume volume, Volume mother, Position p, Rotation r) + { + super("physvol"); + Element volumeref = new Element("volumeref"); + if (volume != null) volumeref.setAttribute("ref",volume.getRefName()); + addContent(volumeref); + + Element positionref = new Element("positionref"); + positionref.setAttribute("ref","identity_pos"); + addContent(positionref); + + Element rotationref = new Element("rotationref"); + rotationref.setAttribute("ref","identity_rot"); + addContent(rotationref); + + setPosition(p); + + setRotation(r); + + mother.addPhysVol(this); + } + + public PhysVol() + { + this(null); + } + public PhysVol(Volume volume) + { + super("physvol"); + Element volumeref = new Element("volumeref"); + if (volume != null) volumeref.setAttribute("ref",volume.getRefName()); + addContent(volumeref); + + Element positionref = new Element("positionref"); + positionref.setAttribute("ref","identity_pos"); + addContent(positionref); + + Element rotationref = new Element("rotationref"); + rotationref.setAttribute("ref","identity_rot"); + addContent(rotationref); + } + public void setVolume(Volume volume) + { + getChild("volumeref").setAttribute("ref",volume.getRefName()); + } + + public void setZ(double z) + { + Element positionref = getChild("positionref"); + if (positionref != null) this.removeContent(positionref); + Position position = (Position) getChild("position"); + if (position == null) + { + position = new Position("volpos_"+(n++)); + addContent(1,position); + } + position.setZ(z); + } + + public void setPosition(Position pos) + { + Element positionRef = getChild("positionref"); + positionRef.setAttribute("ref", pos.getRefName()); + } + + public void setRotation(Rotation rot) + { + Element rotationRef = getChild("rotationref"); + rotationRef.setAttribute("ref",rot.getRefName()); + } + public void addPhysVolID(String name, int value) + { + Element element = new Element("physvolid"); + element.setAttribute("field_name",name); + element.setAttribute("value",String.valueOf(value)); + addContent(element); + } + + public void addPhysVolID(PhysVolID id) + { + addContent(id); + }
}
diff -u -r1.2 -r1.3 --- Trapezoid.java 21 Jan 2006 02:30:01 -0000 1.2 +++ Trapezoid.java 25 Oct 2007 20:06:01 -0000 1.3 @@ -5,58 +5,68 @@
*/ public class Trapezoid extends Solid {
- public Trapezoid(String name) - { - super("trd",name); - } - - public double x1() - { - return getDim("x1"); - } - - public double x2() - { - return getDim("x2"); - } - - public double y1() - { - return getDim("y1"); - } - - public double y2() - { - return getDim("y2"); - } - - public double z() - { - return getDim("z"); - } - - public void setX1(double x1) - { - setAttribute("x1",String.valueOf(x1)); - } - - public void setX2(double x2) - { - setAttribute("x2", String.valueOf(x2)); - } - - public void setY1(double y1) - { - setAttribute("y1", String.valueOf(y1)); - } - - public void setY2(double y2) - { - setAttribute("y2", String.valueOf(y2)); - } - - public void setZ(double z) - { - setAttribute("z",String.valueOf(z)); - }
+ public Trapezoid(String name, double x1, double x2, double y1, double y2, double z) + { + super("trd",name); + setX1(x1); + setX2(x2); + setY1(y1); + setY2(y2); + setZ(z); + } + + public Trapezoid(String name) + { + super("trd",name); + } + + public double x1() + { + return getDim("x1"); + } + + public double x2() + { + return getDim("x2"); + } + + public double y1() + { + return getDim("y1"); + } + + public double y2() + { + return getDim("y2"); + } + + public double z() + { + return getDim("z"); + } + + public void setX1(double x1) + { + setAttribute("x1",String.valueOf(x1)); + } + + public void setX2(double x2) + { + setAttribute("x2", String.valueOf(x2)); + } + + public void setY1(double y1) + { + setAttribute("y1", String.valueOf(y1)); + } + + public void setY2(double y2) + { + setAttribute("y2", String.valueOf(y2)); + } + + public void setZ(double z) + { + setAttribute("z",String.valueOf(z)); + }
}
\ No newline at end of file
diff -u -r1.3 -r1.4 --- Tube.java 20 Jun 2005 21:15:07 -0000 1.3 +++ Tube.java 25 Oct 2007 20:06:01 -0000 1.4 @@ -6,38 +6,44 @@
*/ public class Tube extends Solid {
- - /** Creates a new instance of Tube */ - public Tube(String name) - { - super("tube",name); - - /** - * Set default deltaphi to 360 deg, i.e. full tube segment. - */ - setAttribute("deltaphi", String.valueOf(Math.PI * 2) ); - - /** - * Set default rmin to 0.0. - */ - setAttribute("rmin", "0.0"); - } - public void setZ(double z) - { - setAttribute("z",String.valueOf(z)); - } - public void setRMin(double r) - { - setAttribute("rmin",String.valueOf(r)); - } - public void setRMax(double r) - { - setAttribute("rmax",String.valueOf(r)); - } - public void setDeltaPhi(double phi) - { - setAttribute("deltaphi",String.valueOf(phi)); - } -}
+ public Tube(String name, double innerR, double outerR, double zHalf) + { + super("tube",name); + setRMin(innerR); + setRMax(outerR); + setZ(zHalf); + setAttribute("deltaphi", String.valueOf(Math.PI * 2) ); + }
+ /** Creates a new instance of Tube */ + public Tube(String name) + { + super("tube",name);
+ /** + * Set default deltaphi to 360 deg, i.e. full tube segment. + */ + setAttribute("deltaphi", String.valueOf(Math.PI * 2) ); + + /** + * Set default rmin to 0.0. + */ + setAttribute("rmin", "0.0"); + } + public void setZ(double z) + { + setAttribute("z",String.valueOf(z)); + } + public void setRMin(double r) + { + setAttribute("rmin",String.valueOf(r)); + } + public void setRMax(double r) + { + setAttribute("rmax",String.valueOf(r)); + } + public void setDeltaPhi(double phi) + { + setAttribute("deltaphi",String.valueOf(phi)); + } +}
\ No newline at end of file
diff -u -r1.6 -r1.7 --- Volume.java 12 Sep 2006 01:21:07 -0000 1.6 +++ Volume.java 25 Oct 2007 20:06:01 -0000 1.7 @@ -8,7 +8,20 @@
*/ public class Volume extends RefElement {
-
+ public Volume(String name, Solid solid, Material material) + { + super("volume",name); + + Element materialref = new Element("materialref"); + addContent(materialref); + Element solidref = new Element("solidref"); + addContent(solidref); + + setSolid(solid); + setMaterial(material); + } + +
/** Creates a new instance of Volume */ public Volume(String name) {
@@ -32,14 +45,14 @@
sdref.setAttribute("ref",sens.getRefName()); addContent(sdref); }
-
+
public void setLimitSet(LimitSet limitset) { Element limitsetref = new Element("limitsetref"); limitsetref.setAttribute("ref",limitset.getRefName()); addContent(limitsetref); }
-
+
public void addPhysVol(PhysVol vol) { addContent(vol);
@@ -50,21 +63,26 @@
regionref.setAttribute("ref",region.getRefName()); addContent(regionref); }
-
+
public void setVisAttributes(VisAttributes vis) {
- Element visref = new Element("visref"); - visref.setAttribute("ref",vis.getRefName()); - addContent(visref);
+ Element visref = new Element("visref"); + visref.setAttribute("ref",vis.getRefName()); + addContent(visref);
}
-
+
public String getSolidRef() {
- return getChild("solidref").getAttributeValue("ref");
+ return getChild("solidref").getAttributeValue("ref");
}
-
+
public String getVolumeName() {
- return getAttributeValue("name");
+ return getAttributeValue("name");
+ }
+
+ public String getMaterialRef()
+ {
+ return getAttributeValue("materialref");
} }