Skip to content

Commit

Permalink
v1.4.0. Removed conversion of slat geometry from mm to m. This librar…
Browse files Browse the repository at this point in the history
…y 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.
  • Loading branch information
StephenCzarnecki committed Jul 26, 2022
1 parent 7d52dd2 commit e4bc022
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}")
Expand Down
13 changes: 5 additions & 8 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProductData> product = std::make_shared<ProductData>();
product->name = product_json.at("name").get<std::string>();
Expand Down Expand Up @@ -729,13 +729,6 @@ namespace OpticsParser
double slatTilt = geometry_json.value("slat_tilt", 0.0);
std::string tiltChoice = geometry_json.at("tilt_choice").get<std::string>();

// 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<ProductGeometry>(new VenetianGeometry(
slatWidth, slatSpacing, slatCurvature, slatTilt, tiltChoice, numberSegments));
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/read_igsdb_shading_layer_json.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ TEST_F(TestLoadIGSDBJSONFromDisk, TestLoadIGSDBVenetianShadingLayerJSON)
EXPECT_EQ(product->measurements.has_value(), false);
auto geometry = std::dynamic_pointer_cast<OpticsParser::VenetianGeometry>(
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");
Expand Down

0 comments on commit e4bc022

Please sign in to comment.