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

Method hardApplySpaceType

src/model/Space.cpp:2514–2572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2512 }
2513
2514 void Space_Impl::hardApplySpaceType(bool hardSizeLoads) {
2515 Model model = this->model();
2516 auto space = this->getObject<Space>();
2517
2518 std::string plenumSpaceTypeName = model.plenumSpaceTypeName();
2519
2520 boost::optional<SpaceType> spaceType = this->spaceType();
2521 if (spaceType) {
2522
2523 // Clone the space type if there is a space type
2524 spaceType = spaceType->clone(model).cast<SpaceType>();
2525
2526 // Hard apply schedules to space type loads if there is a space type
2527 spaceType->hardApplySpaceLoadSchedules();
2528
2529 // Move space loads from space type to space if there is a space type
2530 for (const ModelObject& child : spaceType->children()) {
2531 if (auto load_ = child.optionalCast<SpaceLoad>()) {
2532 bool test = load_->setSpace(space);
2533 OS_ASSERT(test);
2534 }
2535 }
2536
2537 // Merge space type default constructions with space default constructions if there is a space type
2538 boost::optional<DefaultConstructionSet> spaceTypeDefaultConstructionSet = spaceType->defaultConstructionSet();
2539 if (spaceTypeDefaultConstructionSet) {
2540 boost::optional<DefaultConstructionSet> defaultConstructionSet = this->defaultConstructionSet();
2541 if (defaultConstructionSet) {
2542 defaultConstructionSet->merge(*spaceTypeDefaultConstructionSet);
2543 } else {
2544 this->setDefaultConstructionSet(*spaceTypeDefaultConstructionSet);
2545 }
2546 }
2547
2548 } else {
2549 // create a new space type
2550 spaceType = SpaceType(model);
2551 }
2552
2553 // always set space type to prevent picking up building level space type
2554 space.setSpaceType(*spaceType);
2555
2556 // Hard apply schedules to space loads, do this before clearing space type default schedule set
2557 this->hardApplySpaceLoadSchedules();
2558
2559 // If hard sizing loads, make each space load refer to unique definition and hard size it
2560 if (hardSizeLoads) {
2561 for (const ModelObject& child : this->children()) {
2562 if (auto load_ = child.optionalCast<SpaceLoad>()) {
2563 load_->hardSize();
2564 }
2565 }
2566 }
2567
2568 // clean the cloned space type
2569 spaceType->resetRenderingColor();
2570 spaceType->resetDefaultConstructionSet();
2571 spaceType->resetDefaultScheduleSet();

Callers 3

modelToRadPreProcessFunction · 0.80
combineSpacesMethod · 0.80
TEST_FFunction · 0.80

Calls 15

spaceTypeMethod · 0.95
childrenMethod · 0.95
plenumSpaceTypeNameMethod · 0.80
SpaceTypeClass · 0.70
modelMethod · 0.45
cloneMethod · 0.45
setSpaceMethod · 0.45
mergeMethod · 0.45
setSpaceTypeMethod · 0.45

Tested by 1

TEST_FFunction · 0.64