convert simple shading to detailed in the current system
| 351 | |
| 352 | // convert simple shading to detailed in the current system |
| 353 | bool GeometryTranslator::convertSimpleShading(const CoordinateChange& coordChange) { |
| 354 | // building transformation |
| 355 | Transformation buildingTransformation = this->buildingTransformation(); |
| 356 | |
| 357 | // Shading::Site |
| 358 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Shading_Site)) { |
| 359 | |
| 360 | // get simple params |
| 361 | OptionalDouble azimuth = oldObject.getDouble(Shading_SiteFields::AzimuthAngle, true); |
| 362 | OptionalDouble tilt = oldObject.getDouble(Shading_SiteFields::TiltAngle, true); |
| 363 | OptionalDouble x0 = oldObject.getDouble(Shading_SiteFields::StartingXCoordinate, true); |
| 364 | OptionalDouble y0 = oldObject.getDouble(Shading_SiteFields::StartingYCoordinate, true); |
| 365 | OptionalDouble z0 = oldObject.getDouble(Shading_SiteFields::StartingZCoordinate, true); |
| 366 | OptionalDouble length = oldObject.getDouble(Shading_SiteFields::Length, true); |
| 367 | OptionalDouble height = oldObject.getDouble(Shading_SiteFields::Height, true); |
| 368 | |
| 369 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !height) { |
| 370 | LOG(Error, "Missing required fields"); |
| 371 | continue; |
| 372 | } |
| 373 | |
| 374 | // get vertices |
| 375 | Point3dVector vertices = verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *height); |
| 376 | |
| 377 | // fields which map directly |
| 378 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ |
| 379 | {Shading_SiteFields::Name, Shading_Site_DetailedFields::Name}, |
| 380 | }; |
| 381 | |
| 382 | // new object |
| 383 | IdfObject newObject(IddObjectType::Shading_Site_Detailed); |
| 384 | |
| 385 | // copy fields over directly |
| 386 | mapFields(oldObject, newObject, fieldMap); |
| 387 | |
| 388 | // set other fields |
| 389 | newObject.setDouble(Shading_Site_DetailedFields::NumberofVertices, 4); |
| 390 | |
| 391 | // swap old object with new one |
| 392 | bool ok = m_workspace.swap(oldObject, newObject); |
| 393 | if (ok) { |
| 394 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::Shading_Site_Detailed); |
| 395 | // set vertices |
| 396 | setVertices(Shading_Site_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 397 | } else { |
| 398 | LOG(Error, "Workspace object swap failed"); |
| 399 | continue; |
| 400 | } |
| 401 | |
| 402 | // remove old object |
| 403 | //m_workspace.removeObject(oldObject.handle()); |
| 404 | } |
| 405 | |
| 406 | // Shading::Building |
| 407 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Shading_Building)) { |
| 408 | |
| 409 | // get transformation |
| 410 | Transformation t; |
nothing calls this directly
no test coverage detected