 |
DD4hep
1.36.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
26 std::string genName(
const std::string& n,
const void* ptr) {
29 ::snprintf(text,
sizeof(text),
"%p",ptr);
38 : m_detDesc(description), m_dataPtr(0) {
52 std::string n = genName(volume->GetName(),volume);
53 if (volume->IsAssembly()) {
99 float red = 0, green = 0, blue = 0;
114 vis.
setAttr(
_U(drawing_style),
"wireframe");
117 attr.
rgb(red, green, blue);
131 throw std::runtime_error(
"Attempt to call createDetector with an invalid geometry!");
137 printout(ALWAYS,
"Vis2XmlExtract",
"++ ==> Dump visualisation attributes "
138 "from in memory detector description...");
147 this->handleVolumeVis(
v->GetName(),
v.ptr());
148 printout(ALWAYS,
"Vis2XmlExtract",
"++ Handled %ld volumes.",geo.
volumes.size());
154 : doc(0), doc_root(0), doc_display(0), doc_structure(0)
158 static long dump_output(
xml_doc_t doc,
int argc,
char** argv ) {
160 return docH.
output(doc, argc > 0 ? argv[0] :
"");
163 static long create_vis(
dd4hep::Detector& description,
int argc,
char** argv ) {
166 return dump_output(doc, argc, argv);
169 static long create_visASCII(
dd4hep::Detector& description,
int ,
char** argv ) {
171 wr.createVis(description.
world());
172 auto& geo = *wr.m_dataPtr;
173 std::map<std::string, xml_comp_t> vis_map;
177 const char* sep =
";";
178 std::ofstream os(argv[0]);
179 for (
xml_coll_t c(geo.doc_structure,
_U(volume)); c; ++c) {
182 auto iter = vis_map.find(ref.refStr());
183 if ( iter != vis_map.end() ) {
186 os <<
"vol:" << vol.nameStr() << sep <<
"vis:" << vis.nameStr() << sep
187 <<
"visible:" << vis.visible() << sep <<
"r:"
188 << col.R() << sep <<
"g:" << col.G() << sep <<
"b:" << col.B() << sep
189 <<
"alpha:" << col.alpha() << sep <<
"line_style:"
190 << vis.attr < std::string > (
_U(line_style)) << sep
191 <<
"drawing_style:" << vis.attr < std::string> (
_U(drawing_style)) << sep
192 <<
"show_daughters:" << vis.show_daughters() << sep << std::endl;
Document create(const char *tag, const char *comment=0) const
Create new XML document by parsing empty xml buffer.
Class to support the access to collections of XmlNodes (or XmlElements)
virtual DetElement world() const =0
Return reference to the top-most (world) detector element.
void append(Handle_t handle) const
Append a new element to the existing tree.
Handle class describing visualization attributes.
Handle_t setRef(const XmlChar *tag, const XmlChar *ref)
Add reference child as a new child node. The obj must have the "name" attribute!
void append(Handle_t e) const
Append a DOM element to the current node.
#define DECLARE_APPLY(name, func)
bool isValid() const
Check the validity of the object held by the handle.
Class to easily access the properties of single XmlElements.
const char * name() const
Access the object name (or "" if not supported by the object)
float alpha() const
Get alpha value.
dd4hep::xml::Component xml_comp_t
int lineStyle() const
Get line style.
int drawingStyle() const
Get drawing style.
bool showDaughters() const
Get Flag to show/hide daughter elements.
Handle class describing a detector element.
Handle class holding a placed volume (also called physical volume)
const XmlChar * name() const
Access the object's name in unicode.
bool rgb(float &red, float &green, float &blue) const
Get RGB values of the color (if valid)
static std::string defaultComment()
Default comment string.
Class supporting the basic functionality of an XML document including ownership.
Class supporting the basic functionality of an XML document.
User abstraction class to manipulate named XML elements (references) within a document.
virtual int output(Document doc, const std::string &fname) const
Write xml document to output file (stdout if file name empty)
bool visible() const
Get visibility flag.
Class supporting to read and parse XML documents.
User abstraction class to manipulate XML elements within a document.
dd4hep::xml::Element xml_elt_t
The main interface to the dd4hep detector description package.
Attribute setAttr(const XmlChar *t, const XmlChar *v) const
Generic attribute setter with unicode value.
VisAttr visAttributes() const
Access the visualisation attributes.
std::vector< Volume > volumes
Object * data() const
Check if placement is properly instrumented.
Handle_t root() const
Access the ROOT eleemnt of the DOM document.