mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
0031353: TDocStd_Application does not have api to set progress indicator
Add support of Message_ProgressIndicator in BinTools classes. Add support of Message_ProgressIndicator with possibility of user break in methods of opening and saving TDocStd_Application. Add tests of ProgressIndicator in TDocStd_Applacation.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <BinTools.hxx>
|
||||
#include <BinTools_ShapeSet.hxx>
|
||||
#include <FSD_FileHeader.hxx>
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
#include <OSD_OpenFile.hxx>
|
||||
#include <Storage_StreamTypeMismatchError.hxx>
|
||||
|
||||
@@ -174,12 +175,13 @@ Standard_IStream& BinTools::GetBool(Standard_IStream& IS, Standard_Boolean& aVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools::Write (const TopoDS_Shape& theShape, Standard_OStream& theStream)
|
||||
void BinTools::Write (const TopoDS_Shape& theShape, Standard_OStream& theStream,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
BinTools_ShapeSet aShapeSet(Standard_True);
|
||||
aShapeSet.SetFormatNb (3);
|
||||
aShapeSet.Add (theShape);
|
||||
aShapeSet.Write (theStream);
|
||||
aShapeSet.Write (theStream, theProgress);
|
||||
aShapeSet.Write (theShape, theStream);
|
||||
}
|
||||
|
||||
@@ -188,10 +190,11 @@ void BinTools::Write (const TopoDS_Shape& theShape, Standard_OStream& theStream)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools::Read (TopoDS_Shape& theShape, Standard_IStream& theStream)
|
||||
void BinTools::Read (TopoDS_Shape& theShape, Standard_IStream& theStream,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
BinTools_ShapeSet aShapeSet(Standard_True);
|
||||
aShapeSet.Read (theStream);
|
||||
aShapeSet.Read (theStream, theProgress);
|
||||
aShapeSet.Read (theShape, theStream, aShapeSet.NbShapes());
|
||||
}
|
||||
|
||||
@@ -200,7 +203,8 @@ void BinTools::Read (TopoDS_Shape& theShape, Standard_IStream& theStream)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BinTools::Write (const TopoDS_Shape& theShape, const Standard_CString theFile)
|
||||
Standard_Boolean BinTools::Write (const TopoDS_Shape& theShape, const Standard_CString theFile,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
std::ofstream aStream;
|
||||
aStream.precision (15);
|
||||
@@ -208,7 +212,7 @@ Standard_Boolean BinTools::Write (const TopoDS_Shape& theShape, const Standard_C
|
||||
if (!aStream.good())
|
||||
return Standard_False;
|
||||
|
||||
Write (theShape, aStream);
|
||||
Write (theShape, aStream, theProgress);
|
||||
aStream.close();
|
||||
return aStream.good();
|
||||
}
|
||||
@@ -218,7 +222,8 @@ Standard_Boolean BinTools::Write (const TopoDS_Shape& theShape, const Standard_C
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BinTools::Read (TopoDS_Shape& theShape, const Standard_CString theFile)
|
||||
Standard_Boolean BinTools::Read (TopoDS_Shape& theShape, const Standard_CString theFile,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
std::filebuf aBuf;
|
||||
OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary);
|
||||
@@ -226,6 +231,6 @@ Standard_Boolean BinTools::Read (TopoDS_Shape& theShape, const Standard_CString
|
||||
return Standard_False;
|
||||
|
||||
Standard_IStream aStream (&aBuf);
|
||||
Read (theShape, aStream);
|
||||
Read (theShape, aStream, theProgress);
|
||||
return aStream.good();
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <Standard_ExtCharacter.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class BinTools_ShapeSet;
|
||||
@@ -63,16 +64,22 @@ public:
|
||||
Standard_EXPORT static Standard_IStream& GetExtChar (Standard_IStream& IS, Standard_ExtCharacter& theValue);
|
||||
|
||||
//! Writes <theShape> on <theStream> in binary format.
|
||||
Standard_EXPORT static void Write (const TopoDS_Shape& theShape, Standard_OStream& theStream);
|
||||
Standard_EXPORT static void Write (const TopoDS_Shape& theShape, Standard_OStream& theStream,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Reads a shape from <theStream> and returns it in <theShape>.
|
||||
Standard_EXPORT static void Read (TopoDS_Shape& theShape, Standard_IStream& theStream);
|
||||
Standard_EXPORT static void Read (TopoDS_Shape& theShape, Standard_IStream& theStream,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Writes <theShape> in <theFile>.
|
||||
Standard_EXPORT static Standard_Boolean Write (const TopoDS_Shape& theShape, const Standard_CString theFile);
|
||||
Standard_EXPORT static Standard_Boolean Write
|
||||
(const TopoDS_Shape& theShape, const Standard_CString theFile,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Reads a shape from <theFile> and returns it in <theShape>.
|
||||
Standard_EXPORT static Standard_Boolean Read (TopoDS_Shape& theShape, const Standard_CString theFile);
|
||||
Standard_EXPORT static Standard_Boolean Read
|
||||
(TopoDS_Shape& theShape, const Standard_CString theFile,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
|
||||
#define LINE 1
|
||||
#define CIRCLE 2
|
||||
@@ -345,11 +346,13 @@ void BinTools_Curve2dSet::WriteCurve2d(const Handle(Geom2d_Curve)& C,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_Curve2dSet::Write(Standard_OStream& OS)const
|
||||
void BinTools_Curve2dSet::Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)const
|
||||
{
|
||||
Standard_Integer i, aNbCurves = myMap.Extent();
|
||||
Message_ProgressSentry aPS(theProgress, "Writing 2D curves", 0, aNbCurves, 1);
|
||||
OS << "Curve2ds "<< aNbCurves << "\n";
|
||||
for (i = 1; i <= aNbCurves; i++) {
|
||||
for (i = 1; i <= aNbCurves && aPS.More(); i++, aPS.Next()) {
|
||||
WriteCurve2d(Handle(Geom2d_Curve)::DownCast(myMap(i)),OS);
|
||||
}
|
||||
}
|
||||
@@ -692,7 +695,8 @@ Standard_IStream& BinTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_Curve2dSet::Read(Standard_IStream& IS)
|
||||
void BinTools_Curve2dSet::Read (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
char buffer[255];
|
||||
|
||||
@@ -710,12 +714,10 @@ void BinTools_Curve2dSet::Read(Standard_IStream& IS)
|
||||
Handle(Geom2d_Curve) C;
|
||||
Standard_Integer i, aNbCurves;
|
||||
IS >> aNbCurves;
|
||||
IS.get();//remove <lf>
|
||||
for (i = 1; i <= aNbCurves; i++) {
|
||||
Message_ProgressSentry aPS(theProgress, "Reading curves 2d", 0, aNbCurves, 1);
|
||||
IS.get();//remove <lf>
|
||||
for (i = 1; i <= aNbCurves && aPS.More(); i++, aPS.Next()) {
|
||||
BinTools_Curve2dSet::ReadCurve2d(IS,C);
|
||||
myMap.Add(C);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -24,6 +24,9 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
|
||||
class Standard_OutOfRange;
|
||||
class Geom2d_Curve;
|
||||
|
||||
@@ -57,42 +60,26 @@ public:
|
||||
|
||||
//! Writes the content of me on the stream <OS> in a
|
||||
//! format that can be read back by Read.
|
||||
Standard_EXPORT void Write (Standard_OStream& OS) const;
|
||||
Standard_EXPORT void Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
//! Reads the content of me from the stream <IS>. me
|
||||
//! is first cleared.
|
||||
Standard_EXPORT void Read (Standard_IStream& IS);
|
||||
Standard_EXPORT void Read (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Dumps the curve on the binary stream, that can be read back.
|
||||
Standard_EXPORT static void WriteCurve2d (const Handle(Geom2d_Curve)& C, Standard_OStream& OS);
|
||||
Standard_EXPORT static void WriteCurve2d(const Handle(Geom2d_Curve)& C, Standard_OStream& OS);
|
||||
|
||||
//! Reads the curve from the stream. The curve is
|
||||
//! assumed to have been written with the Write
|
||||
//! method.
|
||||
Standard_EXPORT static Standard_IStream& ReadCurve2d (Standard_IStream& IS, Handle(Geom2d_Curve)& C);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
TColStd_IndexedMapOfTransient myMap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _BinTools_Curve2dSet_HeaderFile
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
|
||||
#define LINE 1
|
||||
#define CIRCLE 2
|
||||
@@ -358,11 +359,13 @@ void BinTools_CurveSet::WriteCurve(const Handle(Geom_Curve)& C,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_CurveSet::Write(Standard_OStream& OS)const
|
||||
void BinTools_CurveSet::Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)const
|
||||
{
|
||||
Standard_Integer i, nbsurf = myMap.Extent();
|
||||
OS << "Curves "<< nbsurf << "\n";
|
||||
for (i = 1; i <= nbsurf; i++) {
|
||||
Standard_Integer i, nbcurv = myMap.Extent();
|
||||
Message_ProgressSentry aPS(theProgress, "Writing curves", 0, nbcurv, 1);
|
||||
OS << "Curves "<< nbcurv << "\n";
|
||||
for (i = 1; i <= nbcurv &&aPS.More(); i++, aPS.Next()) {
|
||||
WriteCurve(Handle(Geom_Curve)::DownCast(myMap(i)),OS);
|
||||
}
|
||||
}
|
||||
@@ -711,7 +714,8 @@ Standard_IStream& BinTools_CurveSet::ReadCurve(Standard_IStream& IS,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_CurveSet::Read(Standard_IStream& IS)
|
||||
void BinTools_CurveSet::Read (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
char buffer[255];
|
||||
IS >> buffer;
|
||||
@@ -729,11 +733,11 @@ void BinTools_CurveSet::Read(Standard_IStream& IS)
|
||||
Standard_Integer i, nbcurve;
|
||||
IS >> nbcurve;
|
||||
|
||||
Message_ProgressSentry aPS(theProgress, "Reading curves", 0, nbcurve, 1);
|
||||
|
||||
IS.get();//remove <lf>
|
||||
for (i = 1; i <= nbcurve; i++) {
|
||||
for (i = 1; i <= nbcurve && aPS.More(); i++, aPS.Next()) {
|
||||
BinTools_CurveSet::ReadCurve(IS,C);
|
||||
myMap.Add(C);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -24,6 +24,9 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
|
||||
class Standard_OutOfRange;
|
||||
class Geom_Curve;
|
||||
|
||||
@@ -54,11 +57,13 @@ public:
|
||||
|
||||
//! Writes the content of me on the stream <OS> in a
|
||||
//! format that can be read back by Read.
|
||||
Standard_EXPORT void Write (Standard_OStream& OS) const;
|
||||
Standard_EXPORT void Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
//! Reads the content of me from the stream <IS>. me
|
||||
//! is first cleared.
|
||||
Standard_EXPORT void Read (Standard_IStream& IS);
|
||||
Standard_EXPORT void Read (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator) &theProgress = NULL);
|
||||
|
||||
//! Dumps the curve on the stream in binary format
|
||||
//! that can be read back.
|
||||
@@ -69,28 +74,10 @@ public:
|
||||
//! method
|
||||
Standard_EXPORT static Standard_IStream& ReadCurve (Standard_IStream& IS, Handle(Geom_Curve)& C);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
TColStd_IndexedMapOfTransient myMap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _BinTools_CurveSet_HeaderFile
|
||||
|
@@ -51,6 +51,7 @@
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
|
||||
#include <string.h>
|
||||
//#define MDTV_DEB 1
|
||||
@@ -294,14 +295,34 @@ void BinTools_ShapeSet::AddGeometry(const TopoDS_Shape& S)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_ShapeSet::WriteGeometry(Standard_OStream& OS)const
|
||||
void BinTools_ShapeSet::WriteGeometry (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)const
|
||||
{
|
||||
myCurves2d.Write(OS);
|
||||
myCurves.Write(OS);
|
||||
WritePolygon3D(OS);
|
||||
WritePolygonOnTriangulation(OS);
|
||||
mySurfaces.Write(OS);
|
||||
WriteTriangulation(OS);
|
||||
Message_ProgressSentry aPS(theProgress, "Writing geometry", 0, 6, 1);
|
||||
myCurves2d.Write(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
myCurves.Write(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
WritePolygon3D(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
WritePolygonOnTriangulation(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
mySurfaces.Write(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
WriteTriangulation(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -309,7 +330,8 @@ void BinTools_ShapeSet::WriteGeometry(Standard_OStream& OS)const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_ShapeSet::Write(Standard_OStream& OS)const
|
||||
void BinTools_ShapeSet::Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)const
|
||||
{
|
||||
|
||||
// write the copyright
|
||||
@@ -330,18 +352,23 @@ void BinTools_ShapeSet::Write(Standard_OStream& OS)const
|
||||
// write the geometry
|
||||
//-----------------------------------------
|
||||
|
||||
WriteGeometry(OS);
|
||||
Message_ProgressSentry aPS(theProgress, "Writing geometry", 0, 2, 1);
|
||||
|
||||
WriteGeometry(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
|
||||
//-----------------------------------------
|
||||
// write the shapes
|
||||
//-----------------------------------------
|
||||
|
||||
Standard_Integer i, nbShapes = myShapes.Extent();
|
||||
|
||||
Message_ProgressSentry aPSinner(theProgress, "Writing shapes", 0, nbShapes, 1);
|
||||
OS << "\nTShapes " << nbShapes << "\n";
|
||||
|
||||
// subshapes are written first
|
||||
for (i = 1; i <= nbShapes; i++) {
|
||||
for (i = 1; i <= nbShapes && aPS.More(); i++, aPS.Next()) {
|
||||
|
||||
const TopoDS_Shape& S = myShapes(i);
|
||||
|
||||
@@ -369,7 +396,6 @@ void BinTools_ShapeSet::Write(Standard_OStream& OS)const
|
||||
}
|
||||
Write(TopoDS_Shape(),OS); // Null shape to end the list
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -377,7 +403,8 @@ void BinTools_ShapeSet::Write(Standard_OStream& OS)const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_ShapeSet::Read(Standard_IStream& IS)
|
||||
void BinTools_ShapeSet::Read (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
|
||||
Clear();
|
||||
@@ -413,9 +440,11 @@ void BinTools_ShapeSet::Read(Standard_IStream& IS)
|
||||
//-----------------------------------------
|
||||
// read the geometry
|
||||
//-----------------------------------------
|
||||
|
||||
ReadGeometry(IS);
|
||||
|
||||
Message_ProgressSentry aPSouter(theProgress, "Reading", 0, 2, 1);
|
||||
ReadGeometry(IS, theProgress);
|
||||
if (!aPSouter.More())
|
||||
return;
|
||||
aPSouter.Next();
|
||||
//-----------------------------------------
|
||||
// read the shapes
|
||||
//-----------------------------------------
|
||||
@@ -428,12 +457,11 @@ void BinTools_ShapeSet::Read(Standard_IStream& IS)
|
||||
throw Standard_Failure(aMsg.str().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer nbShapes = 0;
|
||||
IS >> nbShapes;
|
||||
IS.get();//remove lf
|
||||
|
||||
for (int i = 1; i <= nbShapes; i++) {
|
||||
Message_ProgressSentry aPSinner(theProgress, "Reading Shapes", 0, nbShapes, 1);
|
||||
for (int i = 1; i <= nbShapes && aPSinner.More(); i++, aPSinner.Next()) {
|
||||
|
||||
TopoDS_Shape S;
|
||||
|
||||
@@ -487,7 +515,8 @@ void BinTools_ShapeSet::Read(Standard_IStream& IS)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_ShapeSet::Write(const TopoDS_Shape& S, Standard_OStream& OS)const
|
||||
void BinTools_ShapeSet::Write (const TopoDS_Shape& S,
|
||||
Standard_OStream& OS)const
|
||||
{
|
||||
if (S.IsNull())
|
||||
|
||||
@@ -505,8 +534,8 @@ void BinTools_ShapeSet::Write(const TopoDS_Shape& S, Standard_OStream& OS)const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_ShapeSet::Read(TopoDS_Shape& S, Standard_IStream& IS,
|
||||
const Standard_Integer nbshapes)const
|
||||
void BinTools_ShapeSet::Read (TopoDS_Shape& S, Standard_IStream& IS,
|
||||
const Standard_Integer nbshapes)const
|
||||
{
|
||||
Standard_Character aChar = '\0';
|
||||
IS >> aChar;
|
||||
@@ -531,14 +560,34 @@ void BinTools_ShapeSet::Read(TopoDS_Shape& S, Standard_IStream& IS,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_ShapeSet::ReadGeometry(Standard_IStream& IS)
|
||||
void BinTools_ShapeSet::ReadGeometry (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
myCurves2d.Read(IS);
|
||||
myCurves.Read(IS);
|
||||
ReadPolygon3D(IS);
|
||||
ReadPolygonOnTriangulation(IS);
|
||||
mySurfaces.Read(IS);
|
||||
ReadTriangulation(IS);
|
||||
Message_ProgressSentry aPS(theProgress, "Reading geomentry", 0, 6, 1);
|
||||
myCurves2d.Read(IS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
myCurves.Read(IS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
ReadPolygon3D(IS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
ReadPolygonOnTriangulation(IS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
mySurfaces.Read(IS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
ReadTriangulation(IS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -546,7 +595,7 @@ void BinTools_ShapeSet::ReadGeometry(Standard_IStream& IS)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_ShapeSet::WriteGeometry(const TopoDS_Shape& S,
|
||||
void BinTools_ShapeSet::WriteGeometry (const TopoDS_Shape& S,
|
||||
Standard_OStream& OS)const
|
||||
{
|
||||
// Write the geometry
|
||||
@@ -1178,14 +1227,17 @@ void BinTools_ShapeSet::AddShapes(TopoDS_Shape& S1,
|
||||
//function : WritePolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinTools_ShapeSet::WritePolygonOnTriangulation(Standard_OStream& OS) const
|
||||
void BinTools_ShapeSet::WritePolygonOnTriangulation
|
||||
(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress) const
|
||||
{
|
||||
const Standard_Integer aNbPol = myNodes.Extent();
|
||||
OS << "PolygonOnTriangulations " << aNbPol << "\n";
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
for (Standard_Integer aPolIter = 1; aPolIter <= aNbPol; ++aPolIter)
|
||||
Message_ProgressSentry aPS(theProgress, "Writing polygons on triangulation", 0, aNbPol, 1);
|
||||
for (Standard_Integer aPolIter = 1; aPolIter <= aNbPol && aPS.More(); ++aPolIter, aPS.Next())
|
||||
{
|
||||
const Handle(Poly_PolygonOnTriangulation)& aPoly = myNodes.FindKey (aPolIter);
|
||||
const TColStd_Array1OfInteger& aNodes = aPoly->Nodes();
|
||||
@@ -1225,7 +1277,9 @@ void BinTools_ShapeSet::WritePolygonOnTriangulation(Standard_OStream& OS) const
|
||||
//function : ReadPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinTools_ShapeSet::ReadPolygonOnTriangulation(Standard_IStream& IS)
|
||||
void BinTools_ShapeSet::ReadPolygonOnTriangulation
|
||||
(Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
char aHeader[255];
|
||||
IS >> aHeader;
|
||||
@@ -1240,7 +1294,8 @@ void BinTools_ShapeSet::ReadPolygonOnTriangulation(Standard_IStream& IS)
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
for (Standard_Integer aPolIter = 1; aPolIter <= aNbPol; ++aPolIter)
|
||||
Message_ProgressSentry aPS(theProgress, "Reading Polygones on triangulation", 0, aNbPol, 1);
|
||||
for (Standard_Integer aPolIter = 1; aPolIter <= aNbPol && aPS.More(); ++aPolIter, aPS.Next())
|
||||
{
|
||||
Standard_Integer aNbNodes = 0;
|
||||
BinTools::GetInteger(IS, aNbNodes);
|
||||
@@ -1281,14 +1336,16 @@ void BinTools_ShapeSet::ReadPolygonOnTriangulation(Standard_IStream& IS)
|
||||
//function : WritePolygon3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinTools_ShapeSet::WritePolygon3D(Standard_OStream& OS)const
|
||||
void BinTools_ShapeSet::WritePolygon3D(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)const
|
||||
{
|
||||
const Standard_Integer aNbPol = myPolygons3D.Extent();
|
||||
OS << "Polygon3D " << aNbPol << "\n";
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
for (Standard_Integer aPolIter = 1; aPolIter <= aNbPol; ++aPolIter)
|
||||
Message_ProgressSentry aPS(theProgress, "Writing polygons 3D", 0, aNbPol, 1);
|
||||
for (Standard_Integer aPolIter = 1; aPolIter <= aNbPol && aPS.More(); ++aPolIter, aPS.Next())
|
||||
{
|
||||
const Handle(Poly_Polygon3D)& aPoly = myPolygons3D.FindKey (aPolIter);
|
||||
BinTools::PutInteger(OS, aPoly->NbNodes());
|
||||
@@ -1328,7 +1385,8 @@ void BinTools_ShapeSet::WritePolygon3D(Standard_OStream& OS)const
|
||||
//function : ReadPolygon3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinTools_ShapeSet::ReadPolygon3D(Standard_IStream& IS)
|
||||
void BinTools_ShapeSet::ReadPolygon3D (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
char aHeader[255];
|
||||
IS >> aHeader;
|
||||
@@ -1347,7 +1405,8 @@ void BinTools_ShapeSet::ReadPolygon3D(Standard_IStream& IS)
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
for (Standard_Integer aPolIter = 1; aPolIter <= aNbPol; ++aPolIter)
|
||||
Message_ProgressSentry aPS(theProgress, "Reading polygones 3D", 0, aNbPol, 1);
|
||||
for (Standard_Integer aPolIter = 1; aPolIter <= aNbPol && aPS.More(); ++aPolIter, aPS.Next())
|
||||
{
|
||||
Standard_Integer aNbNodes = 0;
|
||||
Standard_Boolean hasParameters = Standard_False;
|
||||
@@ -1392,7 +1451,8 @@ void BinTools_ShapeSet::ReadPolygon3D(Standard_IStream& IS)
|
||||
//function : WriteTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinTools_ShapeSet::WriteTriangulation(Standard_OStream& OS) const
|
||||
void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress) const
|
||||
{
|
||||
const Standard_Integer aNbTriangulations = myTriangulations.Extent();
|
||||
OS << "Triangulations " << aNbTriangulations << "\n";
|
||||
@@ -1400,7 +1460,8 @@ void BinTools_ShapeSet::WriteTriangulation(Standard_OStream& OS) const
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
for (Standard_Integer aTriangulationIter = 1; aTriangulationIter <= aNbTriangulations; ++aTriangulationIter)
|
||||
Message_ProgressSentry aPS(theProgress, "Writing triangulation", 0, aNbTriangulations, 1);
|
||||
for (Standard_Integer aTriangulationIter = 1; aTriangulationIter <= aNbTriangulations && aPS.More(); ++aTriangulationIter, aPS.Next())
|
||||
{
|
||||
const Handle(Poly_Triangulation)& aTriangulation = myTriangulations.FindKey (aTriangulationIter);
|
||||
const Standard_Integer aNbNodes = aTriangulation->NbNodes();
|
||||
@@ -1453,7 +1514,8 @@ void BinTools_ShapeSet::WriteTriangulation(Standard_OStream& OS) const
|
||||
//function : ReadTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinTools_ShapeSet::ReadTriangulation (Standard_IStream& IS)
|
||||
void BinTools_ShapeSet::ReadTriangulation (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
char aHeader[255];
|
||||
IS >> aHeader;
|
||||
@@ -1469,7 +1531,8 @@ void BinTools_ShapeSet::ReadTriangulation (Standard_IStream& IS)
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
for (Standard_Integer aTriangulationIter = 1; aTriangulationIter <= aNbTriangulations; ++aTriangulationIter)
|
||||
Message_ProgressSentry aPS(theProgress, "Reading triangulation", 0, aNbTriangulations, 1);
|
||||
for (Standard_Integer aTriangulationIter = 1; aTriangulationIter <= aNbTriangulations && aPS.More(); ++aTriangulationIter, aPS.Next())
|
||||
{
|
||||
Standard_Integer aNbNodes = 0, aNbTriangles = 0;
|
||||
Standard_Boolean hasUV = Standard_False;
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class BinTools_LocationSet;
|
||||
|
||||
@@ -98,7 +99,9 @@ public:
|
||||
//! Write the type.
|
||||
//! calls WriteGeometry(S).
|
||||
//! Write the flags, the subshapes.
|
||||
Standard_EXPORT virtual void Write (Standard_OStream& OS) const;
|
||||
Standard_EXPORT virtual void Write
|
||||
(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
//! Reads the content of me from the binary stream <IS>. me
|
||||
//! is first cleared.
|
||||
@@ -112,7 +115,9 @@ public:
|
||||
//! Reads the type.
|
||||
//! calls ReadGeometry(T,S).
|
||||
//! Reads the flag, the subshapes.
|
||||
Standard_EXPORT virtual void Read (Standard_IStream& IS);
|
||||
Standard_EXPORT virtual void Read
|
||||
(Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Writes on <OS> the shape <S>. Writes the
|
||||
//! orientation, the index of the TShape and the index
|
||||
@@ -121,14 +126,20 @@ public:
|
||||
|
||||
//! Writes the geometry of me on the stream <OS> in a
|
||||
//! binary format that can be read back by Read.
|
||||
Standard_EXPORT virtual void WriteGeometry (Standard_OStream& OS) const;
|
||||
Standard_EXPORT virtual void WriteGeometry
|
||||
(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
//! Reads the geometry of me from the stream <IS>.
|
||||
Standard_EXPORT virtual void ReadGeometry (Standard_IStream& IS);
|
||||
Standard_EXPORT virtual void ReadGeometry
|
||||
(Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Reads from <IS> a shape and returns it in S.
|
||||
//! <NbShapes> is the number of tshapes in the set.
|
||||
Standard_EXPORT virtual void Read (TopoDS_Shape& S, Standard_IStream& IS, const Standard_Integer NbShapes) const;
|
||||
Standard_EXPORT virtual void Read
|
||||
(TopoDS_Shape& S,
|
||||
Standard_IStream& IS, const Standard_Integer NbShapes) const;
|
||||
|
||||
//! Writes the geometry of <S> on the stream <OS> in a
|
||||
//! binary format that can be read back by Read.
|
||||
@@ -146,30 +157,42 @@ public:
|
||||
|
||||
//! Reads the 3d polygons of me
|
||||
//! from the stream <IS>.
|
||||
Standard_EXPORT void ReadPolygon3D (Standard_IStream& IS);
|
||||
Standard_EXPORT void ReadPolygon3D
|
||||
(Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Writes the 3d polygons
|
||||
//! on the stream <OS> in a format that can
|
||||
//! be read back by Read.
|
||||
Standard_EXPORT void WritePolygon3D (Standard_OStream& OS) const;
|
||||
Standard_EXPORT void WritePolygon3D
|
||||
(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
//! Reads the triangulation of me
|
||||
//! from the stream <IS>.
|
||||
Standard_EXPORT void ReadTriangulation (Standard_IStream& IS);
|
||||
Standard_EXPORT void ReadTriangulation
|
||||
(Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Writes the triangulation
|
||||
//! on the stream <OS> in a format that can
|
||||
//! be read back by Read.
|
||||
Standard_EXPORT void WriteTriangulation (Standard_OStream& OS) const;
|
||||
Standard_EXPORT void WriteTriangulation
|
||||
(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
//! Reads the polygons on triangulation of me
|
||||
//! from the stream <IS>.
|
||||
Standard_EXPORT void ReadPolygonOnTriangulation (Standard_IStream& IS);
|
||||
Standard_EXPORT void ReadPolygonOnTriangulation
|
||||
(Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
//! Writes the polygons on triangulation
|
||||
//! on the stream <OS> in a format that can
|
||||
//! be read back by Read.
|
||||
Standard_EXPORT void WritePolygonOnTriangulation (Standard_OStream& OS) const;
|
||||
Standard_EXPORT void WritePolygonOnTriangulation
|
||||
(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
|
||||
#define PLANE 1
|
||||
#define CYLINDER 2
|
||||
@@ -436,12 +437,14 @@ void BinTools_SurfaceSet::WriteSurface(const Handle(Geom_Surface)& S,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_SurfaceSet::Write(Standard_OStream& OS)const
|
||||
void BinTools_SurfaceSet::Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)const
|
||||
{
|
||||
|
||||
Standard_Integer i, nbsurf = myMap.Extent();
|
||||
Message_ProgressSentry aPS(theProgress, "Writing surfases", 0, nbsurf, 1);
|
||||
OS << "Surfaces "<< nbsurf << "\n";
|
||||
for (i = 1; i <= nbsurf; i++) {
|
||||
for (i = 1; i <= nbsurf && aPS.More(); i++, aPS.Next()) {
|
||||
WriteSurface(Handle(Geom_Surface)::DownCast(myMap(i)),OS);
|
||||
}
|
||||
|
||||
@@ -873,7 +876,8 @@ Standard_IStream& BinTools_SurfaceSet::ReadSurface(Standard_IStream& IS,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools_SurfaceSet::Read(Standard_IStream& IS)
|
||||
void BinTools_SurfaceSet::Read (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
char buffer[255];
|
||||
IS >> buffer;
|
||||
@@ -890,10 +894,10 @@ void BinTools_SurfaceSet::Read(Standard_IStream& IS)
|
||||
Handle(Geom_Surface) S;
|
||||
Standard_Integer i, nbsurf;
|
||||
IS >> nbsurf;
|
||||
Message_ProgressSentry aPS(theProgress, "Reading surfaces", 0, nbsurf, 1);
|
||||
IS.get ();//remove <lf>
|
||||
for (i = 1; i <= nbsurf; i++) {
|
||||
for (i = 1; i <= nbsurf && aPS.More(); i++, aPS.Next()) {
|
||||
BinTools_SurfaceSet::ReadSurface(IS,S);
|
||||
myMap.Add(S);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,9 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
|
||||
class Standard_OutOfRange;
|
||||
class Geom_Surface;
|
||||
|
||||
@@ -54,11 +57,13 @@ public:
|
||||
|
||||
//! Writes the content of me on the stream <OS> in
|
||||
//! binary format that can be read back by Read.
|
||||
Standard_EXPORT void Write (Standard_OStream& OS) const;
|
||||
Standard_EXPORT void Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
//! Reads the content of me from the stream <IS>. me
|
||||
//! is first cleared.
|
||||
Standard_EXPORT void Read (Standard_IStream& IS);
|
||||
Standard_EXPORT void Read (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator) &theProgress = NULL);
|
||||
|
||||
//! Dumps the surface on the stream in binary
|
||||
//! format that can be read back.
|
||||
@@ -69,28 +74,10 @@ public:
|
||||
//! method.
|
||||
Standard_EXPORT static Standard_IStream& ReadSurface (Standard_IStream& IS, Handle(Geom_Surface)& S);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
TColStd_IndexedMapOfTransient myMap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _BinTools_SurfaceSet_HeaderFile
|
||||
|
Reference in New Issue
Block a user