Skip to content

Commit 4590700

Browse files
authored
Merge branch 'isl-org:main' into typing-fixes
2 parents b8e0500 + b2d1f78 commit 4590700

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

.github/workflows/macos.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,8 @@ jobs:
345345
PYTAG="-cp$(echo ${{ env.python_version }} | tr -d '.')"
346346
mkdir universal_wheels
347347
pip install delocate
348-
delocate-fuse -v x64_wheels/open3d-*${PYTAG}*.whl arm64_wheels/open3d-*${PYTAG}*.whl
349-
# Normalize file name as delocate-fuse doesn't update it
350-
OLD_WHL_NAME=$(basename x64_wheels/open3d-*${PYTAG}*.whl)
351-
NEW_WHL_NAME=${OLD_WHL_NAME/x86_64/universal2}
352-
mv x64_wheels/${OLD_WHL_NAME} universal_wheels/${NEW_WHL_NAME}
348+
delocate-merge -v -w universal_wheels x64_wheels/open3d-*${PYTAG}*.whl arm64_wheels/open3d-*${PYTAG}*.whl
349+
NEW_WHL_NAME=$(basename universal_wheels/open3d-*${PYTAG}*.whl)
353350
echo "PIP_PKG_NAME=$NEW_WHL_NAME" >> $GITHUB_ENV
354351
355352
- name: Upload merged wheels

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
- Split pybind declarations/definitions to avoid C++ types in Python docs (PR #6869)
4545
- Fix minimal oriented bounding box of MeshBase derived classes and add new unit tests (PR #6898)
4646
- Fix projection of point cloud to Depth/RGBD image if no position attribute is provided (PR #6880)
47+
- Support lowercase types when reading PCD files (PR #6930)
4748

4849
## 0.13
4950

cpp/open3d/io/file_format/FilePCD.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ bool ReadPCDHeader(FILE *file, PCDHeader &header) {
220220
double UnpackBinaryPCDElement(const char *data_ptr,
221221
const char type,
222222
const int size) {
223-
if (type == 'I') {
223+
const char type_uppercase = std::toupper(type, std::locale());
224+
if (type_uppercase == 'I') {
224225
if (size == 1) {
225226
std::int8_t data;
226227
memcpy(&data, data_ptr, sizeof(data));
@@ -236,7 +237,7 @@ double UnpackBinaryPCDElement(const char *data_ptr,
236237
} else {
237238
return 0.0;
238239
}
239-
} else if (type == 'U') {
240+
} else if (type_uppercase == 'U') {
240241
if (size == 1) {
241242
std::uint8_t data;
242243
memcpy(&data, data_ptr, sizeof(data));
@@ -252,7 +253,7 @@ double UnpackBinaryPCDElement(const char *data_ptr,
252253
} else {
253254
return 0.0;
254255
}
255-
} else if (type == 'F') {
256+
} else if (type_uppercase == 'F') {
256257
if (size == 4) {
257258
float data;
258259
memcpy(&data, data_ptr, sizeof(data));
@@ -281,11 +282,12 @@ double UnpackASCIIPCDElement(const char *data_ptr,
281282
const char type,
282283
const int size) {
283284
char *end;
284-
if (type == 'I') {
285+
const char type_uppercase = std::toupper(type, std::locale());
286+
if (type_uppercase == 'I') {
285287
return (double)std::strtol(data_ptr, &end, 0);
286-
} else if (type == 'U') {
288+
} else if (type_uppercase == 'U') {
287289
return (double)std::strtoul(data_ptr, &end, 0);
288-
} else if (type == 'F') {
290+
} else if (type_uppercase == 'F') {
289291
return std::strtod(data_ptr, &end);
290292
}
291293
return 0.0;
@@ -297,13 +299,14 @@ Eigen::Vector3d UnpackASCIIPCDColor(const char *data_ptr,
297299
if (size == 4) {
298300
std::uint8_t data[4] = {0, 0, 0, 0};
299301
char *end;
300-
if (type == 'I') {
302+
const char type_uppercase = std::toupper(type, std::locale());
303+
if (type_uppercase == 'I') {
301304
std::int32_t value = std::strtol(data_ptr, &end, 0);
302305
memcpy(data, &value, 4);
303-
} else if (type == 'U') {
306+
} else if (type_uppercase == 'U') {
304307
std::uint32_t value = std::strtoul(data_ptr, &end, 0);
305308
memcpy(data, &value, 4);
306-
} else if (type == 'F') {
309+
} else if (type_uppercase == 'F') {
307310
float value = std::strtof(data_ptr, &end);
308311
memcpy(data, &value, 4);
309312
}

cpp/open3d/t/io/file_format/FilePCD.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,30 +89,34 @@ struct WriteAttributePtr {
8989
};
9090

9191
static core::Dtype GetDtypeFromPCDHeaderField(char type, int size) {
92-
if (type == 'I') {
92+
char type_uppercase = std::toupper(type, std::locale());
93+
if (type_uppercase == 'I') {
9394
if (size == 1) return core::Dtype::Int8;
9495
if (size == 2) return core::Dtype::Int16;
9596
if (size == 4) return core::Dtype::Int32;
9697
if (size == 8)
9798
return core::Dtype::Int64;
9899
else
99-
utility::LogError("Unsupported data type.");
100-
} else if (type == 'U') {
100+
utility::LogError("Unsupported size {} for data type {}.", size,
101+
type);
102+
} else if (type_uppercase == 'U') {
101103
if (size == 1) return core::Dtype::UInt8;
102104
if (size == 2) return core::Dtype::UInt16;
103105
if (size == 4) return core::Dtype::UInt32;
104106
if (size == 8)
105107
return core::Dtype::UInt64;
106108
else
107-
utility::LogError("Unsupported data type.");
108-
} else if (type == 'F') {
109+
utility::LogError("Unsupported size {} for data type {}.", size,
110+
type);
111+
} else if (type_uppercase == 'F') {
109112
if (size == 4) return core::Dtype::Float32;
110113
if (size == 8)
111114
return core::Dtype::Float64;
112115
else
113-
utility::LogError("Unsupported data type.");
116+
utility::LogError("Unsupported size {} for data type {}.", size,
117+
type);
114118
} else {
115-
utility::LogError("Unsupported data type.");
119+
utility::LogError("Unsupported data type {}.", type);
116120
}
117121
}
118122

@@ -305,13 +309,14 @@ static void ReadASCIIPCDColorsFromField(ReadAttributePtr &attr,
305309
if (field.size == 4) {
306310
std::uint8_t data[4] = {0};
307311
char *end;
308-
if (field.type == 'I') {
312+
char type_uppercase = std::toupper(field.type, std::locale());
313+
if (type_uppercase == 'I') {
309314
std::int32_t value = std::strtol(data_ptr, &end, 0);
310315
std::memcpy(data, &value, sizeof(std::int32_t));
311-
} else if (field.type == 'U') {
316+
} else if (type_uppercase == 'U') {
312317
std::uint32_t value = std::strtoul(data_ptr, &end, 0);
313318
std::memcpy(data, &value, sizeof(std::uint32_t));
314-
} else if (field.type == 'F') {
319+
} else if (type_uppercase == 'F') {
315320
float value = std::strtof(data_ptr, &end);
316321
std::memcpy(data, &value, sizeof(float));
317322
}

0 commit comments

Comments
 (0)