Skip to content

Commit

Permalink
Merge pull request #4597 from NREL/gltf_extra_minimum_fix_to_not_segf…
Browse files Browse the repository at this point in the history
…ault

Hotfix GLTF extras broke running tests in Debug
  • Loading branch information
tijcolem committed May 24, 2022
2 parents 9f64a57 + f32a6a1 commit 86470fe
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 241 deletions.
96 changes: 10 additions & 86 deletions src/model/GltfBoundingBoxWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,110 +29,59 @@

#include "GltfBoundingBoxWrapper.hpp"

#include "RenderingColor.hpp"
#include "ConstructionBase.hpp"
#include "ConstructionBase_Impl.hpp"
#include "ConstructionAirBoundary.hpp"
#include "ConstructionAirBoundary_Impl.hpp"
#include "AirLoopHVAC.hpp"
#include "AirLoopHVAC_Impl.hpp"
#include "ThermalZone.hpp"
#include "ThermalZone_Impl.hpp"
#include "SpaceType.hpp"
#include "SpaceType_Impl.hpp"
#include "Building.hpp"
#include "Building_Impl.hpp"
#include "BuildingStory.hpp"
#include "BuildingStory_Impl.hpp"
#include "BuildingUnit.hpp"
#include "BuildingUnit_Impl.hpp"
#include "Surface.hpp"
#include "Surface_Impl.hpp"
#include "SubSurface.hpp"
#include "SubSurface_Impl.hpp"
#include "ShadingSurface.hpp"
#include "ShadingSurface_Impl.hpp"
#include "InteriorPartitionSurface.hpp"
#include "InteriorPartitionSurface_Impl.hpp"
#include "PlanarSurfaceGroup.hpp"
#include "PlanarSurfaceGroup_Impl.hpp"
#include "Space.hpp"
#include "Space_Impl.hpp"
#include "DefaultConstructionSet.hpp"
#include "DefaultConstructionSet_Impl.hpp"
#include "ShadingSurfaceGroup.hpp"
#include "InteriorPartitionSurfaceGroup.hpp"

#include "../utilities/core/Assert.hpp"
#include "../utilities/core/Compare.hpp"
#include "../utilities/geometry/Point3d.hpp"
#include "../utilities/geometry/Plane.hpp"
#include "../utilities/geometry/BoundingBox.hpp"
#include "../utilities/geometry/Transformation.hpp"
#include "../utilities/geometry/Geometry.hpp"
#include "../utilities/geometry/Polygon3d.hpp"

#include <tiny_gltf.h>

#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <stack>
#include <limits.h>
#include <tuple>

namespace openstudio {
namespace model {

void GltfBoundingBoxWrapper::setlookAtR(double value) {
std::string key = "lookAtR";
lookAtR = make_tuple(key, value);
lookAtR = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setlookAtX(double value) {
std::string key = "lookAtX";
lookAtX = make_tuple(key, value);
lookAtX = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setlookAtY(double value) {
std::string key = "lookAtY";
lookAtY = make_tuple(key, value);
lookAtY = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setlookAtZ(double value) {
std::string key = "lookAtZ";
lookAtZ = make_tuple(key, value);
lookAtZ = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setmaxX(double value) {
std::string key = "maxX";
maxX = make_tuple(key, value);
maxX = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setmaxY(double value) {
std::string key = "maxY";
maxY = make_tuple(key, value);
maxY = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setmaxZ(double value) {
std::string key = "maxZ";
maxZ = make_tuple(key, value);
maxZ = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setminX(double value) {
std::string key = "minX";
minX = make_tuple(key, value);
minX = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setminY(double value) {
std::string key = "minY";
minY = make_tuple(key, value);
minY = std::make_tuple(key, value);
}

void GltfBoundingBoxWrapper::setminZ(double value) {
std::string key = "minZ";
minZ = make_tuple(key, value);
minZ = std::make_tuple(key, value);
}

// Getters
Expand Down Expand Up @@ -176,30 +125,5 @@ namespace model {
return std::get<1>(minZ);
}

GltfBoundingBoxWrapper::GltfBoundingBoxWrapper() {
m_logSink.setLogLevel(Warn);
m_logSink.setThreadId(std::this_thread::get_id());
}

std::vector<LogMessage> GltfBoundingBoxWrapper::warnings() const {
std::vector<LogMessage> result;
for (LogMessage logMessage : m_logSink.logMessages()) {
if (logMessage.logLevel() == Warn) {
result.push_back(logMessage);
}
}
return result;
}

std::vector<LogMessage> GltfBoundingBoxWrapper::errors() const {
std::vector<LogMessage> result;
for (LogMessage logMessage : m_logSink.logMessages()) {
if (logMessage.logLevel() > Warn) {
result.push_back(logMessage);
}
}
return result;
}

} // namespace model
} // namespace openstudio
14 changes: 0 additions & 14 deletions src/model/GltfBoundingBoxWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

#include "ModelAPI.hpp"
#include "Model.hpp"
#include "../utilities/core/Logger.hpp"
#include "../utilities/core/StringStreamLogSink.hpp"

namespace openstudio {
//class GltfMetaDta;
Expand All @@ -41,8 +39,6 @@ namespace model {
class MODEL_API GltfBoundingBoxWrapper
{
public:
GltfBoundingBoxWrapper();

void setlookAtR(double value);
void setlookAtX(double value);
void setlookAtY(double value);
Expand All @@ -65,17 +61,7 @@ namespace model {
double getminY() const;
double getminZ() const;

// Get warning messages generated by the last translation.
std::vector<LogMessage> warnings() const;

// Get error messages generated by the last translation.
std::vector<LogMessage> errors() const;

private:
REGISTER_LOGGER("openstudio.model.GltfBoundingBoxWrapper");

StringStreamLogSink m_logSink;

std::tuple<std::string, double> lookAtR;
std::tuple<std::string, double> lookAtX;
std::tuple<std::string, double> lookAtY;
Expand Down
7 changes: 4 additions & 3 deletions src/model/GltfForwardTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
namespace openstudio {
namespace model {

// TODO: pick one in your usage.
namespace GLTF = tinygltf;

// For raw values for GLTF Materials
Expand Down Expand Up @@ -2826,10 +2827,10 @@ namespace model {
std::vector<MaterialData> allMaterials = getAllMaterials();

/*
This comprises of the other nodes that GLTF provides
This comprises of the other nodes that GLTF provides
for further addition of complex details, textures, lights, etc.
std::vector<GLTF::Scene> scenes;
std::vector<GLTF::Buffer> buffers;
std::vector<GLTF::Animation> animations;
Expand Down
38 changes: 6 additions & 32 deletions src/model/GltfMetaDataWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@

#include "GltfMetaDataWrapper.hpp"

#include <tiny_gltf.h>

#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <tuple>

namespace openstudio {
namespace model {

// TODO: NO GLOBALS!!!
std::vector<GltfModelObjectMetadataWrapper> glTFModelObjectMetadataWrapperVector;
GltfBoundingBoxWrapper glTFBoundingBox;
std::vector<std::string> buildingStoryNames;
Expand Down Expand Up @@ -68,8 +63,6 @@ namespace model {

GltfMetaDataWrapper::GltfMetaDataWrapper() {
resetModelObjectMetaDataCount();
m_logSink.setLogLevel(Warn);
m_logSink.setThreadId(std::this_thread::get_id());
}

double getBoundingBoxlookAtR() {
Expand Down Expand Up @@ -123,22 +116,22 @@ namespace model {

void GltfMetaDataWrapper::setGenerator(const std::string& value) {
std::string key = "generator";
generator = make_tuple(key, value);
generator = std::make_tuple(key, value);
}

void GltfMetaDataWrapper::setType(const std::string& value) {
std::string key = "type";
type = make_tuple(key, value);
type = std::make_tuple(key, value);
}

void GltfMetaDataWrapper::setVersion(const std::string& value) {
std::string key = "version";
version = make_tuple(key, value);
version = std::make_tuple(key, value);
}

void GltfMetaDataWrapper::setNorthAxis(const double& value) {
std::string key = "northAxis";
northAxis = make_tuple(key, value);
northAxis = std::make_tuple(key, value);
}

std::vector<std::string> GltfMetaDataWrapper::getBuildingStoryNames() const {
Expand Down Expand Up @@ -209,6 +202,7 @@ namespace model {
return airLoopCount;
}

// TODO: what the what? setting and returning a single global?
void GltfMetaDataWrapper::setglTFBoundingBoxWrapper(const GltfBoundingBoxWrapper& gbx) {
glTFBoundingBox = gbx;
}
Expand All @@ -225,25 +219,5 @@ namespace model {
return glTFModelObjectMetadataWrapperVector;
}

std::vector<LogMessage> GltfMetaDataWrapper::warnings() const {
std::vector<LogMessage> result;
for (LogMessage logMessage : m_logSink.logMessages()) {
if (logMessage.logLevel() == Warn) {
result.push_back(logMessage);
}
}
return result;
}

std::vector<LogMessage> GltfMetaDataWrapper::errors() const {
std::vector<LogMessage> result;
for (LogMessage logMessage : m_logSink.logMessages()) {
if (logMessage.logLevel() > Warn) {
result.push_back(logMessage);
}
}
return result;
}

} // namespace model
} // namespace openstudio
13 changes: 0 additions & 13 deletions src/model/GltfMetaDataWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

#include "ModelAPI.hpp"
#include "Model.hpp"
#include "../utilities/core/Logger.hpp"
#include "../utilities/core/StringStreamLogSink.hpp"
#include "GltfBoundingBoxWrapper.hpp"
#include "GltfModelObjectMetadataWrapper.hpp"

Expand Down Expand Up @@ -76,17 +74,6 @@ namespace model {
int getSpaceTypeCount() const;
int getConstructionSetCount() const;
int getAirLoopCount() const;

// Get warning messages generated by the last translation.
std::vector<LogMessage> warnings() const;

// Get error messages generated by the last translation.
std::vector<LogMessage> errors() const;

private:
REGISTER_LOGGER("openstudio.model.GltfMetaDataWrapper");

StringStreamLogSink m_logSink;
};

// vector of GltfModelObjectMetadataWrapper
Expand Down

0 comments on commit 86470fe

Please sign in to comment.