Skip to content

Commit

Permalink
Fix #4764 - floor_to_ceiling_height for Shading objects is not respec…
Browse files Browse the repository at this point in the history
…ted in the floorspace reverse translator
  • Loading branch information
ggartside authored and jmarrec committed Jan 5, 2023
1 parent 1741895 commit 707e9de
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/model/FloorspaceReverseTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,20 @@ namespace model {
if (m_currentFSStory.has_value()) {

double minZ = m_currentStoryZ;
double maxZ = minZ + m_currentFSStory->getBelowFloorPlenumHeight();
if (m_currentFSStory->getBelowFloorPlenumHeight() > 0) {
double maxZ = minZ + entity.belowFloorPlenumHeight();
if (entity.belowFloorPlenumHeight() > 0) {
createShadingSurfaceGroup(entity, minZ, maxZ, SpaceTypeEnum::BELOWFLOOR);
}

minZ = maxZ;
maxZ = minZ + m_currentFSStory->floorToCeilingHeight();
if (m_currentFSStory->floorToCeilingHeight() > 0) {
maxZ = minZ + entity.floorToCeilingHeight();
if (entity.floorToCeilingHeight() > 0) {
createShadingSurfaceGroup(entity, minZ, maxZ, SpaceTypeEnum::ABOVEFLOOR);
}

minZ = maxZ;
maxZ = minZ + m_currentFSStory->aboveCeilingPlenumHeight();
if (m_currentFSStory->aboveCeilingPlenumHeight() > 0) {
maxZ = minZ + entity.aboveCeilingPlenumHeight();
if (entity.aboveCeilingPlenumHeight() > 0) {
createShadingSurfaceGroup(entity, minZ, maxZ, SpaceTypeEnum::ABOVECEILING);
}
}
Expand Down
62 changes: 48 additions & 14 deletions src/utilities/floorspace/FSModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,14 @@ FSStory::FSStory(const Json::Value& root, const FSModel& model) : FSBase(root) {

const Json::Value& shadings = root.get("shading", Json::arrayValue);
for (const auto& json_shading : shadings) {
FSShading shading = FSShading(json_shading, *this);
FSShading shading = FSShading(json_shading, model, *this);
if (shading.face().has_value()) {
m_shadings.push_back(shading);
}
}
}

double FSStory::getBelowFloorPlenumHeight() const {
double FSStory::belowFloorPlenumHeight() const {
return m_below_floor_plenum_height;
}

Expand Down Expand Up @@ -525,7 +525,7 @@ void FSConstructionSet::Accept(FSVisitor& visitor) const {
///////////////////////////////////////////////////////////////////////////////////

FSSpace::FSSpace(const Json::Value& root, const FSModel& model, FSStory& story)
: FSBase(root), m_belowFloorPlenumHeight(story.getBelowFloorPlenumHeight()) {
: FSBase(root), m_below_floor_plenum_height(story.belowFloorPlenumHeight()) {

if (checkKeyAndType(root, "thermal_zone_id", Json::stringValue)) {
m_thermalZone = model.thermalZone(root.get("thermal_zone_id", "").asString());
Expand All @@ -546,21 +546,22 @@ FSSpace::FSSpace(const Json::Value& root, const FSModel& model, FSStory& story)
// Heights are optional, if not defined then the value is inherited from the story, if
// defined then the value overrides the value from the story

m_below_floor_plenum_height = story.belowFloorPlenumHeight();
if (checkKeyAndType(root, "below_floor_plenum_height", Json::realValue)) {
double defaultValue = m_belowFloorPlenumHeight / model.lengthToMeters();
m_belowFloorPlenumHeight = root.get("below_floor_plenum_height", defaultValue).asDouble() * model.lengthToMeters();
double defaultValue = m_below_floor_plenum_height / model.lengthToMeters();
m_below_floor_plenum_height = root.get("below_floor_plenum_height", defaultValue).asDouble() * model.lengthToMeters();
}

m_floorToCeilingHeight = story.floorToCeilingHeight();
m_floor_to_ceiling_height = story.floorToCeilingHeight();
if (checkKeyAndType(root, "floor_to_ceiling_height", Json::realValue)) { // Doing this skips null values for exmaple
double defaultValue = m_floorToCeilingHeight / model.lengthToMeters();
m_floorToCeilingHeight = root.get("floor_to_ceiling_height", defaultValue).asDouble() * model.lengthToMeters();
double defaultValue = m_floor_to_ceiling_height / model.lengthToMeters();
m_floor_to_ceiling_height = root.get("floor_to_ceiling_height", defaultValue).asDouble() * model.lengthToMeters();
}

m_aboveCeilingHeight = story.aboveCeilingPlenumHeight();
m_above_ceiling_plenum_height = story.aboveCeilingPlenumHeight();
if (checkKeyAndType(root, "above_ceiling_plenum_height", Json::realValue)) {
double defaultValue = story.aboveCeilingPlenumHeight() / model.lengthToMeters();
m_aboveCeilingHeight = root.get("above_ceiling_plenum_height", defaultValue).asDouble() * model.lengthToMeters();
m_above_ceiling_plenum_height = root.get("above_ceiling_plenum_height", defaultValue).asDouble() * model.lengthToMeters();
}

m_offset = root.get("floor_offset", 0).asDouble() * model.lengthToMeters();
Expand Down Expand Up @@ -605,15 +606,15 @@ int FSSpace::multiplier() const {
}

double FSSpace::belowFloorPlenumHeight() const {
return m_belowFloorPlenumHeight;
return m_below_floor_plenum_height;
}

double FSSpace::floorToCeilingHeight() const {
return m_floorToCeilingHeight;
return m_floor_to_ceiling_height;
}

double FSSpace::aboveCeilingHeight() const {
return m_aboveCeilingHeight;
return m_above_ceiling_plenum_height;
}

double FSSpace::offset() const {
Expand Down Expand Up @@ -982,19 +983,52 @@ boost::optional<FSDoorDefinition> FSDoor::doorDefinition() const {

///////////////////////////////////////////////////////////////////////////////////

FSShading::FSShading(const Json::Value& root, const FSStory& story) : FSBase(root) {
FSShading::FSShading(const Json::Value& root, const FSModel& model, const FSStory& story) : FSBase(root) {

// Get the face. Note: a shading must have a face for it to be added to the model
if (checkKeyAndType(root, "face_id", Json::stringValue)) {
std::string face_id = root.get("face_id", "").asString();
m_face = story.geometry().face(face_id);
}

// Heights are optional, if not defined then the value is inherited from the story, if
// defined then the value overrides the value from the story

m_below_floor_plenum_height = story.belowFloorPlenumHeight();
if (checkKeyAndType(root, "below_floor_plenum_height", Json::realValue)) {
double defaultValue = m_below_floor_plenum_height / model.lengthToMeters();
m_below_floor_plenum_height = root.get("below_floor_plenum_height", defaultValue).asDouble() * model.lengthToMeters();
}

m_floor_to_ceiling_height = story.floorToCeilingHeight();
if (checkKeyAndType(root, "floor_to_ceiling_height", Json::realValue)) { // Doing this skips null values for exmaple
double defaultValue = m_floor_to_ceiling_height / model.lengthToMeters();
m_floor_to_ceiling_height = root.get("floor_to_ceiling_height", defaultValue).asDouble() * model.lengthToMeters();
}

m_above_ceiling_plenum_height = story.aboveCeilingPlenumHeight();
if (checkKeyAndType(root, "above_ceiling_plenum_height", Json::realValue)) {
double defaultValue = story.aboveCeilingPlenumHeight() / model.lengthToMeters();
m_above_ceiling_plenum_height = root.get("above_ceiling_plenum_height", defaultValue).asDouble() * model.lengthToMeters();
}
}

boost::optional<FSFace> FSShading::face() const {
return m_face;
}

double FSShading::belowFloorPlenumHeight() const {
return m_below_floor_plenum_height;
}

double FSShading::floorToCeilingHeight() const {
return m_floor_to_ceiling_height;
}

double FSShading::aboveCeilingPlenumHeight() const {
return m_above_ceiling_plenum_height;
}

void FSShading::Accept(FSVisitor& visitor) const {
visitor.Dispatch(*this);
}
Expand Down
18 changes: 11 additions & 7 deletions src/utilities/floorspace/FSModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ class UTILITIES_API FSSpace : public FSBase
boost::optional<FSConstructionSet> m_constructionSet;
boost::optional<FSFace> m_face;

double m_belowFloorPlenumHeight = 0.0;
double m_floorToCeilingHeight = 0.0;
double m_aboveCeilingHeight = 0.0;
double m_below_floor_plenum_height = 0.0;
double m_floor_to_ceiling_height = 0.0;
double m_above_ceiling_plenum_height = 0.0;
double m_offset = 0.0;
bool m_openToBelow = false;
int m_multiplier = 1;
Expand Down Expand Up @@ -387,14 +387,18 @@ class UTILITIES_API FSDoor : public FSFiller
class UTILITIES_API FSShading : public FSBase
{
public:
explicit FSShading(const Json::Value& root, const FSStory& story);

explicit FSShading(const Json::Value& root, const FSModel& model, const FSStory& story);
double belowFloorPlenumHeight() const;
double floorToCeilingHeight() const;
double aboveCeilingPlenumHeight() const;
void Accept(FSVisitor& visitor) const override;

boost::optional<FSFace> face() const;

private:
boost::optional<FSFace> m_face;
double m_floor_to_ceiling_height = 0.0;
double m_below_floor_plenum_height = 0.0;
double m_above_ceiling_plenum_height = 0.0;
};

class UTILITIES_API FSStory : public FSBase
Expand All @@ -403,7 +407,7 @@ class UTILITIES_API FSStory : public FSBase
explicit FSStory(const Json::Value& root, const FSModel& model);
void Accept(FSVisitor& visitor) const override;

double getBelowFloorPlenumHeight() const;
double belowFloorPlenumHeight() const;
double floorToCeilingHeight() const;
double aboveCeilingPlenumHeight() const;
double floorToFloorHeight() const;
Expand Down

0 comments on commit 707e9de

Please sign in to comment.