From e4bc02228dc3cf68aade54e08d11ead52ee7c421 Mon Sep 17 00:00:00 2001 From: StephenCzarnecki Date: Tue, 26 Jul 2022 10:45:32 -0400 Subject: [PATCH] v1.4.0. Removed conversion of slat geometry from mm to m. This library should only parse data files. The only exception is in the (possibly theoretical) case where BSDF XML files have thickness unit = meter. In that case thickness is converted to mm to match thickness of optics files and IGSDB v1 and v2 json. --- CMakeLists.txt | 2 +- src/Parser.cpp | 13 +++++-------- test/read_igsdb_shading_layer_json.unit.cpp | 6 +++--- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7688e3e..76a56f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.8) -project( OpticalMeasurementParser VERSION 1.3.0 LANGUAGES CXX ) +project( OpticalMeasurementParser VERSION 1.4.0 LANGUAGES CXX ) set(LIB_NAME ${PROJECT_NAME}) if(NOT "${CMAKE_CXX_STANDARD}") diff --git a/src/Parser.cpp b/src/Parser.cpp index 6809957..eda71f5 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -576,7 +576,7 @@ namespace OpticsParser { /* NOTE: All values in v2 json are strings. Actually this is unfortunately not true. - Some values are strings like wavelength values but some are numbers like thickness. + Some values are strings like wavelength values but some are numbers like thickness. */ std::shared_ptr product = std::make_shared(); product->name = product_json.at("name").get(); @@ -729,13 +729,6 @@ namespace OpticsParser double slatTilt = geometry_json.value("slat_tilt", 0.0); std::string tiltChoice = geometry_json.at("tilt_choice").get(); - // These values are stored as mm in the sources being parsed. - // Convert to meters here for consistancy with other non-wavelength - // length units. - slatWidth /= 1000.0; - slatSpacing /= 1000.0; - slatCurvature /= 1000.0; - return std::shared_ptr(new VenetianGeometry( slatWidth, slatSpacing, slatCurvature, slatTilt, tiltChoice, numberSegments)); } @@ -981,6 +974,10 @@ OpticsParser::ProductData parseIGSDBJson(nlohmann::json const & product_json) {} else if(thickness.has_value() && toLower(thicknessUnitStr) == "meter") { + // Convert to mm here. This is the only case of unit conversion + // and is only here so that the very rare (possibly only theoretical) + // case when BSDF XML files have thickness in meters result in a parsed + // product that has the same thickness as optics files and IGSDB v1 and v2 json *thickness *= 1000.0; } else diff --git a/test/read_igsdb_shading_layer_json.unit.cpp b/test/read_igsdb_shading_layer_json.unit.cpp index 7100cca..7b15bd5 100644 --- a/test/read_igsdb_shading_layer_json.unit.cpp +++ b/test/read_igsdb_shading_layer_json.unit.cpp @@ -44,9 +44,9 @@ TEST_F(TestLoadIGSDBJSONFromDisk, TestLoadIGSDBVenetianShadingLayerJSON) EXPECT_EQ(product->measurements.has_value(), false); auto geometry = std::dynamic_pointer_cast( product->compositionInformation->geometry); - EXPECT_EQ(geometry->slatWidth, 0.0148); - EXPECT_EQ(geometry->slatSpacing, 0.0127); - EXPECT_EQ(geometry->slatCurvature, 0.03313057); + EXPECT_EQ(geometry->slatWidth, 14.8); + EXPECT_EQ(geometry->slatSpacing, 12.7); + EXPECT_EQ(geometry->slatCurvature, 33.13057); EXPECT_EQ(geometry->numberSegments, 5); auto material = product->compositionInformation->material; EXPECT_EQ(material->productName.value(), "White Venetian Blind Slat");