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

PCDLoader: Fix regex to match header fields at line start #29196

Merged

Conversation

lenville
Copy link
Contributor

Description

This PR improves the robustness of the PCDLoader by refining how header information is parsed from PCD files. The update addresses an issue where the regex patterns used to extract header fields such as VERSION, FIELDS, SIZE, and others did not account for multi-line strings. This could lead to incorrect parsing, especially when the header data wasn't at the start of the entire string.

The need for this fix arose due to the addition of new, extended custom fields in PCD files. These custom fields introduced more complex formatting, causing the previous regex patterns to fail in certain cases.

Changes include:

  • Modified regex patterns to use the ^ anchor combined with the m (multiline) flag, ensuring that each pattern matches the beginning of each line within the header string.
  • This update prevents potential mismatches and enhances the accuracy of the PCD file parsing process.

These improvements are essential for handling PCD files with complex or non-standard formatting, including those with extended custom fields, ensuring that the loader remains reliable across different datasets.

Tests have been run on various PCD files, including those with custom fields, to confirm that these changes work as expected.

This PR improves the robustness of the `PCDLoader` by refining how header information is parsed from PCD files. The update addresses an issue where the regex patterns used to extract header fields such as `VERSION`, `FIELDS`, `SIZE`, and others did not account for multi-line strings. This could lead to incorrect parsing, especially when the header data wasn't at the start of the entire string.

The need for this fix arose due to the addition of new, extended custom fields in PCD files. These custom fields introduced more complex formatting, causing the previous regex patterns to fail in certain cases.

**Changes include:**
- Modified regex patterns to use the `^` anchor combined with the `m` (multiline) flag, ensuring that each pattern matches the beginning of each line within the header string.
- This update prevents potential mismatches and enhances the accuracy of the PCD file parsing process.

These improvements are essential for handling PCD files with complex or non-standard formatting, including those with extended custom fields, ensuring that the loader remains reliable across different datasets.

Tests have been run on various PCD files, including those with custom fields, to confirm that these changes work as expected.
@Mugen87 Mugen87 merged commit e2ace0b into mrdoob:dev Aug 21, 2024
11 checks passed
@Mugen87 Mugen87 added this to the r168 milestone Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants