MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / convertSimpleShading

Method convertSimpleShading

src/energyplus/GeometryTranslator.cpp:353–945  ·  view source on GitHub ↗

convert simple shading to detailed in the current system

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 15

mapFieldsFunction · 0.85
setVerticesFunction · 0.85
getVerticesFunction · 0.85
absFunction · 0.85
degToRadFunction · 0.85
iddObjectMethod · 0.80
inverseMethod · 0.80
Point3dClass · 0.50
getObjectsByTypeMethod · 0.45
getDoubleMethod · 0.45

Tested by

no test coverage detected