File indexing completed on 2024-04-06 12:05:25
0001 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0002
0003 #include <iterator>
0004 #include <memory>
0005 #include <ostream>
0006
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008
0009 class DDCompactView;
0010 class DDLogicalPart;
0011
0012 DDFilteredView::DDFilteredView(const DDCompactView& cpv, const DDFilter& fltr) : epv_(cpv), filter_(&fltr) {
0013 parents_.emplace_back(epv_.geoHistory());
0014 }
0015
0016 const DDLogicalPart& DDFilteredView::logicalPart() const { return epv_.logicalPart(); }
0017
0018 const std::string& DDFilteredView::name() const { return epv_.logicalPart().name().name(); }
0019
0020 const DDSolidShape DDFilteredView::shape() const { return epv_.logicalPart().solid().shape(); }
0021
0022 std::string const DDFilteredView::material() const { return epv_.logicalPart().material().name().fullname(); }
0023
0024 const std::vector<double>& DDFilteredView::parameters() const { return epv_.logicalPart().solid().parameters(); }
0025
0026 const DDTranslation& DDFilteredView::translation() const { return epv_.translation(); }
0027
0028 const DDRotationMatrix& DDFilteredView::rotation() const { return epv_.rotation(); }
0029
0030 const DDGeoHistory& DDFilteredView::geoHistory() const { return epv_.geoHistory(); }
0031
0032 std::vector<const DDsvalues_type*> DDFilteredView::specifics() const {
0033 std::vector<const DDsvalues_type*> result;
0034 epv_.specificsV(result);
0035 return result;
0036 }
0037
0038 void DDFilteredView::specificsV(std::vector<const DDsvalues_type*>& result) const { epv_.specificsV(result); }
0039
0040 void DDFilteredView::mergedSpecificsV(DDsvalues_type& merged) const { epv_.mergedSpecificsV(merged); }
0041
0042 DDsvalues_type DDFilteredView::mergedSpecifics() const {
0043 DDsvalues_type merged;
0044 epv_.mergedSpecificsV(merged);
0045 return merged;
0046 }
0047
0048 int DDFilteredView::copyno() const { return epv_.copyno(); }
0049
0050 const DDGeoHistory& DDFilteredView::scope() const { return epv_.scope(); }
0051
0052 bool DDFilteredView::setScope(const DDGeoHistory& hist) {
0053 bool result = epv_.setScope(hist, 0);
0054 if (result) {
0055 parents_.clear();
0056 parents_.emplace_back(hist);
0057 }
0058 return result;
0059 }
0060
0061 void DDFilteredView::clearScope() {
0062 epv_.clearScope();
0063 parents_.clear();
0064 parents_.emplace_back(epv_.geoHistory());
0065 }
0066
0067 bool DDFilteredView::next() {
0068 bool result = false;
0069 while (epv_.next()) {
0070 if (filter()) {
0071 result = true;
0072 break;
0073 }
0074 }
0075 return result;
0076 }
0077
0078
0079
0080
0081
0082
0083
0084 bool DDFilteredView::firstChild() {
0085 bool result = false;
0086
0087
0088 DDGeoHistory savedPos = epv_.geoHistory();
0089
0090
0091 DDGeoHistory savedScope = epv_.scope_;
0092 int savedDepth = epv_.depth_;
0093
0094
0095 epv_.scope_ = epv_.geoHistory();
0096 epv_.depth_ = 0;
0097
0098
0099 if (next()) {
0100 result = true;
0101 epv_.scope_ = savedScope;
0102 epv_.depth_ = savedDepth;
0103 } else {
0104 epv_.scope_ = savedScope;
0105 epv_.depth_ = savedDepth;
0106 epv_.goToHistory(savedPos);
0107 }
0108
0109 if (result) {
0110 parents_.emplace_back(epv_.geoHistory());
0111 }
0112
0113 return result;
0114 }
0115
0116
0117
0118
0119
0120
0121
0122 bool DDFilteredView::nextSibling() {
0123
0124
0125
0126 bool result = false;
0127 DDGeoHistory savedPos = epv_.geoHistory();
0128
0129 bool flag = true;
0130
0131 while (flag) {
0132 if (epv_.nextSibling()) {
0133 if (filter()) {
0134 result = true;
0135 break;
0136 } else if (firstChild()) {
0137 result = true;
0138
0139 parents_.pop_back();
0140 break;
0141 }
0142 }
0143 else if (!epv_.parent()) {
0144 flag = false;
0145 }
0146 if (epv_.geoHistory().size() == parents_[parents_.size() - 2].size()) {
0147 flag = false;
0148 }
0149 }
0150
0151 if (!result)
0152 epv_.goToHistory(savedPos);
0153 else
0154 parents_.back() = epv_.geoHistory();
0155
0156 return result;
0157 }
0158
0159 bool DDFilteredView::parent() {
0160 bool result = false;
0161
0162 if (parents_.size() == 1) {
0163 result = false;
0164 } else {
0165 parents_.pop_back();
0166 epv_.goToHistory(parents_.back());
0167 result = true;
0168 }
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 return result;
0179 }
0180
0181 void DDFilteredView::reset() {
0182 epv_.reset();
0183 parents_.clear();
0184 parents_.emplace_back(epv_.geoHistory());
0185 }
0186
0187 bool DDFilteredView::filter() { return filter_->accept(epv_); }
0188
0189 DDFilteredView::nav_type DDFilteredView::navPos() const { return epv_.navPos(); }
0190
0191 DDFilteredView::nav_type DDFilteredView::copyNumbers() const { return epv_.copyNumbers(); }
0192
0193 bool DDFilteredView::goTo(const DDFilteredView::nav_type& ) {
0194
0195
0196 bool result(false);
0197 return result;
0198 }
0199
0200 void DDFilteredView::print() {
0201 edm::LogInfo("DDFliteredView") << "FilteredView Status" << std::endl
0202 << "-------------------" << std::endl
0203 << "scope = " << epv_.scope_ << std::endl
0204 << "parents:" << std::endl;
0205 for (const auto& parent : parents_)
0206 edm::LogInfo("DDFliteredView") << " " << parent << std::endl;
0207 }
0208
0209 const std::vector<DDGeoHistory>& DDFilteredView::history() const { return parents_; }