mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +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:
@@ -102,8 +102,8 @@ Standard_Boolean Draw_ProgressIndicator::Show(const Standard_Boolean force)
|
||||
if ( scale.GetName().IsNull() ) continue; // skip unnamed scopes
|
||||
aText << " " << scale.GetName()->ToCString() << ": ";
|
||||
|
||||
// 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() );
|
||||
// print progress info differently for finite and infinite scopes
|
||||
if ( scale.GetInfinite() )
|
||||
{
|
||||
|
@@ -281,12 +281,12 @@ Standard_Boolean RWStl::writeASCII (const Handle(Poly_Triangulation)& theMesh,
|
||||
char aBuffer[512];
|
||||
memset (aBuffer, 0, sizeof(aBuffer));
|
||||
|
||||
const Standard_Integer NBTriangles = theMesh->NbTriangles();
|
||||
Message_ProgressSentry aPS (theProgInd, "Triangles", 0,
|
||||
theMesh->NbTriangles(), IND_THRESHOLD);
|
||||
NBTriangles, 1);
|
||||
|
||||
const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
|
||||
const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
|
||||
const Standard_Integer NBTriangles = theMesh->NbTriangles();
|
||||
Standard_Integer anElem[3] = {0, 0, 0};
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
const Standard_Integer aNBTriangles = theMesh->NbTriangles();
|
||||
Message_ProgressSentry aPS (theProgInd, "Triangles", 0,
|
||||
theMesh->NbTriangles(), IND_THRESHOLD);
|
||||
aNBTriangles, 1);
|
||||
|
||||
const Standard_Size aNbChunkTriangles = 4096;
|
||||
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 Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
|
||||
const Standard_Integer aNBTriangles = theMesh->NbTriangles();
|
||||
|
||||
Standard_Character aConv[4];
|
||||
convertInteger (aNBTriangles, aConv);
|
||||
@@ -431,7 +433,9 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
|
||||
// update progress only per 1k triangles
|
||||
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 :
|
||||
//=============================================================================
|
||||
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 aNbTriangles = 0;
|
||||
@@ -125,8 +126,8 @@ Standard_Boolean StlAPI_Writer::Write (const TopoDS_Shape& theShape,
|
||||
|
||||
OSD_Path aPath (theFileName);
|
||||
Standard_Boolean isDone = (myASCIIMode
|
||||
? RWStl::WriteAscii (aMesh, aPath)
|
||||
: RWStl::WriteBinary (aMesh, aPath));
|
||||
? RWStl::WriteAscii(aMesh, aPath, theProgress)
|
||||
: RWStl::WriteBinary(aMesh, aPath, theProgress));
|
||||
|
||||
if (isDone && (aNbFacesNoTri > 0))
|
||||
{
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
|
||||
@@ -45,7 +46,8 @@ public:
|
||||
//! Converts a given shape to STL format and writes it to file with a given filename.
|
||||
//! \return the error state.
|
||||
Standard_EXPORT Standard_Boolean Write (const TopoDS_Shape& theShape,
|
||||
const Standard_CString theFileName);
|
||||
const Standard_CString theFileName,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
private:
|
||||
Standard_Boolean myASCIIMode;
|
||||
|
@@ -333,7 +333,8 @@ static Standard_Integer writestl
|
||||
}
|
||||
StlAPI_Writer aWriter;
|
||||
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)
|
||||
di << "** Error **: Mesh writing has been failed.\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user