View Issue Details

IDProjectCategoryView StatusLast Update
0026338CommunityOCCT:Data Exchangepublic2017-07-22 14:22
ReporterTimo Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version6.9.0 
Target Version7.0.0Fixed in Version7.0.0 
Summary0026338: STL export (especially binary) needs a lot of time if selected export path is not local
DescriptionIf the output path of an STL export refers to a network location instead of a file on a local disk, the export can be quite slow.

The reason is that in RWStl::WriteAscii the file is accessed once for every triangle. In RWStl::WriteBinary it is even worse. The file is accessed 13 times for every triangle. If a model contains many triangles this can be quite noticeable and block the export for a while. In a test, for 6000 triangles the binary export needed 25 seconds, whereas the ASCII export needed only a few seconds. Surely, it depends on the network.

Wouldn't it be better to use some buffer or "virtual" file in memory to do the export and then to write it to the real file location only once. Then the export should be quite quick. In case of extraordinary big files this could lead to memory problems but I cannot imagine someone exporting an STL file of several giga bytes.

The ASCII export already uses a buffer so that there is only one file access per triangle. At least it would be good that binary export does the same. But I personally would prefer one file access per export.

What do you think about it?
Steps To ReproduceCopy the appended brep file to a network location. Start Draw and change the directory to the network location.

Then run the following commands to see the difference between ASCII and binary export. The file contains ~ 6000 triangles. In case the difference is not noticable you can increase it via incmesh command.

restore cylinder.brep c

whatis c

trinfo c

writestl p c1.stl 0

writestl p c2.stl 1
TagsNo tags attached.
Test case numberbugs stlvrml bug26338; perf de bug26338_1, bug26338_2

Attached Files

  • cylinder.zip (73,336 bytes)

Relationships

related to 0028840 closedbugmaster Open CASCADE Data Exchange - rewrite the STL Reader/Writer 
parent of 0028938 closedbugmaster Open CASCADE Tests - remove useless file artifacts of test cases perf/de/bug26338 
related to 0027561 closedbugmaster Community Data Exchange - since OCCT 7.0.0, exporting a curve to STL creates a file that results in an endless loop when read 

Activities

Timo

2015-06-12 15:17

developer  

cylinder.zip (73,336 bytes)

git

2016-02-25 07:37

administrator   ~0051093

Branch CR26338 has been created by abv.

SHA-1: 64be7ad322ba7f2b7b84cd1d78afa2035663e845


Detailed log of new commits:

Author: abv
Date: Thu Feb 25 07:30:18 2016 +0300

    0026338: STL export (especially binary) needs a lot of time if selected export path is not local
    
    Method StlAPI_Writer::Write() is reimplemented to write triangulation directly, without conversion to StlMesh_Mesh.
    
    New DRAW command "tessellate" is added to generate rapidly triangulation of prescribed size (on surface).
    Command "tricheck" is protected to deal correctly with triangulation without UV data.
    
    New tests added: perf de bug26338_1 and _2

abv

2016-02-25 11:50

manager   ~0051107

Fix pushed to CR26338, please review.

Note that the problem was more than just inefficiency of the file access (OSD_File implementation). The whole procedure was organized very inefficiently: instead of writing triangulation from shape directly, it converted it to StlMesh data structures which are poorly designed and extremely slow for big meshes. This component should be completely redesigned. Meanwhile I have re-implemented StlAPI_Writer class to write shape triangulation directly to STL.

The result is significant boost of performance in all modes.

CPU time of writing big mesh (2M triangles) on my workstation (Intel i5-3450):

                          | master | CR26338
----------------------------------------------------------
binary STL, local drive | 17 s | 0.26 s
Ascii STL, local drive | 33 s | 14.8 s (mostly spent by printf())
binary STL, network drive | -- | 11 s
Ascii STL, network drive | -- | 75 s

(here I could not wait till master finished writing to network drive, and killed process after waiting for 1.5 hours)

Elapsed time of writing mesh with 2K triangles to network drive:

           | master | CR26338
------------------------------------------------------
binary STL | 97 s | 0.11 s
Ascii STL | 7 s | 0.23 s

git

2016-02-25 15:03

administrator   ~0051116

Branch CR26338 has been updated forcibly by abv.

SHA-1: 5868ad7ac6a397dfb7e95fa69212995a9c07bce4

git

2016-02-26 16:45

administrator   ~0051174

Branch CR26338 has been updated forcibly by abv.

SHA-1: 774a813644ffb15b318d1b603eccfe76680a552c

git

2016-02-26 17:38

administrator   ~0051179

Branch CR26338_1 has been created by abv.

SHA-1: 27c0e50478b682812b3666f99640f16f9e922947


Detailed log of new commits:

Author: abv
Date: Thu Feb 25 07:30:18 2016 +0300

    0026338: STL export (especially binary) needs a lot of time if selected export path is not local
    
    Method StlAPI_Writer::Write() is reimplemented to write triangulation directly, without conversion to StlMesh_Mesh.
    
    New DRAW command "tessellate" is added to generate rapidly triangulation of prescribed size (on surface).
    Command "tricheck" is protected to deal correctly with triangulation without UV data.
    
    New tests added: perf de bug26338_1 and _2; bugs stlvrml bug26338

kgv

2016-02-26 17:41

developer   ~0051180

Please test the patch.

git

2016-02-26 18:22

administrator   ~0051185

Branch CR26338_1 has been updated forcibly by abv.

SHA-1: 6927caf88db3bb4970ab14841d1cd9365a9c7da4

apv

2016-02-29 12:21

tester   ~0051211

Dear BugMaster,

Branch CR26338_1 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
SHA-1: 6927caf88db3bb4970ab14841d1cd9365a9c7da4

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MacOS: 0 (0 on master)
products component:
   Linux: 41 (41 on master)
   Windows: 0 (0 on master)

Regressions/Differences:
Not detected

Testing cases:
bugs stlvrml bug26338 - OK
http://occt-tests/CR26338-1-master-occt-64/Debian70-64/bugs/stlvrml/bug26338.html
http://occt-tests/CR26338-1-master-occt-64/Windows-64-VC10/bugs/stlvrml/bug26338.html
perf de bug26338_1 - OK
http://occt-tests/CR26338-1-master-occt-64/Debian70-64/perf/de/bug26338_1.html
http://occt-tests/CR26338-1-master-occt-64/Windows-64-VC10/perf/de/bug26338_1.html
perf de bug26338_2 - OK
http://occt-tests/CR26338-1-master-occt-64/Debian70-64/perf/de/bug26338_2.html
http://occt-tests/CR26338-1-master-occt-64/Windows-64-VC10/perf/de/bug26338_2.html

Testing on Linux:
Total MEMORY difference: 90291178 / 90553839 [-0.29%]
Total CPU difference: 19234.78999999991 / 19576.260000000108 [-1.74%]

Testing on Windows:
Total MEMORY difference: 57382759 / 57104393 [+0.49%]
Total CPU difference: 18258.04503799906 / 17709.873124098754 [+3.10%]

git

2016-02-29 12:26

administrator   ~0051212

Branch CR26338_1 has been updated by apv.

SHA-1: fd8ed84f08d676862c0931bee2d58aaffef9ffce


Detailed log of new commits:

Author: apv
Date: Mon Feb 29 12:26:11 2016 +0300

    Correction of testing environment

Timo

2016-03-04 17:02

developer   ~0051412

Why is the runtime of Tests on Windows worse ([+3.10%])?

abv

2016-03-04 17:11

manager   ~0051415

These are fluctuations due to instability of testing environment (hardware / software). We are working on improving the tests stability, but it is not an easy subject. Note that tests are executed in parallel thus there is a certain amount of randomness.

git

2016-04-17 12:56

administrator   ~0052770

Branch CR26338 has been deleted by kgv.

SHA-1: 774a813644ffb15b318d1b603eccfe76680a552c

git

2016-04-17 13:07

administrator   ~0052799

Branch CR26338_1 has been deleted by kgv.

SHA-1: fd8ed84f08d676862c0931bee2d58aaffef9ffce

Related Changesets

occt: master b508cbc5

2016-02-25 04:30:18

abv


Committer: bugmaster Details Diff
0026338: STL export (especially binary) needs a lot of time if selected export path is not local

Method StlAPI_Writer::Write() is reimplemented to write triangulation directly, without conversion to StlMesh_Mesh.

New DRAW command "tessellate" is added to generate rapidly triangulation of prescribed size (on surface).

Command "tricheck" is protected to deal correctly with triangulation without UV data.

New tests added: perf de bug26338_1 and _2; bugs stlvrml bug26338

Correction of testing environment
Affected Issues
0026338
mod - src/MeshTest/MeshTest.cxx Diff File
mod - src/MeshTest/MeshTest_PluginCommands.cxx Diff File
mod - src/StlAPI/StlAPI_ErrorStatus.hxx Diff File
mod - src/StlAPI/StlAPI_Writer.cxx Diff File
add - tests/bugs/stlvrml/bug26338 Diff File
add - tests/perf/de/bug26338_1 Diff File
add - tests/perf/de/bug26338_2 Diff File
mod - tests/perf/grids.list Diff File

Issue History

Date Modified Username Field Change
2015-06-12 15:17 Timo New Issue
2015-06-12 15:17 Timo Assigned To => gka
2015-06-12 15:17 Timo File Added: cylinder.zip
2015-12-15 14:08 abv Steps to Reproduce Updated
2016-02-08 18:08 abv Assigned To gka => abv
2016-02-25 07:37 git Note Added: 0051093
2016-02-25 11:50 abv Note Added: 0051107
2016-02-25 11:50 abv Assigned To abv => gka
2016-02-25 11:50 abv Status new => resolved
2016-02-25 15:03 git Note Added: 0051116
2016-02-25 15:04 abv Assigned To gka => kgv
2016-02-25 15:34 abv Assigned To kgv => abv
2016-02-25 15:34 abv Status resolved => assigned
2016-02-26 16:45 git Note Added: 0051174
2016-02-26 16:46 abv Assigned To abv => kgv
2016-02-26 16:46 abv Status assigned => resolved
2016-02-26 17:38 git Note Added: 0051179
2016-02-26 17:41 kgv Note Added: 0051180
2016-02-26 17:41 kgv Assigned To kgv => bugmaster
2016-02-26 17:41 kgv Status resolved => reviewed
2016-02-26 18:22 git Note Added: 0051185
2016-02-26 19:29 apv Assigned To bugmaster => apv
2016-02-29 12:16 apv Test case number => bugs stlvrml bug26338; perf de bug26338_1, bug26338_2
2016-02-29 12:21 apv Note Added: 0051211
2016-02-29 12:21 apv Assigned To apv => bugmaster
2016-02-29 12:21 apv Status reviewed => tested
2016-02-29 12:26 git Note Added: 0051212
2016-03-04 16:52 bugmaster Changeset attached => occt master b508cbc5
2016-03-04 16:52 bugmaster Status tested => verified
2016-03-04 16:52 bugmaster Resolution open => fixed
2016-03-04 17:02 Timo Note Added: 0051412
2016-03-04 17:11 abv Note Added: 0051415
2016-04-17 12:56 git Note Added: 0052770
2016-04-17 13:07 git Note Added: 0052799
2016-04-20 15:43 aiv Fixed in Version => 7.0.0
2016-04-20 15:49 aiv Status verified => closed
2016-06-02 17:05 Timo Relationship added related to 0027561
2017-06-13 13:23 abv Relationship added related to 0028840
2017-07-22 14:22 kgv Relationship added parent of 0028938