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
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() )
{
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)
{
// update progress only per 1k triangles
if ((aTriIter % IND_THRESHOLD) == 0)
{
- aPS.Next();
+ if (!aPS.More())
+ return Standard_False;
+ aPS.Next(IND_THRESHOLD);
}
}
{
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;
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);
// update progress only per 1k triangles
if ((aTriIter % IND_THRESHOLD) == 0)
{
- aPS.Next();
+ if (!aPS.More())
+ return Standard_False;
+ aPS.Next(IND_THRESHOLD);
}
}
//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;
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))
{
#include <Standard_Handle.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
+#include <Message_ProgressIndicator.hxx>
class TopoDS_Shape;
//! 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;
}
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";
}
set out [OCC28478 3 2]
set expected {
- {Progress: 0% Outer: 1 / 3}
+ {Progress: 0% Outer: 0 / 3}
{Progress: 17% Outer: 1 / 3 Inner: 1 / 2}
{Progress: 33% Outer: 1 / 3 Inner: 2 / 2}
{Progress: 50% Outer: 2 / 3 Inner: 1 / 2}
set out [OCC28478 3 2 -inf]
set expected {
- {Progress: 0% Outer: 1 / 3}
+ {Progress: 0% Outer: 0 / 3}
{Progress: 11% Outer: 1 / 3 Inner: 1}
{Progress: 17% Outer: 1 / 3 Inner: 2}
{Progress: 20% Outer: 1 / 3 Inner: 3}
--- /dev/null
+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 ""
+}