| 169 | } |
| 170 | |
| 171 | boost::optional<ConstructionBase> SubSurface_Impl::construction() const { |
| 172 | // DLM: there is duplicate code in ForwardTranslator::resolveMatchedSubSurfaceConstructionConflicts |
| 173 | // if you update this code you must update that code |
| 174 | |
| 175 | // DLM: I am not sure we should be doing this here at all, maybe this method should just |
| 176 | // return the same thing constructionWithSearchDistance does? |
| 177 | |
| 178 | boost::optional<std::pair<ConstructionBase, int>> constructionWithSearchDistance = this->constructionWithSearchDistance(); |
| 179 | |
| 180 | model::OptionalSubSurface adjacentSubSurface = this->adjacentSubSurface(); |
| 181 | if (!adjacentSubSurface) { |
| 182 | if (constructionWithSearchDistance) { |
| 183 | return constructionWithSearchDistance->first; |
| 184 | } |
| 185 | return boost::none; |
| 186 | } |
| 187 | |
| 188 | boost::optional<std::pair<model::ConstructionBase, int>> adjacentConstructionWithSearchDistance = |
| 189 | adjacentSubSurface->constructionWithSearchDistance(); |
| 190 | |
| 191 | if (constructionWithSearchDistance && !adjacentConstructionWithSearchDistance) { |
| 192 | // return this construction |
| 193 | return constructionWithSearchDistance->first; |
| 194 | } |
| 195 | |
| 196 | if (!constructionWithSearchDistance && adjacentConstructionWithSearchDistance) { |
| 197 | // return adjacent construction |
| 198 | return adjacentConstructionWithSearchDistance->first; |
| 199 | } |
| 200 | |
| 201 | if (!constructionWithSearchDistance && !adjacentConstructionWithSearchDistance) { |
| 202 | // no constructions, nothing to be done |
| 203 | return boost::none; |
| 204 | } |
| 205 | |
| 206 | // both surfaces return a construction |
| 207 | |
| 208 | if (constructionWithSearchDistance->first.handle() == adjacentConstructionWithSearchDistance->first.handle()) { |
| 209 | // both surfaces have same construction |
| 210 | return constructionWithSearchDistance->first; |
| 211 | } |
| 212 | |
| 213 | // both surfaces return a construction and they are not the same |
| 214 | |
| 215 | if (constructionWithSearchDistance->second < adjacentConstructionWithSearchDistance->second) { |
| 216 | // lower search distance to construction |
| 217 | return constructionWithSearchDistance->first; |
| 218 | } |
| 219 | |
| 220 | if (constructionWithSearchDistance->second > adjacentConstructionWithSearchDistance->second) { |
| 221 | // lower search distance to adjacent construction |
| 222 | return adjacentConstructionWithSearchDistance->first; |
| 223 | } |
| 224 | |
| 225 | // both surfaces return a construction, they are not the same, and both have same search distance |
| 226 | |
| 227 | if (constructionWithSearchDistance->first.optionalCast<model::LayeredConstruction>() |
| 228 | && adjacentConstructionWithSearchDistance->first.optionalCast<model::LayeredConstruction>()) { |
no test coverage detected