File indexing completed on 2025-10-31 08:16:30
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 #include "Acts/Detector/detail/BlueprintDrawer.hpp"
0010 
0011 #include <vector>
0012 
0013 namespace {
0014 
0015 
0016 
0017 
0018 
0019 std::string shapeStr(
0020     const Acts::Experimental::detail::BlueprintDrawer::Options::Node& node) {
0021   return "[shape=\"" + node.shape + "\";style=\"filled\";fillcolor=\"" +
0022          node.color + "\"];";
0023 }
0024 
0025 
0026 
0027 
0028 
0029 
0030 std::string labelStr(
0031     const Acts::Experimental::detail::BlueprintDrawer::Options::Node& node,
0032     const std::string& label, const std::vector<std::string>& info = {}) {
0033   std::string lText = "[label=<<font face=\"";
0034   lText += node.face;
0035   lText += "\" point-size=\"";
0036   lText += std::to_string(node.labelText);
0037   lText += "\">" + label;
0038   if (!info.empty()) {
0039     lText += "</font><br/>";
0040     lText += "<font face=\"";
0041     lText += node.face;
0042     lText += "\" point-size=\"";
0043     lText += std::to_string(node.infoText);
0044     lText += "\">";
0045     for (const auto& i : info) {
0046       lText += i;
0047       lText += "<br/>";
0048     }
0049   }
0050   lText += "</font>";
0051   lText += ">];";
0052   return lText;
0053 }
0054 
0055 }  
0056 
0057 void Acts::Experimental::detail::BlueprintDrawer::dotStream(
0058     std::ostream& ss, const Acts::Experimental::Gen2Blueprint::Node& node,
0059     const Options& options) {
0060   
0061   std::string nodeName = node.name;
0062   std::replace(nodeName.begin(), nodeName.end(), '/', '_');
0063 
0064   
0065   if (node.isRoot()) {
0066     ss << "digraph " << options.graphName << " {" << '\n';
0067     ss << nodeName << " " << labelStr(options.root, nodeName, node.auxiliary)
0068        << '\n';
0069     ss << nodeName << " " << shapeStr(options.root) << '\n';
0070 
0071   } else if (node.isLeaf()) {
0072     ss << nodeName << " " << labelStr(options.leaf, nodeName, node.auxiliary)
0073        << '\n';
0074     ss << nodeName << " "
0075        << ((node.internalsBuilder != nullptr) ? shapeStr(options.leaf)
0076                                               : shapeStr(options.gap))
0077        << '\n';
0078   } else {
0079     ss << nodeName << " " << labelStr(options.branch, nodeName, node.auxiliary)
0080        << '\n';
0081     ss << nodeName << " " << shapeStr(options.branch) << '\n';
0082   }
0083   
0084   for (const auto& c : node.children) {
0085     
0086     std::string childName = c->name;
0087     std::replace(childName.begin(), childName.end(), '/', '_');
0088     ss << nodeName << " -> " << childName << ";" << '\n';
0089     dotStream(ss, *c, options);
0090   }
0091 
0092   
0093   Options::Node shape = node.isLeaf() ? options.shape : options.virtualShape;
0094   std::stringstream bts;
0095   bts << node.boundsType;
0096   ss << nodeName + "_shape " << shapeStr(shape) << '\n';
0097   ss << nodeName + "_shape "
0098      << labelStr(shape, bts.str(),
0099                  {"t = " + toString(node.transform.translation(), 1),
0100                   "b = " + toString(node.boundaryValues, 1)})
0101      << '\n';
0102   ss << nodeName << " -> " << nodeName + "_shape [ arrowhead = \"none\" ];"
0103      << '\n';
0104 
0105   
0106   if (node.internalsBuilder != nullptr) {
0107     ss << nodeName + "_int " << shapeStr(options.internals) << '\n';
0108     ss << nodeName << " -> " << nodeName + "_int;" << '\n';
0109   }
0110 
0111   if (node.geoIdGenerator != nullptr) {
0112     ss << nodeName + "_geoID " << shapeStr(options.geoID) << '\n';
0113     ss << nodeName << " -> " << nodeName + "_geoID;" << '\n';
0114   }
0115 
0116   if (node.rootVolumeFinderBuilder != nullptr) {
0117     ss << nodeName + "_roots " << shapeStr(options.roots) << '\n';
0118     ss << nodeName << " -> " << nodeName + "_roots;" << '\n';
0119   }
0120 
0121   if (node.isRoot()) {
0122     ss << "}" << '\n';
0123   }
0124 }