| 2357 | } |
| 2358 | |
| 2359 | void SvgSerializer::setSectionHeightsFromStoreys(double offset) { |
| 2360 | if (!file) { |
| 2361 | Logger::Error("No file specified"); |
| 2362 | return; |
| 2363 | } |
| 2364 | with_section_heights_from_storey_ = true; |
| 2365 | section_data_.emplace(); |
| 2366 | auto storeys = file->instances_by_type("IfcBuildingStorey"); |
| 2367 | const double lu = file->getUnit("LENGTHUNIT").second; |
| 2368 | if (storeys && storeys->size() > 0) { |
| 2369 | for (auto& s : *storeys) { |
| 2370 | auto attr_value = ((IfcUtil::IfcBaseEntity*)s)->get("Elevation"); |
| 2371 | if (!attr_value.isNull()) { |
| 2372 | double elev; |
| 2373 | try { |
| 2374 | elev = attr_value; |
| 2375 | } catch (std::exception& e) { |
| 2376 | Logger::Error(e); |
| 2377 | continue; |
| 2378 | } |
| 2379 | if (!section_data_->empty()) { |
| 2380 | boost::get<horizontal_plan>(section_data_->back()).next_elevation = elev * lu; |
| 2381 | } |
| 2382 | section_data_->push_back(horizontal_plan{ (IfcUtil::IfcBaseEntity*)s, elev * lu, offset, std::numeric_limits<double>::infinity() }); |
| 2383 | } |
| 2384 | } |
| 2385 | } else { |
| 2386 | section_data_->push_back(horizontal_plan_at_element{}); |
| 2387 | } |
| 2388 | } |
| 2389 | |
| 2390 | namespace { |
| 2391 | std::string array_to_string(double v) { |