Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport changes from QGIS #473

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions mdal/3rdparty/libplyxx/libplyxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ SOFTWARE.
#include <string>
#include <iostream>

#define BIG_ENDIAN 1
#define LITTLE_ENDIAN 0
#define PLYXX_BIG_ENDIAN 1
#define PLYXX_LITTLE_ENDIAN 0

namespace libply
{
Expand Down Expand Up @@ -337,7 +337,7 @@ namespace libply
const std::vector<PropertyDefinition> properties = elementDefinition.properties;
size_t t_idx = 0;
size_t e_idx = 0;
for ( PropertyDefinition p : properties )
for ( const PropertyDefinition &p : properties )
{
if ( t_idx == m_tokens.size() || e_idx == elementBuffer.size() )
{
Expand Down Expand Up @@ -378,16 +378,16 @@ namespace libply
char buffer[MAX_PROPERTY_SIZE];
size_t e_idx = 0;

for ( PropertyDefinition p : properties )
for ( const PropertyDefinition &p : properties )
{
uint32_t endian;
if ( format == File::Format::BINARY_LITTLE_ENDIAN )
{
endian = LITTLE_ENDIAN;
endian = PLYXX_LITTLE_ENDIAN;
}
else
{
endian = BIG_ENDIAN;
endian = PLYXX_BIG_ENDIAN;
}
if ( !p.isList )
{
Expand All @@ -403,7 +403,7 @@ namespace libply
const auto lengthType = p.listLengthType;
const auto lengthTypeSize = TYPE_SIZE_MAP.at( lengthType );
fs.read( buffer, lengthTypeSize );
size_t listLength = static_cast<size_t>( *buffer );
size_t listLength = static_cast<size_t>( static_cast<unsigned long>( *buffer ) );

ListProperty *lp = dynamic_cast<ListProperty *>( &elementBuffer[e_idx] );
lp->define( p.type, listLength );
Expand Down Expand Up @@ -512,8 +512,9 @@ namespace libply
case Type::UINT32: return "uint";
case Type::INT32: return "int";
case Type::FLOAT32: return "float";
case Type::FLOAT64: return "double";
case Type::COORDINATE: return "double";
case Type::FLOAT64:
case Type::COORDINATE:
return "double";
}
return "";
}
Expand Down Expand Up @@ -545,7 +546,7 @@ namespace libply
std::stringstream ss;
const std::vector<PropertyDefinition> properties = elementDefinition.properties;
size_t e_idx = 0;
for ( PropertyDefinition p : properties )
for ( const PropertyDefinition &p : properties )
{
if ( !p.isList )
{
Expand Down Expand Up @@ -581,11 +582,11 @@ namespace libply

if ( format == File::Format::BINARY_LITTLE_ENDIAN )
{
endian = LITTLE_ENDIAN;
endian = PLYXX_LITTLE_ENDIAN;
}
else
{
endian = BIG_ENDIAN;
endian = PLYXX_BIG_ENDIAN;
}

const std::vector<PropertyDefinition> properties = elementDefinition.properties;
Expand All @@ -597,7 +598,7 @@ namespace libply
auto &cast = p.writeCastFunction;
size_t write_size;
cast( buffer[e_idx], write_buffer, write_size, endian );
file.write( reinterpret_cast<char *>( write_buffer ), write_size );
file.write( reinterpret_cast<char *>( write_buffer ), static_cast<std::streamsize>( write_size ) );
e_idx++;
}
else
Expand All @@ -610,7 +611,7 @@ namespace libply
{
size_t write_size;
cast( lp->value( i ), write_buffer, write_size, endian );
file.write( reinterpret_cast<char *>( write_buffer ), write_size );
file.write( reinterpret_cast<char *>( write_buffer ), static_cast<std::streamsize>( write_size ) );
}
e_idx++;
}
Expand Down
4 changes: 2 additions & 2 deletions mdal/3rdparty/libplyxx/libplyxx_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ namespace libply
t.quad = 1;
if ( t.islittle ^ endian ) return w;

auto ptr = reinterpret_cast<uint8_t *>( &w );
std::array<uint8_t, sizeof( T )> raw_src, raw_dst;
auto ptr = reinterpret_cast<std::uint8_t *>( &w );
std::array<std::uint8_t, sizeof( T )> raw_src, raw_dst;

for ( std::size_t i = 0; i < sizeof( T ); ++i )
raw_src[i] = ptr[i];
Expand Down
Loading