Skip to content

Commit

Permalink
E57Simple: Use uint16_t for colours (#167)
Browse files Browse the repository at this point in the history
This allows us to use the E57Reader to read colours in las2e57-produced files.

Fixes #159
  • Loading branch information
asmaloney authored Nov 5, 2022
1 parent 7cc6af5 commit b35b042
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/E57SimpleData.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ namespace e57
//! Value = 0 if the intensity is considered valid, 1 otherwise
int8_t *isIntensityInvalid = nullptr;

uint8_t *colorRed = nullptr; //!< Pointer to a buffer with the Red color coefficient. Unit is unspecified
uint8_t *colorGreen = nullptr; //!< Pointer to a buffer with the Green color coefficient. Unit is unspecified
uint8_t *colorBlue = nullptr; //!< Pointer to a buffer with the Blue color coefficient. Unit is unspecified
uint16_t *colorRed = nullptr; //!< Pointer to a buffer with the Red color coefficient. Unit is unspecified
uint16_t *colorGreen = nullptr; //!< Pointer to a buffer with the Green color coefficient. Unit is unspecified
uint16_t *colorBlue = nullptr; //!< Pointer to a buffer with the Blue color coefficient. Unit is unspecified
int8_t *isColorInvalid = nullptr; //!< Value = 0 if the color is considered valid, 1 otherwise

//! Pointer to a buffer with the range (in meters) of points in spherical coordinates.
Expand Down
6 changes: 3 additions & 3 deletions src/E57SimpleData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ namespace e57

if ( data3D.pointFields.colorRedField )
{
colorRed = new uint8_t[cPointCount];
colorRed = new uint16_t[cPointCount];
}

if ( data3D.pointFields.colorGreenField )
{
colorGreen = new uint8_t[cPointCount];
colorGreen = new uint16_t[cPointCount];
}

if ( data3D.pointFields.colorBlueField )
{
colorBlue = new uint8_t[cPointCount];
colorBlue = new uint16_t[cPointCount];
}

if ( data3D.pointFields.isColorInvalidField )
Expand Down
39 changes: 39 additions & 0 deletions test/src/test_SimpleReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,42 @@ TEST( SimpleReaderData, BunnyInt32 )

delete reader;
}

TEST( SimpleReaderData, ColourRepresentation )
{
e57::Reader *reader = nullptr;

E57_ASSERT_NO_THROW( reader =
new e57::Reader( TestData::Path() + "/3rdParty/las2e57/ColourRepresentation.e57", {} ) );

ASSERT_TRUE( reader->IsOpen() );
EXPECT_EQ( reader->GetImage2DCount(), 0 );
ASSERT_EQ( reader->GetData3DCount(), 1 );

e57::E57Root fileHeader;
ASSERT_TRUE( reader->GetE57Root( fileHeader ) );

CheckFileHeader( fileHeader );
EXPECT_EQ( fileHeader.guid, "6107aa44-6289-4e9c-80bd-f36cc3fbd44b" );

e57::Data3D data3DHeader;
ASSERT_TRUE( reader->ReadData3D( 0, data3DHeader ) );

ASSERT_EQ( data3DHeader.pointCount, 153 );
EXPECT_EQ( data3DHeader.guid, "98d85152-82b3-4120-b06e-0c1bb10b6dec" );

const uint64_t cNumPoints = data3DHeader.pointCount;

e57::Data3DPointsData pointsData( data3DHeader );

auto vectorReader = reader->SetUpData3DPointsData( 0, cNumPoints, pointsData );

uint64_t cNumRead = 0;
E57_ASSERT_NO_THROW( cNumRead = vectorReader.read() );

vectorReader.close();

EXPECT_EQ( cNumRead, cNumPoints );

delete reader;
}

0 comments on commit b35b042

Please sign in to comment.