src/model/PlanarSurfaceGroup.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "PlanarSurfaceGroup.hpp" | ||
| 7 | #include "PlanarSurfaceGroup_Impl.hpp" | ||
| 8 | #include "Model.hpp" | ||
| 9 | #include "Model_Impl.hpp" | ||
| 10 | #include "Building.hpp" | ||
| 11 | #include "Building_Impl.hpp" | ||
| 12 | |||
| 13 | #include "../utilities/geometry/Geometry.hpp" | ||
| 14 | #include "../utilities/geometry/Transformation.hpp" | ||
| 15 | #include "../utilities/geometry/BoundingBox.hpp" | ||
| 16 | #include "../utilities/geometry/Point3d.hpp" | ||
| 17 | #include "../utilities/geometry/Vector3d.hpp" | ||
| 18 | #include "../utilities/geometry/EulerAngles.hpp" | ||
| 19 | |||
| 20 | #include "../utilities/core/Assert.hpp" | ||
| 21 | |||
| 22 | namespace openstudio { | ||
| 23 | namespace model { | ||
| 24 | |||
| 25 | namespace detail { | ||
| 26 | |||
| 27 | 8002 | PlanarSurfaceGroup_Impl::PlanarSurfaceGroup_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 28 | 8002 | : ParentObject_Impl(idfObject, model, keepHandle) { | |
| 29 | // connect signals | ||
| 30 |
1/1✓ Branch 1 taken 8002 times.
|
8002 | this->PlanarSurfaceGroup_Impl::onChange.connect<PlanarSurfaceGroup_Impl, &PlanarSurfaceGroup_Impl::clearCachedVariables>(this); |
| 31 | 8002 | } | |
| 32 | |||
| 33 | 3006 | PlanarSurfaceGroup_Impl::PlanarSurfaceGroup_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 34 | 3006 | : ParentObject_Impl(other, model, keepHandle) { | |
| 35 | // connect signals | ||
| 36 |
1/1✓ Branch 1 taken 3006 times.
|
3006 | this->PlanarSurfaceGroup_Impl::onChange.connect<PlanarSurfaceGroup_Impl, &PlanarSurfaceGroup_Impl::clearCachedVariables>(this); |
| 37 | 3006 | } | |
| 38 | |||
| 39 | 2502 | PlanarSurfaceGroup_Impl::PlanarSurfaceGroup_Impl(const PlanarSurfaceGroup_Impl& other, Model_Impl* model, bool keepHandle) | |
| 40 | 2502 | : ParentObject_Impl(other, model, keepHandle) { | |
| 41 | // connect signals | ||
| 42 |
1/1✓ Branch 1 taken 2502 times.
|
2502 | this->PlanarSurfaceGroup_Impl::onChange.connect<PlanarSurfaceGroup_Impl, &PlanarSurfaceGroup_Impl::clearCachedVariables>(this); |
| 43 | 2502 | } | |
| 44 | |||
| 45 | 1143252 | openstudio::Transformation PlanarSurfaceGroup_Impl::transformation() const { | |
| 46 |
2/2✓ Branch 1 taken 7839 times.
✓ Branch 2 taken 1135413 times.
|
1143252 | if (!m_cachedTransformation) { |
| 47 |
1/1✓ Branch 1 taken 7839 times.
|
7839 | double x = this->xOrigin(); |
| 48 |
1/1✓ Branch 1 taken 7839 times.
|
7839 | double y = this->yOrigin(); |
| 49 |
1/1✓ Branch 1 taken 7839 times.
|
7839 | double z = this->zOrigin(); |
| 50 | |||
| 51 | // translation | ||
| 52 |
2/2✓ Branch 1 taken 7839 times.
✓ Branch 4 taken 7839 times.
|
7839 | Transformation translation = Transformation::translation(Vector3d(x, y, z)); |
| 53 | |||
| 54 |
1/1✓ Branch 1 taken 7839 times.
|
7839 | double dORN = this->directionofRelativeNorth(); |
| 55 | |||
| 56 | // rotate negative amount around the z axis, EnergyPlus defines rotation clockwise | ||
| 57 |
3/3✓ Branch 1 taken 7839 times.
✓ Branch 4 taken 7839 times.
✓ Branch 7 taken 7839 times.
|
7839 | Transformation rotation = Transformation::rotation(Vector3d(0, 0, 1), -openstudio::degToRad(dORN)); |
| 58 | |||
| 59 |
2/2✓ Branch 1 taken 7839 times.
✓ Branch 4 taken 7839 times.
|
7839 | m_cachedTransformation = translation * rotation; |
| 60 | 7839 | } | |
| 61 | |||
| 62 | 1143252 | return m_cachedTransformation.get(); | |
| 63 | } | ||
| 64 | |||
| 65 | 803 | bool PlanarSurfaceGroup_Impl::setTransformation(const openstudio::Transformation& transformation) { | |
| 66 | |||
| 67 |
1/1✓ Branch 1 taken 803 times.
|
803 | EulerAngles eulerAngles = transformation.eulerAngles(); |
| 68 |
5/8✓ Branch 1 taken 803 times.
✓ Branch 3 taken 803 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 803 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 803 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 803 times.
|
803 | if ((eulerAngles.psi() != 0) || (eulerAngles.theta() != 0)) { |
| 69 | ✗ | return false; | |
| 70 | } | ||
| 71 | |||
| 72 |
2/2✓ Branch 1 taken 803 times.
✓ Branch 4 taken 803 times.
|
803 | double dORN = -radToDeg(eulerAngles.phi()); |
| 73 |
1/1✓ Branch 1 taken 803 times.
|
803 | this->setDirectionofRelativeNorth(dORN, false); |
| 74 | |||
| 75 |
1/1✓ Branch 1 taken 803 times.
|
803 | Vector3d translation = transformation.translation(); |
| 76 |
2/2✓ Branch 1 taken 803 times.
✓ Branch 4 taken 803 times.
|
803 | this->setXOrigin(translation.x(), false); |
| 77 |
2/2✓ Branch 1 taken 803 times.
✓ Branch 4 taken 803 times.
|
803 | this->setYOrigin(translation.y(), false); |
| 78 |
2/2✓ Branch 1 taken 803 times.
✓ Branch 4 taken 803 times.
|
803 | this->setZOrigin(translation.z(), false); |
| 79 |
1/1✓ Branch 1 taken 803 times.
|
803 | this->emitChangeSignals(); |
| 80 | |||
| 81 | 803 | return true; | |
| 82 | 803 | } | |
| 83 | |||
| 84 | 1387 | openstudio::Transformation PlanarSurfaceGroup_Impl::siteTransformation() const { | |
| 85 |
1/1✓ Branch 1 taken 1387 times.
|
1387 | Transformation transformation; |
| 86 | |||
| 87 |
2/2✓ Branch 1 taken 1387 times.
✓ Branch 4 taken 1387 times.
|
1387 | boost::optional<Building> building = this->model().building(); |
| 88 |
2/2✓ Branch 0 taken 1386 times.
✓ Branch 1 taken 1 time.
|
1387 | if (building) { |
| 89 |
4/4✓ Branch 1 taken 1386 times.
✓ Branch 4 taken 1386 times.
✓ Branch 7 taken 1386 times.
✓ Branch 10 taken 1386 times.
|
1386 | transformation = building->transformation() * this->buildingTransformation(); |
| 90 | } else { | ||
| 91 |
1/1✓ Branch 1 taken 1 time.
|
1 | transformation = this->buildingTransformation(); |
| 92 | } | ||
| 93 | 2774 | return transformation; | |
| 94 | 1387 | } | |
| 95 | |||
| 96 | ✗ | openstudio::BoundingBox PlanarSurfaceGroup_Impl::boundingBoxParentCoordinates() const { | |
| 97 | ✗ | return transformation() * boundingBox(); | |
| 98 | } | ||
| 99 | |||
| 100 | 34938 | openstudio::BoundingBox PlanarSurfaceGroup_Impl::boundingBoxBuildingCoordinates() const { | |
| 101 |
3/3✓ Branch 1 taken 34938 times.
✓ Branch 4 taken 34938 times.
✓ Branch 7 taken 34938 times.
|
34938 | return buildingTransformation() * boundingBox(); |
| 102 | } | ||
| 103 | |||
| 104 | ✗ | openstudio::BoundingBox PlanarSurfaceGroup_Impl::boundingBoxSiteCoordinates() const { | |
| 105 | ✗ | return siteTransformation() * boundingBox(); | |
| 106 | } | ||
| 107 | |||
| 108 | 14480 | void PlanarSurfaceGroup_Impl::clearCachedVariables() { | |
| 109 | 14480 | m_cachedTransformation.reset(); | |
| 110 | 14480 | } | |
| 111 | |||
| 112 | } // namespace detail | ||
| 113 | |||
| 114 | 4984 | PlanarSurfaceGroup::PlanarSurfaceGroup(IddObjectType iddObjectType, const Model& model) : ParentObject(iddObjectType, model) { | |
| 115 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 4984 times.
✗ Branch 5 not taken.
|
4984 | OS_ASSERT(getImpl<detail::PlanarSurfaceGroup_Impl>()); |
| 116 | 4984 | } | |
| 117 | |||
| 118 | 196 | double PlanarSurfaceGroup::directionofRelativeNorth() const { | |
| 119 |
1/1✓ Branch 3 taken 196 times.
|
196 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->directionofRelativeNorth(); |
| 120 | } | ||
| 121 | |||
| 122 | 1141 | bool PlanarSurfaceGroup::isDirectionofRelativeNorthDefaulted() const { | |
| 123 |
1/1✓ Branch 3 taken 1141 times.
|
1141 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->isDirectionofRelativeNorthDefaulted(); |
| 124 | } | ||
| 125 | |||
| 126 | 1169 | double PlanarSurfaceGroup::xOrigin() const { | |
| 127 |
1/1✓ Branch 3 taken 1169 times.
|
1169 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->xOrigin(); |
| 128 | } | ||
| 129 | |||
| 130 | 58 | bool PlanarSurfaceGroup::isXOriginDefaulted() const { | |
| 131 |
1/1✓ Branch 3 taken 58 times.
|
58 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->isXOriginDefaulted(); |
| 132 | } | ||
| 133 | |||
| 134 | 1169 | double PlanarSurfaceGroup::yOrigin() const { | |
| 135 |
1/1✓ Branch 3 taken 1169 times.
|
1169 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->yOrigin(); |
| 136 | } | ||
| 137 | |||
| 138 | 58 | bool PlanarSurfaceGroup::isYOriginDefaulted() const { | |
| 139 |
1/1✓ Branch 3 taken 58 times.
|
58 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->isYOriginDefaulted(); |
| 140 | } | ||
| 141 | |||
| 142 | 1169 | double PlanarSurfaceGroup::zOrigin() const { | |
| 143 |
1/1✓ Branch 3 taken 1169 times.
|
1169 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->zOrigin(); |
| 144 | } | ||
| 145 | |||
| 146 | 58 | bool PlanarSurfaceGroup::isZOriginDefaulted() const { | |
| 147 |
1/1✓ Branch 3 taken 58 times.
|
58 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->isZOriginDefaulted(); |
| 148 | } | ||
| 149 | |||
| 150 | 70 | bool PlanarSurfaceGroup::setDirectionofRelativeNorth(double directionofRelativeNorth) { | |
| 151 |
1/1✓ Branch 3 taken 70 times.
|
70 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->setDirectionofRelativeNorth(directionofRelativeNorth); |
| 152 | } | ||
| 153 | |||
| 154 | 58 | void PlanarSurfaceGroup::resetDirectionofRelativeNorth() { | |
| 155 |
1/1✓ Branch 3 taken 58 times.
|
58 | getImpl<detail::PlanarSurfaceGroup_Impl>()->resetDirectionofRelativeNorth(); |
| 156 | 58 | } | |
| 157 | |||
| 158 | 541 | bool PlanarSurfaceGroup::setXOrigin(double xOrigin) { | |
| 159 |
1/1✓ Branch 3 taken 541 times.
|
541 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->setXOrigin(xOrigin); |
| 160 | } | ||
| 161 | |||
| 162 | 58 | void PlanarSurfaceGroup::resetXOrigin() { | |
| 163 |
1/1✓ Branch 3 taken 58 times.
|
58 | getImpl<detail::PlanarSurfaceGroup_Impl>()->resetXOrigin(); |
| 164 | 58 | } | |
| 165 | |||
| 166 | 483 | bool PlanarSurfaceGroup::setYOrigin(double yOrigin) { | |
| 167 |
1/1✓ Branch 3 taken 483 times.
|
483 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->setYOrigin(yOrigin); |
| 168 | } | ||
| 169 | |||
| 170 | 58 | void PlanarSurfaceGroup::resetYOrigin() { | |
| 171 |
1/1✓ Branch 3 taken 58 times.
|
58 | getImpl<detail::PlanarSurfaceGroup_Impl>()->resetYOrigin(); |
| 172 | 58 | } | |
| 173 | |||
| 174 | 151 | bool PlanarSurfaceGroup::setZOrigin(double zOrigin) { | |
| 175 |
1/1✓ Branch 3 taken 151 times.
|
151 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->setZOrigin(zOrigin); |
| 176 | } | ||
| 177 | |||
| 178 | 58 | void PlanarSurfaceGroup::resetZOrigin() { | |
| 179 |
1/1✓ Branch 3 taken 58 times.
|
58 | getImpl<detail::PlanarSurfaceGroup_Impl>()->resetZOrigin(); |
| 180 | 58 | } | |
| 181 | |||
| 182 | 1059757 | openstudio::Transformation PlanarSurfaceGroup::transformation() const { | |
| 183 |
1/1✓ Branch 3 taken 1059757 times.
|
1059757 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->transformation(); |
| 184 | } | ||
| 185 | |||
| 186 | 36615 | openstudio::Transformation PlanarSurfaceGroup::buildingTransformation() const { | |
| 187 |
1/1✓ Branch 3 taken 36615 times.
|
36615 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->buildingTransformation(); |
| 188 | } | ||
| 189 | |||
| 190 | 1387 | openstudio::Transformation PlanarSurfaceGroup::siteTransformation() const { | |
| 191 |
1/1✓ Branch 3 taken 1387 times.
|
1387 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->siteTransformation(); |
| 192 | } | ||
| 193 | |||
| 194 | 123 | bool PlanarSurfaceGroup::setTransformation(const openstudio::Transformation& transformation) { | |
| 195 |
1/1✓ Branch 3 taken 123 times.
|
123 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->setTransformation(transformation); |
| 196 | } | ||
| 197 | |||
| 198 | 680 | bool PlanarSurfaceGroup::changeTransformation(const openstudio::Transformation& transformation) { | |
| 199 |
1/1✓ Branch 3 taken 680 times.
|
680 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->changeTransformation(transformation); |
| 200 | } | ||
| 201 | |||
| 202 | 4960 | openstudio::BoundingBox PlanarSurfaceGroup::boundingBox() const { | |
| 203 |
1/1✓ Branch 3 taken 4960 times.
|
4960 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->boundingBox(); |
| 204 | } | ||
| 205 | |||
| 206 | ✗ | openstudio::BoundingBox PlanarSurfaceGroup::boundingBoxParentCoordinates() const { | |
| 207 | ✗ | return getImpl<detail::PlanarSurfaceGroup_Impl>()->boundingBoxParentCoordinates(); | |
| 208 | } | ||
| 209 | |||
| 210 | 34938 | openstudio::BoundingBox PlanarSurfaceGroup::boundingBoxBuildingCoordinates() const { | |
| 211 |
1/1✓ Branch 3 taken 34938 times.
|
34938 | return getImpl<detail::PlanarSurfaceGroup_Impl>()->boundingBoxBuildingCoordinates(); |
| 212 | } | ||
| 213 | |||
| 214 | ✗ | openstudio::BoundingBox PlanarSurfaceGroup::boundingBoxSiteCoordinates() const { | |
| 215 | ✗ | return getImpl<detail::PlanarSurfaceGroup_Impl>()->boundingBoxSiteCoordinates(); | |
| 216 | } | ||
| 217 | |||
| 218 | /// @cond | ||
| 219 |
1/1✓ Branch 3 taken 1235356 times.
|
1235356 | PlanarSurfaceGroup::PlanarSurfaceGroup(std::shared_ptr<detail::PlanarSurfaceGroup_Impl> impl) : ParentObject(std::move(impl)) {} |
| 220 | /// @endcond | ||
| 221 | |||
| 222 | } // namespace model | ||
| 223 | } // namespace openstudio | ||
| 224 |