MantisBT - Open CASCADE
View Issue Details
0031504Open CASCADE[OCCT] OCCT:Data Exchangepublic2020-04-17 10:302020-05-22 17:40
avn 
akaftasev 
normalminor 
assignedopen 
WindowsVC++ 201364 bit
[OCCT] 7.4.0 
[OCCT] 7.5.0* 
0031504: Data Exchange - Wrong output of progress indicator when writing to stl.
The 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.
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

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);
No tags attached.
? wright_whirlwind_radial_engine_occ.stl (9,931,282) 2020-04-17 10:30
https://tracker.dev.opencascade.org/
png write.png (6,668) 2020-04-17 10:31
https://tracker.dev.opencascade.org/
png read.png (22,857) 2020-04-17 10:31
https://tracker.dev.opencascade.org/
Issue History
2020-04-17 10:30avnNew Issue
2020-04-17 10:30avnAssigned To => gka
2020-04-17 10:30avnFile Added: wright_whirlwind_radial_engine_occ.stl
2020-04-17 10:31avnFile Added: write.png
2020-04-17 10:31avnFile Added: read.png
2020-04-17 10:37avnDescription Updatedbug_revision_view_page.php?rev_id=22815#r22815
2020-04-17 10:37avnSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=22817#r22817
2020-04-29 14:47utverdovAssigned Togka => akaftasev
2020-05-08 00:11kgvSummaryWrong output of progress indicator when writing to stl. => Data Exchange - Wrong output of progress indicator when writing to stl.
2020-05-08 00:11kgvDescription Updatedbug_revision_view_page.php?rev_id=22906#r22906
2020-05-08 00:11kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=22907#r22907
2020-05-15 11:55szyNote Added: 0092136
2020-05-15 11:55szyStatusnew => assigned
2020-05-22 17:40gitNote Added: 0092305

Notes
(0092136)
szy   
2020-05-15 11:55   
start it, please.
(0092305)
git   
2020-05-22 17:40   
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