Added enumerations BinTools_FormatVersion & TopTools_FormatVersion for more clear version tracking in the code.
Added new BinTools::Write() & BRepTools::Write() overloaded functions with version & isWithTriangles parameters.
Added new "readbrep"/"writebrep" DRAW commands handling reading and writing of both Binary and ASCII .brep formats
and providing arguments to setup writing of triangulation data and of format version.
"binrestore" is made an alias to new command "readbrep".
"binsave" now is an alias to new "writebrep" saving into binary format by default ("writebrep" writes into ASCII format by default).
//=======================================================================
//function : Write
-//purpose :
+//purpose :
//=======================================================================
-
-void BRepTools::Write(const TopoDS_Shape& Sh, Standard_OStream& S,
+void BRepTools::Write (const TopoDS_Shape& theShape,
+ Standard_OStream& theStream,
+ const Standard_Boolean theWithTriangles,
+ const TopTools_FormatVersion theVersion,
const Message_ProgressRange& theProgress)
{
- BRepTools_ShapeSet SS;
- SS.Add(Sh);
- SS.Write(S, theProgress);
- SS.Write(Sh,S);
+ BRepTools_ShapeSet aShapeSet (theWithTriangles);
+ aShapeSet.SetFormatNb (theVersion);
+ aShapeSet.Add (theShape);
+ aShapeSet.Write (theStream, theProgress);
+ aShapeSet.Write (theShape, theStream);
}
-
//=======================================================================
//function : Read
//purpose :
//=======================================================================
//function : Write
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Boolean BRepTools::Write(const TopoDS_Shape& Sh,
- const Standard_CString File,
- const Message_ProgressRange& theProgress)
+Standard_Boolean BRepTools::Write (const TopoDS_Shape& theShape,
+ const Standard_CString theFile,
+ const Standard_Boolean theWithTriangles,
+ const TopTools_FormatVersion theVersion,
+ const Message_ProgressRange& theProgress)
{
std::ofstream os;
- OSD_OpenStream(os, File, std::ios::out);
+ OSD_OpenStream(os, theFile, std::ios::out);
if (!os.is_open() || !os.good())
return Standard_False;
Standard_Boolean isGood = (os.good() && !os.eof());
if(!isGood)
return isGood;
-
- BRepTools_ShapeSet SS;
- SS.Add(Sh);
-
+
+ BRepTools_ShapeSet SS (theWithTriangles);
+ SS.SetFormatNb (theVersion);
+ SS.Add (theShape);
+
os << "DBRep_DrawableShape\n"; // for easy Draw read
SS.Write(os, theProgress);
isGood = os.good();
- if(isGood )
- SS.Write(Sh,os);
+ if (isGood)
+ {
+ SS.Write (theShape, os);
+ }
os.flush();
isGood = os.good();
#ifndef _BRepTools_HeaderFile
#define _BRepTools_HeaderFile
+#include <TopTools_FormatVersion.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
//! Dumps the topological structure and the geometry
//! of <Sh> on the stream <S>.
Standard_EXPORT static void Dump (const TopoDS_Shape& Sh, Standard_OStream& S);
-
- //! Writes <Sh> on <S> in an ASCII format.
- Standard_EXPORT static void Write (const TopoDS_Shape& Sh, Standard_OStream& S,
+
+ //! Writes the shape to the stream in an ASCII format TopTools_FormatVersion_VERSION_1.
+ //! This alias writes shape with triangulation data.
+ //! @param theShape [in] the shape to write
+ //! @param theStream [in][out] the stream to output shape into
+ //! @param theRange the range of progress indicator to fill in
+ static void Write (const TopoDS_Shape& theShape,
+ Standard_OStream& theStream,
+ const Message_ProgressRange& theProgress = Message_ProgressRange())
+ {
+ Write (theShape, theStream, Standard_True,
+ TopTools_FormatVersion_VERSION_1, theProgress);
+ }
+
+ //! Writes the shape to the stream in an ASCII format of specified version.
+ //! @param theShape [in] the shape to write
+ //! @param theStream [in][out] the stream to output shape into
+ //! @param theWithTriangles [in] flag which specifies whether to save shape with (TRUE) or without (FALSE) triangles;
+ //! has no effect on triangulation-only geometry
+ //! @param theVersion [in] the TopTools format version
+ //! @param theRange the range of progress indicator to fill in
+ Standard_EXPORT static void Write (const TopoDS_Shape& theShape,
+ Standard_OStream& theStream,
+ const Standard_Boolean theWithTriangles,
+ const TopTools_FormatVersion theVersion,
const Message_ProgressRange& theProgress = Message_ProgressRange());
-
+
//! Reads a Shape from <S> in returns it in <Sh>.
//! <B> is used to build the shape.
Standard_EXPORT static void Read (TopoDS_Shape& Sh, Standard_IStream& S, const BRep_Builder& B,
const Message_ProgressRange& theProgress = Message_ProgressRange());
-
- //! Writes <Sh> in <File>.
- Standard_EXPORT static Standard_Boolean Write (const TopoDS_Shape& Sh, const Standard_CString File,
+
+ //! Writes the shape to the file in an ASCII format TopTools_FormatVersion_VERSION_1.
+ //! This alias writes shape with triangulation data.
+ //! @param theShape [in] the shape to write
+ //! @param theFile [in] the path to file to output shape into
+ //! @param theRange the range of progress indicator to fill in
+ static Standard_Boolean Write (const TopoDS_Shape& theShape,
+ const Standard_CString theFile,
+ const Message_ProgressRange& theProgress = Message_ProgressRange())
+ {
+ return Write (theShape, theFile, Standard_True,
+ TopTools_FormatVersion_VERSION_1, theProgress);
+ }
+
+ //! Writes the shape to the file in an ASCII format of specified version.
+ //! @param theShape [in] the shape to write
+ //! @param theFile [in] the path to file to output shape into
+ //! @param theWithTriangles [in] flag which specifies whether to save shape with (TRUE) or without (FALSE) triangles;
+ //! has no effect on triangulation-only geometry
+ //! @param theVersion [in] the TopTools format version
+ //! @param theRange the range of progress indicator to fill in
+ Standard_EXPORT static Standard_Boolean Write (const TopoDS_Shape& theShape,
+ const Standard_CString theFile,
+ const Standard_Boolean theWithTriangles,
+ const TopTools_FormatVersion theVersion,
const Message_ProgressRange& theProgress = Message_ProgressRange());
-
+
//! Reads a Shape from <File>, returns it in <Sh>.
//! <B> is used to build the shape.
Standard_EXPORT static Standard_Boolean Read (TopoDS_Shape& Sh, const Standard_CString File,
//=======================================================================
//function : BRepTools_ShapeSet
-//purpose :
+//purpose :
//=======================================================================
-
-BRepTools_ShapeSet::BRepTools_ShapeSet(const Standard_Boolean isWithTriangles)
- :myWithTriangles(isWithTriangles)
+BRepTools_ShapeSet::BRepTools_ShapeSet (const Standard_Boolean theWithTriangles)
+: myWithTriangles (theWithTriangles)
{
}
//=======================================================================
//function : BRepTools_ShapeSet
-//purpose :
+//purpose :
//=======================================================================
-
-BRepTools_ShapeSet::BRepTools_ShapeSet (const BRep_Builder& B,
- const Standard_Boolean isWithTriangles) :
- myBuilder(B), myWithTriangles(isWithTriangles)
+BRepTools_ShapeSet::BRepTools_ShapeSet (const BRep_Builder& theBuilder,
+ const Standard_Boolean theWithTriangles)
+: myBuilder (theBuilder),
+ myWithTriangles (theWithTriangles)
{
}
+//=======================================================================
+//function : ~BRepTools_ShapeSet
+//purpose :
+//=======================================================================
+BRepTools_ShapeSet::~BRepTools_ShapeSet()
+{
+ //
+}
//=======================================================================
//function : Clear
OS << "\n";
// Write UV Points // for XML Persistence higher performance
- if (FormatNb() == 2)
+ if (FormatNb() >= TopTools_FormatVersion_VERSION_2)
{
gp_Pnt2d Pf,Pl;
if (CR->IsCurveOnClosedSurface()) {
GeomTools::GetReal(IS, last);
// read UV Points // for XML Persistence higher performance
- if (FormatNb() == 2)
+ if (FormatNb() >= TopTools_FormatVersion_VERSION_2)
{
GeomTools::GetReal(IS, PfX);
GeomTools::GetReal(IS, PfY);
// Modified by Sergey KHROMOV - Wed Apr 24 12:11:17 2002 End
if (closed) {
- if (FormatNb() == 2)
+ if (FormatNb() >= TopTools_FormatVersion_VERSION_2)
myBuilder.UpdateEdge(E,myCurves2d.Curve2d(pc),
myCurves2d.Curve2d(pc2),
mySurfaces.Surface(s),
}
else
{
- if (FormatNb() == 2)
+ if (FormatNb() >= TopTools_FormatVersion_VERSION_2)
myBuilder.UpdateEdge(E,myCurves2d.Curve2d(pc),
mySurfaces.Surface(s),
Locations().Location(l),tol,
DEFINE_STANDARD_ALLOC
-
//! Builds an empty ShapeSet.
- //! Parameter <isWithTriangles> is added for XML Persistence
- Standard_EXPORT BRepTools_ShapeSet (const Standard_Boolean isWithTriangles = Standard_True);
+ //! @param theWithTriangles flag to write triangulation data
+ Standard_EXPORT BRepTools_ShapeSet (const Standard_Boolean theWithTriangles = Standard_True);
//! Builds an empty ShapeSet.
- //! Parameter <isWithTriangles> is added for XML Persistence
- Standard_EXPORT BRepTools_ShapeSet (const BRep_Builder& B,
- const Standard_Boolean isWithTriangles = Standard_True);
-
+ //! @param theWithTriangles flag to write triangulation data
+ Standard_EXPORT BRepTools_ShapeSet (const BRep_Builder& theBuilder,
+ const Standard_Boolean theWithTriangles = Standard_True);
+
+ Standard_EXPORT virtual ~BRepTools_ShapeSet();
+
+ //! Return true if shape should be stored with triangles.
+ Standard_Boolean IsWithTriangles() const { return myWithTriangles; }
+
+ //! Define if shape will be stored with triangles.
+ //! Ignored (always written) if face defines only triangulation (no surface).
+ void SetWithTriangles (const Standard_Boolean theWithTriangles) { myWithTriangles = theWithTriangles; }
+
//! Clears the content of the set.
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
#include <TDF_Data.hxx>
#include <TDF_Label.hxx>
#include <TDocStd_Document.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <TDocStd_Owner.hxx>
#include <Message_ProgressScope.hxx>
else if (aStr == END_TYPES)
break;
else if (begin) {
- if ( aFileVer < 8 ) {
+ if ( aFileVer < TDocStd_FormatVersion_VERSION_8) {
#ifdef DATATYPE_MIGRATION
TCollection_AsciiString newName;
if(Storage_Schema::CheckTypeMigration(aStr, newName)) {
Message_ProgressScope aPS(theRange, "Reading data", 3);
// 2b. Read the TOC of Sections
- if (aFileVer >= 3) {
+ if (aFileVer >= TDocStd_FormatVersion_VERSION_3) {
BinLDrivers_DocumentSection aSection;
do {
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream, aFileVer);
}
// Read Sections (post-reading type)
- if (aFileVer >= 3) {
+ if (aFileVer >= TDocStd_FormatVersion_VERSION_3) {
BinLDrivers_VectorOfDocumentSection::Iterator aSectIter (mySections);
for (; aSectIter.More(); aSectIter.Next()) {
BinLDrivers_DocumentSection& aCurSection = aSectIter.ChangeValue();
const Standard_Integer theFileVersion,
const Standard_Integer theCurVersion)
{
- if (theFileVersion < 2 || theFileVersion > theCurVersion) {
+ if (theFileVersion < TDocStd_FormatVersion_VERSION_2 || theFileVersion > theCurVersion) {
// file was written with another version
return Standard_False;
}
#include <Standard_Integer.hxx>
#include <BinObjMgt_Persistent.hxx>
+#include <TDocStd_FormatVersion.hxx>
class BinMDF_ADriverTable;
class Message_Messenger;
static void SetAttributeID(const BinObjMgt_Persistent& theSource, const Handle(T)& anAtt, const Standard_Integer aDocFormatVersion)
{
Standard_Boolean ok = Standard_True;
- if(aDocFormatVersion > 9) { // process user defined guid
+ if(aDocFormatVersion >= TDocStd_FormatVersion_VERSION_10) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;
#include <Standard_Type.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <BinMDataStd.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_AsciiStringDriver,BinMDF_ADriver)
Standard_Boolean ok = Source >> aString;
if (ok)
aStrAtt->Set( aString );
- if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 8) { // process user defined guid
+ if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_9) { // process user defined guid
const Standard_Integer& aPos = Source.Position();
Standard_GUID aGuid;
ok = Source >> aGuid;
#include <TColStd_HArray1OfByte.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_ByteArrayDriver,BinMDF_ADriver)
anAtt->ChangeArray(bytes);
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;
#include <TColStd_HArray1OfExtendedString.hxx>
#include <TDataStd_ExtStringArray.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_ExtStringArrayDriver,BinMDF_ADriver)
if(ok) {
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue)) {
return Standard_False;
#include <Standard_Type.hxx>
#include <TDataStd_Name.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <BinMDataStd.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_GenericExtStringDriver,BinMDF_ADriver)
Standard_Boolean ok = Source >> aStr;
if (ok)
aStrAttr->Set( aStr );
- if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 8) { // process user defined guid
+ if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_9) { // process user defined guid
const Standard_Integer& aPos = Source.Position();
Standard_GUID aGuid;
ok = Source >> aGuid;
#include <TColStd_PackedMapOfInteger.hxx>
#include <TDataStd_IntPackedMap.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_IntPackedMapDriver,BinMDF_ADriver)
}
Standard_Boolean aDelta(Standard_False);
- if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (Source >> aDeltaValue))
return Standard_False;
#include <TColStd_HArray1OfInteger.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_IntegerArrayDriver,BinMDF_ADriver)
if(!theSource.GetIntArray (&aTargetArray(aFirstInd), aLength))
return Standard_False;
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;
#include <Standard_Type.hxx>
#include <TDataStd_Integer.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <BinMDataStd.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_IntegerDriver,BinMDF_ADriver)
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);
- if(theRT.GetHeaderData()->StorageVersion().IntegerValue() > 8) { // process user defined guid
+ if(theRT.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_9) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;
return Standard_False;
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;
#include <Standard_Type.hxx>
#include <TDataStd_Real.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <BinMDataStd.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_RealDriver,BinMDF_ADriver)
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 8) { // process user defined guid
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_9) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;
IMPLEMENT_STANDARD_RTTIEXT(BinMNaming_NamedShapeDriver,BinMDF_ADriver)
#define SHAPESET "SHAPE_SECTION"
-#define FORMAT_NUMBER 3
//=======================================================================
static Standard_Character EvolutionToChar(const TNaming_Evolution theEvol)
{
BinMNaming_NamedShapeDriver::BinMNaming_NamedShapeDriver
(const Handle(Message_Messenger)& theMsgDriver)
- : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TNaming_NamedShape)->Name()), myShapeSet(Standard_False),myFormatNb(FORMAT_NUMBER)
+: BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TNaming_NamedShape)->Name()),
+ myShapeSet (Standard_False),
+ myFormatNb (BinTools_FormatVersion_VERSION_3)
{
}
#include <TColStd_Array1OfInteger.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Tool.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <TNaming_Iterator.hxx>
#include <TNaming_ListIteratorOfListOfNamedShape.hxx>
#include <TNaming_NamedShape.hxx>
myMessageDriver->Send (aMsg, Message_Warning);
}
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 3) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_4) {
TCollection_AsciiString entry;
ok = theSource >> entry;
if(ok) {
aName.ContextLabel(tLab);
}
}
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 4 &&
- theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < 7) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_5 &&
+ theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() <= TDocStd_FormatVersion_VERSION_6) {
// Orientation processing - converting from old format
Handle(TNaming_NamedShape) aNShape;
if(anAtt->Label().FindAttribute(TNaming_NamedShape::GetID(), aNShape)) {
}
}
}
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 6) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_7) {
ok = theSource >> anIndx;
TopAbs_Orientation OrientationToApply(TopAbs_FORWARD);
if(ok) {
}
Standard_Integer aFileVer = theMap.GetHeaderData()->StorageVersion().IntegerValue();
- if( aFileVer > 5 && myLocations == 0 )
+ if( aFileVer >= TDocStd_FormatVersion_VERSION_6 && myLocations == 0 )
{
return Standard_False;
}
Standard_Integer aPower;
Handle(TopLoc_Datum3D) aDatum;
- if( aFileVer > 5 )
+ if( aFileVer >= TDocStd_FormatVersion_VERSION_6)
{
const TopLoc_Location& aLoc = myLocations->Location(anId);
aPower = aLoc.FirstPower();
//=======================================================================
//function : Write
-//purpose :
+//purpose :
//=======================================================================
-
-void BinTools::Write (const TopoDS_Shape& theShape, Standard_OStream& theStream,
+void BinTools::Write (const TopoDS_Shape& theShape,
+ Standard_OStream& theStream,
+ const Standard_Boolean theWithTriangles,
+ const BinTools_FormatVersion theVersion,
const Message_ProgressRange& theRange)
{
- BinTools_ShapeSet aShapeSet(Standard_True);
- aShapeSet.SetFormatNb (3);
+ BinTools_ShapeSet aShapeSet (theWithTriangles);
+ aShapeSet.SetFormatNb (theVersion);
aShapeSet.Add (theShape);
aShapeSet.Write (theStream, theRange);
aShapeSet.Write (theShape, theStream);
//=======================================================================
//function : Write
-//purpose :
+//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 Standard_Boolean theWithTriangles,
+ const BinTools_FormatVersion theVersion,
const Message_ProgressRange& theRange)
{
std::ofstream aStream;
if (!aStream.good())
return Standard_False;
- Write (theShape, aStream, theRange);
+ Write (theShape, aStream, theWithTriangles, theVersion, theRange);
aStream.close();
return aStream.good();
}
#ifndef _BinTools_HeaderFile
#define _BinTools_HeaderFile
+#include <BinTools_FormatVersion.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
Standard_EXPORT static Standard_IStream& GetBool (Standard_IStream& IS, Standard_Boolean& theValue);
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,
- const Message_ProgressRange& theRange = Message_ProgressRange());
-
+
+ //! Writes the shape to the stream in binary format BinTools_FormatVersion_CURRENT.
+ //! This alias writes shape with triangulation data.
+ //! @param theShape [in] the shape to write
+ //! @param theStream [in][out] the stream to output shape into
+ //! @param theRange the range of progress indicator to fill in
+ static void Write (const TopoDS_Shape& theShape,
+ Standard_OStream& theStream,
+ const Message_ProgressRange& theRange = Message_ProgressRange())
+ {
+ Write (theShape, theStream, Standard_True,
+ BinTools_FormatVersion_CURRENT, theRange);
+ }
+
+ //! Writes the shape to the stream in binary format of specified version.
+ //! @param theShape [in] the shape to write
+ //! @param theStream [in][out] the stream to output shape into
+ //! @param theWithTriangles [in] flag which specifies whether to save shape with (TRUE) or without (FALSE) triangles;
+ //! has no effect on triangulation-only geometry
+ //! @param theVersion [in] the BinTools format version
+ //! @param theRange the range of progress indicator to fill in
+ Standard_EXPORT static void Write(const TopoDS_Shape& theShape, Standard_OStream& theStream,
+ const Standard_Boolean theWithTriangles,
+ const BinTools_FormatVersion theVersion,
+ const Message_ProgressRange& theRange = Message_ProgressRange());
+
//! Reads a shape from <theStream> and returns it in <theShape>.
Standard_EXPORT static void Read (TopoDS_Shape& theShape, Standard_IStream& theStream,
const Message_ProgressRange& theRange = Message_ProgressRange());
-
- //! Writes <theShape> in <theFile>.
- Standard_EXPORT static Standard_Boolean Write
- (const TopoDS_Shape& theShape, const Standard_CString theFile,
- const Message_ProgressRange& theRange = Message_ProgressRange());
-
+
+ //! Writes the shape to the file in binary format BinTools_FormatVersion_CURRENT.
+ //! @param theShape [in] the shape to write
+ //! @param theFile [in] the path to file to output shape into
+ //! @param theRange the range of progress indicator to fill in
+ static Standard_Boolean Write (const TopoDS_Shape& theShape,
+ const Standard_CString theFile,
+ const Message_ProgressRange& theRange = Message_ProgressRange())
+ {
+ return Write (theShape, theFile, Standard_True,
+ BinTools_FormatVersion_CURRENT, theRange);
+ }
+
+ //! Writes the shape to the file in binary format of specified version.
+ //! @param theShape [in] the shape to write
+ //! @param theFile [in] the path to file to output shape into
+ //! @param theWithTriangles [in] flag which specifies whether to save shape with (TRUE) or without (FALSE) triangles;
+ //! has no effect on triangulation-only geometry
+ //! @param theVersion [in] the BinTools format version
+ //! @param theRange the range of progress indicator to fill in
+ Standard_EXPORT static Standard_Boolean Write (const TopoDS_Shape& theShape,
+ const Standard_CString theFile,
+ const Standard_Boolean theWithTriangles,
+ const BinTools_FormatVersion theVersion,
+ const Message_ProgressRange& theRange = Message_ProgressRange());
+
//! Reads a shape from <theFile> and returns it in <theShape>.
Standard_EXPORT static Standard_Boolean Read
(TopoDS_Shape& theShape, const Standard_CString theFile,
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BinToolsFormatVersion_HeaderFile
+#define _BinToolsFormatVersion_HeaderFile
+
+//! Defined BinTools format version
+enum BinTools_FormatVersion
+{
+ BinTools_FormatVersion_VERSION_1 = 1, //!< Does not write CurveOnSurface UV Points into the file.
+ //! On reading calls Check() method.
+ BinTools_FormatVersion_VERSION_2 = 2, //!< Stores CurveOnSurface UV Points.
+ //! On reading format is recognized from Version string.
+ BinTools_FormatVersion_VERSION_3 = 3, //!< (OCCT 6.2.1) Correctly processes geometry with points on Curve,
+ //! or point on Surface, or points on curve of surface [#0009745]
+
+ BinTools_FormatVersion_CURRENT = BinTools_FormatVersion_VERSION_3 //!< The current version.
+};
+
+#endif
#include <string.h>
//#define MDTV_DEB 1
-const char* Version_1 = "Open CASCADE Topology V1 (c)";
-const char* Version_2 = "Open CASCADE Topology V2 (c)";
-const char* Version_3 = "Open CASCADE Topology V3 (c)";
+Standard_CString BinTools_ShapeSet::Version_1 = "Open CASCADE Topology V1 (c)";
+Standard_CString BinTools_ShapeSet::Version_2 = "Open CASCADE Topology V2 (c)";
+Standard_CString BinTools_ShapeSet::Version_3 = "Open CASCADE Topology V3 (c)";
+
//=======================================================================
//function : operator << (gp_Pnt)
//purpose :
}
//=======================================================================
//function : BinTools_ShapeSet
-//purpose :
+//purpose :
//=======================================================================
-
-BinTools_ShapeSet::BinTools_ShapeSet(const Standard_Boolean isWithTriangles)
- :myFormatNb(3), myWithTriangles(isWithTriangles)
+BinTools_ShapeSet::BinTools_ShapeSet (const Standard_Boolean theWithTriangles)
+: myFormatNb (BinTools_FormatVersion_CURRENT),
+ myWithTriangles (theWithTriangles)
{}
//=======================================================================
//=======================================================================
void BinTools_ShapeSet::SetFormatNb(const Standard_Integer theFormatNb)
{
+ Standard_ASSERT_RETURN(theFormatNb >= BinTools_FormatVersion_VERSION_1 &&
+ theFormatNb <= BinTools_FormatVersion_CURRENT,
+ "Error: unsupported BinTools version.", );
+
myFormatNb = theFormatNb;
}
void BinTools_ShapeSet::Write (Standard_OStream& OS,
const Message_ProgressRange& theRange)const
{
-
// write the copyright
- if (myFormatNb == 3)
+ if (myFormatNb == BinTools_FormatVersion_VERSION_3)
+ {
OS << "\n" << Version_3 << "\n";
- else if (myFormatNb == 2)
+ }
+ else if (myFormatNb == BinTools_FormatVersion_VERSION_2)
+ {
OS << "\n" << Version_2 << "\n";
+ }
else
+ {
OS << "\n" << Version_1 << "\n";
+ }
//-----------------------------------------
// write the locations
} while ( ! IS.fail() && strcmp(vers,Version_1) && strcmp(vers,Version_2) &&
strcmp(vers,Version_3));
if (IS.fail()) {
- std::cout << "BinTools_ShapeSet::Read: File was not written with this version of the topology"<<std::endl;
- return;
+ std::cout << "BinTools_ShapeSet::Read: File was not written with this version of the topology" << std::endl;
+ return;
}
- if (strcmp(vers,Version_3) == 0) SetFormatNb(3);
- else if (strcmp(vers,Version_2) == 0) SetFormatNb(2);
- else SetFormatNb(1);
+ if (strcmp (vers, Version_3) == 0)
+ {
+ SetFormatNb (BinTools_FormatVersion_VERSION_3);
+ }
+ else if (strcmp (vers, Version_2) == 0)
+ {
+ SetFormatNb (BinTools_FormatVersion_VERSION_2);
+ }
+ else
+ {
+ SetFormatNb (BinTools_FormatVersion_VERSION_1);
+ }
//-----------------------------------------
// read the locations
S.Free(aFree);
S.Modified(aMod);
- if (myFormatNb >= 2)
+ if (myFormatNb >= BinTools_FormatVersion_VERSION_2)
S.Checked(aChecked);
else
S.Checked (Standard_False); // force check at reading..
S.Convex (aConv);
// check
- if (myFormatNb == 1)
+ if (myFormatNb == BinTools_FormatVersion_VERSION_1)
if(T == TopAbs_FACE) {
const TopoDS_Face& F = TopoDS::Face(S);
BRepTools::Update(F);
BinTools::PutReal(OS, last);
// Write UV Points for higher performance
- if (FormatNb() >= 2)
+ if (myFormatNb >= BinTools_FormatVersion_VERSION_2)
{
gp_Pnt2d Pf,Pl;
if (CR->IsCurveOnClosedSurface()) {
BRep_ListOfPointRepresentation& lpr = TV->ChangePoints();
TopLoc_Location L;
- Standard_Boolean aNewF = (myFormatNb > 2);
+ Standard_Boolean aNewF = (myFormatNb >= BinTools_FormatVersion_VERSION_3);
do {
if(aNewF) {
val = (Standard_Integer)IS.get();//case {0|1|2|3}
BinTools::GetReal(IS, last);
// read UV Points // for XML Persistence higher performance
- if (FormatNb() >= 2)
+ if (myFormatNb >= BinTools_FormatVersion_VERSION_2)
{
BinTools::GetReal(IS, PfX);
BinTools::GetReal(IS, PfY);
break;
if (closed) {
- if (FormatNb() >= 2)
+ if (myFormatNb >= BinTools_FormatVersion_VERSION_2)
myBuilder.UpdateEdge(E,myCurves2d.Curve2d(pc),
myCurves2d.Curve2d(pc2),
mySurfaces.Surface(s),
}
else
{
- if (FormatNb() >= 2)
+ if (myFormatNb >= BinTools_FormatVersion_VERSION_2)
myBuilder.UpdateEdge(E,myCurves2d.Curve2d(pc),
mySurfaces.Surface(s),
Locations().Location(l),tol,
#include <Standard_Handle.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
+#include <BinTools_FormatVersion.hxx>
#include <BinTools_LocationSet.hxx>
#include <Standard_Integer.hxx>
#include <BRep_Builder.hxx>
DEFINE_STANDARD_ALLOC
-
//! Builds an empty ShapeSet.
- //! Parameter <isWithTriangles> is added for XML Persistence
- Standard_EXPORT BinTools_ShapeSet(const Standard_Boolean isWithTriangles = Standard_False);
-
+ //! @param theWithTriangles [in] flag to write triangulation data
+ Standard_EXPORT BinTools_ShapeSet (const Standard_Boolean theWithTriangles = Standard_False);
+
Standard_EXPORT virtual ~BinTools_ShapeSet();
//! Return true if shape should be stored with triangles.
//! Define if shape will be stored with triangles.
//! Ignored (always written) if face defines only triangulation (no surface).
- void SetWithTriangles (const Standard_Boolean isWithTriangles) { myWithTriangles = isWithTriangles; }
+ void SetWithTriangles (const Standard_Boolean theWithTriangles) { myWithTriangles = theWithTriangles; }
+ //! Sets the BinTools_FormatVersion.
Standard_EXPORT void SetFormatNb (const Standard_Integer theFormatNb);
-
- //! two formats available for the moment:
- //! First: does not write CurveOnSurface UV Points into the file
- //! on reading calls Check() method.
- //! Second: stores CurveOnSurface UV Points.
- //! On reading format is recognized from Version string.
+
+ //! Returns the BinTools_FormatVersion.
Standard_EXPORT Standard_Integer FormatNb() const;
//! Clears the content of the set.
(Standard_OStream& OS,
const Message_ProgressRange& theRange = Message_ProgressRange()) const;
+public:
+
+ static Standard_CString Version_1;
+ static Standard_CString Version_2;
+ static Standard_CString Version_3;
+
private:
TopTools_IndexedMapOfShape myShapes;
BinTools_Curve2dSet.hxx
BinTools_CurveSet.cxx
BinTools_CurveSet.hxx
+BinTools_FormatVersion.hxx
BinTools_LocationSet.cxx
BinTools_LocationSet.hxx
BinTools_LocationSetPtr.hxx
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
+#include <BinTools_ShapeSet.hxx>
#include <BRep_TEdge.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepGProp.hxx>
#include <GProp.hxx>
#include <GProp_GProps.hxx>
#include <NCollection_Vector.hxx>
+#include <OSD_OpenFile.hxx>
#include <Poly_Triangulation.hxx>
#include <Precision.hxx>
#include <Standard.hxx>
}
//=======================================================================
-// binsave
+// writebrep
//=======================================================================
-
-static Standard_Integer binsave(Draw_Interpretor& di, Standard_Integer n, const char** a)
+static Standard_Integer writebrep (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (n <= 2) return 1;
+ Standard_Integer aVersion = -1;
+ TCollection_AsciiString aShapeName, aFileName;
+ TopoDS_Shape aShape;
+ bool isBinaryFormat = false, isWithTriangles = true;
+ if (!strcasecmp (theArgVec[0], "binsave"))
+ {
+ isBinaryFormat = true;
+ }
- TopoDS_Shape aShape = DBRep::Get (a[1]);
- if (aShape.IsNull())
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString aParam (theArgVec[anArgIter]);
+ aParam.LowerCase();
+ if (aParam == "-binary")
+ {
+ isBinaryFormat = true;
+ if (anArgIter + 1 < theNbArgs
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isBinaryFormat))
+ {
+ ++anArgIter;
+ }
+ }
+ else if (aParam == "-version"
+ && anArgIter + 1 < theNbArgs)
+ {
+ aVersion = Draw::Atoi (theArgVec[++anArgIter]);
+ if (aVersion <= 0)
+ {
+ theDI << "Syntax error: unknown version";
+ return 1;
+ }
+ }
+ else if (aParam == "-notriangles"
+ || aParam == "-triangles")
+ {
+ isWithTriangles = true;
+ if (anArgIter + 1 < theNbArgs
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isWithTriangles))
+ {
+ ++anArgIter;
+ }
+ if (aParam == "-notriangles")
+ {
+ isWithTriangles = !isWithTriangles;
+ }
+ }
+ else if (aShapeName.IsEmpty())
+ {
+ aShapeName = theArgVec[anArgIter];
+ aShape = DBRep::Get (aShapeName);
+ if (aShape.IsNull())
+ {
+ theDI << "Syntax error: " << aShapeName << " is not a shape";
+ return 1;
+ }
+ }
+ else if (aFileName.IsEmpty())
+ {
+ aFileName = theArgVec[anArgIter];
+ }
+ else
+ {
+ theDI << "Syntax error: unknown argument '" << aParam << "'";
+ return 1;
+ }
+ }
+ if (aFileName.IsEmpty())
{
- di << a[1] << " is not a shape";
+ theDI << "Syntax error: wrong number of arguments";
return 1;
}
- if (!BinTools::Write (aShape, a[2]))
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI);
+ if (isBinaryFormat)
{
- di << "Cannot write to the file " << a[2];
- return 1;
+ if (aVersion > BinTools_FormatVersion_CURRENT)
+ {
+ theDI << "Syntax error: unknown format version";
+ return 1;
+ }
+
+ BinTools_FormatVersion aBinToolsVersion = aVersion > 0
+ ? static_cast<BinTools_FormatVersion> (aVersion)
+ : BinTools_FormatVersion_CURRENT;
+ if (!BinTools::Write (aShape, aFileName.ToCString(), isWithTriangles, aBinToolsVersion, aProgress->Start()))
+ {
+ theDI << "Cannot write to the file " << aFileName;
+ return 1;
+ }
}
+ else
+ {
+ if (aVersion > TopTools_FormatVersion_VERSION_2)
+ {
+ theDI << "Syntax error: unknown format version";
+ return 1;
+ }
- di << a[1];
+ TopTools_FormatVersion aTopToolsVersion = aVersion > 0
+ ? static_cast<TopTools_FormatVersion> (aVersion)
+ : TopTools_FormatVersion_CURRENT;
+ if (!BRepTools::Write (aShape, aFileName.ToCString(), isWithTriangles, aTopToolsVersion, aProgress->Start()))
+ {
+ theDI << "Cannot write to the file " << aFileName;
+ return 1;
+ }
+ }
+ theDI << aShapeName;
return 0;
}
//=======================================================================
-// binrestore
+// readbrep
//=======================================================================
-
-static Standard_Integer binrestore(Draw_Interpretor& di, Standard_Integer n, const char** a)
+static Standard_Integer readbrep (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (n <= 2) return 1;
+ if (theNbArgs != 3)
+ {
+ theDI << "Syntax error: wrong number of arguments";
+ return 1;
+ }
+
+ Standard_CString aFileName = theArgVec[1];
+ Standard_CString aShapeName = theArgVec[2];
+ bool isBinaryFormat = true;
+ {
+ // probe file header to recognize format
+ std::ifstream aFile;
+ OSD_OpenStream (aFile, aFileName, std::ios::in | std::ios::binary);
+ if (!aFile.is_open())
+ {
+ theDI << "Error: cannot read the file '" << aFileName << "'";
+ return 1;
+ }
+
+ char aStringBuf[255] = {};
+ aFile.read (aStringBuf, 255);
+ if (aFile.fail())
+ {
+ theDI << "Error: cannot read the file '" << aFileName << "'";
+ return 1;
+ }
+ isBinaryFormat = !(::strncmp (aStringBuf, "DBRep_DrawableShape", 19) == 0);
+ }
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI);
TopoDS_Shape aShape;
- if (!BinTools::Read (aShape, a[1]))
+ if (isBinaryFormat)
{
- di << "Cannot read from the file " << a[1];
- return 1;
+ if (!BinTools::Read (aShape, aFileName, aProgress->Start()))
+ {
+ theDI << "Error: cannot read from the file '" << aFileName << "'";
+ return 1;
+ }
+ }
+ else
+ {
+ if (!BRepTools::Read (aShape, aFileName, BRep_Builder(), aProgress->Start()))
+ {
+ theDI << "Error: cannot read from the file '" << aFileName << "'";
+ return 1;
+ }
}
- DBRep::Set (a[2], aShape);
- di << a[2];
+ DBRep::Set (aShapeName, aShape);
+ theDI << aShapeName;
return 0;
}
"\n\t\t +|-c : switch on/off output to cout of Progress Indicator"
"\n\t\t +|-g : switch on/off graphical mode of Progress Indicator",
XProgress,"DE: General");
-
- theCommands.Add("binsave", "binsave shape filename\n"
- "\t\tsave the shape in the binary format file",
- __FILE__, binsave, g);
- theCommands.Add("binrestore", "binrestore filename shape\n"
- "\t\trestore the shape from the binary format file",
- __FILE__, binrestore, g);
+ theCommands.Add("writebrep",
+ "writebrep shape filename [-binary] [-version Version] [-noTriangles]"
+ "\n\t\t: Save the shape in the ASCII (default) or binary format file."
+ "\n\t\t: -binary write into the binary format (ASCII when unspecified)"
+ "\n\t\t: -version a number of format version to save;"
+ "\n\t\t: ASCII versions: 1, 2 (1 for ASCII when unspecified);"
+ "\n\t\t: Binary versions: 1, 2 and 3 (3 for Binary when unspecified)."
+ "\n\t\t: -noTriangles skip triangulation data (OFF when unspecified).",
+ __FILE__, writebrep, g);
+ theCommands.Add("readbrep",
+ "readbrep filename shape"
+ "\n\t\t: Restore the shape from the binary or ASCII format file.",
+ __FILE__, readbrep, g);
+ theCommands.Add("binsave", "binsave shape filename", __FILE__, writebrep, g);
+ theCommands.Add("binrestore",
+ "alias to readbrep command",
+ __FILE__, readbrep, g);
theCommands.Add ("removeinternals", "removeinternals shape [force flag {0/1}]"
"\n\t\t Removes sub-shapes with internal orientation from the shape.\n"
static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
- if (n <= 2) return 1;
+ if (n < 3)
+ {
+ di << "Syntax error: wrong number of arguments!\n";
+ di.PrintHelp(a[0]);
+ return 1;
+ }
const char* name = a[2];
std::ofstream os;
Standard_EXPORT void SetNumberOfObjects (const Standard_Integer anObjectNumber);
Standard_EXPORT void SetStorageVersion (const TCollection_AsciiString& aVersion);
-
+
+ void SetStorageVersion (const Standard_Integer theVersion)
+ {
+ SetStorageVersion (TCollection_AsciiString (theVersion));
+ }
+
Standard_EXPORT void SetCreationDate (const TCollection_AsciiString& aDate);
Standard_EXPORT void SetSchemaVersion (const TCollection_AsciiString& aVersion);
TopTools_DataMapOfShapeReal.hxx
TopTools_DataMapOfShapeSequenceOfShape.hxx
TopTools_DataMapOfShapeShape.hxx
+TopTools_FormatVersion.hxx
TopTools_HArray1OfListOfShape.hxx
TopTools_HArray1OfShape.hxx
TopTools_HArray2OfShape.hxx
--- /dev/null
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _TopToolsFormatVersion_HeaderFile
+#define _TopToolsFormatVersion_HeaderFile
+
+//! Defined TopTools format version
+enum TopTools_FormatVersion
+{
+ TopTools_FormatVersion_VERSION_1 = 1, //!< Does not write CurveOnSurface UV Points into the file. On reading calls Check() method.
+ TopTools_FormatVersion_VERSION_2 = 2, //!< Stores CurveOnSurface UV Points. On reading format is recognized from Version string.
+
+ TopTools_FormatVersion_CURRENT = TopTools_FormatVersion_VERSION_1 //!< The current version.
+};
+
+#endif
#include <TopoDS_Shape.hxx>
#include <TopTools_LocationSet.hxx>
#include <TopTools_ShapeSet.hxx>
+#include <Standard_Assert.hxx>
+
+#include <BRep_TFace.hxx>
#include <locale.h>
#include <string.h>
-static const char* Version = "CASCADE Topology V1, (c) Matra-Datavision";
-static const char* Version2 = "CASCADE Topology V2, (c) Matra-Datavision";
+Standard_CString TopTools_ShapeSet::Version_1 = "CASCADE Topology V1, (c) Matra-Datavision";
+Standard_CString TopTools_ShapeSet::Version_2 = "CASCADE Topology V2, (c) Matra-Datavision";
//=======================================================================
//function : TopTools_ShapeSet
//purpose :
//=======================================================================
-
-TopTools_ShapeSet::TopTools_ShapeSet() : myFormatNb(1)
+TopTools_ShapeSet::TopTools_ShapeSet()
+: myFormatNb (TopTools_FormatVersion_VERSION_1)
{
}
//=======================================================================
void TopTools_ShapeSet::SetFormatNb(const Standard_Integer theFormatNb)
{
+ Standard_ASSERT_RETURN(theFormatNb == TopTools_FormatVersion_VERSION_1 ||
+ theFormatNb == TopTools_FormatVersion_VERSION_2,
+ "Error: unsupported TopTools version.", );
+
myFormatNb = theFormatNb;
}
std::streamsize prec = OS.precision(15);
// write the copyright
- if (myFormatNb == 2)
- OS << "\n" << Version2 << "\n";
+ if (myFormatNb == TopTools_FormatVersion_VERSION_2)
+ {
+ OS << "\n" << Version_2 << "\n";
+ }
else
- OS << "\n" << Version << "\n";
+ {
+ OS << "\n" << Version_1 << "\n";
+ }
//-----------------------------------------
// write the locations
vers[lv] = '\0';
}
- } while ( ! IS.fail() && strcmp(vers,Version) && strcmp(vers,Version2) );
+ } while (!IS.fail()
+ && strcmp(vers, Version_1)
+ && strcmp(vers, Version_2));
if (IS.fail()) {
std::cout << "File was not written with this version of the topology"<<std::endl;
IS.imbue (anOldLocale);
return;
}
- if (strcmp(vers,Version2) == 0) SetFormatNb(2);
- else SetFormatNb(1);
+ else if (strcmp(vers, Version_2) == 0)
+ {
+ SetFormatNb(TopTools_FormatVersion_VERSION_2);
+ }
+ else
+ {
+ SetFormatNb(TopTools_FormatVersion_VERSION_1);
+ }
//-----------------------------------------
// read the locations
S.Free (buffer[0] == '1');
S.Modified (buffer[1] == '1');
- if (myFormatNb == 2)
+ if (myFormatNb >= TopTools_FormatVersion_VERSION_2)
S.Checked (buffer[2] == '1');
else
S.Checked (Standard_False); // force check at reading..
// check
- if (myFormatNb == 1)
+ if (myFormatNb == TopTools_FormatVersion_VERSION_1)
Check(T,S);
myShapes.Add(S);
#include <Standard_OStream.hxx>
#include <Standard_IStream.hxx>
#include <TopAbs_ShapeEnum.hxx>
+#include <TopTools_FormatVersion.hxx>
class TopoDS_Shape;
class TopTools_LocationSet;
Standard_EXPORT virtual ~TopTools_ShapeSet();
+ //! Sets the TopTools_FormatVersion
Standard_EXPORT void SetFormatNb (const Standard_Integer theFormatNb);
- //! two formats available for the moment:
- //! First: does not write CurveOnSurface UV Points into the file
- //! on reading calls Check() method.
- //! Second: stores CurveOnSurface UV Points.
- //! On reading format is recognized from Version string.
+ //! Returns the TopTools_FormatVersion
Standard_EXPORT Standard_Integer FormatNb() const;
//! Clears the content of the set. This method can be
//! Returns number of shapes read from file.
Standard_EXPORT Standard_Integer NbShapes() const;
+public:
+
+ static Standard_CString Version_1;
+ static Standard_CString Version_2;
+
private:
//! Reads from <IS> a shape and returns it in S.
theApplication -> MessageDriver();
// 1. Read info // to be done
TCollection_AsciiString anAbsoluteDirectory = GetDirFromFile(myFileName);
- Standard_Integer aCurDocVersion = 0;
+ Standard_Integer aCurDocVersion = TDocStd_FormatVersion_VERSION_2; // minimum supported version
TCollection_ExtendedString anInfo;
const XmlObjMgt_Element anInfoElem =
theElement.GetChildByTagName ("info");
if (anInfoElem != NULL) {
XmlObjMgt_DOMString aDocVerStr = anInfoElem.getAttribute("DocVersion");
- if(aDocVerStr == NULL)
- aCurDocVersion = 2;
- else if (!aDocVerStr.GetInteger(aCurDocVersion)) {
- TCollection_ExtendedString aMsg =
- TCollection_ExtendedString ("Cannot retrieve the current Document version"
- " attribute as \"") + aDocVerStr + "\"";
- if(!aMsgDriver.IsNull())
- aMsgDriver->Send(aMsg.ToExtString(), Message_Fail);
+ if (aDocVerStr != NULL)
+ {
+ Standard_Integer anIntegerVersion = 0;
+ if (aDocVerStr.GetInteger (anIntegerVersion))
+ {
+ aCurDocVersion = anIntegerVersion;
+ }
+ else
+ {
+ TCollection_ExtendedString aMsg =
+ TCollection_ExtendedString ("Cannot retrieve the current Document version"
+ " attribute as \"") + aDocVerStr + "\"";
+ if (!aMsgDriver.IsNull())
+ {
+ aMsgDriver->Send(aMsg.ToExtString(), Message_Fail);
+ }
+ }
}
-
+
// oan: OCC22305 - check a document verison and if it's greater than
// current version of storage driver set an error status and return
if( aCurDocVersion > TDocStd_Document::CurrentStorageFormatVersion() )
return;
}
- if( aCurDocVersion < 2) aCurDocVersion = 2;
Standard_Boolean isRef = Standard_False;
for (LDOM_Node aNode = anInfoElem.getFirstChild();
aNode != NULL; aNode = aNode.getNextSibling()) {
if (TDocStd_Document::CurrentStorageFormatVersion() < aDoc->StorageFormatVersion())
{
TCollection_ExtendedString anErrorString("Unacceptable storage format version, the last verson is used");
- aMessageDriver->Send (anErrorString.ToExtString(), Message_Warning);
+ aMessageDriver->Send (anErrorString.ToExtString(), Message_Warning);
}
- else
+ else
+ {
aFormatVersion = aDoc->StorageFormatVersion();
- anInfoElem.setAttribute ("DocVersion", aFormatVersion);
+ }
+ const TCollection_AsciiString aStringFormatVersion (aFormatVersion);
+ anInfoElem.setAttribute ("DocVersion", aStringFormatVersion.ToCString());
// User info with Copyright
TColStd_SequenceOfAsciiString aUserInfo;
#include <TDF_Label.hxx>
#include <TDF_TagSource.hxx>
#include <TDF_Tool.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <XmlMDF.hxx>
#include <XmlMDF_ADriver.hxx>
#include <XmlMDF_ADriverTable.hxx>
// was replaced by TDataXtd_Presentation. Therefore, for old versions
// we write old name of the attribute (TPrsStd_AISPresentation).
Standard_CString typeName = aDriver->TypeName().ToCString();
- if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < 8 &&
+ if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < TDocStd_FormatVersion_VERSION_8 &&
strcmp(typeName, "TDataXtd_Presentation") == 0)
{
typeName = "TPrsStd_AISPresentation";
#include <TColStd_HArray1OfByte.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <XmlMDataStd.hxx>
#include <XmlMDataStd_ByteArrayDriver.hxx>
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_Persistent.hxx>
+
IMPLEMENT_DOMSTRING (AttributeIDString, "bytearrattguid")
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ByteArrayDriver,XmlMDF_ADriver)
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
#include <Standard_Type.hxx>
#include <TDataStd_ExtStringArray.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <XmlMDataStd.hxx>
#include <XmlMDataStd_ExtStringArrayDriver.hxx>
#include <XmlObjMgt.hxx>
// Read delta-flag.
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
// So, if the user wants to save the document under the 7th or earlier versions,
// don't apply this improvement.
Standard_Character c = '-';
- if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 7)
+ if (theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_8)
{
// Preferrable symbols for the separator: - _ . : ^ ~
// Don't use a space as a separator: XML low-level parser sometimes "eats" it.
#include <TColStd_PackedMapOfInteger.hxx>
#include <TDataStd_IntPackedMap.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <XmlMDataStd.hxx>
#include <XmlMDataStd_IntPackedMapDriver.hxx>
#include <XmlMDF_ADriver.hxx>
if(Ok) {
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
#include <Standard_Type.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <XmlMDataStd.hxx>
#include <XmlMDataStd_IntegerArrayDriver.hxx>
#include <XmlObjMgt.hxx>
}
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
#include <TColStd_HArray1OfReal.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <XmlMDataStd.hxx>
#include <XmlMDataStd_RealArrayDriver.hxx>
#include <XmlObjMgt.hxx>
}
Standard_Boolean aDelta(Standard_False);
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
#include <Standard_Type.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <XmlMDataStd_TreeNodeDriver.hxx>
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_Persistent.hxx>
// tree id
// A not default ID is skipped for storage version 8 and newer.
if (aS->ID() != TDataStd_TreeNode::GetDefaultTreeID() ||
- theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < 8)
+ theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < TDocStd_FormatVersion_VERSION_8)
{
Standard_Character aGuidStr [40];
Standard_PCharacter pGuidStr=aGuidStr;
// Add text to the "shapes" element
if (myShapeSet.NbShapes() > 0) {
- myShapeSet.SetFormatNb(2);
+ myShapeSet.SetFormatNb(TopTools_FormatVersion_VERSION_2);
LDOM_OSStream aStream (16 * 1024);
// ostrstream aStream;
// aStream.rdbuf() -> setbuf (0, 16380);
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Tool.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <TNaming_Iterator.hxx>
#include <TNaming_ListIteratorOfListOfNamedShape.hxx>
#include <TNaming_Name.hxx>
}
aNgName.Index(aNb);
//
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 3) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_4) {
XmlObjMgt_DOMString aDomEntry = anElem.getAttribute(::ContextLabelString());
if (aDomEntry != NULL)
{
std::cout << "Retrieving Context Label is NULL" <<std::endl;
#endif
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 4 &&
- theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < 7) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_5 &&
+ theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < TDocStd_FormatVersion_VERSION_7) {
// Orientation processing - converting from old format
Handle(TNaming_NamedShape) aNS;
if (aNg->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
}
}
}
- if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 6) {
+ if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= TDocStd_FormatVersion_VERSION_7) {
aDOMStr = anElem.getAttribute(::OrientString());
if (!aDOMStr.GetInteger(aNb))
{
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
+#include <TDocStd_FormatVersion.hxx>
#include <TopLoc_Datum3D.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_LocationSet.hxx>
return Standard_False;
Standard_Integer aFileVer = theMap.GetHeaderData()->StorageVersion().IntegerValue();
- if( aFileVer > 5 && myLocations == 0 )
+ if( aFileVer >= TDocStd_FormatVersion_VERSION_6 && myLocations == 0 )
{
return Standard_False;
}
Standard_Integer aPower;
Handle(TopLoc_Datum3D) aDatum;
- if( aFileVer > 5 )
+ if( aFileVer >= TDocStd_FormatVersion_VERSION_6)
{
// Get Location ID
Standard_Integer anId;
--- /dev/null
+puts "=========="
+puts "0031946: Modeling Data - replace version numbers with enumerations in TopTools and BinTools"
+puts "=========="
+puts ""
+
+pload MODELING VISUALIZATION
+
+box testBox 10 20 30
+incmesh testBox 0.1
+
+writebrep testBox "${imagedir}/${casename}_topBox1.brep"
+readbrep "${imagedir}/${casename}_topBox1.brep" topBox1
+trinfo topBox1
+checktrinfo topBox1 -tri 12
+
+writebrep testBox "${imagedir}/${casename}_topBox2.brep" -noTriangles
+readbrep "${imagedir}/${casename}_topBox2.brep" topBox2
+trinfo topBox2
+checktrinfo topBox2 -tri 0
+
+writebrep testBox "${imagedir}/${casename}_topBox3.brep" -noTriangles on -binary off
+readbrep "${imagedir}/${casename}_topBox3.brep" topBox3
+trinfo topBox3
+checktrinfo topBox3 -tri 0
+
+writebrep testBox "${imagedir}/${casename}_topBox4.brep" -noTriangles off -binary off
+readbrep "${imagedir}/${casename}_topBox4.brep" topBox4
+trinfo topBox4
+checktrinfo topBox4 -tri 12
+
+writebrep testBox "${imagedir}/${casename}_binBox1.bbrep" -binary on
+readbrep "${imagedir}/${casename}_binBox1.bbrep" binBox1
+trinfo binBox1
+checktrinfo binBox1 -tri 12
+
+writebrep testBox "${imagedir}/${casename}_binBox2.bbrep" -noTriangles -binary on
+readbrep "${imagedir}/${casename}_binBox2.bbrep" binBox2
+trinfo binBox2
+checktrinfo binBox2 -tri 0
+
+writebrep testBox "${imagedir}/${casename}_binBox3.bbrep" -noTriangles on -binary on
+readbrep "${imagedir}/${casename}_binBox3.bbrep" binBox3
+trinfo binBox3
+checktrinfo binBox3 -tri 0
+
+writebrep testBox "${imagedir}/${casename}_binBox4.bbrep" -noTriangles off -binary on
+readbrep "${imagedir}/${casename}_binBox4.bbrep" binBox4
+trinfo binBox4
+checktrinfo binBox4 -tri 12