MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / setInfiltrationDesignFlowRateHelper

Method setInfiltrationDesignFlowRateHelper

src/model/Space.cpp:2443–2487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2441 }
2442
2443 SpaceInfiltrationDesignFlowRate Space_Impl::setInfiltrationDesignFlowRateHelper() {
2444 // We try to grab an existing one, whether that's on the SpaceType or Space, because we want to retain other parameters like Term Coefficients
2445 auto spis = this->spaceInfiltrationDesignFlowRates();
2446
2447 boost::optional<SpaceInfiltrationDesignFlowRate> spi_;
2448
2449 // handle space type
2450 if (auto sp_ = this->spaceType()) {
2451 auto sp_spis = sp_->spaceInfiltrationDesignFlowRates();
2452 if (!sp_spis.empty()) {
2453 // if sp is used by multiple ParentObjects (includes Space, Building, excludes SpaceLoadInstances), create and use clone instead of original
2454 if (sp_->getModelObjectSources<ParentObject>().size() > 1u) {
2455 sp_ = sp_->clone().cast<SpaceType>();
2456 sp_spis = sp_->spaceInfiltrationDesignFlowRates();
2457 setSpaceType(*sp_);
2458 }
2459 // If the Space didn't have one, we move the SpaceType one to the space
2460 if (spis.empty()) {
2461 spi_ = std::move(sp_spis.front());
2462 sp_spis.erase(sp_spis.begin());
2463 spi_->setSpace(getObject<Space>());
2464 }
2465
2466 for (auto& spi : sp_spis) {
2467 spi.remove();
2468 }
2469 }
2470 }
2471
2472 if (spi_) {
2473 return *spi_;
2474 }
2475
2476 if (spis.empty()) {
2477 SpaceInfiltrationDesignFlowRate spi(this->model());
2478 spi.setSpace(getObject<Space>());
2479 return spi;
2480 }
2481
2482 auto& spi = spis[0];
2483 for (auto& spi : spis | std::views::drop(1)) {
2484 spi.remove();
2485 }
2486 return spi;
2487 }
2488
2489 bool Space_Impl::setInfiltrationDesignFlowRate(double infiltrationDesignFlowRate) {
2490 auto spi = setInfiltrationDesignFlowRateHelper();

Callers

nothing calls this directly

Calls 10

spaceTypeMethod · 0.95
beginMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
cloneMethod · 0.45
eraseMethod · 0.45
setSpaceMethod · 0.45
removeMethod · 0.45
modelMethod · 0.45

Tested by

no test coverage detected