Skip to content

Commit

Permalink
E57Simple: Change field name from pointsSize to pointCount (#164)
Browse files Browse the repository at this point in the history
This actually stores the number of points, not the size of the data, so change the name (and fix the docs) to make it clearer.
  • Loading branch information
asmaloney authored Nov 4, 2022
1 parent 7fd9ef4 commit 1c65fe8
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 48 deletions.
5 changes: 2 additions & 3 deletions include/E57SimpleData.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,8 @@ namespace e57
PointGroupingSchemes pointGroupingSchemes; //!< The defined schemes that group points in different ways
PointStandardizedFieldsAvailable pointFields; //!< The active fields used in the WritePoints function.

//! Total size of the compressed vector of PointRecord structures referring to the binary data that actually
//! stores the point data
int64_t pointsSize = 0;
//! The number of points in the Data3D.
int64_t pointCount = 0;
};

//! @brief Stores pointers to user-provided buffers
Expand Down
52 changes: 26 additions & 26 deletions src/E57SimpleData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ namespace e57
template <typename COORDTYPE>
Data3DPointsData_t<COORDTYPE>::Data3DPointsData_t( Data3D &data3D ) : _selfAllocated( true )
{
const auto cSize = data3D.pointsSize;
const auto cPointCount = data3D.pointCount;

if ( cSize < 1 )
if ( cPointCount < 1 )
{
throw E57_EXCEPTION2( E57_ERROR_VALUE_OUT_OF_BOUNDS, "pointsSize=" + toString( cSize ) + " minimum=1" );
throw E57_EXCEPTION2( E57_ERROR_VALUE_OUT_OF_BOUNDS, "pointCount=" + toString( cPointCount ) + " minimum=1" );
}

// We need to adjust min/max for floats.
Expand All @@ -51,117 +51,117 @@ namespace e57

if ( data3D.pointFields.cartesianXField )
{
cartesianX = new COORDTYPE[cSize];
cartesianX = new COORDTYPE[cPointCount];
}

if ( data3D.pointFields.cartesianYField )
{
cartesianY = new COORDTYPE[cSize];
cartesianY = new COORDTYPE[cPointCount];
}

if ( data3D.pointFields.cartesianZField )
{
cartesianZ = new COORDTYPE[cSize];
cartesianZ = new COORDTYPE[cPointCount];
}

if ( data3D.pointFields.cartesianInvalidStateField )
{
cartesianInvalidState = new int8_t[cSize];
cartesianInvalidState = new int8_t[cPointCount];
}

if ( data3D.pointFields.intensityField )
{
intensity = new float[cSize];
intensity = new float[cPointCount];
}

if ( data3D.pointFields.isIntensityInvalidField )
{
isIntensityInvalid = new int8_t[cSize];
isIntensityInvalid = new int8_t[cPointCount];
}

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

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

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

if ( data3D.pointFields.isColorInvalidField )
{
isColorInvalid = new int8_t[cSize];
isColorInvalid = new int8_t[cPointCount];
}

if ( data3D.pointFields.sphericalRangeField )
{
sphericalRange = new COORDTYPE[cSize];
sphericalRange = new COORDTYPE[cPointCount];
}

if ( data3D.pointFields.sphericalAzimuthField )
{
sphericalAzimuth = new COORDTYPE[cSize];
sphericalAzimuth = new COORDTYPE[cPointCount];
}

if ( data3D.pointFields.sphericalElevationField )
{
sphericalElevation = new COORDTYPE[cSize];
sphericalElevation = new COORDTYPE[cPointCount];
}

if ( data3D.pointFields.sphericalInvalidStateField )
{
sphericalInvalidState = new int8_t[cSize];
sphericalInvalidState = new int8_t[cPointCount];
}

if ( data3D.pointFields.rowIndexField )
{
rowIndex = new int32_t[cSize];
rowIndex = new int32_t[cPointCount];
}

if ( data3D.pointFields.columnIndexField )
{
columnIndex = new int32_t[cSize];
columnIndex = new int32_t[cPointCount];
}

if ( data3D.pointFields.returnIndexField )
{
returnIndex = new int8_t[cSize];
returnIndex = new int8_t[cPointCount];
}

if ( data3D.pointFields.returnCountField )
{
returnCount = new int8_t[cSize];
returnCount = new int8_t[cPointCount];
}

if ( data3D.pointFields.timeStampField )
{
timeStamp = new double[cSize];
timeStamp = new double[cPointCount];
}

if ( data3D.pointFields.isTimeStampInvalidField )
{
isTimeStampInvalid = new int8_t[cSize];
isTimeStampInvalid = new int8_t[cPointCount];
}

if ( data3D.pointFields.normalXField )
{
normalX = new float[cSize];
normalX = new float[cPointCount];
}

if ( data3D.pointFields.normalYField )
{
normalY = new float[cSize];
normalY = new float[cPointCount];
}

if ( data3D.pointFields.normalZField )
{
normalZ = new float[cSize];
normalZ = new float[cPointCount];
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ namespace e57
const StructureNode proto( points.prototype() );

data3DHeader.guid = StringNode( scan.get( "guid" ) ).value();
data3DHeader.pointsSize = points.childCount();
data3DHeader.pointCount = points.childCount();

if ( scan.isDefined( "name" ) )
{
Expand Down
4 changes: 2 additions & 2 deletions src/WriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@ namespace e57
// "/data3D/0/pointGroupingSchemes/groupingByLine/groups/0/idElementValue"
const int64_t groupsSize = data3DHeader.pointGroupingSchemes.groupingByLine.groupsSize;
const int64_t countSize = data3DHeader.pointGroupingSchemes.groupingByLine.pointCountSize;
const int64_t pointsSize = data3DHeader.pointsSize;
const int64_t pointsCount = data3DHeader.pointCount;

StructureNode lineGroupProto( imf_ );

lineGroupProto.set( "startPointIndex", IntegerNode( imf_, 0, 0, pointsSize - 1 ) );
lineGroupProto.set( "startPointIndex", IntegerNode( imf_, 0, 0, pointsCount - 1 ) );
lineGroupProto.set( "idElementValue", IntegerNode( imf_, 0, 0, groupsSize - 1 ) );
lineGroupProto.set( "pointCount", IntegerNode( imf_, 0, 0, countSize ) );

Expand Down
4 changes: 2 additions & 2 deletions test/src/test_SimpleData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TEST( SimpleDataHeader, HeaderMinMaxFloat )
{
e57::Data3D dataHeader;

dataHeader.pointsSize = 1;
dataHeader.pointCount = 1;

EXPECT_EQ( dataHeader.pointFields.pointRangeMinimum, e57::E57_DOUBLE_MIN );
EXPECT_EQ( dataHeader.pointFields.pointRangeMaximum, e57::E57_DOUBLE_MAX );
Expand All @@ -42,7 +42,7 @@ TEST( SimpleDataHeader, HeaderMinMaxDouble )
{
e57::Data3D dataHeader;

dataHeader.pointsSize = 1;
dataHeader.pointCount = 1;

EXPECT_EQ( dataHeader.pointFields.pointRangeMinimum, e57::E57_DOUBLE_MIN );
EXPECT_EQ( dataHeader.pointFields.pointRangeMaximum, e57::E57_DOUBLE_MAX );
Expand Down
16 changes: 8 additions & 8 deletions test/src/test_SimpleReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ TEST( SimpleReaderData, ColouredCubeFloat )
e57::Data3D data3DHeader;
ASSERT_TRUE( reader->ReadData3D( 0, data3DHeader ) );

ASSERT_EQ( data3DHeader.pointsSize, 7'680 );
ASSERT_EQ( data3DHeader.pointCount, 7'680 );
EXPECT_EQ( data3DHeader.guid, "Coloured Cube Float Scan Header GUID" );

const uint64_t cNumPoints = data3DHeader.pointsSize;
const uint64_t cNumPoints = data3DHeader.pointCount;

e57::Data3DPointsData pointsData( data3DHeader );

Expand Down Expand Up @@ -123,10 +123,10 @@ TEST( SimpleReaderData, ColouredCubeFloatToDouble )
e57::Data3D data3DHeader;
ASSERT_TRUE( reader->ReadData3D( 0, data3DHeader ) );

ASSERT_EQ( data3DHeader.pointsSize, 7'680 );
ASSERT_EQ( data3DHeader.pointCount, 7'680 );
EXPECT_EQ( data3DHeader.guid, "Coloured Cube Float Scan Header GUID" );

const uint64_t cNumPoints = data3DHeader.pointsSize;
const uint64_t cNumPoints = data3DHeader.pointCount;

e57::Data3DPointsData_d pointsData( data3DHeader );

Expand Down Expand Up @@ -160,10 +160,10 @@ TEST( SimpleReaderData, BunnyDouble )
e57::Data3D data3DHeader;
ASSERT_TRUE( reader->ReadData3D( 0, data3DHeader ) );

ASSERT_EQ( data3DHeader.pointsSize, 30'571 );
ASSERT_EQ( data3DHeader.pointCount, 30'571 );
EXPECT_EQ( data3DHeader.guid, "{9CA24C38-C93E-40E8-A366-F49977C7E3EB}" );

const uint64_t cNumPoints = data3DHeader.pointsSize;
const uint64_t cNumPoints = data3DHeader.pointCount;

e57::Data3DPointsData pointsData( data3DHeader );

Expand Down Expand Up @@ -197,10 +197,10 @@ TEST( SimpleReaderData, BunnyInt32 )
e57::Data3D data3DHeader;
ASSERT_TRUE( reader->ReadData3D( 0, data3DHeader ) );

EXPECT_EQ( data3DHeader.pointsSize, 30'571 );
EXPECT_EQ( data3DHeader.pointCount, 30'571 );
EXPECT_EQ( data3DHeader.guid, "{9CA24C38-C93E-40E8-A366-F49977C7E3EB}" );

const uint64_t cNumPoints = data3DHeader.pointsSize;
const uint64_t cNumPoints = data3DHeader.pointCount;

e57::Data3DPointsData pointsData( data3DHeader );

Expand Down
12 changes: 6 additions & 6 deletions test/src/test_SimpleWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ TEST( SimpleWriter, ColouredCubeDouble )
e57::Data3D header;
header.guid = "Coloured Cube Double Scan Header GUID";
header.description = "libE57Format test: cube of coloured points using doubles";
header.pointsSize = cNumPoints;
header.pointCount = cNumPoints;

// setting this to < 0.0 indicates we want to write doubles
header.pointFields.pointRangeScaledInteger = -1.0;
Expand Down Expand Up @@ -220,7 +220,7 @@ TEST( SimpleWriter, ColouredCubeFloat )
e57::Data3D header;
header.guid = "Coloured Cube Float Scan Header GUID";
header.description = "libE57Format test: cube of coloured points using floats";
header.pointsSize = cNumPoints;
header.pointCount = cNumPoints;

setUsingColouredCartesianPoints( header );

Expand Down Expand Up @@ -283,7 +283,7 @@ TEST( SimpleWriter, ColouredCubeScaledInt )
e57::Data3D header;
header.guid = "Cube Scaled Int Scan Header GUID";
header.description = "libE57Format test: cube of coloured points using scaled integers";
header.pointsSize = cNumPoints;
header.pointCount = cNumPoints;

// setting this to > 0.0 indicates we want to write scaled ints and to use this as the scale
header.pointFields.pointRangeScaledInteger = 0.001;
Expand Down Expand Up @@ -337,7 +337,7 @@ TEST( SimpleWriter, MultipleScans )
constexpr int cNumPoints = 8;

e57::Data3D header;
header.pointsSize = cNumPoints;
header.pointCount = cNumPoints;
header.pointFields.cartesianXField = true;
header.pointFields.cartesianYField = true;
header.pointFields.cartesianZField = true;
Expand Down Expand Up @@ -411,7 +411,7 @@ TEST( SimpleWriter, CartesianPoints )

e57::Data3D header;
header.guid = "Cartesian Points Header GUID";
header.pointsSize = cNumPoints;
header.pointCount = cNumPoints;
header.pointFields.cartesianXField = true;
header.pointFields.cartesianYField = true;
header.pointFields.cartesianZField = true;
Expand Down Expand Up @@ -449,7 +449,7 @@ TEST( SimpleWriter, ColouredCartesianPoints )

e57::Data3D header;
header.guid = "Coloured Cartesian Points Header GUID";
header.pointsSize = cNumPoints;
header.pointCount = cNumPoints;

setUsingColouredCartesianPoints( header );

Expand Down

0 comments on commit 1c65fe8

Please sign in to comment.