mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
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
This commit is contained in:
parent
59ec2ccec9
commit
1fc1a207b0
@ -102,8 +102,8 @@ Standard_Boolean Draw_ProgressIndicator::Show(const Standard_Boolean force)
|
|||||||
if ( scale.GetName().IsNull() ) continue; // skip unnamed scopes
|
if ( scale.GetName().IsNull() ) continue; // skip unnamed scopes
|
||||||
aText << " " << scale.GetName()->ToCString() << ": ";
|
aText << " " << scale.GetName()->ToCString() << ": ";
|
||||||
|
|
||||||
// if scope has subscopes, print end of subscope as its current position
|
// if scope has subscopes, print end of subscope as it s current position
|
||||||
Standard_Real locPos = ( i >1 ? GetScope ( i-1 ).GetLast() : GetPosition() );
|
Standard_Real locPos = ( (i >1 && GetPosition()!=0) ? GetScope ( i-1 ).GetLast() : GetPosition() );
|
||||||
// print progress info differently for finite and infinite scopes
|
// print progress info differently for finite and infinite scopes
|
||||||
if ( scale.GetInfinite() )
|
if ( scale.GetInfinite() )
|
||||||
{
|
{
|
||||||
|
@ -281,12 +281,12 @@ Standard_Boolean RWStl::writeASCII (const Handle(Poly_Triangulation)& theMesh,
|
|||||||
char aBuffer[512];
|
char aBuffer[512];
|
||||||
memset (aBuffer, 0, sizeof(aBuffer));
|
memset (aBuffer, 0, sizeof(aBuffer));
|
||||||
|
|
||||||
|
const Standard_Integer NBTriangles = theMesh->NbTriangles();
|
||||||
Message_ProgressSentry aPS (theProgInd, "Triangles", 0,
|
Message_ProgressSentry aPS (theProgInd, "Triangles", 0,
|
||||||
theMesh->NbTriangles(), IND_THRESHOLD);
|
NBTriangles, 1);
|
||||||
|
|
||||||
const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
|
const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
|
||||||
const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
|
const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
|
||||||
const Standard_Integer NBTriangles = theMesh->NbTriangles();
|
|
||||||
Standard_Integer anElem[3] = {0, 0, 0};
|
Standard_Integer anElem[3] = {0, 0, 0};
|
||||||
for (Standard_Integer aTriIter = 1; aTriIter <= NBTriangles; ++aTriIter)
|
for (Standard_Integer aTriIter = 1; aTriIter <= NBTriangles; ++aTriIter)
|
||||||
{
|
{
|
||||||
@ -330,7 +330,9 @@ Standard_Boolean RWStl::writeASCII (const Handle(Poly_Triangulation)& theMesh,
|
|||||||
// update progress only per 1k triangles
|
// update progress only per 1k triangles
|
||||||
if ((aTriIter % IND_THRESHOLD) == 0)
|
if ((aTriIter % IND_THRESHOLD) == 0)
|
||||||
{
|
{
|
||||||
aPS.Next();
|
if (!aPS.More())
|
||||||
|
return Standard_False;
|
||||||
|
aPS.Next(IND_THRESHOLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,9 +357,10 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
|
|||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Standard_Integer aNBTriangles = theMesh->NbTriangles();
|
||||||
Message_ProgressSentry aPS (theProgInd, "Triangles", 0,
|
Message_ProgressSentry aPS (theProgInd, "Triangles", 0,
|
||||||
theMesh->NbTriangles(), IND_THRESHOLD);
|
aNBTriangles, 1);
|
||||||
|
|
||||||
const Standard_Size aNbChunkTriangles = 4096;
|
const Standard_Size aNbChunkTriangles = 4096;
|
||||||
const Standard_Size aChunkSize = aNbChunkTriangles * THE_STL_SIZEOF_FACET;
|
const Standard_Size aChunkSize = aNbChunkTriangles * THE_STL_SIZEOF_FACET;
|
||||||
@ -366,7 +369,6 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
|
|||||||
|
|
||||||
const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
|
const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
|
||||||
const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
|
const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
|
||||||
const Standard_Integer aNBTriangles = theMesh->NbTriangles();
|
|
||||||
|
|
||||||
Standard_Character aConv[4];
|
Standard_Character aConv[4];
|
||||||
convertInteger (aNBTriangles, aConv);
|
convertInteger (aNBTriangles, aConv);
|
||||||
@ -431,7 +433,9 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
|
|||||||
// update progress only per 1k triangles
|
// update progress only per 1k triangles
|
||||||
if ((aTriIter % IND_THRESHOLD) == 0)
|
if ((aTriIter % IND_THRESHOLD) == 0)
|
||||||
{
|
{
|
||||||
aPS.Next();
|
if (!aPS.More())
|
||||||
|
return Standard_False;
|
||||||
|
aPS.Next(IND_THRESHOLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,8 @@ StlAPI_Writer::StlAPI_Writer()
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
Standard_Boolean StlAPI_Writer::Write (const TopoDS_Shape& theShape,
|
Standard_Boolean StlAPI_Writer::Write (const TopoDS_Shape& theShape,
|
||||||
const Standard_CString theFileName)
|
const Standard_CString theFileName,
|
||||||
|
const Handle(Message_ProgressIndicator)& theProgress)
|
||||||
{
|
{
|
||||||
Standard_Integer aNbNodes = 0;
|
Standard_Integer aNbNodes = 0;
|
||||||
Standard_Integer aNbTriangles = 0;
|
Standard_Integer aNbTriangles = 0;
|
||||||
@ -125,8 +126,8 @@ Standard_Boolean StlAPI_Writer::Write (const TopoDS_Shape& theShape,
|
|||||||
|
|
||||||
OSD_Path aPath (theFileName);
|
OSD_Path aPath (theFileName);
|
||||||
Standard_Boolean isDone = (myASCIIMode
|
Standard_Boolean isDone = (myASCIIMode
|
||||||
? RWStl::WriteAscii (aMesh, aPath)
|
? RWStl::WriteAscii(aMesh, aPath, theProgress)
|
||||||
: RWStl::WriteBinary (aMesh, aPath));
|
: RWStl::WriteBinary(aMesh, aPath, theProgress));
|
||||||
|
|
||||||
if (isDone && (aNbFacesNoTri > 0))
|
if (isDone && (aNbFacesNoTri > 0))
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <Standard_Handle.hxx>
|
#include <Standard_Handle.hxx>
|
||||||
#include <Standard_Boolean.hxx>
|
#include <Standard_Boolean.hxx>
|
||||||
#include <Standard_CString.hxx>
|
#include <Standard_CString.hxx>
|
||||||
|
#include <Message_ProgressIndicator.hxx>
|
||||||
|
|
||||||
class TopoDS_Shape;
|
class TopoDS_Shape;
|
||||||
|
|
||||||
@ -45,7 +46,8 @@ public:
|
|||||||
//! Converts a given shape to STL format and writes it to file with a given filename.
|
//! Converts a given shape to STL format and writes it to file with a given filename.
|
||||||
//! \return the error state.
|
//! \return the error state.
|
||||||
Standard_EXPORT Standard_Boolean Write (const TopoDS_Shape& theShape,
|
Standard_EXPORT Standard_Boolean Write (const TopoDS_Shape& theShape,
|
||||||
const Standard_CString theFileName);
|
const Standard_CString theFileName,
|
||||||
|
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Standard_Boolean myASCIIMode;
|
Standard_Boolean myASCIIMode;
|
||||||
|
@ -333,7 +333,8 @@ static Standard_Integer writestl
|
|||||||
}
|
}
|
||||||
StlAPI_Writer aWriter;
|
StlAPI_Writer aWriter;
|
||||||
aWriter.ASCIIMode() = isASCIIMode;
|
aWriter.ASCIIMode() = isASCIIMode;
|
||||||
Standard_Boolean isOK = aWriter.Write (aShape, argv[2]);
|
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
|
||||||
|
Standard_Boolean isOK = aWriter.Write (aShape, argv[2], aProgress);
|
||||||
if (!isOK)
|
if (!isOK)
|
||||||
di << "** Error **: Mesh writing has been failed.\n";
|
di << "** Error **: Mesh writing has been failed.\n";
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ pload QAcommands
|
|||||||
set out [OCC28478 3 2]
|
set out [OCC28478 3 2]
|
||||||
|
|
||||||
set expected {
|
set expected {
|
||||||
{Progress: 0% Outer: 1 / 3}
|
{Progress: 0% Outer: 0 / 3}
|
||||||
{Progress: 17% Outer: 1 / 3 Inner: 1 / 2}
|
{Progress: 17% Outer: 1 / 3 Inner: 1 / 2}
|
||||||
{Progress: 33% Outer: 1 / 3 Inner: 2 / 2}
|
{Progress: 33% Outer: 1 / 3 Inner: 2 / 2}
|
||||||
{Progress: 50% Outer: 2 / 3 Inner: 1 / 2}
|
{Progress: 50% Outer: 2 / 3 Inner: 1 / 2}
|
||||||
|
@ -8,7 +8,7 @@ pload QAcommands
|
|||||||
set out [OCC28478 3 2 -inf]
|
set out [OCC28478 3 2 -inf]
|
||||||
|
|
||||||
set expected {
|
set expected {
|
||||||
{Progress: 0% Outer: 1 / 3}
|
{Progress: 0% Outer: 0 / 3}
|
||||||
{Progress: 11% Outer: 1 / 3 Inner: 1}
|
{Progress: 11% Outer: 1 / 3 Inner: 1}
|
||||||
{Progress: 17% Outer: 1 / 3 Inner: 2}
|
{Progress: 17% Outer: 1 / 3 Inner: 2}
|
||||||
{Progress: 20% Outer: 1 / 3 Inner: 3}
|
{Progress: 20% Outer: 1 / 3 Inner: 3}
|
||||||
|
35
tests/de_mesh/shape_write_stl/B1
Normal file
35
tests/de_mesh/shape_write_stl/B1
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
sphere s 10
|
||||||
|
tessellate result s 100 100
|
||||||
|
XProgress -tclOutput
|
||||||
|
XProgress +t
|
||||||
|
set out [writestl result s.stl]
|
||||||
|
|
||||||
|
set expected {
|
||||||
|
{Progress: 0% Triangles: 0 / 20000}
|
||||||
|
{Progress: 5% Triangles: 1001 / 20000}
|
||||||
|
{Progress: 10% Triangles: 2001 / 20000}
|
||||||
|
{Progress: 15% Triangles: 3001 / 20000}
|
||||||
|
{Progress: 20% Triangles: 4001 / 20000}
|
||||||
|
{Progress: 25% Triangles: 5001 / 20000}
|
||||||
|
{Progress: 30% Triangles: 6001 / 20000}
|
||||||
|
{Progress: 35% Triangles: 7001 / 20000}
|
||||||
|
{Progress: 40% Triangles: 8001 / 20000}
|
||||||
|
{Progress: 45% Triangles: 9001 / 20000}
|
||||||
|
{Progress: 50% Triangles: 10001 / 20000}
|
||||||
|
{Progress: 55% Triangles: 11001 / 20000}
|
||||||
|
{Progress: 60% Triangles: 12001 / 20000}
|
||||||
|
{Progress: 65% Triangles: 13001 / 20000}
|
||||||
|
{Progress: 70% Triangles: 14001 / 20000}
|
||||||
|
{Progress: 75% Triangles: 15001 / 20000}
|
||||||
|
{Progress: 80% Triangles: 16001 / 20000}
|
||||||
|
{Progress: 85% Triangles: 17001 / 20000}
|
||||||
|
{Progress: 90% Triangles: 18001 / 20000}
|
||||||
|
{Progress: 95% Triangles: 19001 / 20000}
|
||||||
|
{Progress: 100% Triangles: 20000 / 20000}
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [string compare [string trim $out] [join $expected "\n"]] } {
|
||||||
|
puts "Error: output (see above) does not match expected one:"
|
||||||
|
puts "[join $expected "\n"]"
|
||||||
|
puts ""
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user