mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0031946: Modeling Data - replace version numbers with enumerations in TopTools and BinTools
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).
This commit is contained in:
@@ -24,6 +24,7 @@ TopTools_DataMapOfShapeListOfShape.hxx
|
||||
TopTools_DataMapOfShapeReal.hxx
|
||||
TopTools_DataMapOfShapeSequenceOfShape.hxx
|
||||
TopTools_DataMapOfShapeShape.hxx
|
||||
TopTools_FormatVersion.hxx
|
||||
TopTools_HArray1OfListOfShape.hxx
|
||||
TopTools_HArray1OfShape.hxx
|
||||
TopTools_HArray2OfShape.hxx
|
||||
|
26
src/TopTools/TopTools_FormatVersion.hxx
Normal file
26
src/TopTools/TopTools_FormatVersion.hxx
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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
|
@@ -28,18 +28,21 @@
|
||||
#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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -52,6 +55,10 @@ TopTools_ShapeSet::~TopTools_ShapeSet()
|
||||
//=======================================================================
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -451,10 +458,14 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS, const Message_ProgressRange
|
||||
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
|
||||
@@ -606,14 +617,22 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange&
|
||||
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
|
||||
@@ -681,7 +700,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange&
|
||||
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..
|
||||
@@ -693,7 +712,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange&
|
||||
|
||||
// check
|
||||
|
||||
if (myFormatNb == 1)
|
||||
if (myFormatNb == TopTools_FormatVersion_VERSION_1)
|
||||
Check(T,S);
|
||||
|
||||
myShapes.Add(S);
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <TopTools_FormatVersion.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class TopTools_LocationSet;
|
||||
@@ -50,13 +51,10 @@ public:
|
||||
|
||||
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
|
||||
@@ -181,6 +179,11 @@ public:
|
||||
//! 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.
|
||||
|
Reference in New Issue
Block a user