View Issue Details

IDProjectCategoryView StatusLast Update
0029219Open CASCADEOCCT:Application Frameworkpublic2023-03-19 18:31
Reporterkgv Assigned Tovro  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version7.2.0 
Target Version7.7.0Fixed in Version7.6.2 
Summary0029219: Application Framework - XML document is written with CRLF on Windows
DescriptionIt seems that XML document has different EOL depending on the platform - CRLF on Windows and LF on other systems. Most likely, it is due to std::ofstream being opened in text mode instead of binary mode.

It would be useful saving XML files in consistent way across systems - e.g. using LF instead of CRLF on Windows (this would also reduce file size a little).
Steps To ReproduceA set of small scripts are attached. They produce a small file of the considered file format.
TagsNo tags attached.
Test case numberNot required

Attached Files

  • occt_brep (43 bytes)
  • occt_iges (50 bytes)
  • occt_step (50 bytes)
  • occt_stl (61 bytes)
  • occt_vrml (61 bytes)
  • occt_xml (46 bytes)

Relationships

related to 0029218 closedbugmaster Open CASCADE Application Framework - reading XML document calls LDOM parsing at least 3 times 

Activities

mpv

2017-10-16 10:04

developer   ~0071511

Windows end-of-lines for text files is standard. XML is a text file. We cannot simply change it in OCCT.

kgv

2017-10-16 10:28

developer   ~0071516

OK, the issue is not specific to XML export - BREP/STEP/IGES are also written with CRLF on Windows. However, behavior is still questionable:
- OCCT XML:    CRLF
- OCCT BREP:   CRLF
- OCCT STEP:   CRLF
- OCCT IGES:   CRLF
- OCCT VRML:   CRLF
- OCCT STL:    LF
- Blender X3D: CRLF
- Blender STL: CRLF
- Blender OBJ: LF
- Blender PLY: LF
- RPly:        LF

vro

2022-02-18 19:06

developer   ~0106978

I checked a STL file of Open CASCADE in ASCII format on Windows - it ends by CRLF. In Open CASCADE it writes by _wfopen (filename, "w") Windows API function.
Also, I checked Blender OBJ: it uses the same _wfopen (filename, "wb"), but in binary mode (additional 'b' is used) - it ends by LF.

So, I suppose all writers of Open CASCADE should end by CR LF on Windows, am I right?

kgv

2022-02-18 19:45

developer   ~0106981

> So, I suppose all writers of Open CASCADE should end by CR LF on Windows, am I right?

I propose all OCCT writers to output LF endlines on all platforms, when this is allowed by file format specification.

git

2022-02-21 10:41

administrator   ~0107002

Branch CR29219 has been created by vro.

SHA-1: 20e8b3e4656f756871936926479429c6d81aecbf


Detailed log of new commits:

Author: vro
Date: Mon Feb 21 10:41:05 2022 +0300

    0029219: Application Framework - XML document is written with CRLF on Windows
    
    The last symbol of a line is synchronized with external products.
    Also, XML ends by LF now.
    
    Modified:
    XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
    BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
    STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
    IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
    VRML: VrmlAPI_Writer::write_v2() ends by LF
    STL: RWStl::WriteAscii() ends by CR LF (to synchronize with Blender)

vro

2022-02-21 10:43

developer   ~0107003

Short scripts are added to generate the corresponding files:
XML
BREP
STEP
IGES
STL
VRML
occt_brep (43 bytes)
occt_iges (50 bytes)
occt_step (50 bytes)
occt_stl (61 bytes)
occt_vrml (61 bytes)
occt_xml (46 bytes)

vro

2022-02-21 13:15

developer   ~0107007

Dear Mikhail, could you revise the fix, pease?
The branch: occt - CR29219.
Result of compilation and testing: http://jenkins-test-08.nnov.opencascade.com/view/CR29219-master-VRO/view/COMPARE/ (as usual, Open GL driver for D3D failed, and a test on performance failed, but this test doesn't involve any write-operations - we might ignore these instabilities).

The following change were done:
XML - ends by LF
BREP - ends by LF
STEP - ends by LF
IGES - ends by LF
STL - ends by CR LF
VRML - ends by LF

Also, considered DXF files stored by AutoCAD. They end by CR LF like OCCT does - no changes.

kgv

2022-02-21 14:17

developer   ~0107008

> STL: RWStl::WriteAscii() ends by CR LF (to synchronize with Blender)

I guess this comment is irrelevant to the current patch and could be removed from git commit description (no changes done to STL writer).

git

2022-02-21 15:13

administrator   ~0107010

Branch CR29219 has been updated by vro.

SHA-1: 8b1fed81a20bfb0235d68f00e89537f11b706194


Detailed log of new commits:

Author: vro
Date: Mon Feb 21 15:13:35 2022 +0300

    0029219: Application Framework - XML document is written with CRLF on Windows
    
    The last symbol of a line is synchronized with external products.
    Also, XML ends by LF now.
    
    Modified:
    XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
    BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
    STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
    IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
    VRML: VrmlAPI_Writer::write_v2() ends by LF

Author: vro
Date: Mon Feb 21 15:12:40 2022 +0300

    Merge branch 'CR29219' of git.dev.opencascade.org:occt into CR29219

Author: vro
Date: Mon Feb 21 10:41:05 2022 +0300

    0029219: Application Framework - XML document is written with CRLF on Windows
    
    The last symbol of a line is synchronized with external products.
    Also, XML ends by LF now.
    
    Modified:
    XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
    BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
    STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
    IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
    VRML: VrmlAPI_Writer::write_v2() ends by LF

vro

2022-02-21 15:44

developer   ~0107012

The message for the last commit is corrected.

mpv

2022-02-21 16:13

developer   ~0107013

Reviewed
OCCT: CR32785_2
PRODUCTS: None

smoskvin

2022-02-26 18:10

administrator   ~0107073

Combination -
OCCT branch : IR-2022-02-25
master SHA - e61aa824dbdbe2cdbdf3606827c136f3f70de90f
49e51745631c52b6c452c65adae4d6dfa21a1b1e
Products branch : IR-2022-02-25 SHA - 859115827d7f98f21dc3e653fecea4c712aae052
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18467.180000000375 / 18497.380000000365 [-0.16%]
Products
Total CPU difference: 11716.630000000077 / 11705.020000000135 [+0.10%]
Windows-64-VC14:
OCCT
Total CPU difference: 20359.046875 / 20453.9375 [-0.46%]
Products
Total CPU difference: 13140.734375 / 13176.3125 [-0.27%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2022-02-26 19:21

administrator   ~0107077

Branch CR29219 has been deleted by mnt.

SHA-1: 8b1fed81a20bfb0235d68f00e89537f11b706194

Related Changesets

occt: master 5a846a5d

2022-02-21 10:41:05

vro


Committer: smoskvin Details Diff
0029219: Application Framework - XML document is written with CRLF on Windows

The last symbol of a line is synchronized with external products.
Also, XML ends by LF now.

Modified:
XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
VRML: VrmlAPI_Writer::write_v2() ends by LF

0029219: Application Framework - XML document is written with CRLF on Windows

The last symbol of a line is synchronized with external products.
Also, XML ends by LF now.

Modified:
XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
VRML: VrmlAPI_Writer::write_v2() ends by LF
STL: RWStl::WriteAscii() ends by CR LF (to synchronize with Blender)

0029219: Application Framework - XML document is written with CRLF on Windows

The last symbol of a line is synchronized with external products.
Also, XML ends by LF now.

Modified:
XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
VRML: VrmlAPI_Writer::write_v2() ends by LF
Affected Issues
0029219
mod - src/BRepTools/BRepTools.cxx Diff File
mod - src/Draw/Draw_VariableCommands.cxx Diff File
mod - src/IGESControl/IGESControl_Writer.cxx Diff File
mod - src/IGESSelect/IGESSelect_WorkLibrary.cxx Diff File
mod - src/StepSelect/StepSelect_WorkLibrary.cxx Diff File
mod - src/VrmlAPI/VrmlAPI_Writer.cxx Diff File
mod - src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx Diff File
mod - src/XSDRAWIGES/XSDRAWIGES.cxx Diff File

Issue History

Date Modified Username Field Change
2017-10-12 14:53 kgv New Issue
2017-10-12 14:53 kgv Assigned To => mpv
2017-10-12 14:53 kgv Relationship added related to 0029218
2017-10-16 10:04 mpv Note Added: 0071511
2017-10-16 10:04 mpv Assigned To mpv => kgv
2017-10-16 10:04 mpv Status new => feedback
2017-10-16 10:28 kgv Note Added: 0071516
2019-09-04 17:49 kgv Target Version 7.4.0 => 7.5.0
2020-08-28 16:34 kgv Target Version 7.5.0 => 7.6.0
2021-09-09 23:18 kgv Target Version 7.6.0 => 7.7.0
2022-02-10 11:28 szy Assigned To kgv => vro
2022-02-10 11:28 szy Status feedback => assigned
2022-02-18 19:06 vro Note Added: 0106978
2022-02-18 19:45 kgv Note Added: 0106981
2022-02-21 10:41 git Note Added: 0107002
2022-02-21 10:43 vro Note Added: 0107003
2022-02-21 10:43 vro File Added: occt_brep
2022-02-21 10:43 vro File Added: occt_iges
2022-02-21 10:43 vro File Added: occt_step
2022-02-21 10:43 vro File Added: occt_stl
2022-02-21 10:43 vro File Added: occt_vrml
2022-02-21 10:43 vro File Added: occt_xml
2022-02-21 13:15 vro Assigned To vro => mpv
2022-02-21 13:15 vro Status assigned => resolved
2022-02-21 13:15 vro Steps to Reproduce Updated
2022-02-21 13:15 vro Note Added: 0107007
2022-02-21 14:17 kgv Note Added: 0107008
2022-02-21 15:13 git Note Added: 0107010
2022-02-21 15:44 vro Note Added: 0107012
2022-02-21 16:13 mpv Assigned To mpv => bugmaster
2022-02-21 16:13 mpv Status resolved => reviewed
2022-02-21 16:13 mpv Note Added: 0107013
2022-02-26 18:10 smoskvin Status reviewed => tested
2022-02-26 18:10 smoskvin Note Added: 0107073
2022-02-26 18:11 smoskvin Test case number => Not required
2022-02-26 18:37 smoskvin Changeset attached => occt master 5a846a5d
2022-02-26 18:37 vro Assigned To bugmaster => vro
2022-02-26 18:37 vro Status tested => verified
2022-02-26 18:37 vro Resolution open => fixed
2022-02-26 19:21 git Note Added: 0107077
2023-03-19 18:31 vglukhik Status verified => closed
2023-03-19 18:31 vglukhik Fixed in Version => 7.6.2