Skip to content

Data Exchange, Step Export - Preserving control directives#601

Merged
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:step_control_dir
Jul 12, 2025
Merged

Data Exchange, Step Export - Preserving control directives#601
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:step_control_dir

Conversation

@dpasukhi
Copy link
Copy Markdown
Member

@dpasukhi dpasukhi commented Jul 10, 2025

Fixed issue when control directives inside existed text is corrupted during export.
Added GTest to validate conversion

Fixed issue when control directives inside existed text is corrupted during export.
Added GTest to validate conversion
@dpasukhi dpasukhi added this to the Release 8.0 milestone Jul 10, 2025
@dpasukhi dpasukhi requested a review from Copilot July 10, 2025 16:55
@dpasukhi dpasukhi self-assigned this Jul 10, 2025
@dpasukhi dpasukhi added 2. Bug Something isn't working 1. Data Exchange Import/Export or iterating of the CAD data labels Jul 10, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors text handling in STEP export to correctly escape special characters while preserving existing control directives, integrates the new logic into the Send method, and adds GTest coverage for the conversion.

  • Introduced CleanTextForSend static helper with detailed documentation.
  • Updated StepData_StepWriter::Send to use the new helper and simplified quoting/line‐wrapping logic.
  • Added comprehensive GTests for CleanTextForSend and updated the test suite configuration.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.hxx Declares CleanTextForSend helper with doc comments
src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx Implements CleanTextForSend, refactors Send, removes old logic
src/DataExchange/TKDESTEP/GTests/StepData_StepWriter_Test.cxx Adds GTests covering CleanTextForSend scenarios
src/DataExchange/TKDESTEP/GTests/FILES.cmake Registers the new test file in CMake
Comments suppressed due to low confidence (4)

src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.hxx:278

  • The doc comment shows syntax with braces (\X{HH}\) but the implementation handles \XHH\ without braces. Update the comment to match actual supported pattern or enforce brace syntax.
  //! - \X{HH}\ : Single byte character encoding (U+0000 to U+00FF)

src/DataExchange/TKDESTEP/GTests/StepData_StepWriter_Test.cxx:19

  • Current tests only cover CleanTextForSend. You should add tests for StepData_StepWriter::Send to verify surrounding quotes and line-wrapping behavior.
// Test CleanTextForSend with basic character escaping

src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx:833

  • [nitpick] Variable name aNn is not descriptive. Consider renaming to cleanedLength or similar for readability.
  Standard_Integer        aNn  = aVal.Length();

src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx:1212

  • The code matches \XHH\ sequences but the header comment refers to \X{HH}\. Consider clarifying in code or docs whether braces are required or optional.
      else if (anI + 4 <= aNb && theText.Value(anI + 1) == 'X' && theText.Value(anI + 4) == '\\')

Comment thread src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx
Comment thread src/DataExchange/TKDESTEP/StepData/StepData_StepWriter.cxx
@dpasukhi dpasukhi requested a review from AtheneNoctuaPt July 10, 2025 17:06
Comment on lines +1218 to +1223
Standard_Boolean aThirdIsHex =
((aThirdChar >= '0' && aThirdChar <= '9') || (aThirdChar >= 'A' && aThirdChar <= 'F')
|| (aThirdChar >= 'a' && aThirdChar <= 'f'));
Standard_Boolean aFourthIsHex =
((aFourthChar >= '0' && aFourthChar <= '9') || (aFourthChar >= 'A' && aFourthChar <= 'F')
|| (aFourthChar >= 'a' && aFourthChar <= 'f'));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two checks can be replaced with std::isxdigit()

}
}
// Check for \P{char}\ patterns (need exactly 4 characters: \P{char}\)
else if (anI + 3 <= aNb && theText.Value(anI + 1) == 'P' && theText.Value(anI + 3) == '\\')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn´t we check 2nd character for std::isalpha?

@dpasukhi dpasukhi merged commit 08f6de3 into Open-Cascade-SAS:IR Jul 12, 2025
23 checks passed
@dpasukhi dpasukhi deleted the step_control_dir branch July 12, 2025 16:05
@github-project-automation github-project-automation bot moved this from Todo to Done in Maintenance Jul 12, 2025
dpasukhi added a commit that referenced this pull request Sep 6, 2025
- Introduced `CleanTextForSend` static helper with detailed documentation.
- Updated `StepData_StepWriter::Send` to use the new helper and simplified quoting/line‐wrapping logic.
- Added comprehensive GTests for `CleanTextForSend` and updated the test suite configuration.
dpasukhi added a commit that referenced this pull request Sep 6, 2025
- Introduced `CleanTextForSend` static helper with detailed documentation.
- Updated `StepData_StepWriter::Send` to use the new helper and simplified quoting/line‐wrapping logic.
- Added comprehensive GTests for `CleanTextForSend` and updated the test suite configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Data Exchange Import/Export or iterating of the CAD data 2. Bug Something isn't working

Development

Successfully merging this pull request may close these issues.

3 participants