View Issue Details

IDProjectCategoryView StatusLast Update
0031504Open CASCADEOCCT:Data Exchangepublic2021-03-24 10:57
Reporteravn Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformWindowsOSVC++ 2013 
Product Version7.4.0 
Target Version7.5.0Fixed in Version7.5.0 
Summary0031504: Data Exchange - Wrong output of progress indicator when writing to stl.
DescriptionThe function below allows you to read data from a file with the stl extension and write this data to a new file with the stl extension. In this case, the progress indicator is fed only to the input RWStl::WriteAscii.

#include <Draw_ProgressIndicator.hxx>
#include <RWStl.hxx>

static Standard_Integer DRAW_ReWriteSTL(Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
{
  TCollection_AsciiString aFilePathToRead  = theArgv[1];
  TCollection_AsciiString aFilePathToWrite = theArgv[2];
  if ( aFilePathToRead.IsEmpty() || aFilePathToWrite.IsEmpty() )
    return 1;
  //
  // Read STL file to the triangulation.
  Handle(Poly_Triangulation) aTriangulation = RWStl::ReadFile (aFilePathToRead.ToCString(), NULL);
  //
  //
  // Indicator.
  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
  aProgress->SetTextMode(true);
  //
  // Write to STL.
  OSD_Path aPath (aFilePathToWrite.ToCString());
  if ( !RWStl::WriteAscii (aTriangulation, aPath, aProgress) )
    return 1; // Success
  //
  return 0;
}


theCommands.Add("rewrite_stl",
                "rewrite_stl filenameToRead filenameToWrite",
                __FILE__, DRAW_ReWriteSTL, grp);


Execute the command "rewrite_stl C:/dev_cad_party/wright_whirlwind_radial_engine_occ.stl C:/dev_cad_party/NEW_wright_whirlwind_radial_engine_occ.stl" on wright_whirlwind_radial_engine_occ.stl (attached to the problem). When writing, we have the output presented on write.png (attached to the task).

Bug: the progress indicator showed that it performed 3% (1000/36512) when writing, but in fact the model was completely recorded. We also see that 1000 triangles are loaded, although there should be 2000.

Note, if you submit the progress indicator to read, then we get the output presented on read.png.

A possible reason for this behavior (one of the following):

1. Incorrect call of the Next() method at aPS (Message_ProgressSentry) in the RWStl.cxx file. You can call the following Next: Next(const Standard_Real span, const Standard_CString name) with span = IND_THRESHOLD (RWStl.cxx).

2. Wrong step (the i index of myScopes(i) is incorrectly chosen) in Message_ProgressIndicator::NextScope() in the Message_ProgressIndicator.lxx file.

3. Error in the Message_ProgressIndicator::NextScope() method (file - Message_ProgressIndicator.cxx) when calling BaseToLocal - LocalToBase.
Steps To ReproduceExecute the command "rewrite_stl C:/dev_cad_party/wright_whirlwind_radial_engine_occ.stl C:/dev_cad_party/NEW_wright_whirlwind_radial_engine_occ.stl" on wright_whirlwind_radial_engine_occ.stl

Bug: the progress indicator showed that it performed 3% (1000/36512) when writing, but in fact the model was completely recorded. We also see that 1000 triangles are loaded, although there should be 2000.

#include <Draw_ProgressIndicator.hxx>
#include <RWStl.hxx>

static Standard_Integer DRAW_ReWriteSTL(Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
{
  TCollection_AsciiString aFilePathToRead  = theArgv[1];
  TCollection_AsciiString aFilePathToWrite = theArgv[2];
  if ( aFilePathToRead.IsEmpty() || aFilePathToWrite.IsEmpty() )
    return 1;
  //
  // Read STL file to the triangulation.
  Handle(Poly_Triangulation) aTriangulation = RWStl::ReadFile (aFilePathToRead.ToCString(), NULL);
  //
  //
  // Indicator.
  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
  aProgress->SetTextMode(true);
  //
  // Write to STL.
  OSD_Path aPath (aFilePathToWrite.ToCString());
  if ( !RWStl::WriteAscii (aTriangulation, aPath, aProgress) )
    return 1; // Success
  //
  return 0;
}

theCommands.Add("rewrite_stl",
                "rewrite_stl filenameToRead filenameToWrite",
                __FILE__, DRAW_ReWriteSTL, grp);
TagsNo tags attached.
Test case numberde_mesh/shape_write_stl/B1

Attached Files

  • wright_whirlwind_radial_engine_occ.stl (9,931,282 bytes)
  • write.png (6,668 bytes)
  • read.png (22,857 bytes)

Relationships

related to 0025748 closedabv Foundation Classes - Parallel version of progress indicator 
parent of 0032243 closedbugmaster Tests - unexpected file artifact s.stl at the root of repository 

Activities

avn

2020-04-17 10:30

developer  

wright_whirlwind_radial_engine_occ.stl (9,931,282 bytes)

avn

2020-04-17 10:31

developer  

write.png (6,668 bytes)

avn

2020-04-17 10:31

developer  

read.png (22,857 bytes)

szy

2020-05-15 11:55

manager   ~0092136

start it, please.

git

2020-05-22 17:40

administrator   ~0092305

Branch CR31504 has been created by akaftasev.

SHA-1: 387fc74b4984bb4ac354260b286396b30cd4a51b


Detailed log of new commits:

Author: akaftasev
Date: Fri May 22 17:07:12 2020 +0300

    resolve problem with incomplete indicator output

Author: akaftasev
Date: Fri May 22 13:04:49 2020 +0300

    add commands rewrite

git

2020-05-26 14:28

administrator   ~0092345

Branch CR31504 has been updated by akaftasev.

SHA-1: 3584b5dd376f8bbaeb0f5b015b9bc7343ffaeef4


Detailed log of new commits:

Author: akaftasev
Date: Tue May 26 14:29:07 2020 +0300

    change condition

git

2020-05-26 14:31

administrator   ~0092346

Branch CR31504 has been updated forcibly by akaftasev.

SHA-1: fe11ecfb6513bc975ee3e9d23f31e6380a0b6fc2

git

2020-05-26 19:10

administrator   ~0092348

Branch CR31504 has been updated by akaftasev.

SHA-1: 87784d9612ed91d1bbbe52ea2bc5c531d285167f


Detailed log of new commits:

Author: akaftasev
Date: Tue May 26 19:11:12 2020 +0300

    change tests for new condition

git

2020-05-27 16:52

administrator   ~0092362

Branch CR31504 has been updated by akaftasev.

SHA-1: a7146a343cb3ed7699f966e869edb9c7b912e358


Detailed log of new commits:

Author: akaftasev
Date: Wed May 27 16:50:22 2020 +0300

    add test for this bug

git

2020-05-28 11:09

administrator   ~0092380

Branch CR31504 has been updated forcibly by akaftasev.

SHA-1: cd330b037e10b9d285cd0c6847a607a9e77bb595

gka

2020-06-02 12:20

developer   ~0092444

Branch CR31504 was reviewed

git

2020-06-03 17:47

administrator   ~0092465

Branch CR31504 has been updated by akaftasev.

SHA-1: 31a453f5067eacbbb6bd72cc8a3c3766d92db4d9


Detailed log of new commits:

Author: kgv
Date: Thu May 28 19:42:13 2020 +0300

    0031477: Visualization, TKOpenGl - fetch/wrap getBufferSubData() function from WebGL 2.0
    
    Added OpenGl_Context::GetBufferSubData() implementing getBufferSubData() based on capabilities of various APIs.
    Added OpenGl_VertexBuffer::GetSubData() similar to OpenGl_VertexBuffer::SubData().

Author: kgv
Date: Wed May 27 20:46:34 2020 +0300

    0031583: Visualization, OpenGl_Context - load OpenGL ES 3.0 functions
    
    OpenGl_Context now retrieves complete functions sets of OpenGL ES 3.0, 3.1 and 3.2.

Author: vsv
Date: Wed May 20 15:50:15 2020 +0300

    0031573: Visualization - Do not show seam edge for shading presentation with boundary edges in VTK

Author: kgv
Date: Wed May 27 13:36:17 2020 +0300

    0031580: Visualization, TKOpenGl - cubemap initialization error on OpenGL ES 2.0
    
    OpenGl_Texture::InitCubeMap() now avoids using sized internal format in case of GLES2.
    OpenGl_Sampler::applySamplerParams() now checks OpenGL version before setting GL_TEXTURE_WRAP_R.

Author: mkrylova
Date: Fri May 15 13:54:26 2020 +0300

    0029917: Foundation Classes - OSD_FileNode AccessMoment and CreationMoment return the same date on Windows
    
    fAccess in CreationMoment() function for Windows has been modified from TRUE to FALSE

kgv

2020-06-04 10:28

developer   ~0092471

Last edited: 2020-06-04 10:30

   theCommands.Add("OCC31294", "OCC31294", __FILE__, OCC31294, group);
+  theCommands.Add("rewrite_stl",

Commands within TKQADraw are expected to be bug-prefixed, not free-form.
Anyway, it doesn't look that this command belongs to TKQADraw at all.
Please move it to XSDRAWSTLVRML.cxx, rename to "writestl" with syntax "writestl shape file" and proper checks - see writegltf as example in the same file.
The command then should not include "aProgress->SetTclOutput(Standard_True);" - this should be enabled via another Draw Harness command in test script.

-    if ((aTriIter % IND_THRESHOLD) == 0)
+    if ((aTriIter % IND_THRESHOLD) == 0 && aPS.More())

The place for aPS.More() is incorrect - aPS.More() is expected to be used for aborting progress instead of preventing progress updates.
It could be put inside if((aTriIter % IND_THRESHOLD) == 0) condition and properly abort the loop.

-    // if scope has subscopes, print end of subscope as its current position
-    Standard_Real locPos = ( i >1 ? GetScope ( i-1 ).GetLast() : GetPosition() );
+    // if scope has subscopes, print end of subscope as it s current position
+    Standard_Real locPos = ( (i >1 && GetPosition()!=0) ? GetScope ( i-1 ).GetLast() : GetPosition() );
...
-  {Progress: 0% Outer: 1 / 3}
+  {Progress: 0% Outer: 0 / 3}

Please provide more detailed description in commit for this change, e.g. describe that indication has been changed to report 0 instead of 1 for first step. This change looks unrelated to this bug.

git

2020-06-04 13:33

administrator   ~0092481

Branch CR31504 has been updated by akaftasev.

SHA-1: ead524da13ff023ef792181391f43622be07d9d1


Detailed log of new commits:

Author: akaftasev
Date: Thu Jun 4 13:34:33 2020 +0300

    Merge branch 'CR31504' of ssh://dev.opencascade.org/occt into CR31504

Author: akaftasev
Date: Fri May 22 13:04:49 2020 +0300

    0031504: Data Exchange - Wrong output of progress indicator when writing to stl
    
    add new condition for first indicated element
    change usage of Next() to Next(step)
    add test

git

2020-06-04 13:34

administrator   ~0092482

Branch CR31504 has been updated forcibly by akaftasev.

SHA-1: cd330b037e10b9d285cd0c6847a607a9e77bb595

git

2020-06-04 13:36

administrator   ~0092483

Branch CR31504 has been updated forcibly by akaftasev.

SHA-1: 81f02382c995fa7d72db29b96936c0f88e556789

git

2020-06-05 14:28

administrator   ~0092488

Branch CR31504 has been updated forcibly by akaftasev.

SHA-1: 41dbc48947b818ac744a90eb7b7c0acb74fbb750

git

2020-06-05 15:59

administrator   ~0092490

Branch CR31504 has been updated forcibly by akaftasev.

SHA-1: b4c74d2a5a144b59267309d8ae6c4abd419668f5

git

2020-06-05 16:58

administrator   ~0092491

Branch CR31504 has been updated forcibly by akaftasev.

SHA-1: a5b70db256913fbd75307bbd12004ad90025aacd

git

2020-06-05 17:14

administrator   ~0092492

Branch CR31504 has been updated forcibly by akaftasev.

SHA-1: 9fb1fbca168e7a9272a4306032daa336aa0241cb

git

2020-06-20 13:42

administrator   ~0092612

Branch CR31504 has been deleted by inv.

SHA-1: 9fb1fbca168e7a9272a4306032daa336aa0241cb

Related Changesets

occt: master 1fc1a207

2020-05-22 10:04:49

akaftasev


Committer: bugmaster Details Diff
0031504: Data Exchange - Wrong output of progress indicator when writing to stl

Added new condition for first indicated element at Draw_ProgressIndicator::Show(),
because it’s more logical that at start progress starts at 0
Changed usage of Next() to Next(step) for increment progress to IND_THRESHOLD in RWStl::writeASCII() and RWStl::writeBinary()
Changed condition for continuation of writing and add interrupt to this function
Added possibility to use Progress indicator in writestl
Changed paremeter in constructor Message_ProgressSentry aPS() IND_THRESHOLD to 1
Changed test
Affected Issues
0031504
mod - src/Draw/Draw_ProgressIndicator.cxx Diff File
mod - src/RWStl/RWStl.cxx Diff File
mod - src/StlAPI/StlAPI_Writer.cxx Diff File
mod - src/StlAPI/StlAPI_Writer.hxx Diff File
mod - src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx Diff File
mod - tests/bugs/fclasses/bug28478 Diff File
mod - tests/bugs/fclasses/bug31092 Diff File
add - tests/de_mesh/shape_write_stl/B1 Diff File

Issue History

Date Modified Username Field Change
2020-04-17 10:30 avn New Issue
2020-04-17 10:30 avn Assigned To => gka
2020-04-17 10:30 avn File Added: wright_whirlwind_radial_engine_occ.stl
2020-04-17 10:31 avn File Added: write.png
2020-04-17 10:31 avn File Added: read.png
2020-04-17 10:37 avn Description Updated
2020-04-17 10:37 avn Steps to Reproduce Updated
2020-04-29 14:47 utverdov Assigned To gka => akaftasev
2020-05-08 00:11 kgv Summary Wrong output of progress indicator when writing to stl. => Data Exchange - Wrong output of progress indicator when writing to stl.
2020-05-08 00:11 kgv Description Updated
2020-05-08 00:11 kgv Steps to Reproduce Updated
2020-05-15 11:55 szy Note Added: 0092136
2020-05-15 11:55 szy Status new => assigned
2020-05-22 17:40 git Note Added: 0092305
2020-05-26 14:28 git Note Added: 0092345
2020-05-26 14:31 git Note Added: 0092346
2020-05-26 19:10 git Note Added: 0092348
2020-05-27 11:43 akaftasev Assigned To akaftasev => gka
2020-05-27 11:43 akaftasev Status assigned => resolved
2020-05-27 14:44 akaftasev Assigned To gka => akaftasev
2020-05-27 14:44 akaftasev Status resolved => assigned
2020-05-27 16:52 git Note Added: 0092362
2020-05-28 11:09 git Note Added: 0092380
2020-05-28 11:11 akaftasev Assigned To akaftasev => gka
2020-05-28 11:11 akaftasev Status assigned => resolved
2020-06-02 12:20 gka Note Added: 0092444
2020-06-02 12:20 gka Assigned To gka => bugmaster
2020-06-02 12:20 gka Status resolved => reviewed
2020-06-03 17:47 git Note Added: 0092465
2020-06-04 10:28 kgv Note Added: 0092471
2020-06-04 10:28 kgv Assigned To bugmaster => akaftasev
2020-06-04 10:28 kgv Status reviewed => assigned
2020-06-04 10:30 kgv Note Edited: 0092471
2020-06-04 13:33 git Note Added: 0092481
2020-06-04 13:34 git Note Added: 0092482
2020-06-04 13:36 git Note Added: 0092483
2020-06-05 14:28 git Note Added: 0092488
2020-06-05 15:59 git Note Added: 0092490
2020-06-05 16:58 git Note Added: 0092491
2020-06-05 17:14 git Note Added: 0092492
2020-06-05 17:21 akaftasev Assigned To akaftasev => kgv
2020-06-05 17:21 akaftasev Status assigned => resolved
2020-06-05 17:22 kgv Assigned To kgv => bugmaster
2020-06-05 17:22 kgv Status resolved => reviewed
2020-06-05 17:23 kgv Relationship added related to 0025748
2020-06-14 10:52 bugmaster Changeset attached => occt master 1fc1a207
2020-06-14 10:52 bugmaster Status reviewed => verified
2020-06-14 10:52 bugmaster Resolution open => fixed
2020-06-14 10:57 bugmaster Test case number => de_mesh/shape_write_stl/B1
2020-06-20 13:42 git Note Added: 0092612
2020-12-02 16:43 emo Fixed in Version => 7.5.0
2020-12-02 17:12 emo Status verified => closed
2021-03-24 10:57 kgv Relationship added parent of 0032243