| 858 | } |
| 859 | |
| 860 | double Space_Impl::ceilingHeight() const { |
| 861 | boost::optional<double> value = getDouble(OS_SpaceFields::CeilingHeight, true); |
| 862 | if (value) { |
| 863 | return value.get(); |
| 864 | } |
| 865 | |
| 866 | double result = 0; |
| 867 | |
| 868 | // TODO: need a better method |
| 869 | double roofHeight = 0; |
| 870 | int numRoof = 0; |
| 871 | double floorHeight = 0; |
| 872 | int numFloor = 0; |
| 873 | for (const Surface& surface : this->surfaces()) { |
| 874 | if (istringEqual(surface.surfaceType(), "Floor")) { |
| 875 | for (const Point3d& point : surface.vertices()) { |
| 876 | floorHeight += point.z(); |
| 877 | ++numFloor; |
| 878 | } |
| 879 | } else if (istringEqual(surface.surfaceType(), "RoofCeiling")) { |
| 880 | for (const Point3d& point : surface.vertices()) { |
| 881 | roofHeight += point.z(); |
| 882 | ++numRoof; |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | if ((numRoof > 0) && (numFloor > 0)) { |
| 888 | roofHeight /= numRoof; |
| 889 | floorHeight /= numFloor; |
| 890 | result = roofHeight - floorHeight; |
| 891 | } |
| 892 | |
| 893 | return result; |
| 894 | } |
| 895 | |
| 896 | bool Space_Impl::isCeilingHeightDefaulted() const { |
| 897 | return isEmpty(OS_SpaceFields::CeilingHeight); |