File indexing completed on 2024-04-06 12:05:26
0001 #include "DetectorDescription/Core/interface/ExtrudedPolygon.h"
0002 #include "DataFormats/Math/interface/GeantUnits.h"
0003 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
0004 #include "DetectorDescription/Core/interface/Solid.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007
0008 #include <cassert>
0009
0010 using DDI::ExtrudedPolygon;
0011 using namespace geant_units::operators;
0012
0013 ExtrudedPolygon::ExtrudedPolygon(const std::vector<double>& x,
0014 const std::vector<double>& y,
0015 const std::vector<double>& z,
0016 const std::vector<double>& zx,
0017 const std::vector<double>& zy,
0018 const std::vector<double>& zscale)
0019 : Solid(DDSolidShape::ddextrudedpolygon) {
0020 assert(x.size() == y.size());
0021 assert(z.size() == zx.size());
0022 assert(z.size() == zy.size());
0023 assert(z.size() == zscale.size());
0024
0025 p_.reserve(x.size() + y.size() + z.size() + zx.size() + zy.size() + zscale.size() + 1);
0026 p_.emplace_back(z.size());
0027 p_.insert(p_.end(), x.begin(), x.end());
0028 p_.insert(p_.end(), y.begin(), y.end());
0029 p_.insert(p_.end(), z.begin(), z.end());
0030 p_.insert(p_.end(), zx.begin(), zx.end());
0031 p_.insert(p_.end(), zy.begin(), zy.end());
0032 p_.insert(p_.end(), zscale.begin(), zscale.end());
0033 }
0034
0035 double ExtrudedPolygon::volume() const {
0036 double volume = 0;
0037
0038 return volume;
0039 }
0040
0041 void DDI::ExtrudedPolygon::stream(std::ostream& os) const {
0042 auto xysize = (unsigned int)((p_.size() - 4 * p_[0]) * 0.5);
0043 os << " XY Points[cm]=";
0044 for (unsigned int k = 1; k <= xysize; ++k)
0045 os << convertMmToCm(p_[k]) << ", " << convertMmToCm(p_[k + xysize]) << "; ";
0046 os << " with " << p_[0] << " Z sections:";
0047 unsigned int m0 = p_.size() - 4 * p_[0];
0048 for (unsigned int m = m0; m < m0 + p_[0]; ++m) {
0049 os << " z[cm]=" << convertMmToCm(p_[m]);
0050 os << ", x[cm]=" << convertMmToCm(p_[m + p_[0]]);
0051 os << ", y[cm]=" << convertMmToCm(p_[m + 2 * p_[0]]);
0052 os << ", scale[cm]=" << convertMmToCm(p_[m + 3 * p_[0]]) << ";";
0053 }
0054 }