-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathSpace.cpp
3416 lines (2830 loc) · 126 KB
/
Space.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
* written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************************************************************/
#include "Space.hpp"
#include "Space_Impl.hpp"
#include "Model.hpp"
#include "Model_Impl.hpp"
#include "Building.hpp"
#include "Building_Impl.hpp"
#include "SpaceType.hpp"
#include "SpaceType_Impl.hpp"
#include "RenderingColor.hpp"
#include "RenderingColor_Impl.hpp"
#include "ConstructionBase.hpp"
#include "ConstructionBase_Impl.hpp"
#include "DefaultConstructionSet.hpp"
#include "DefaultConstructionSet_Impl.hpp"
#include "DefaultScheduleSet.hpp"
#include "DefaultScheduleSet_Impl.hpp"
#include "Schedule.hpp"
#include "Schedule_Impl.hpp"
#include "ThermalZone.hpp"
#include "ThermalZone_Impl.hpp"
#include "BuildingStory.hpp"
#include "BuildingStory_Impl.hpp"
#include "BuildingUnit.hpp"
#include "BuildingUnit_Impl.hpp"
#include "ShadingSurfaceGroup.hpp"
#include "ShadingSurfaceGroup_Impl.hpp"
#include "ShadingSurface.hpp"
#include "ShadingSurface_Impl.hpp"
#include "InteriorPartitionSurfaceGroup.hpp"
#include "InteriorPartitionSurfaceGroup_Impl.hpp"
#include "InteriorPartitionSurface.hpp"
#include "InteriorPartitionSurface_Impl.hpp"
#include "Surface.hpp"
#include "Surface_Impl.hpp"
#include "SubSurface.hpp"
#include "SubSurface_Impl.hpp"
#include "InternalMass.hpp"
#include "InternalMass_Impl.hpp"
#include "InternalMassDefinition.hpp"
#include "InternalMassDefinition_Impl.hpp"
#include "People.hpp"
#include "People_Impl.hpp"
#include "PeopleDefinition.hpp"
#include "PeopleDefinition_Impl.hpp"
#include "Lights.hpp"
#include "Lights_Impl.hpp"
#include "LightsDefinition.hpp"
#include "LightsDefinition_Impl.hpp"
#include "Luminaire.hpp"
#include "Luminaire_Impl.hpp"
#include "LuminaireDefinition.hpp"
#include "LuminaireDefinition_Impl.hpp"
#include "ElectricEquipment.hpp"
#include "ElectricEquipment_Impl.hpp"
#include "ElectricEquipmentDefinition.hpp"
#include "ElectricEquipmentDefinition_Impl.hpp"
#include "ElectricEquipmentITEAirCooled.hpp"
#include "ElectricEquipmentITEAirCooled_Impl.hpp"
#include "ElectricEquipmentITEAirCooledDefinition.hpp"
#include "ElectricEquipmentITEAirCooledDefinition_Impl.hpp"
#include "GasEquipment.hpp"
#include "GasEquipment_Impl.hpp"
#include "GasEquipmentDefinition.hpp"
#include "GasEquipmentDefinition_Impl.hpp"
#include "HotWaterEquipment.hpp"
#include "HotWaterEquipment_Impl.hpp"
#include "SteamEquipment.hpp"
#include "SteamEquipment_Impl.hpp"
#include "OtherEquipment.hpp"
#include "OtherEquipment_Impl.hpp"
#include "WaterUseEquipment.hpp"
#include "WaterUseEquipment_Impl.hpp"
#include "DaylightingControl.hpp"
#include "DaylightingControl_Impl.hpp"
#include "IlluminanceMap.hpp"
#include "IlluminanceMap_Impl.hpp"
#include "SpaceInfiltrationDesignFlowRate.hpp"
#include "SpaceInfiltrationDesignFlowRate_Impl.hpp"
#include "SpaceInfiltrationEffectiveLeakageArea.hpp"
#include "SpaceInfiltrationEffectiveLeakageArea_Impl.hpp"
#include "SpaceInfiltrationFlowCoefficient.hpp"
#include "SpaceInfiltrationFlowCoefficient_Impl.hpp"
#include "DesignSpecificationOutdoorAir.hpp"
#include "DesignSpecificationOutdoorAir_Impl.hpp"
#include "GlareSensor.hpp"
#include "GlareSensor_Impl.hpp"
#include <utilities/idd/OS_Space_FieldEnums.hxx>
#include <utilities/idd/OS_Surface_FieldEnums.hxx>
#include <utilities/idd/OS_SubSurface_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>
#include "../utilities/geometry/Geometry.hpp"
#include "../utilities/geometry/Transformation.hpp"
#include "../utilities/geometry/Point3d.hpp"
#include "../utilities/geometry/Vector3d.hpp"
#include "../utilities/geometry/EulerAngles.hpp"
#include "../utilities/geometry/BoundingBox.hpp"
#include "../utilities/geometry/Polygon3d.hpp"
#include "../utilities/core/Assert.hpp"
#undef BOOST_UBLAS_TYPE_CHECK
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4244)
#endif
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#include <cmath>
namespace openstudio {
namespace model {
namespace detail {
Space_Impl::Space_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : PlanarSurfaceGroup_Impl(idfObject, model, keepHandle) {
OS_ASSERT(idfObject.iddObject().type() == Space::iddObjectType());
}
Space_Impl::Space_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
: PlanarSurfaceGroup_Impl(other, model, keepHandle) {
OS_ASSERT(other.iddObject().type() == Space::iddObjectType());
}
Space_Impl::Space_Impl(const Space_Impl& other, Model_Impl* model, bool keepHandle) : PlanarSurfaceGroup_Impl(other, model, keepHandle) {}
boost::optional<ParentObject> Space_Impl::parent() const {
return boost::optional<ParentObject>(this->model().building());
}
bool Space_Impl::setParent(ParentObject& newParent) {
bool result = false;
if (newParent.optionalCast<Building>()) {
result = (this->model() == newParent.model());
}
return result;
}
std::vector<ModelObject> Space_Impl::children() const {
std::vector<ModelObject> result;
// shading groups
ShadingSurfaceGroupVector shadingSurfaceGroups = this->shadingSurfaceGroups();
result.insert(result.end(), shadingSurfaceGroups.begin(), shadingSurfaceGroups.end());
// interior surface partition groups
InteriorPartitionSurfaceGroupVector interiorPartitionSurfaceGroups = this->interiorPartitionSurfaceGroups();
result.insert(result.end(), interiorPartitionSurfaceGroups.begin(), interiorPartitionSurfaceGroups.end());
// surfaces
SurfaceVector surfaces = this->surfaces();
result.insert(result.end(), surfaces.begin(), surfaces.end());
// internal mass
InternalMassVector internalMass = this->internalMass();
result.insert(result.end(), internalMass.begin(), internalMass.end());
// lights
LightsVector lights = this->lights();
result.insert(result.end(), lights.begin(), lights.end());
// luminaires
LuminaireVector luminaires = this->luminaires();
result.insert(result.end(), luminaires.begin(), luminaires.end());
// people
PeopleVector people = this->people();
result.insert(result.end(), people.begin(), people.end());
// electric equipment
ElectricEquipmentVector electricEquipment = this->electricEquipment();
result.insert(result.end(), electricEquipment.begin(), electricEquipment.end());
// IT electric equipment
ElectricEquipmentITEAirCooledVector electricEquipmentITEAirCooled = this->electricEquipmentITEAirCooled();
result.insert(result.end(), electricEquipmentITEAirCooled.begin(), electricEquipmentITEAirCooled.end());
// gas equipment
GasEquipmentVector gasEquipment = this->gasEquipment();
result.insert(result.end(), gasEquipment.begin(), gasEquipment.end());
// hot water equipment
HotWaterEquipmentVector hotWaterEquipment = this->hotWaterEquipment();
result.insert(result.end(), hotWaterEquipment.begin(), hotWaterEquipment.end());
// steam equipment
SteamEquipmentVector steamEquipment = this->steamEquipment();
result.insert(result.end(), steamEquipment.begin(), steamEquipment.end());
// other equipment
OtherEquipmentVector otherEquipment = this->otherEquipment();
result.insert(result.end(), otherEquipment.begin(), otherEquipment.end());
// water use equipment
WaterUseEquipmentVector waterUseEquipment = this->waterUseEquipment();
result.insert(result.end(), waterUseEquipment.begin(), waterUseEquipment.end());
// daylighting controls
DaylightingControlVector daylightingControls = this->daylightingControls();
result.insert(result.end(), daylightingControls.begin(), daylightingControls.end());
// illuminance map
IlluminanceMapVector illuminanceMaps = this->illuminanceMaps();
result.insert(result.end(), illuminanceMaps.begin(), illuminanceMaps.end());
// glare sensor
GlareSensorVector glareSensors = this->glareSensors();
result.insert(result.end(), glareSensors.begin(), glareSensors.end());
// SpaceInfiltration_DesignFlowRate
SpaceInfiltrationDesignFlowRateVector spaceInfiltrationDesignFlowRates = this->spaceInfiltrationDesignFlowRates();
result.insert(result.end(), spaceInfiltrationDesignFlowRates.begin(), spaceInfiltrationDesignFlowRates.end());
// SpaceInfiltration_EffectiveLeakageArea
SpaceInfiltrationEffectiveLeakageAreaVector spaceInfiltrationEffectiveLeakageAreas = this->spaceInfiltrationEffectiveLeakageAreas();
result.insert(result.end(), spaceInfiltrationEffectiveLeakageAreas.begin(), spaceInfiltrationEffectiveLeakageAreas.end());
// SpaceInfiltration_FlowCoefficient
SpaceInfiltrationFlowCoefficientVector spaceInfiltrationFlowCoefficients = this->spaceInfiltrationFlowCoefficients();
result.insert(result.end(), spaceInfiltrationFlowCoefficients.begin(), spaceInfiltrationFlowCoefficients.end());
return result;
}
std::vector<IddObjectType> Space_Impl::allowableChildTypes() const {
std::vector<IddObjectType> result;
result.push_back(IddObjectType::OS_ShadingSurfaceGroup);
result.push_back(IddObjectType::OS_InteriorPartitionSurfaceGroup);
result.push_back(IddObjectType::OS_Surface);
result.push_back(IddObjectType::OS_Lights);
result.push_back(IddObjectType::OS_Luminaire);
result.push_back(IddObjectType::OS_People);
result.push_back(IddObjectType::OS_ElectricEquipment);
result.push_back(IddObjectType::OS_ElectricEquipment_ITE_AirCooled);
result.push_back(IddObjectType::OS_GasEquipment);
result.push_back(IddObjectType::OS_HotWaterEquipment);
result.push_back(IddObjectType::OS_Daylighting_Control);
result.push_back(IddObjectType::OS_IlluminanceMap);
result.push_back(IddObjectType::OS_SpaceInfiltration_DesignFlowRate);
result.push_back(IddObjectType::OS_SpaceInfiltration_EffectiveLeakageArea);
result.push_back(IddObjectType::OS_SpaceInfiltration_FlowCoefficient);
return result;
}
const std::vector<std::string>& Space_Impl::outputVariableNames() const {
static const std::vector<std::string> result;
return result;
}
IddObjectType Space_Impl::iddObjectType() const {
return Space::iddObjectType();
}
Transformation Space_Impl::buildingTransformation() const {
return this->transformation();
}
bool Space_Impl::changeTransformation(const openstudio::Transformation& transformation) {
Transformation oldTransformation = this->transformation();
if (!setTransformation(transformation)) {
return false;
}
// go through and update all child points and transformations so that:
// (Tnew^-1 * Told) * xold = childTransformation * xold = xnew
Transformation childTransformation = transformation.inverse() * oldTransformation;
for (Surface surface : this->surfaces()) {
bool test = surface.setVertices(childTransformation * surface.vertices());
if (!test) {
LOG(Error, "Could not transform vertices for Surface '" << surface.name().get() << "'.");
}
for (SubSurface subSurface : surface.subSurfaces()) {
test = subSurface.setVertices(childTransformation * subSurface.vertices());
if (!test) {
LOG(Error, "Could not transform vertices for SubSurface '" << subSurface.name().get() << "'.");
}
}
}
for (ShadingSurfaceGroup shadingSurfaceGroup : this->shadingSurfaceGroups()) {
bool test = shadingSurfaceGroup.setTransformation(childTransformation * shadingSurfaceGroup.transformation());
OS_ASSERT(test);
}
for (InteriorPartitionSurfaceGroup interiorPartitionSurfaceGroup : this->interiorPartitionSurfaceGroups()) {
bool test = interiorPartitionSurfaceGroup.setTransformation(childTransformation * interiorPartitionSurfaceGroup.transformation());
OS_ASSERT(test);
}
for (Luminaire luminaire : this->luminaires()) {
bool test = luminaire.setTransformation(childTransformation * luminaire.transformation());
OS_ASSERT(test);
}
for (DaylightingControl daylightingControl : this->daylightingControls()) {
bool test = daylightingControl.setTransformation(childTransformation * daylightingControl.transformation());
OS_ASSERT(test);
}
for (IlluminanceMap illuminanceMap : this->illuminanceMaps()) {
bool test = illuminanceMap.setTransformation(childTransformation * illuminanceMap.transformation());
OS_ASSERT(test);
}
return true;
}
BoundingBox Space_Impl::boundingBox() const {
BoundingBox result;
for (Surface surface : this->surfaces()) {
result.addPoints(surface.vertices());
}
for (ShadingSurfaceGroup shadingSurfaceGroup : this->shadingSurfaceGroups()) {
result.addPoints(shadingSurfaceGroup.transformation() * shadingSurfaceGroup.boundingBox().corners());
}
for (InteriorPartitionSurfaceGroup interiorPartitionSurfaceGroup : this->interiorPartitionSurfaceGroups()) {
result.addPoints(interiorPartitionSurfaceGroup.transformation() * interiorPartitionSurfaceGroup.boundingBox().corners());
}
for (Luminaire luminaire : this->luminaires()) {
result.addPoint(luminaire.position());
}
for (DaylightingControl daylightingControl : this->daylightingControls()) {
result.addPoint(daylightingControl.position());
}
for (IlluminanceMap illuminanceMap : this->illuminanceMaps()) {
result.addPoints(illuminanceMap.transformation() * illuminanceMap.corners());
}
for (GlareSensor glareSensor : this->glareSensors()) {
result.addPoint(glareSensor.position());
}
return result;
}
double Space_Impl::directionofRelativeNorth() const {
boost::optional<double> value = getDouble(OS_SpaceFields::DirectionofRelativeNorth, true);
OS_ASSERT(value);
return value.get();
}
bool Space_Impl::isDirectionofRelativeNorthDefaulted() const {
return isEmpty(OS_SpaceFields::DirectionofRelativeNorth);
}
double Space_Impl::xOrigin() const {
boost::optional<double> value = getDouble(OS_SpaceFields::XOrigin, true);
OS_ASSERT(value);
return value.get();
}
bool Space_Impl::isXOriginDefaulted() const {
return isEmpty(OS_SpaceFields::XOrigin);
}
double Space_Impl::yOrigin() const {
boost::optional<double> value = getDouble(OS_SpaceFields::YOrigin, true);
OS_ASSERT(value);
return value.get();
}
bool Space_Impl::isYOriginDefaulted() const {
return isEmpty(OS_SpaceFields::YOrigin);
}
double Space_Impl::zOrigin() const {
boost::optional<double> value = getDouble(OS_SpaceFields::ZOrigin, true);
OS_ASSERT(value);
return value.get();
}
bool Space_Impl::isZOriginDefaulted() const {
return isEmpty(OS_SpaceFields::ZOrigin);
}
bool Space_Impl::partofTotalFloorArea() const {
boost::optional<std::string> value = getString(OS_SpaceFields::PartofTotalFloorArea, false, true);
if (!value) {
if (this->isPlenum()) {
return false;
}
value = getString(OS_SpaceFields::PartofTotalFloorArea, true);
}
OS_ASSERT(value);
return openstudio::istringEqual(value.get(), "Yes");
}
bool Space_Impl::isPartofTotalFloorAreaDefaulted() const {
return isEmpty(OS_SpaceFields::PartofTotalFloorArea);
}
bool Space_Impl::setDirectionofRelativeNorth(double directionofRelativeNorth, bool driverMethod) {
bool result = setDouble(OS_SpaceFields::DirectionofRelativeNorth, directionofRelativeNorth, driverMethod);
OS_ASSERT(result);
return result;
}
void Space_Impl::resetDirectionofRelativeNorth() {
bool result = setString(OS_SpaceFields::DirectionofRelativeNorth, "");
OS_ASSERT(result);
}
bool Space_Impl::setXOrigin(double xOrigin, bool driverMethod) {
bool result = setDouble(OS_SpaceFields::XOrigin, xOrigin, driverMethod);
OS_ASSERT(result);
return result;
}
void Space_Impl::resetXOrigin() {
bool result = setString(OS_SpaceFields::XOrigin, "");
OS_ASSERT(result);
}
bool Space_Impl::setYOrigin(double yOrigin, bool driverMethod) {
bool result = setDouble(OS_SpaceFields::YOrigin, yOrigin, driverMethod);
OS_ASSERT(result);
return result;
}
void Space_Impl::resetYOrigin() {
bool result = setString(OS_SpaceFields::YOrigin, "");
OS_ASSERT(result);
}
bool Space_Impl::setZOrigin(double zOrigin, bool driverMethod) {
bool result = setDouble(OS_SpaceFields::ZOrigin, zOrigin, driverMethod);
OS_ASSERT(result);
return result;
}
void Space_Impl::resetZOrigin() {
bool result = setString(OS_SpaceFields::ZOrigin, "");
OS_ASSERT(result);
}
bool Space_Impl::setPartofTotalFloorArea(bool partofTotalFloorArea) {
bool result = false;
if (partofTotalFloorArea) {
result = setString(OS_SpaceFields::PartofTotalFloorArea, "Yes");
} else {
result = setString(OS_SpaceFields::PartofTotalFloorArea, "No");
}
OS_ASSERT(result);
return result;
}
void Space_Impl::resetPartofTotalFloorArea() {
bool result = setString(OS_SpaceFields::PartofTotalFloorArea, "");
OS_ASSERT(result);
}
boost::optional<SpaceType> Space_Impl::spaceType() const {
boost::optional<SpaceType> result = getObject<ModelObject>().getModelObjectTarget<SpaceType>(OS_SpaceFields::SpaceTypeName);
if (!result) {
if (this->isPlenum()) {
result = this->model().plenumSpaceType();
} else {
boost::optional<Building> building = this->model().building();
if (building) {
result = building->spaceType();
}
}
}
return result;
}
bool Space_Impl::isSpaceTypeDefaulted() const {
return isEmpty(OS_SpaceFields::SpaceTypeName);
}
bool Space_Impl::setSpaceType(const SpaceType& spaceType) {
return setPointer(OS_SpaceFields::SpaceTypeName, spaceType.handle());
}
void Space_Impl::resetSpaceType() {
setString(OS_SpaceFields::SpaceTypeName, "");
}
boost::optional<DefaultConstructionSet> Space_Impl::defaultConstructionSet() const {
return getObject<ModelObject>().getModelObjectTarget<DefaultConstructionSet>(OS_SpaceFields::DefaultConstructionSetName);
}
boost::optional<ConstructionBase> Space_Impl::getDefaultConstruction(const PlanarSurface& planarSurface) const {
boost::optional<std::pair<ConstructionBase, int>> result = this->getDefaultConstructionWithSearchDistance(planarSurface);
if (result) {
return result->first;
}
return boost::none;
}
boost::optional<std::pair<ConstructionBase, int>> Space_Impl::getDefaultConstructionWithSearchDistance(const PlanarSurface& planarSurface) const {
boost::optional<ConstructionBase> result;
boost::optional<DefaultConstructionSet> defaultConstructionSet;
boost::optional<SpaceType> spaceType;
boost::optional<BuildingStory> buildingStory;
boost::optional<Building> building;
// first check this object
defaultConstructionSet = this->defaultConstructionSet();
if (defaultConstructionSet) {
result = defaultConstructionSet->getDefaultConstruction(planarSurface);
if (result) {
return std::make_pair(*result, 1);
}
}
// then check space type
spaceType = this->spaceType();
if (spaceType && !this->isSpaceTypeDefaulted()) {
defaultConstructionSet = spaceType->defaultConstructionSet();
if (defaultConstructionSet) {
result = defaultConstructionSet->getDefaultConstruction(planarSurface);
if (result) {
return std::make_pair(*result, 2);
}
}
}
// then check building story
buildingStory = this->buildingStory();
if (buildingStory) {
defaultConstructionSet = buildingStory->defaultConstructionSet();
if (defaultConstructionSet) {
result = defaultConstructionSet->getDefaultConstruction(planarSurface);
if (result) {
return std::make_pair(*result, 3);
}
}
}
// then check building
building = this->model().building();
if (building) {
defaultConstructionSet = building->defaultConstructionSet();
if (defaultConstructionSet) {
result = defaultConstructionSet->getDefaultConstruction(planarSurface);
if (result) {
return std::make_pair(*result, 4);
}
}
// then check building's space type
spaceType = building->spaceType();
if (spaceType) {
defaultConstructionSet = spaceType->defaultConstructionSet();
if (defaultConstructionSet) {
result = defaultConstructionSet->getDefaultConstruction(planarSurface);
if (result) {
return std::make_pair(*result, 5);
}
}
}
}
return boost::none;
}
bool Space_Impl::setDefaultConstructionSet(const DefaultConstructionSet& defaultConstructionSet) {
return setPointer(OS_SpaceFields::DefaultConstructionSetName, defaultConstructionSet.handle());
}
void Space_Impl::resetDefaultConstructionSet() {
setString(OS_SpaceFields::DefaultConstructionSetName, "");
}
boost::optional<DefaultScheduleSet> Space_Impl::defaultScheduleSet() const {
return getObject<ModelObject>().getModelObjectTarget<DefaultScheduleSet>(OS_SpaceFields::DefaultScheduleSetName);
}
boost::optional<Schedule> Space_Impl::getDefaultSchedule(const DefaultScheduleType& defaultScheduleType) const {
boost::optional<Schedule> result;
boost::optional<DefaultScheduleSet> defaultScheduleSet;
boost::optional<SpaceType> spaceType;
boost::optional<BuildingStory> buildingStory;
boost::optional<Building> building;
// first check this object
defaultScheduleSet = this->defaultScheduleSet();
if (defaultScheduleSet) {
result = defaultScheduleSet->getDefaultSchedule(defaultScheduleType);
if (result) {
return result;
}
}
// then check space type
spaceType = this->spaceType();
if (spaceType) {
defaultScheduleSet = spaceType->defaultScheduleSet();
if (defaultScheduleSet) {
result = defaultScheduleSet->getDefaultSchedule(defaultScheduleType);
if (result) {
return result;
}
}
}
// then check building story
buildingStory = this->buildingStory();
if (buildingStory) {
defaultScheduleSet = buildingStory->defaultScheduleSet();
if (defaultScheduleSet) {
result = defaultScheduleSet->getDefaultSchedule(defaultScheduleType);
if (result) {
return result;
}
}
}
// then check building
building = this->model().building();
if (building) {
defaultScheduleSet = building->defaultScheduleSet();
if (defaultScheduleSet) {
result = defaultScheduleSet->getDefaultSchedule(defaultScheduleType);
if (result) {
return result;
}
}
// then check building's space type
spaceType = building->spaceType();
if (spaceType) {
defaultScheduleSet = spaceType->defaultScheduleSet();
if (defaultScheduleSet) {
result = defaultScheduleSet->getDefaultSchedule(defaultScheduleType);
if (result) {
return result;
}
}
}
}
return boost::none;
}
bool Space_Impl::setDefaultScheduleSet(const DefaultScheduleSet& defaultScheduleSet) {
return setPointer(OS_SpaceFields::DefaultScheduleSetName, defaultScheduleSet.handle());
}
void Space_Impl::resetDefaultScheduleSet() {
setString(OS_SpaceFields::DefaultScheduleSetName, "");
}
OptionalThermalZone Space_Impl::thermalZone() const {
return getObject<ModelObject>().getModelObjectTarget<ThermalZone>(OS_SpaceFields::ThermalZoneName);
}
bool Space_Impl::setThermalZone(ThermalZone& thermalZone) {
bool result = this->setPointer(OS_SpaceFields::ThermalZoneName, thermalZone.handle());
if (result) {
thermalZone.checkDaylightingControlsAndIlluminanceMaps();
}
return result;
}
void Space_Impl::resetThermalZone() {
bool result = this->setString(OS_SpaceFields::ThermalZoneName, "");
OS_ASSERT(result);
}
OptionalBuildingStory Space_Impl::buildingStory() const {
return getObject<ModelObject>().getModelObjectTarget<BuildingStory>(OS_SpaceFields::BuildingStoryName);
}
bool Space_Impl::setBuildingStory(const BuildingStory& buildingStory) {
return this->setPointer(OS_SpaceFields::BuildingStoryName, buildingStory.handle());
}
void Space_Impl::resetBuildingStory() {
bool result = this->setString(OS_SpaceFields::BuildingStoryName, "");
OS_ASSERT(result);
}
boost::optional<BuildingUnit> Space_Impl::buildingUnit() const {
return getObject<ModelObject>().getModelObjectTarget<BuildingUnit>(OS_SpaceFields::BuildingUnitName);
}
bool Space_Impl::setBuildingUnit(const BuildingUnit& buildingUnit) {
return this->setPointer(OS_SpaceFields::BuildingUnitName, buildingUnit.handle());
}
void Space_Impl::resetBuildingUnit() {
bool result = this->setString(OS_SpaceFields::BuildingUnitName, "");
OS_ASSERT(result);
}
ShadingSurfaceGroupVector Space_Impl::shadingSurfaceGroups() const {
return getObject<ModelObject>().getModelObjectSources<ShadingSurfaceGroup>(ShadingSurfaceGroup::iddObjectType());
}
InteriorPartitionSurfaceGroupVector Space_Impl::interiorPartitionSurfaceGroups() const {
return getObject<ModelObject>().getModelObjectSources<InteriorPartitionSurfaceGroup>(InteriorPartitionSurfaceGroup::iddObjectType());
}
SurfaceVector Space_Impl::surfaces() const {
return getObject<ModelObject>().getModelObjectSources<Surface>(Surface::iddObjectType());
}
std::vector<InternalMass> Space_Impl::internalMass() const {
return getObject<Space>().getModelObjectSources<InternalMass>(InternalMass::iddObjectType());
}
PeopleVector Space_Impl::people() const {
return getObject<ModelObject>().getModelObjectSources<People>(People::iddObjectType());
}
LightsVector Space_Impl::lights() const {
return getObject<ModelObject>().getModelObjectSources<Lights>(Lights::iddObjectType());
}
LuminaireVector Space_Impl::luminaires() const {
return getObject<ModelObject>().getModelObjectSources<Luminaire>(Luminaire::iddObjectType());
}
ElectricEquipmentVector Space_Impl::electricEquipment() const {
return getObject<ModelObject>().getModelObjectSources<ElectricEquipment>(ElectricEquipment::iddObjectType());
}
ElectricEquipmentITEAirCooledVector Space_Impl::electricEquipmentITEAirCooled() const {
return getObject<ModelObject>().getModelObjectSources<ElectricEquipmentITEAirCooled>(ElectricEquipmentITEAirCooled::iddObjectType());
}
GasEquipmentVector Space_Impl::gasEquipment() const {
return getObject<ModelObject>().getModelObjectSources<GasEquipment>(GasEquipment::iddObjectType());
}
HotWaterEquipmentVector Space_Impl::hotWaterEquipment() const {
return getObject<ModelObject>().getModelObjectSources<HotWaterEquipment>(HotWaterEquipment::iddObjectType());
}
SteamEquipmentVector Space_Impl::steamEquipment() const {
return getObject<ModelObject>().getModelObjectSources<SteamEquipment>(SteamEquipment::iddObjectType());
}
OtherEquipmentVector Space_Impl::otherEquipment() const {
return getObject<ModelObject>().getModelObjectSources<OtherEquipment>(OtherEquipment::iddObjectType());
}
WaterUseEquipmentVector Space_Impl::waterUseEquipment() const {
return getObject<ModelObject>().getModelObjectSources<WaterUseEquipment>(WaterUseEquipment::iddObjectType());
}
DaylightingControlVector Space_Impl::daylightingControls() const {
return getObject<ModelObject>().getModelObjectSources<DaylightingControl>(DaylightingControl::iddObjectType());
}
IlluminanceMapVector Space_Impl::illuminanceMaps() const {
return getObject<ModelObject>().getModelObjectSources<IlluminanceMap>(IlluminanceMap::iddObjectType());
}
GlareSensorVector Space_Impl::glareSensors() const {
return getObject<ModelObject>().getModelObjectSources<GlareSensor>(GlareSensor::iddObjectType());
}
SpaceInfiltrationDesignFlowRateVector Space_Impl::spaceInfiltrationDesignFlowRates() const {
return getObject<ModelObject>().getModelObjectSources<SpaceInfiltrationDesignFlowRate>(SpaceInfiltrationDesignFlowRate::iddObjectType());
}
SpaceInfiltrationEffectiveLeakageAreaVector Space_Impl::spaceInfiltrationEffectiveLeakageAreas() const {
return getObject<ModelObject>().getModelObjectSources<SpaceInfiltrationEffectiveLeakageArea>(
SpaceInfiltrationEffectiveLeakageArea::iddObjectType());
}
SpaceInfiltrationFlowCoefficientVector Space_Impl::spaceInfiltrationFlowCoefficients() const {
return getObject<ModelObject>().getModelObjectSources<SpaceInfiltrationFlowCoefficient>(SpaceInfiltrationFlowCoefficient::iddObjectType());
}
boost::optional<DesignSpecificationOutdoorAir> Space_Impl::designSpecificationOutdoorAir() const {
boost::optional<DesignSpecificationOutdoorAir> result;
result = getObject<ModelObject>().getModelObjectTarget<DesignSpecificationOutdoorAir>(OS_SpaceFields::DesignSpecificationOutdoorAirObjectName);
if (!result) {
boost::optional<SpaceType> spaceType = this->spaceType();
if (spaceType) {
result = spaceType->designSpecificationOutdoorAir();
}
}
return result;
}
bool Space_Impl::isDesignSpecificationOutdoorAirDefaulted() const {
return isEmpty(OS_SpaceFields::DesignSpecificationOutdoorAirObjectName);
}
bool Space_Impl::setDesignSpecificationOutdoorAir(const DesignSpecificationOutdoorAir& designSpecificationOutdoorAir) {
return setPointer(OS_SpaceFields::DesignSpecificationOutdoorAirObjectName, designSpecificationOutdoorAir.handle());
}
void Space_Impl::resetDesignSpecificationOutdoorAir() {
bool test = setString(OS_SpaceFields::DesignSpecificationOutdoorAirObjectName, "");
OS_ASSERT(test);
}
int Space_Impl::multiplier() const {
int result = 1;
OptionalThermalZone thermalZone = this->thermalZone();
if (thermalZone) {
result = thermalZone->multiplier();
}
return result;
}
double Space_Impl::floorArea() const {
double result = 0;
for (const Surface& surface : this->surfaces()) {
if (istringEqual(surface.surfaceType(), "Floor")) {
if (surface.isAirWall()) {
continue;
}
result += surface.grossArea();
}
}
return result;
}
double Space_Impl::exteriorArea() const {
double result = 0;
for (const Surface& surface : this->surfaces()) {
if (istringEqual(surface.outsideBoundaryCondition(), "Outdoors")) {
result += surface.grossArea();
}
}
return result;
}
double Space_Impl::exteriorWallArea() const {
double result = 0;
for (const Surface& surface : this->surfaces()) {
if (istringEqual(surface.outsideBoundaryCondition(), "Outdoors")) {
if (istringEqual(surface.surfaceType(), "Wall")) {
result += surface.grossArea();
}
}
}
return result;
}
double Space_Impl::volume() const {
double result = 0;
// TODO: need a better method
double roofHeight = 0;
int numRoof = 0;
double floorHeight = 0;
int numFloor = 0;
for (const Surface& surface : this->surfaces()) {
if (istringEqual(surface.surfaceType(), "Floor")) {
for (const Point3d& point : surface.vertices()) {
floorHeight += point.z();
++numFloor;
}
} else if (istringEqual(surface.surfaceType(), "RoofCeiling")) {
for (const Point3d& point : surface.vertices()) {
roofHeight += point.z();
++numRoof;
}
}
}
if ((numRoof > 0) && (numFloor > 0)) {
roofHeight /= numRoof;
floorHeight /= numFloor;
result = (roofHeight - floorHeight) * this->floorArea();
}
return result;
}
double Space_Impl::numberOfPeople() const {
double result = 0.0;
double area = floorArea();
for (const People& person : this->people()) {
result += person.getNumberOfPeople(area);
}
if (OptionalSpaceType st = spaceType()) {
for (const People& person : st->people()) {
result += person.getNumberOfPeople(area);
}
}
return result;
}
bool Space_Impl::setNumberOfPeople(double numberOfPeople) {
OptionalPeople templatePeople;
PeopleVector myPeople = people();
if (myPeople.empty()) {
if (OptionalSpaceType st = spaceType()) {
myPeople = st->people();
}
}
if (!myPeople.empty()) {
templatePeople = myPeople[0];
}
return setNumberOfPeople(numberOfPeople, templatePeople);
}
bool Space_Impl::setNumberOfPeople(double numberOfPeople, const boost::optional<People>& templatePeople) {
if (numberOfPeople < 0.0) {
LOG(Error, "Space cannot set numberOfPeople to " << numberOfPeople << ", the value must be >= 0.0.");
return false;
}
// create or modify People and PeopleDefinition object
OptionalPeople myPeople = getMySpaceLoadInstance<People, PeopleDefinition>(templatePeople);
if (!myPeople) {
LOG(Error, "The templatePeople object must be in the same Model as this Space.");
return false;
}
// set space and number of people
bool ok(true);
myPeople->makeUnique();
ok = myPeople->setSpace(getObject<Space>());
OS_ASSERT(ok);
ok = myPeople->peopleDefinition().setNumberofPeople(numberOfPeople);
OS_ASSERT(ok);
ok = myPeople->setMultiplier(1);
OS_ASSERT(ok);
// remove all other people from space
PeopleVector allMyPeople = people();
removeAllButOneSpaceLoadInstance<People>(allMyPeople, *myPeople);
// handle space type
if (OptionalSpaceType spaceType = this->spaceType()) {
if (!spaceType->people().empty()) {
// if spaceType is used by multiple ParentObjects (includes Space, Building, excludes
// SpaceLoadInstances), create and use clone instead of original
if (spaceType->getModelObjectSources<ParentObject>().size() > 1u) {
spaceType = spaceType->clone().cast<SpaceType>();
setSpaceType(*spaceType);
}
allMyPeople = spaceType->people();
for (People& peopleObject : allMyPeople) {
peopleObject.remove();
}
}
}
return true;
}
double Space_Impl::peoplePerFloorArea() const {
double result = 0.0;
double area = floorArea();
for (const People& person : this->people()) {