1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031136: Modeling Data - BinXCAF persistence loses normals from triangulation-only Faces

* Information about normals are stored in BinOCAF, XmlOCAF, BRep and BBRep (in case of triangulation-only Faces).
* Versions of formats have been changed (11 for BinOCAF, 10 for XmlOCAF, 4 for BRep Shape and 3 for Binary BRep Shape)
* Add new optional -version parameter for save/binsave draw commands
This commit is contained in:
asuraven
2020-11-03 17:22:14 +03:00
committed by bugmaster
parent 1ab25a0bdb
commit b0df19edbf
63 changed files with 1521 additions and 825 deletions

View File

@@ -54,6 +54,7 @@ The following sample code reads a shape from ASCII file and writes it to a binar
* \<flag\>: = "0" | "1";
* \<int\>: It is an integer number from -2<sup>31</sup> to 2<sup>31</sup>-1 which is written in denary system;
* \<real\>: It is a real from -1.7976931348623158 @f$\cdot@f$ 10<sup>308</sup> to 1.7976931348623158 @f$\cdot@f$ 10<sup>308</sup> which is written in decimal or E form with base 10.The point is used as a delimiter of the integer and fractional parts;
* \<short real\>: It is a real from -3.402823 @f$\cdot@f$ 10<sup>38</sup> to 3.402823 @f$\cdot@f$ 10<sup>38</sup> which is written in decimal or E form with base 10.The point is used as a delimiter of the integer and fractional parts;
* \<2D point\>: = \<real\>\<_\>\<real\>;
* \<3D point\>: = \<real\>(\<_\>\<real)\><sup>2</sup>;
* \<2D direction\>: It is a \<2D point\> *x y* so that *x<sup>2</sup> + y<sup>2</sup>* = 1;
@@ -71,7 +72,7 @@ The following sample code reads a shape from ASCII file and writes it to a binar
\<content type\> = "DBRep_DrawableShape" \<_\\n\>\<_\\n\>;
\<content type\> have other values [1].
\<version\> = ("CASCADE Topology V1, (c) Matra-Datavision" | "CASCADE Topology V2, (c) Matra-Datavision")\<_\\n\>;
\<version\> = ("CASCADE Topology V1, (c) Matra-Datavision" | "CASCADE Topology V2, (c) Matra-Datavision" | "Open CASCADE Topology V3 (c)")\<_\\n\>;
The difference of the versions is described in the document.
Sections \<locations\>, \<geometry\> and \<shapes\> are described below in separate chapters of the document.
@@ -1436,14 +1437,16 @@ The example record describes a polyline from *m*=2 nodes with a parameter prese
<triangulation records> = <triangulation record> ^ <triangulation count>;
<triangulation record> = <triangulation node count> <_> <triangulation triangle count> <_> <triangulation parameter presence flag> <_> <triangulation deflection> <_\n>
<triangulation nodes> [<_> <triangulation u v parameters>] <_> <triangulation triangles> <_\n>;
<triangulation record> = <triangulation node count> <_> <triangulation triangle count> <_> <triangulation parameter presence flag> [<_> <need to write normals flag>] <_> <triangulation deflection> <_\n>
<triangulation nodes> [<_> <triangulation u v parameters>] <_> <triangulation triangles> [<_> <triangulation normals>] <_\n>;
<triangulation node count> = <int>;
<triangulation triangle count> = <int>;
<triangulation parameter presence flag> = <flag>;
<need to write normals flag> = <flag>;
<triangulation deflection> = <real>;
@@ -1458,10 +1461,17 @@ The example record describes a polyline from *m*=2 nodes with a parameter prese
<triangulation triangles> = (<triangulation triangle> <_>) ^ <triangulation triangle count>;
<triangulation triangle> = <int> <_> <int> <_> <int>.
<triangulation triangle> = <int> <_> <int> <_> <int>;
<triangulation normals> = (<triangulation normal> <_>) ^ <triangulation node count> ^ 3;
<triangulation normal> = <short real>.
~~~~
**Description**
\<triangulation u v parameters\> are used in version 2 or later.
\<need to write normals flag\> and \<triangulation normals\> are used in version 3.
\<triangulation record\> describes a triangulation *T* which approximates a surface *S*. The triangulation data consist of a node count @f$ m \geq 3 @f$, a triangle count @f$ k \geq 1 @f$, a parameter presence flag *p*, a deflection @f$ d \geq 0 @f$, nodes @f$ N_{i}\; (1\leq i \leq m) @f$, parameter pairs @f$ u_{i}\; v_{i}\; (1\leq i \leq m) @f$, triangles @f$ n_{j,1}\; n_{j,2}\; n_{j,3}\; (1\leq j \leq k,\; n_{j,l} \in \left \{1,...,m \right \}\; (1\leq l\leq 3)) @f$. The parameters are present only if *p*=1. The deflection describes the triangulation deflection from the surface:
@@ -1640,7 +1650,7 @@ An example of section shapes and a whole *.brep file are given in chapter 7 @re
* @f$ f_{1} @f$ -- free;
* @f$ f_{2} @f$ -- modified;
* @f$ f_{3} @f$ -- IGNORED(version 1) \\ checked (version 2);
* @f$ f_{3} @f$ -- IGNORED(version 1 only) \\ checked (version 2 or later);
* @f$ f_{4} @f$ -- orientable;
* @f$ f_{5} @f$ -- closed;
* @f$ f_{6} @f$ -- infinite;
@@ -1827,10 +1837,10 @@ Flags \<edge data same parameter flag\>, \<edge data same range flag\> and \<edg
\<edge data representation data 1\> describes a 3D curve.
\<edge data representation data 2\> describes a 2D curve on a surface.
\<curve values for parameter minimal and maximal values\> are used only in version 2.
\<curve values for parameter minimal and maximal values\> are used in version 2 or later.
\<edge data representation data 3\> describes a 2D curve on a closed surface.
\<curve values for parameter minimal and maximal values\> are used only in version 2.
\<curve values for parameter minimal and maximal values\> are used in version 2 or later.
\<edge data representation data 5\> describes a 3D polyline.

View File

@@ -2159,6 +2159,14 @@ Existing message files containing 8-bit characters (previously interpreted as ch
@section upgrade_occt760 Upgrade to OCCT 7.6.0
@subsection upgrade_760_changesInStorageOfShapes Changes in storage of shapes
Information about per-vertex triangulations normals is now stored in BinOCAF and XmlOCAF document,
BRep and Binary BRep Shape formats (only in case of triangulation-only Faces, with no analytical geometry to restore normals).
Versions of formats have been changed (11 for BinOCAF, 10 for XmlOCAF, 4 for BRep Shape and 3 for Binary BRep Shape).
Files written with the new version will not be readable by applications of old versions.
@subsection upgrade_760_trimming_surface Trimming surface
Geom_RectangularTrimmedSurface sequentially trimming in U and V directions already no longer loses the first trim.

View File

@@ -190,7 +190,11 @@ void BRepTools_ShapeSet::AddGeometry(const TopoDS_Shape& S)
}
}
else if (CR->IsPolygonOnTriangulation()) {
myTriangulations.Add(CR->Triangulation());
// NCollection_IndexedDataMap::Add() function use is correct because
// Bin(Brep)Tools_ShapeSet::AddGeometry() is called from Bin(Brep)Tools_ShapeSet::Add()
// that processes shapes recursively from complex to elementary ones.
// As a result, the TopAbs_FACE's will be processed earlier than the TopAbs_EDGE's.
myTriangulations.Add(CR->Triangulation(), Standard_False); // edge triangulation does not need normals
myNodes.Add(CR->PolygonOnTriangulation());
ChangeLocations().Add(CR->Location());
if (CR->IsPolygonOnClosedTriangulation())
@@ -211,12 +215,19 @@ void BRepTools_ShapeSet::AddGeometry(const TopoDS_Shape& S)
else if (S.ShapeType() == TopAbs_FACE) {
// Add the surface geometry
Standard_Boolean needNormals = Standard_False;
Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(S.TShape());
if (!TF->Surface().IsNull()) mySurfaces.Add(TF->Surface());
if (!TF->Surface().IsNull())
{
mySurfaces.Add(TF->Surface());
}
else
{
needNormals = Standard_True;
}
if (myWithTriangles || TF->Surface().IsNull()) { // for XML Persistence
Handle(Poly_Triangulation) Tr = TF->Triangulation();
if (!Tr.IsNull()) myTriangulations.Add(Tr);
if (!Tr.IsNull()) myTriangulations.Add(Tr, needNormals);
}
ChangeLocations().Add(TF->Location());
@@ -592,7 +603,7 @@ void BRepTools_ShapeSet::WriteGeometry (const TopoDS_Shape& S, Standard_OStream
OS << "\n";
// Write UV Points // for XML Persistence higher performance
if (FormatNb() == 2)
if (FormatNb() >= TOP_TOOLS_VERSION_2)
{
gp_Pnt2d Pf,Pl;
if (CR->IsCurveOnClosedSurface()) {
@@ -902,7 +913,7 @@ void BRepTools_ShapeSet::ReadGeometry (const TopAbs_ShapeEnum T,
GeomTools::GetReal(IS, last);
// read UV Points // for XML Persistence higher performance
if (FormatNb() == 2)
if (FormatNb() >= TOP_TOOLS_VERSION_2)
{
GeomTools::GetReal(IS, PfX);
GeomTools::GetReal(IS, PfY);
@@ -920,7 +931,7 @@ void BRepTools_ShapeSet::ReadGeometry (const TopAbs_ShapeEnum T,
// Modified by Sergey KHROMOV - Wed Apr 24 12:11:17 2002 End
if (closed) {
if (FormatNb() == 2)
if (FormatNb() >= TOP_TOOLS_VERSION_2)
myBuilder.UpdateEdge(E,myCurves2d.Curve2d(pc),
myCurves2d.Curve2d(pc2),
mySurfaces.Surface(s),
@@ -941,7 +952,7 @@ void BRepTools_ShapeSet::ReadGeometry (const TopAbs_ShapeEnum T,
}
else
{
if (FormatNb() == 2)
if (FormatNb() >= TOP_TOOLS_VERSION_2)
myBuilder.UpdateEdge(E,myCurves2d.Curve2d(pc),
mySurfaces.Surface(s),
Locations().Location(l),tol,
@@ -995,7 +1006,7 @@ void BRepTools_ShapeSet::ReadGeometry (const TopAbs_ShapeEnum T,
myBuilder.UpdateEdge
(E, Handle(Poly_PolygonOnTriangulation)::DownCast(myNodes(pt)),
Handle(Poly_PolygonOnTriangulation)::DownCast(myNodes(pt2)),
Handle(Poly_Triangulation)::DownCast(myTriangulations(t)),
myTriangulations.FindKey(t),
Locations().Location(l));
}
else {
@@ -1003,7 +1014,7 @@ void BRepTools_ShapeSet::ReadGeometry (const TopAbs_ShapeEnum T,
pt > 0 && pt <= myNodes.Extent())
myBuilder.UpdateEdge
(E,Handle(Poly_PolygonOnTriangulation)::DownCast(myNodes(pt)),
Handle(Poly_Triangulation)::DownCast(myTriangulations(t)),
myTriangulations.FindKey(t),
Locations().Location(l));
}
// range
@@ -1055,7 +1066,7 @@ void BRepTools_ShapeSet::ReadGeometry (const TopAbs_ShapeEnum T,
//only triangulation
IS >> s;
myBuilder.UpdateFace(TopoDS::Face(S),
Handle(Poly_Triangulation)::DownCast(myTriangulations(s)));
myTriangulations.FindKey(s));
}
// else pos = IS.tellg();
@@ -1072,7 +1083,7 @@ void BRepTools_ShapeSet::ReadGeometry (const TopAbs_ShapeEnum T,
s = atoi ( &string[2] );
if (s > 0 && s <= myTriangulations.Extent())
myBuilder.UpdateFace(TopoDS::Face(S),
Handle(Poly_Triangulation)::DownCast(myTriangulations(s)));
myTriangulations.FindKey(s));
}
// else IS.seekg(pos);
}
@@ -1415,16 +1426,24 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS,
Handle(Poly_Triangulation) T;
for (i = 1; i <= nbtri && aPS.More(); i++, aPS.Next()) {
T = Handle(Poly_Triangulation)::DownCast(myTriangulations(i));
T = myTriangulations.FindKey(i);
const Standard_Boolean toWriteNormals = myTriangulations(i);
if (Compact) {
OS << T->NbNodes() << " " << T->NbTriangles() << " ";
OS << ((T->HasUVNodes()) ? "1" : "0") << " ";
if (FormatNb() >= TOP_TOOLS_VERSION_3)
{
OS << ((T->HasNormals() && toWriteNormals) ? "1" : "0") << " ";
}
}
else {
OS << " "<< i << " : Triangulation with " << T->NbNodes() << " Nodes and "
<< T->NbTriangles() <<" Triangles\n";
OS << " "<<((T->HasUVNodes()) ? "with" : "without") << " UV nodes\n";
if (FormatNb() >= TOP_TOOLS_VERSION_3)
{
OS << " " << ((T->HasNormals() && toWriteNormals) ? "with" : "without") << " normals\n";
}
}
// write the deflection
@@ -1479,6 +1498,32 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS,
if (!Compact) OS << "\n";
else OS << " ";
}
if (FormatNb() >= TOP_TOOLS_VERSION_3)
{
if (T->HasNormals() && toWriteNormals)
{
if (!Compact) OS << "\nNormals :\n";
const TShort_Array1OfShortReal& Normals = T->Normals();
for (j = 1; j <= nbNodes * 3; j++)
{
if (!Compact)
{
OS << std::setw(10) << j << " : ";
OS << std::setw(17);
}
OS << Normals(j) << " ";
if (!Compact)
{
OS << "\n";
}
else
{
OS << " ";
}
}
}
}
OS << "\n";
}
}
@@ -1505,8 +1550,10 @@ void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_P
// Standard_Integer i, j, val, nbtri;
Standard_Integer i, j, nbtri =0;
Standard_Real d, x, y, z;
Standard_Real normal;
Standard_Integer nbNodes =0, nbTriangles=0;
Standard_Boolean hasUV= Standard_False;
Standard_Boolean hasNormals= Standard_False;
Handle(Poly_Triangulation) T;
@@ -1519,11 +1566,19 @@ void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_P
for (i=1; i<=nbtri && aPS.More();i++, aPS.Next()) {
IS >> nbNodes >> nbTriangles >> hasUV;
if (FormatNb() >= TOP_TOOLS_VERSION_3)
{
IS >> hasNormals;
}
GeomTools::GetReal(IS, d);
TColgp_Array1OfPnt Nodes(1, nbNodes);
TColgp_Array1OfPnt2d UVNodes(1, nbNodes);
Handle(TShort_HArray1OfShortReal) Normals;
if (hasNormals)
{
Normals = new TShort_HArray1OfShortReal(1, nbNodes * 3);
}
for (j = 1; j <= nbNodes; j++) {
GeomTools::GetReal(IS, x);
GeomTools::GetReal(IS, y);
@@ -1546,12 +1601,24 @@ void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_P
IS >> n1 >> n2 >> n3;
Triangles(j).Set(n1,n2,n3);
}
if (hasNormals)
{
for (j = 1; j <= nbNodes * 3; j++)
{
GeomTools::GetReal(IS, normal);
Normals->SetValue(j, static_cast<Standard_ShortReal>(normal));
}
}
if (hasUV) T = new Poly_Triangulation(Nodes,UVNodes,Triangles);
else T = new Poly_Triangulation(Nodes,Triangles);
T->Deflection(d);
myTriangulations.Add(T);
if (hasNormals)
{
T->SetNormals(Normals);
}
myTriangulations.Add(T, hasNormals);
}
}

View File

@@ -159,7 +159,9 @@ private:
GeomTools_Curve2dSet myCurves2d;
TColStd_IndexedMapOfTransient myPolygons2D;
TColStd_IndexedMapOfTransient myPolygons3D;
TColStd_IndexedMapOfTransient myTriangulations;
NCollection_IndexedDataMap<Handle(Poly_Triangulation),
Standard_Boolean> myTriangulations; //!< Contains a boolean flag with information
//! to save normals for triangulation
TColStd_IndexedMapOfTransient myNodes;
Standard_Boolean myWithTriangles;

View File

@@ -33,7 +33,6 @@
//#include <BinMNaming.hxx>
static Standard_GUID BinLStorageDriver ("13a56835-8269-11d5-aab2-0050044b1af1");
static Standard_GUID BinLRetrievalDriver("13a56836-8269-11d5-aab2-0050044b1af1");
#define CURRENT_DOCUMENT_VERSION 10
//=======================================================================
//function : Factory
@@ -100,7 +99,7 @@ Handle(BinMDF_ADriverTable) BinLDrivers::AttributeDrivers
TCollection_AsciiString BinLDrivers::StorageVersion()
{
TCollection_AsciiString aVersionStr (CURRENT_DOCUMENT_VERSION);
TCollection_AsciiString aVersionStr (THE_CURRENT_VERSION);
return aVersionStr;
}

View File

@@ -17,6 +17,7 @@
#define _BinLDrivers_HeaderFile
#include <Standard_Handle.hxx>
#include <BinLDrivers_FormatVersion.hxx>
class Standard_Transient;
class Standard_GUID;
@@ -43,6 +44,10 @@ public:
//! returns last storage version
Standard_EXPORT static TCollection_AsciiString StorageVersion();
public:
static const Standard_Integer THE_CURRENT_VERSION = BIN_LDRIVERS_VERSION_11;
};
#endif // _BinLDrivers_HeaderFile

View File

@@ -168,7 +168,7 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
return;
}
Standard_Integer aFileVer = aHeaderData->StorageVersion().IntegerValue();
Standard_Integer aCurrVer = BinLDrivers::StorageVersion().IntegerValue();
Standard_Integer aCurrVer = BinLDrivers::THE_CURRENT_VERSION;
// maintain one-way compatibility starting from version 2+
if (!CheckDocumentVersion(aFileVer, aCurrVer)) {
myReaderStatus = PCDM_RS_NoVersion;
@@ -192,7 +192,7 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
else if (aStr == END_TYPES)
break;
else if (begin) {
if ( aFileVer < 8 ) {
if ( aFileVer < BIN_LDRIVERS_VERSION_8) {
#ifdef DATATYPE_MIGRATION
TCollection_AsciiString newName;
if(Storage_Schema::CheckTypeMigration(aStr, newName)) {
@@ -236,7 +236,7 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
Message_ProgressScope aPS(theRange, "Reading data", 3);
// 2b. Read the TOC of Sections
if (aFileVer >= 3) {
if (aFileVer >= BIN_LDRIVERS_VERSION_3) {
BinLDrivers_DocumentSection aSection;
do {
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream, aFileVer);
@@ -347,7 +347,7 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
}
// Read Sections (post-reading type)
if (aFileVer >= 3) {
if (aFileVer >= BIN_LDRIVERS_VERSION_3) {
BinLDrivers_VectorOfDocumentSection::Iterator aSectIter (mySections);
for (; aSectIter.More(); aSectIter.Next()) {
BinLDrivers_DocumentSection& aCurSection = aSectIter.ChangeValue();
@@ -569,7 +569,7 @@ Standard_Boolean BinLDrivers_DocumentRetrievalDriver::CheckDocumentVersion(
const Standard_Integer theFileVersion,
const Standard_Integer theCurVersion)
{
if (theFileVersion < 2 || theFileVersion > theCurVersion) {
if (theFileVersion < BIN_LDRIVERS_VERSION_2 || theFileVersion > theCurVersion) {
// file was written with another version
return Standard_False;
}

View File

@@ -199,7 +199,7 @@ void BinLDrivers_DocumentSection::ReadTOC
theSection.myName = (Standard_CString)&aBuf[0];
uint64_t aValue[3];
if (theDocFormatVersion <= 9)
if (theDocFormatVersion <= BIN_LDRIVERS_VERSION_9)
{
// Old documents stored file position as 4-bytes values.
Standard_Integer aValInt[3];

View File

@@ -0,0 +1,32 @@
// 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 _BinLDriversFormatVersion_HeaderFile
#define _BinLDriversFormatVersion_HeaderFile
//! Defined BinLDrivers format version
enum BinLDrivers_FormatVersion
{
BIN_LDRIVERS_VERSION_2 = 2, //!< First supported version
BIN_LDRIVERS_VERSION_3, //!< Add Delta to numbers data, changes in ShapeSection
BIN_LDRIVERS_VERSION_4, //!< entry, ContextLabel for tree
BIN_LDRIVERS_VERSION_5, //!< Convert old format to new
BIN_LDRIVERS_VERSION_6, //!< Add location
BIN_LDRIVERS_VERSION_7, //!< Add orientation, type migration
BIN_LDRIVERS_VERSION_8, //!< Stop convert old format
BIN_LDRIVERS_VERSION_9, //!< Add GUIDs, ReadTOC changed
BIN_LDRIVERS_VERSION_10, //!< Process user defined guid
BIN_LDRIVERS_VERSION_11 //!< Add normals to Shape
};
#endif

View File

@@ -6,5 +6,6 @@ BinLDrivers_DocumentSection.cxx
BinLDrivers_DocumentSection.hxx
BinLDrivers_DocumentStorageDriver.cxx
BinLDrivers_DocumentStorageDriver.hxx
BinLDrivers_FormatVersion.hxx
BinLDrivers_Marker.hxx
BinLDrivers_VectorOfDocumentSection.hxx

View File

@@ -22,6 +22,7 @@
#include <Standard_Integer.hxx>
#include <BinObjMgt_Persistent.hxx>
#include <BinLDrivers_FormatVersion.hxx>
class BinMDF_ADriverTable;
class Message_Messenger;
@@ -41,7 +42,7 @@ template<class T>
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 >= BIN_LDRIVERS_VERSION_10) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;

View File

@@ -62,7 +62,7 @@ Standard_Boolean BinMDataStd_AsciiStringDriver::Paste
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() >= BIN_LDRIVERS_VERSION_9) { // process user defined guid
const Standard_Integer& aPos = Source.Position();
Standard_GUID aGuid;
ok = Source >> aGuid;

View File

@@ -71,7 +71,7 @@ Standard_Boolean BinMDataStd_ByteArrayDriver::Paste(const BinObjMgt_Persistent&
anAtt->ChangeArray(bytes);
Standard_Boolean aDelta(Standard_False);
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= BIN_LDRIVERS_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;

View File

@@ -81,7 +81,7 @@ Standard_Boolean BinMDataStd_ExtStringArrayDriver::Paste
if(ok) {
Standard_Boolean aDelta(Standard_False);
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= BIN_LDRIVERS_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue)) {
return Standard_False;

View File

@@ -67,7 +67,7 @@ Standard_Boolean BinMDataStd_GenericExtStringDriver::Paste
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() >= BIN_LDRIVERS_VERSION_9) { // process user defined guid
const Standard_Integer& aPos = Source.Position();
Standard_GUID aGuid;
ok = Source >> aGuid;

View File

@@ -87,7 +87,7 @@ Standard_Boolean BinMDataStd_IntPackedMapDriver::Paste
}
Standard_Boolean aDelta(Standard_False);
if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(RelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= BIN_LDRIVERS_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (Source >> aDeltaValue))
return Standard_False;

View File

@@ -69,7 +69,7 @@ Standard_Boolean BinMDataStd_IntegerArrayDriver::Paste
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() >= BIN_LDRIVERS_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;

View File

@@ -59,7 +59,7 @@ Standard_Boolean BinMDataStd_IntegerDriver::Paste
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() >= BIN_LDRIVERS_VERSION_9) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;

View File

@@ -70,7 +70,7 @@ Standard_Boolean BinMDataStd_RealArrayDriver::Paste
return Standard_False;
Standard_Boolean aDelta(Standard_False);
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= BIN_LDRIVERS_VERSION_3) {
Standard_Byte aDeltaValue;
if (! (theSource >> aDeltaValue))
return Standard_False;

View File

@@ -59,7 +59,7 @@ Standard_Boolean BinMDataStd_RealDriver::Paste
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() >= BIN_LDRIVERS_VERSION_9) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;

View File

@@ -34,7 +34,6 @@
IMPLEMENT_STANDARD_RTTIEXT(BinMNaming_NamedShapeDriver,BinMDF_ADriver)
#define SHAPESET "SHAPE_SECTION"
#define FORMAT_NUMBER 3
//=======================================================================
static Standard_Character EvolutionToChar(const TNaming_Evolution theEvol)
{
@@ -142,7 +141,7 @@ static int TranslateFrom (const BinObjMgt_Persistent& theSource,
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_ShapeSet::THE_CURRENT_VERSION)
{
}

View File

@@ -13,7 +13,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BinLDrivers_FormatVersion.hxx>
#include <BinMDF_ADriver.hxx>
#include <BinMNaming.hxx>
#include <BinMNaming_NamingDriver.hxx>
@@ -237,7 +237,7 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
myMessageDriver->Send (aMsg, Message_Warning);
}
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 3) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= BIN_LDRIVERS_VERSION_4) {
TCollection_AsciiString entry;
ok = theSource >> entry;
if(ok) {
@@ -254,8 +254,8 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
aName.ContextLabel(tLab);
}
}
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 4 &&
theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < 7) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= BIN_LDRIVERS_VERSION_5 &&
theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < BIN_LDRIVERS_VERSION_7) {
// Orientation processing - converting from old format
Handle(TNaming_NamedShape) aNShape;
if(anAtt->Label().FindAttribute(TNaming_NamedShape::GetID(), aNShape)) {
@@ -274,7 +274,7 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
}
}
}
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 6) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= BIN_LDRIVERS_VERSION_7) {
ok = theSource >> anIndx;
TopAbs_Orientation OrientationToApply(TopAbs_FORWARD);
if(ok) {

View File

@@ -93,7 +93,7 @@ Standard_Boolean BinMXCAFDoc_LocationDriver::Translate(const BinObjMgt_Persisten
}
Standard_Integer aFileVer = theMap.GetHeaderData()->StorageVersion().IntegerValue();
if( aFileVer > 5 && myLocations == 0 )
if( aFileVer >= BIN_LDRIVERS_VERSION_6 && myLocations == 0 )
{
return Standard_False;
}
@@ -101,7 +101,7 @@ Standard_Boolean BinMXCAFDoc_LocationDriver::Translate(const BinObjMgt_Persisten
Standard_Integer aPower;
Handle(TopLoc_Datum3D) aDatum;
if( aFileVer > 5 )
if( aFileVer >= BIN_LDRIVERS_VERSION_6 )
{
const TopLoc_Location& aLoc = myLocations->Location(anId);
aPower = aLoc.FirstPower();

View File

@@ -178,7 +178,6 @@ void BinTools::Write (const TopoDS_Shape& theShape, Standard_OStream& theStream,
const Message_ProgressRange& theRange)
{
BinTools_ShapeSet aShapeSet(Standard_True);
aShapeSet.SetFormatNb (3);
aShapeSet.Add (theShape);
aShapeSet.Write (theStream, theRange);
aShapeSet.Write (theShape, theStream);

View File

@@ -0,0 +1,31 @@
// 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
{
BIN_TOOLS_DEFAULT_VERSION = 0, //!< Default version
BIN_TOOLS_VERSION_1 = 1, //!< Does not write CurveOnSurface UV Points
//! into the file. On reading calls Check() method.
BIN_TOOLS_VERSION_2 = 2, //!< Stores CurveOnSurface UV Points.
//! On reading format is recognized from Version string.
BIN_TOOLS_VERSION_3 = 3,
BIN_TOOLS_VERSION_4 = 4 //!< Stores per-vertex normal information in case
//! of triangulation-only Faces, because
//! no analytical geometry to restore normals
};
#endif

View File

@@ -55,9 +55,11 @@
#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)";
Standard_CString BinTools_ShapeSet::Version_4 = "Open CASCADE Topology V4 (c)";
//=======================================================================
//function : operator << (gp_Pnt)
//purpose :
@@ -76,7 +78,7 @@ static Standard_OStream& operator <<(Standard_OStream& OS, const gp_Pnt P)
//=======================================================================
BinTools_ShapeSet::BinTools_ShapeSet(const Standard_Boolean isWithTriangles)
:myFormatNb(3), myWithTriangles(isWithTriangles)
:myFormatNb(THE_CURRENT_VERSION), myWithTriangles(isWithTriangles)
{}
//=======================================================================
@@ -93,6 +95,10 @@ BinTools_ShapeSet::~BinTools_ShapeSet()
//=======================================================================
void BinTools_ShapeSet::SetFormatNb(const Standard_Integer theFormatNb)
{
Standard_ASSERT_RETURN(theFormatNb >= BIN_TOOLS_VERSION_1 &&
theFormatNb <= THE_CURRENT_VERSION,
"Error: unsupported BinTools version.", );
myFormatNb = theFormatNb;
}
@@ -255,7 +261,11 @@ void BinTools_ShapeSet::AddGeometry(const TopoDS_Shape& S)
}
}
else if (CR->IsPolygonOnTriangulation()) {
myTriangulations.Add(CR->Triangulation());
// NCollection_IndexedDataMap::Add() function use is correct because
// Bin(Brep)Tools_ShapeSet::AddGeometry() is called from Bin(Brep)Tools_ShapeSet::Add()
// that processes shapes recursively from complex to elementary ones.
// As a result, the TopAbs_FACE's will be processed earlier than the TopAbs_EDGE's.
myTriangulations.Add(CR->Triangulation(), Standard_False); // edge triangulation does not need normals
myNodes.Add(CR->PolygonOnTriangulation());
ChangeLocations().Add(CR->Location());
if (CR->IsPolygonOnClosedTriangulation())
@@ -276,14 +286,21 @@ void BinTools_ShapeSet::AddGeometry(const TopoDS_Shape& S)
else if (S.ShapeType() == TopAbs_FACE) {
// Add the surface geometry
Standard_Boolean needNormals(Standard_False);
Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(S.TShape());
if (!TF->Surface().IsNull()) mySurfaces.Add(TF->Surface());
if (!TF->Surface().IsNull())
{
mySurfaces.Add(TF->Surface());
}
else
{
needNormals = Standard_True;
}
if (myWithTriangles
|| TF->Surface().IsNull())
{
Handle(Poly_Triangulation) Tr = TF->Triangulation();
if (!Tr.IsNull()) myTriangulations.Add(Tr);
if (!Tr.IsNull()) myTriangulations.Add(Tr, needNormals);
}
ChangeLocations().Add(TF->Location());
@@ -327,12 +344,22 @@ void BinTools_ShapeSet::Write (Standard_OStream& OS,
{
// write the copyright
if (myFormatNb == 3)
if (myFormatNb == BIN_TOOLS_VERSION_4)
{
OS << "\n" << Version_4 << "\n";
}
else if (myFormatNb == BIN_TOOLS_VERSION_3)
{
OS << "\n" << Version_3 << "\n";
else if (myFormatNb == 2)
}
else if (myFormatNb == BIN_TOOLS_VERSION_2)
{
OS << "\n" << Version_2 << "\n";
}
else
{
OS << "\n" << Version_1 << "\n";
}
//-----------------------------------------
// write the locations
@@ -413,15 +440,28 @@ void BinTools_ShapeSet::Read (Standard_IStream& IS,
}
} while ( ! IS.fail() && strcmp(vers,Version_1) && strcmp(vers,Version_2) &&
strcmp(vers,Version_3));
strcmp(vers,Version_3) && strcmp(vers,Version_4));
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_4) == 0)
{
SetFormatNb(BIN_TOOLS_VERSION_4);
}
else if (strcmp(vers, Version_3) == 0)
{
SetFormatNb(BIN_TOOLS_VERSION_3);
}
else if (strcmp(vers, Version_2) == 0)
{
SetFormatNb(BIN_TOOLS_VERSION_2);
}
else
{
SetFormatNb(BIN_TOOLS_VERSION_1);
}
//-----------------------------------------
// read the locations
@@ -481,7 +521,7 @@ void BinTools_ShapeSet::Read (Standard_IStream& IS,
S.Free(aFree);
S.Modified(aMod);
if (myFormatNb >= 2)
if (myFormatNb >= BIN_TOOLS_VERSION_2)
S.Checked(aChecked);
else
S.Checked (Standard_False); // force check at reading..
@@ -491,7 +531,7 @@ void BinTools_ShapeSet::Read (Standard_IStream& IS,
S.Convex (aConv);
// check
if (myFormatNb == 1)
if (myFormatNb == BIN_TOOLS_VERSION_1)
if(T == TopAbs_FACE) {
const TopoDS_Face& F = TopoDS::Face(S);
BRepTools::Update(F);
@@ -684,7 +724,7 @@ void BinTools_ShapeSet::WriteGeometry (const TopoDS_Shape& S,
BinTools::PutReal(OS, last);
// Write UV Points for higher performance
if (FormatNb() >= 2)
if (myFormatNb >= BIN_TOOLS_VERSION_2)
{
gp_Pnt2d Pf,Pl;
if (CR->IsCurveOnClosedSurface()) {
@@ -828,7 +868,7 @@ void BinTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T,
BRep_ListOfPointRepresentation& lpr = TV->ChangePoints();
TopLoc_Location L;
Standard_Boolean aNewF = (myFormatNb > 2);
Standard_Boolean aNewF = (myFormatNb >= BIN_TOOLS_VERSION_3);
do {
if(aNewF) {
val = (Standard_Integer)IS.get();//case {0|1|2|3}
@@ -992,7 +1032,7 @@ void BinTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T,
BinTools::GetReal(IS, last);
// read UV Points // for XML Persistence higher performance
if (FormatNb() >= 2)
if (myFormatNb >= BIN_TOOLS_VERSION_2)
{
BinTools::GetReal(IS, PfX);
BinTools::GetReal(IS, PfY);
@@ -1008,7 +1048,7 @@ void BinTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T,
break;
if (closed) {
if (FormatNb() >= 2)
if (myFormatNb >= BIN_TOOLS_VERSION_2)
myBuilder.UpdateEdge(E,myCurves2d.Curve2d(pc),
myCurves2d.Curve2d(pc2),
mySurfaces.Surface(s),
@@ -1029,7 +1069,7 @@ void BinTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T,
}
else
{
if (FormatNb() >= 2)
if (myFormatNb >= BIN_TOOLS_VERSION_2)
myBuilder.UpdateEdge(E,myCurves2d.Curve2d(pc),
mySurfaces.Surface(s),
Locations().Location(l),tol,
@@ -1080,11 +1120,11 @@ void BinTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T,
BinTools::GetInteger(IS, l);
if (closed)
{
myBuilder.UpdateEdge (E, myNodes(pt), myNodes(pt2), myTriangulations(t), Locations().Location(l));
myBuilder.UpdateEdge (E, myNodes(pt), myNodes(pt2), myTriangulations.FindKey(t), Locations().Location(l));
}
else
{
myBuilder.UpdateEdge (E, myNodes(pt), myTriangulations(t), Locations().Location(l));
myBuilder.UpdateEdge (E, myNodes(pt), myTriangulations.FindKey(t), Locations().Location(l));
}
// range
break;
@@ -1133,7 +1173,7 @@ void BinTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T,
// cas triangulation
if(aByte == 2) {
BinTools::GetInteger(IS, s);
myBuilder.UpdateFace(TopoDS::Face(S), myTriangulations(s));
myBuilder.UpdateFace(TopoDS::Face(S), myTriangulations.FindKey(s));
}
}
break;
@@ -1446,11 +1486,16 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
for (Standard_Integer aTriangulationIter = 1; aTriangulationIter <= aNbTriangulations && aPS.More(); ++aTriangulationIter, aPS.Next())
{
const Handle(Poly_Triangulation)& aTriangulation = myTriangulations.FindKey (aTriangulationIter);
Standard_Boolean NeedToWriteNormals = myTriangulations.FindFromIndex(aTriangulationIter);
const Standard_Integer aNbNodes = aTriangulation->NbNodes();
const Standard_Integer aNbTriangles = aTriangulation->NbTriangles();
BinTools::PutInteger(OS, aNbNodes);
BinTools::PutInteger(OS, aNbTriangles);
BinTools::PutBool(OS, aTriangulation->HasUVNodes() ? 1 : 0);
if (myFormatNb >= BIN_TOOLS_VERSION_4)
{
BinTools::PutBool(OS, (aTriangulation->HasNormals() && NeedToWriteNormals) ? 1 : 0);
}
BinTools::PutReal(OS, aTriangulation->Deflection());
// write the 3d nodes
@@ -1482,6 +1527,20 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
BinTools::PutInteger(OS, aTri.Value (2));
BinTools::PutInteger(OS, aTri.Value (3));
}
// write the normals
if (myFormatNb >= BIN_TOOLS_VERSION_4)
{
if (aTriangulation->HasNormals() && NeedToWriteNormals)
{
const TShort_Array1OfShortReal& aNormals = aTriangulation->Normals();
for (Standard_Integer aNormalIter = 1; aNormalIter <= 3 * aNbNodes; ++aNormalIter)
{
const Standard_ShortReal& aNormal = aNormals.Value(aNormalIter);
BinTools::PutShortReal(OS, aNormal);
}
}
}
}
}
catch (Standard_Failure const& anException)
@@ -1518,12 +1577,17 @@ void BinTools_ShapeSet::ReadTriangulation (Standard_IStream& IS,
{
Standard_Integer aNbNodes = 0, aNbTriangles = 0;
Standard_Boolean hasUV = Standard_False;
Standard_Boolean hasNormals = Standard_False;
Standard_Real aDefl = 0.0;
BinTools::GetInteger(IS, aNbNodes);
BinTools::GetInteger(IS, aNbTriangles);
BinTools::GetBool(IS, hasUV);
if (myFormatNb >= BIN_TOOLS_VERSION_4)
{
BinTools::GetBool(IS, hasNormals);
}
BinTools::GetReal(IS, aDefl); //deflection
Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation (aNbNodes, aNbTriangles, hasUV);
Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation (aNbNodes, aNbTriangles, hasUV, hasNormals);
aTriangulation->Deflection (aDefl);
TColgp_Array1OfPnt& aNodes = aTriangulation->ChangeNodes();
@@ -1556,7 +1620,19 @@ void BinTools_ShapeSet::ReadTriangulation (Standard_IStream& IS,
BinTools::GetInteger(IS, aTri.ChangeValue (3));
}
myTriangulations.Add (aTriangulation);
if (hasNormals)
{
TShort_Array1OfShortReal& aNormals = aTriangulation->ChangeNormals();
for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes*3; ++aNormalIter)
{
Standard_ShortReal aNormalFromFile;
BinTools::GetShortReal(IS, aNormalFromFile);
Standard_ShortReal& aNormalCoordinate = aNormals.ChangeValue(aNormalIter);
aNormalCoordinate = aNormalFromFile;
}
}
myTriangulations.Add (aTriangulation, hasNormals);
}
}
catch (Standard_Failure const& anException)

View File

@@ -21,6 +21,7 @@
#include <Standard_Handle.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BinTools_FormatVersion.hxx>
#include <BinTools_LocationSet.hxx>
#include <Standard_Integer.hxx>
#include <BRep_Builder.hxx>
@@ -58,13 +59,10 @@ public:
//! Ignored (always written) if face defines only triangulation (no surface).
void SetWithTriangles (const Standard_Boolean isWithTriangles) { myWithTriangles = isWithTriangles; }
//! 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.
@@ -194,6 +192,14 @@ public:
(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;
static Standard_CString Version_4;
static const BinTools_FormatVersion THE_CURRENT_VERSION = BIN_TOOLS_VERSION_4;
private:
TopTools_IndexedMapOfShape myShapes;
@@ -205,7 +211,9 @@ private:
BinTools_Curve2dSet myCurves2d;
NCollection_IndexedMap<Handle(Poly_Polygon2D), TColStd_MapTransientHasher> myPolygons2D;
NCollection_IndexedMap<Handle(Poly_Polygon3D), TColStd_MapTransientHasher> myPolygons3D;
NCollection_IndexedMap<Handle(Poly_Triangulation), TColStd_MapTransientHasher> myTriangulations;
NCollection_IndexedDataMap<Handle(Poly_Triangulation),
Standard_Boolean> myTriangulations; //!< Contains a boolean flag with information
//! to save normals for triangulation
NCollection_IndexedMap<Handle(Poly_PolygonOnTriangulation), TColStd_MapTransientHasher> myNodes;
Standard_Boolean myWithTriangles;

View File

@@ -4,6 +4,7 @@ BinTools_Curve2dSet.cxx
BinTools_Curve2dSet.hxx
BinTools_CurveSet.cxx
BinTools_CurveSet.hxx
BinTools_FormatVersion.hxx
BinTools_LocationSet.cxx
BinTools_LocationSet.hxx
BinTools_LocationSetPtr.hxx

View File

@@ -14,7 +14,7 @@
// 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>
@@ -27,6 +27,7 @@
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <Draw_ProgressIndicator.hxx>
#include <Draw_SaveAndRestore.hxx>
#include <Message_ProgressRange.hxx>
#include <Draw_Segment3D.hxx>
#include <gp_Ax2.hxx>
@@ -1379,24 +1380,66 @@ static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc,
// binsave
//=======================================================================
static Standard_Integer binsave(Draw_Interpretor& di, Standard_Integer n, const char** a)
static Standard_Integer binsave(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (n <= 2) return 1;
if (argc < 3)
{
di << "Syntax error: wrong number of arguments!\n";
di.PrintHelp(argv[0]);
return 1;
}
TopoDS_Shape aShape = DBRep::Get (a[1]);
BinTools_FormatVersion aVersion = BinTools_ShapeSet::THE_CURRENT_VERSION;
for (Standard_Integer i = 3; i < argc; ++i)
{
TCollection_AsciiString aParam(argv[i]);
aParam.LowerCase();
if (aParam == "-version")
{
++i;
if (i < argc)
{
aVersion = static_cast<BinTools_FormatVersion>(Draw::Atoi(argv[i]));
}
if (aVersion == BIN_TOOLS_DEFAULT_VERSION)
{
aVersion = BinTools_ShapeSet::THE_CURRENT_VERSION;
}
if (aVersion < BIN_TOOLS_VERSION_1)
{
di << "Version must not be negative\n";
return 1;
}
if (aVersion > BinTools_ShapeSet::THE_CURRENT_VERSION)
{
di << "Version higher than "
<< BinTools_ShapeSet::THE_CURRENT_VERSION
<< " is not supported\n";
return 1;
}
}
else
{
di << "Syntax error: unknown argument '" << aParam << "'\n";
return 1;
}
}
TopoDS_Shape aShape = DBRep::Get (argv[1]);
if (aShape.IsNull())
{
di << a[1] << " is not a shape";
di << argv[1] << " is not a shape";
return 1;
}
if (!BinTools::Write (aShape, a[2]))
if (!BinTools::Write (aShape, argv[2]))
{
di << "Cannot write to the file " << a[2];
di << "Cannot write to the file " << argv[2];
return 1;
}
di << a[1];
di << argv[1];
return 0;
}
@@ -1573,60 +1616,68 @@ Standard_Real DBRep::HLRAngle()
{ return anglHLR; }
//=======================================================================
//function :
//purpose : save and restore shapes
//class : DBRep_SaveAndRestore
//=======================================================================
static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
class DBRep_SaveAndRestore : public Draw_SaveAndRestoreBase
{
return d->IsInstance(STANDARD_TYPE(DBRep_DrawableShape));
}
public:
DBRep_SaveAndRestore()
:Draw_SaveAndRestoreBase("DBRep_DrawableShape") {}
static void ssave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
{
Handle(DBRep_DrawableShape)
N = Handle(DBRep_DrawableShape)::DownCast(d);
BRep_Builder B;
BRepTools_ShapeSet S(B);
S.Add (N->Shape());
Handle(Draw_ProgressIndicator) aProgress = Draw::GetProgressBar();
S.Write(OS, Message_ProgressIndicator::Start(aProgress));
if (! aProgress.IsNull() && aProgress->UserBreak())
return;
S.Write(N->Shape(),OS);
}
Standard_Boolean Test(const Handle(Draw_Drawable3D)& d) const Standard_OVERRIDE
{
return d->IsInstance(STANDARD_TYPE(DBRep_DrawableShape));
}
void Save(const Handle(Draw_Drawable3D)&d, std::ostream& OS, TopTools_FormatVersion theVersion) const Standard_OVERRIDE
{
Handle(DBRep_DrawableShape) N = Handle(DBRep_DrawableShape)::DownCast(d);
BRep_Builder B;
BRepTools_ShapeSet S(B);
S.SetFormatNb(theVersion);
S.Add (N->Shape());
Handle(Draw_ProgressIndicator) aProgress = Draw::GetProgressBar();
S.Write(OS, Message_ProgressIndicator::Start(aProgress));
if (! aProgress.IsNull() && aProgress->UserBreak())
return;
S.Write(N->Shape(),OS);
}
Handle(Draw_Drawable3D) Restore(std::istream& IS) const Standard_OVERRIDE
{
BRep_Builder B;
BRepTools_ShapeSet S(B);
Handle(Draw_ProgressIndicator) aProgress = Draw::GetProgressBar();
S.Read(IS, Message_ProgressIndicator::Start(aProgress));
Handle(DBRep_DrawableShape) N;
if (! aProgress.IsNull() && aProgress->UserBreak())
return N;
TopoDS_Shape theShape;
S.Read(theShape,IS );
N = new DBRep_DrawableShape(theShape,
Draw_vert,
Draw_jaune,
Draw_rouge,
Draw_bleu,
size,
nbIsos,
discret);
N->DisplayTriangulation(disptriangles);
N->DisplayPolygons(disppolygons);
N->DisplayHLR(withHLR,withRg1,withRgN,withHid,anglHLR);
static Handle(Draw_Drawable3D) srestore (std::istream& IS)
{
BRep_Builder B;
BRepTools_ShapeSet S(B);
Handle(Draw_ProgressIndicator) aProgress = Draw::GetProgressBar();
S.Read(IS, Message_ProgressIndicator::Start(aProgress));
Handle(DBRep_DrawableShape) N;
if (! aProgress.IsNull() && aProgress->UserBreak())
return N;
TopoDS_Shape theShape;
S.Read(theShape,IS );
N = new DBRep_DrawableShape(theShape,
Draw_vert,
Draw_jaune,
Draw_rouge,
Draw_bleu,
size,
nbIsos,
discret);
N->DisplayTriangulation(disptriangles);
N->DisplayPolygons(disppolygons);
N->DisplayHLR(withHLR,withRg1,withRgN,withHid,anglHLR);
return N;
}
}
};
static Draw_SaveAndRestore ssr("DBRep_DrawableShape",
stest,ssave,srestore);
static DBRep_SaveAndRestore saveAndRestoreDBRep;
//=======================================================================
//function : dumps
//purpose :
//=======================================================================
void dumps (const TopoDS_Shape& S)
{
BRepTools::Dump(S,std::cout);

View File

@@ -37,35 +37,8 @@ extern Draw_Viewer dout;
extern Standard_Boolean Draw_Batch;
#endif
class Draw_SaveAndRestore {
public :
Standard_EXPORT Draw_SaveAndRestore
(const char* name,
Standard_Boolean (*test)(const Handle(Draw_Drawable3D)&),
void (*save)(const Handle(Draw_Drawable3D)&, std::ostream&),
Handle(Draw_Drawable3D) (*restore) (std::istream&),
Standard_Boolean display = Standard_True);
const char* Name() const {return myName;}
Standard_Boolean Test(const Handle(Draw_Drawable3D)&d);
void Save(const Handle(Draw_Drawable3D)& d, std::ostream& os) const;
Handle(Draw_Drawable3D) Restore(std::istream&) const;
Standard_Boolean Disp() const {return myDisplay;}
Draw_SaveAndRestore* Next() {return myNext;}
private :
const char* myName;
Standard_Boolean (*myTest)(const Handle(Draw_Drawable3D)&);
void (*mySave)(const Handle(Draw_Drawable3D)&, std::ostream&);
Handle(Draw_Drawable3D) (*myRestore) (std::istream&);
Standard_Boolean myDisplay;
Draw_SaveAndRestore* myNext;
};
#endif

View File

@@ -0,0 +1,75 @@
// 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.
#include <Draw_SaveAndRestore.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools_ShapeSet.hxx>
#include <DBRep_DrawableShape.hxx>
#include <Draw_Number.hxx>
#include <Draw_ProgressIndicator.hxx>
Draw_SaveAndRestoreBase* Draw_SaveAndRestoreBase::Draw_FirstSaveAndRestore = NULL;
// ================================================================
// Function : Draw_SaveAndRestoreBase
// Purpose :
// ================================================================
Draw_SaveAndRestoreBase::Draw_SaveAndRestoreBase (Standard_CString theName, Standard_Boolean theDisplay)
: myNext(Draw_FirstSaveAndRestore),
myName (theName),
myDisplay (theDisplay)
{
Draw_FirstSaveAndRestore = this;
}
// ================================================================
// Function : Test
// Purpose :
// ================================================================
Standard_Boolean Draw_SaveAndRestoreNumber::Test (const Handle(Draw_Drawable3D)& theDrawable3D) const
{
return theDrawable3D->IsInstance(STANDARD_TYPE(Draw_Number));
}
// ================================================================
// Function : Save
// Purpose :
// ================================================================
void Draw_SaveAndRestoreNumber::Save (const Handle(Draw_Drawable3D)& theDrawable3D,
std::ostream& theStream,
TopTools_FormatVersion theVersion) const
{
(void) theVersion;
Handle(Draw_Number) aNum = Handle(Draw_Number)::DownCast(theDrawable3D);
std::ios::fmtflags aFlags = theStream.flags();
theStream.setf(std::ios::scientific);
theStream.precision(15);
theStream.width(30);
theStream << aNum->Value() << "\n";
theStream.setf(aFlags);
}
// ================================================================
// Function : Restore
// Purpose :
// ================================================================
Handle(Draw_Drawable3D) Draw_SaveAndRestoreNumber::Restore (std::istream& is) const
{
Standard_Real val = RealLast();
is >> val;
Handle(Draw_Number) N = new Draw_Number(val);
return N;
}
static Draw_SaveAndRestoreNumber saveAndRestoreNumber;

View File

@@ -0,0 +1,65 @@
// 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 Draw_SaveAndRestore_HeaderFile
#define Draw_SaveAndRestore_HeaderFile
#include <Draw.hxx>
#include <TopTools_FormatVersion.hxx>
class Draw_SaveAndRestoreBase
{
public:
static Draw_SaveAndRestoreBase* GetFirst() { return Draw_FirstSaveAndRestore; }
public:
Standard_EXPORT Draw_SaveAndRestoreBase (Standard_CString thename,
Standard_Boolean theDisplay = Standard_True);
public:
virtual void Save (const Handle(Draw_Drawable3D)& theDrawable3D,
std::ostream& theStream,
TopTools_FormatVersion theVersion) const = 0;
virtual Handle(Draw_Drawable3D) Restore (std::istream& is) const = 0;
virtual Standard_Boolean Test (const Handle(Draw_Drawable3D)& theDrawable3D) const = 0;
Standard_CString Name() const { return myName; }
const Draw_SaveAndRestoreBase* Next() const { return myNext; }
Standard_Boolean Disp() const { return myDisplay; }
private:
Draw_SaveAndRestoreBase* myNext;
Standard_CString myName;
Standard_Boolean myDisplay;
private:
static Draw_SaveAndRestoreBase* Draw_FirstSaveAndRestore;
};
class Draw_SaveAndRestoreNumber : public Draw_SaveAndRestoreBase
{
public:
Draw_SaveAndRestoreNumber()
: Draw_SaveAndRestoreBase ("Draw_Number", Standard_False) {}
Standard_EXPORT virtual void Save (const Handle(Draw_Drawable3D)& theDrawable3D,
std::ostream& theStream,
TopTools_FormatVersion theVersion) const Standard_OVERRIDE;
Standard_EXPORT virtual Handle(Draw_Drawable3D) Restore (std::istream& is) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Test (const Handle(Draw_Drawable3D)& theDrawable3D) const Standard_OVERRIDE;
};
#endif

View File

@@ -25,12 +25,14 @@
#include <Draw_Number.hxx>
#include <Message.hxx>
#include <Draw_ProgressIndicator.hxx>
#include <Draw_SaveAndRestore.hxx>
#include <Draw_SequenceOfDrawable3D.hxx>
#include <Message.hxx>
#include <NCollection_Map.hxx>
#include <Standard_SStream.hxx>
#include <Standard_Stream.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopTools_ShapeSet.hxx>
#include <ios>
#ifdef _WIN32
@@ -68,82 +70,57 @@ static Standard_Integer p_b;
static const char* p_Name = "";
static Draw_SaveAndRestore* Draw_First = NULL;
//=======================================================================
//function : Draw_SaveAndRestore
//purpose :
//=======================================================================
Draw_SaveAndRestore::Draw_SaveAndRestore
(const char* name,
Standard_Boolean (*test)(const Handle(Draw_Drawable3D)&),
void (*save)(const Handle(Draw_Drawable3D)&, std::ostream&),
Handle(Draw_Drawable3D) (*restore) (std::istream&),
Standard_Boolean display) :
myName(name),
myTest(test),
mySave(save),
myRestore(restore),
myDisplay(display),
myNext(Draw_First)
{
Draw_First = this;
}
Standard_Boolean Draw_SaveAndRestore::Test(const Handle(Draw_Drawable3D)&d)
{return (*myTest) (d);}
void Draw_SaveAndRestore::Save(const Handle(Draw_Drawable3D)& d,
std::ostream& os) const
{ (*mySave) (d,os);}
Handle(Draw_Drawable3D) Draw_SaveAndRestore::Restore(std::istream& is) const
{return (*myRestore) (is);}
//=======================================================================
// numeric save and restore
//=======================================================================
static Standard_Boolean numtest(const Handle(Draw_Drawable3D)& d)
{
return d->IsInstance(STANDARD_TYPE(Draw_Number));
}
static void numsave (const Handle(Draw_Drawable3D)& theDrawable,
std::ostream& theStream)
{
Handle(Draw_Number) aNum = Handle(Draw_Number)::DownCast (theDrawable);
std::ios::fmtflags aFlags = theStream.flags();
theStream.setf (std::ios::scientific);
theStream.precision (15);
theStream.width (30);
theStream << aNum->Value() << "\n";
theStream.setf (aFlags);
}
static Handle(Draw_Drawable3D) numrestore (std::istream& is)
{
Standard_Real val;
is >> val;
Handle(Draw_Number) N = new Draw_Number(val);
return N;
}
static Draw_SaveAndRestore numsr("Draw_Number",
numtest,numsave,numrestore,
Standard_False);
//=======================================================================
// save
//=======================================================================
static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const char** a)
static Standard_Integer save(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (n <= 2) return 1;
if (argc < 3)
{
di << "Syntax error: wrong number of arguments!\n";
di.PrintHelp(argv[0]);
return 1;
}
const char* name = a[2];
TopTools_FormatVersion aVersion = TopTools_ShapeSet::THE_CURRENT_VERSION;
for (Standard_Integer i = 3; i < argc; ++i)
{
TCollection_AsciiString aParam(argv[i]);
aParam.LowerCase();
if (aParam == "-version")
{
++i;
if (i < argc)
{
aVersion = static_cast<TopTools_FormatVersion>(Draw::Atoi(argv[i]));
}
if (aVersion == TOP_TOOLS_DEFAULT_VERSION)
{
aVersion = TopTools_ShapeSet::THE_CURRENT_VERSION;
}
if (aVersion < TOP_TOOLS_VERSION_1)
{
di << "Version must not be negative\n";
return 1;
}
if (aVersion > TopTools_ShapeSet::THE_CURRENT_VERSION)
{
di << "Version higher than "
<< static_cast<Standard_Integer>(TopTools_ShapeSet::THE_CURRENT_VERSION)
<< " is not supported\n"; \
return 1;
}
}
else
{
di << "Syntax error: unknown argument '" << aParam << "'\n";
return 1;
}
}
Standard_CString name = argv[2];
std::ofstream os;
os.precision(15);
OSD_OpenStream(os, name, std::ios::out);
@@ -153,10 +130,10 @@ static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const cha
return 1;
}
Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
Handle(Draw_Drawable3D) D = Draw::Get(argv[1]);
if (!D.IsNull()) {
// find a tool
Draw_SaveAndRestore* tool = Draw_First;
const Draw_SaveAndRestoreBase* tool = Draw_SaveAndRestoreBase::GetFirst();
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
while (tool) {
@@ -166,13 +143,14 @@ static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const cha
if (tool) {
os << tool->Name() << "\n";
Draw::SetProgressBar(progress);
tool->Save(D,os);
tool->Save(D, os, aVersion);
os << "\n";
}
else {
di << "No method for saving " << a[1];
di << "No method for saving " << argv[1];
return 1;
}
Draw::SetProgressBar( 0 );
}
@@ -189,7 +167,7 @@ static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const cha
return 1;
}
di << a[1];
di << argv[1];
return 0;
}
@@ -220,10 +198,10 @@ static Standard_Integer restore(Draw_Interpretor& di, Standard_Integer n, const
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
Draw::SetProgressBar(progress);
Draw_SaveAndRestore* tool = Draw_First;
Draw_SaveAndRestore* aDBRepTool = NULL;
const Draw_SaveAndRestoreBase* tool = Draw_SaveAndRestoreBase::GetFirst();
const Draw_SaveAndRestoreBase* aDBRepTool = NULL;
while (tool) {
const char* toolName = tool->Name();
Standard_CString toolName = tool->Name();
if (!strcmp(typ,toolName)) break;
if (!strcmp("DBRep_DrawableShape",toolName))
aDBRepTool = tool;

View File

@@ -54,6 +54,8 @@ Draw_Printer.hxx
Draw_ProgressIndicator.cxx
Draw_ProgressIndicator.hxx
Draw_Replace.tcl
Draw_SaveAndRestore.cxx
Draw_SaveAndRestore.hxx
Draw_Segment2D.cxx
Draw_Segment2D.hxx
Draw_Segment3D.cxx

View File

@@ -261,14 +261,41 @@ proc datadir {{dir ""}} {
return $Draw_DataDir
}
help save {save variable [filename]} "DRAW Variables management"
help save {
Use: save variable [filename] [options...]
Allowed options are:
-version versnumber: a number of format version to save.
Awailable versions are 1, 2, 3
Default version is 3
} "DRAW Variables management"
proc save {name {file ""}} {
proc save {name {file ""} {args {}}} {
# set default values of arguments
set version 0
# check arguments
for {set narg 0} {$narg < [llength $args]} {incr narg} {
set arg [lindex $args $narg]
# set version
if { $arg == "-version" } {
incr narg
if { $narg < [llength $args] && ! [regexp {^-} [lindex $args $narg]] } {
set version [lindex $args $narg]
} else {
error "Option -version requires argument"
}
continue
}
# unsupported option
error "Error: unsupported option \"$arg\""
}
if {$file == ""} {set file $name}
upvar $name n
if {![isdraw n]} {error "save : $name is not a Draw variable"}
global Draw_DataDir
bsave n [file join $Draw_DataDir $file]
bsave n [file join $Draw_DataDir $file] "-version" $version
return [file join $Draw_DataDir $file]
}

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,7 @@
#include <DBRep.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <Draw_SaveAndRestore.hxx>
#include <gp_Ax3.hxx>
#include <HLRAlgo_Projector.hxx>
#include <HLRAppli_ReflectLines.hxx>
@@ -596,91 +597,84 @@ void HLRTest::Commands (Draw_Interpretor& theCommands)
}
//=======================================================================
//function : save and restore projector
//purpose :
// class : HLRTest_SaveAndRestore
//=======================================================================
static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
class HLRTest_SaveAndRestore : public Draw_SaveAndRestoreBase
{
return d->IsInstance(STANDARD_TYPE(HLRTest_Projector));
}
public:
//=======================================================================
//function : ssave
//purpose :
//=======================================================================
HLRTest_SaveAndRestore()
:Draw_SaveAndRestoreBase("HLRTest_Projector") {}
static void ssave (const Handle(Draw_Drawable3D)&d, std::ostream& OS)
{
Handle(HLRTest_Projector) HP =
Handle(HLRTest_Projector)::DownCast(d);
Standard_Boolean Test(const Handle(Draw_Drawable3D)& d) const Standard_OVERRIDE
{
return d->IsInstance(STANDARD_TYPE(HLRTest_Projector));
}
const HLRAlgo_Projector& P = HP->Projector();
OS << (P.Perspective() ? "1" : "0") << "\n";
if (P.Perspective())
OS << P.Focus() << "\n";
void Save(const Handle(Draw_Drawable3D)& d, std::ostream& OS, TopTools_FormatVersion theVersion) const Standard_OVERRIDE
{
(void) theVersion;
Handle(HLRTest_Projector) HP =
Handle(HLRTest_Projector)::DownCast(d);
const HLRAlgo_Projector& P = HP->Projector();
OS << (P.Perspective() ? "1" : "0") << "\n";
if (P.Perspective())
OS << P.Focus() << "\n";
gp_Trsf T = P.Transformation();
gp_XYZ V = T.TranslationPart();
gp_Mat M = T.VectorialPart();
gp_Trsf T = P.Transformation();
gp_XYZ V = T.TranslationPart();
gp_Mat M = T.VectorialPart();
OS << M(1,1) << " ";
OS << M(1,2) << " ";
OS << M(1,3) << " ";
OS << V.Coord(1) << " ";
OS << "\n";
OS << M(2,1) << " ";
OS << M(2,2) << " ";
OS << M(2,3) << " ";
OS << V.Coord(2) << " ";
OS << "\n";
OS << M(3,1) << " ";
OS << M(3,2) << " ";
OS << M(3,3) << " ";
OS << V.Coord(3) << " ";
OS << "\n";
OS << M(1,1) << " ";
OS << M(1,2) << " ";
OS << M(1,3) << " ";
OS << V.Coord(1) << " ";
OS << "\n";
OS << M(2,1) << " ";
OS << M(2,2) << " ";
OS << M(2,3) << " ";
OS << V.Coord(2) << " ";
OS << "\n";
OS << M(3,1) << " ";
OS << M(3,2) << " ";
OS << M(3,3) << " ";
OS << V.Coord(3) << " ";
OS << "\n";
}
}
//=======================================================================
//function : srestore
//purpose :
//=======================================================================
static Handle(Draw_Drawable3D) srestore (std::istream& IS)
{
Standard_Boolean pers;
IS >> pers;
Standard_Real focus = 1;
if (pers) IS >> focus;
Handle(Draw_Drawable3D) Restore(std::istream& IS) const Standard_OVERRIDE
{
Standard_Boolean pers;
IS >> pers;
Standard_Real focus = 1;
if (pers) IS >> focus;
gp_Trsf T;
Standard_Real V1[3],V2[3],V3[3];
Standard_Real V[3];
gp_Trsf T;
Standard_Real V1[3],V2[3],V3[3];
Standard_Real V[3];
IS >> V1[0] >> V1[1] >> V1[2] >> V[0];
IS >> V2[0] >> V2[1] >> V2[2] >> V[1];
IS >> V3[0] >> V3[1] >> V3[2] >> V[2];
IS >> V1[0] >> V1[1] >> V1[2] >> V[0];
IS >> V2[0] >> V2[1] >> V2[2] >> V[1];
IS >> V3[0] >> V3[1] >> V3[2] >> V[2];
gp_Dir D1(V1[0],V1[1],V1[2]);
gp_Dir D2(V2[0],V2[1],V2[2]);
gp_Dir D3(V3[0],V3[1],V3[2]);
gp_Ax3 axes(gp_Pnt(0,0,0),D3,D1);
D3.Cross(D1);
if (D3.Dot(D2) < 0) axes.YReverse();
T.SetTransformation(axes);
gp_Dir D1(V1[0],V1[1],V1[2]);
gp_Dir D2(V2[0],V2[1],V2[2]);
gp_Dir D3(V3[0],V3[1],V3[2]);
gp_Ax3 axes(gp_Pnt(0,0,0),D3,D1);
D3.Cross(D1);
if (D3.Dot(D2) < 0) axes.YReverse();
T.SetTransformation(axes);
T.SetTranslationPart(gp_Vec(V[0],V[1],V[2]));
T.SetTranslationPart(gp_Vec(V[0],V[1],V[2]));
HLRAlgo_Projector P(T,pers,focus);
Handle(HLRTest_Projector) HP = new HLRTest_Projector(P);
return HP;
}
HLRAlgo_Projector P(T,pers,focus);
Handle(HLRTest_Projector) HP = new HLRTest_Projector(P);
return HP;
}
//=======================================================================
//function : ssr
//purpose :
//=======================================================================
};
static Draw_SaveAndRestore ssr("HLRTest_Projector",stest,ssave,srestore);
static HLRTest_SaveAndRestore saveAndRestoreHLRTest;

View File

@@ -41,9 +41,30 @@ Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
//=======================================================================
//function : Poly_Triangulation
//purpose :
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
const Standard_Integer theNbTriangles,
const Standard_Boolean theHasUVNodes,
const Standard_Boolean theHasNormals)
: myDeflection(0),
myNodes (1, theNbNodes),
myTriangles (1, theNbTriangles)
{
if (theHasUVNodes)
{
myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
}
if (theHasNormals)
{
myNormals = new TShort_HArray1OfShortReal(1, theNbNodes * 3);
}
}
//=======================================================================
//function : Poly_Triangulation
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& theNodes,
const Poly_Array1OfTriangle& theTriangles)
: myDeflection(0),

View File

@@ -76,6 +76,17 @@ public:
//! enable a 2D representation).
Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes, const Standard_Integer nbTriangles, const Standard_Boolean UVNodes);
//! Constructs a triangulation from a set of triangles.
//! The triangulation is initialized without a triangle or a node,
//! but capable of containing nbNodes nodes, and nbTriangles triangles.
//! Here the UVNodes flag indicates whether 2D nodes will be associated with 3D ones,
//! (i.e. to enable a 2D representation).
//! Here the hasNormals flag indicates whether normals will be given and associated with nodes.
Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes,
const Standard_Integer nbTriangles,
const Standard_Boolean UVNodes,
const Standard_Boolean hasNormals);
//! Constructs a triangulation from a set of triangles. The
//! triangulation is initialized with 3D points from Nodes and triangles
//! from Triangles.

View File

@@ -111,6 +111,11 @@ public:
Standard_EXPORT void SetNumberOfObjects (const Standard_Integer anObjectNumber);
Standard_EXPORT void SetStorageVersion (const TCollection_AsciiString& aVersion);
void SetStorageVersion (const Standard_Integer aVersion)
{
SetStorageVersion(TCollection_AsciiString(aVersion));
}
Standard_EXPORT void SetCreationDate (const TCollection_AsciiString& aDate);

View File

@@ -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

View File

@@ -0,0 +1,30 @@
// 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
{
TOP_TOOLS_DEFAULT_VERSION = 0, //!< Default version
TOP_TOOLS_VERSION_1 = 1, //!< Does not write CurveOnSurface UV Points into
//! the file. On reading calls Check() method.
TOP_TOOLS_VERSION_2 = 2, //!< Stores CurveOnSurface UV Points. On reading format is
//! recognized from Version string.
TOP_TOOLS_VERSION_3 = 3 //!< Stores per-vertex normal information in case
//! of triangulation-only Faces, because
//! no analytical geometry to restore normals
};
#endif

View File

@@ -28,18 +28,22 @@
#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";
Standard_CString TopTools_ShapeSet::Version_3 = "Open CASCADE Topology V3 (c)";
//=======================================================================
//function : TopTools_ShapeSet
//purpose :
//=======================================================================
TopTools_ShapeSet::TopTools_ShapeSet() : myFormatNb(1)
TopTools_ShapeSet::TopTools_ShapeSet() : myFormatNb(THE_CURRENT_VERSION)
{
}
@@ -52,6 +56,10 @@ TopTools_ShapeSet::~TopTools_ShapeSet()
//=======================================================================
void TopTools_ShapeSet::SetFormatNb(const Standard_Integer theFormatNb)
{
Standard_ASSERT_RETURN(theFormatNb >= TOP_TOOLS_VERSION_1 &&
theFormatNb <= THE_CURRENT_VERSION,
"Error: unsupported TopTools version.", );
myFormatNb = theFormatNb;
}
@@ -451,10 +459,18 @@ 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 == TOP_TOOLS_VERSION_3)
{
OS << "\n" << Version_3 << "\n";
}
else if (myFormatNb == TOP_TOOLS_VERSION_2)
{
OS << "\n" << Version_2 << "\n";
}
else
OS << "\n" << Version << "\n";
{
OS << "\n" << Version_1 << "\n";
}
//-----------------------------------------
// write the locations
@@ -606,14 +622,27 @@ 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) &&
strcmp(vers, Version_3));
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);
if (strcmp(vers, Version_3) == 0)
{
SetFormatNb(TOP_TOOLS_VERSION_3);
}
else if (strcmp(vers, Version_2) == 0)
{
SetFormatNb(TOP_TOOLS_VERSION_2);
}
else
{
SetFormatNb(TOP_TOOLS_VERSION_1);
}
//-----------------------------------------
// read the locations
@@ -681,7 +710,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 >= TOP_TOOLS_VERSION_2)
S.Checked (buffer[2] == '1');
else
S.Checked (Standard_False); // force check at reading..
@@ -693,7 +722,7 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS, const Message_ProgressRange&
// check
if (myFormatNb == 1)
if (myFormatNb == TOP_TOOLS_VERSION_1)
Check(T,S);
myShapes.Add(S);

View File

@@ -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,13 @@ public:
//! Returns number of shapes read from file.
Standard_EXPORT Standard_Integer NbShapes() const;
public:
static const TopTools_FormatVersion THE_CURRENT_VERSION = TOP_TOOLS_VERSION_3;
static Standard_CString Version_1;
static Standard_CString Version_2;
static Standard_CString Version_3;
private:
//! Reads from <IS> a shape and returns it in S.

View File

@@ -4,6 +4,7 @@ XmlLDrivers_DocumentRetrievalDriver.cxx
XmlLDrivers_DocumentRetrievalDriver.hxx
XmlLDrivers_DocumentStorageDriver.cxx
XmlLDrivers_DocumentStorageDriver.hxx
XmlLDrivers_FormatVersion.hxx
XmlLDrivers_NamespaceDef.cxx
XmlLDrivers_NamespaceDef.hxx
XmlLDrivers_SequenceOfNamespaceDef.hxx

View File

@@ -33,7 +33,6 @@
static Standard_GUID XmlLStorageDriver ("13a56820-8269-11d5-aab2-0050044b1af1");
static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1");
static int CURRENT_DOCUMENT_VERSION(9);
//=======================================================================
//function : Factory
@@ -128,9 +127,9 @@ Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers
//purpose : Document storage version
//=======================================================================
int XmlLDrivers::StorageVersion()
TCollection_AsciiString XmlLDrivers::StorageVersion()
{
return CURRENT_DOCUMENT_VERSION;
return TCollection_AsciiString(THE_CURRENT_VERSION);
}
// Declare entry point PLUGINFACTORY

View File

@@ -17,6 +17,7 @@
#define _XmlLDrivers_HeaderFile
#include <Standard_Handle.hxx>
#include <XmlLDrivers_FormatVersion.hxx>
class Standard_Transient;
class Standard_GUID;
@@ -41,8 +42,12 @@ public:
Standard_EXPORT static void DefineFormat (const Handle(TDocStd_Application)& theApp);
Standard_EXPORT static Handle(XmlMDF_ADriverTable) AttributeDrivers (const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT static int StorageVersion();
Standard_EXPORT static TCollection_AsciiString StorageVersion();
public:
static const Standard_Integer THE_CURRENT_VERSION = XML_LDRIVERS_VERSION_10;
};
#endif // _XmlLDrivers_HeaderFile

View File

@@ -252,25 +252,32 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
theApplication -> MessageDriver();
// 1. Read info // to be done
TCollection_AsciiString anAbsoluteDirectory = GetDirFromFile(myFileName);
Standard_Integer aCurDocVersion = 0;
Standard_Integer aCurDocVersion = XML_LDRIVERS_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;
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 > XmlLDrivers::StorageVersion() )
if( aCurDocVersion > XmlLDrivers::THE_CURRENT_VERSION )
{
TCollection_ExtendedString aMsg =
TCollection_ExtendedString ("error: wrong file version: ") +
@@ -282,7 +289,6 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
return;
}
if( aCurDocVersion < 2) aCurDocVersion = 2;
Standard_Boolean isRef = Standard_False;
for (LDOM_Node aNode = anInfoElem.getFirstChild();
aNode != NULL; aNode = aNode.getNextSibling()) {

View File

@@ -269,10 +269,10 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument
// anInfoElem.setAttribute("appv", anAppVersion.ToCString());
// Document version
Standard_Integer aFormatVersion(XmlLDrivers::StorageVersion());// the last version of the format
if (theDocument->StorageFormatVersion() > 0)
Standard_Integer aFormatVersion(XmlLDrivers::THE_CURRENT_VERSION); // the last version of the format
if (theDocument->StorageFormatVersion() >= XML_LDRIVERS_VERSION_2) // the minimal supported version
{
if (XmlLDrivers::StorageVersion() < theDocument->StorageFormatVersion())
if (theDocument->StorageFormatVersion() > XmlLDrivers::THE_CURRENT_VERSION)
{
TCollection_ExtendedString anErrorString("Unacceptable storage format version, the last verson is used");
aMessageDriver->Send(anErrorString.ToExtString(), Message_Warning);
@@ -280,7 +280,8 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument
else
aFormatVersion = theDocument->StorageFormatVersion();
}
anInfoElem.setAttribute("DocVersion", aFormatVersion);
TCollection_AsciiString aStringFormatVersion(aFormatVersion);
anInfoElem.setAttribute("DocVersion", aStringFormatVersion.ToCString());
// User info with Copyright
TColStd_SequenceOfAsciiString aUserInfo;

View File

@@ -0,0 +1,30 @@
// 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 _XmlLDriversFormatVersion_HeaderFile
#define _XmlLDriversFormatVersion_HeaderFile
enum XmlLDrivers_FormatVersion
{
XML_LDRIVERS_VERSION_2 = 2,
XML_LDRIVERS_VERSION_3,
XML_LDRIVERS_VERSION_4,
XML_LDRIVERS_VERSION_5,
XML_LDRIVERS_VERSION_6,
XML_LDRIVERS_VERSION_7,
XML_LDRIVERS_VERSION_8,
XML_LDRIVERS_VERSION_9,
XML_LDRIVERS_VERSION_10
};
#endif

View File

@@ -35,6 +35,7 @@
#include <XmlObjMgt_DOMString.hxx>
#include <XmlObjMgt_Persistent.hxx>
#include <XmlLDrivers.hxx>
#include <XmlLDrivers_FormatVersion.hxx>
#include <TDocStd_Owner.hxx>
#include <TDocStd_Document.hxx>
#include <Standard_GUID.hxx>
@@ -107,7 +108,7 @@ Standard_Integer XmlMDF::WriteSubTree
// 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() < XML_LDRIVERS_VERSION_8 &&
strcmp(typeName, "TDataXtd_Presentation") == 0)
{
typeName = "TPrsStd_AISPresentation";

View File

@@ -24,6 +24,8 @@
#include <XmlMDataStd_ByteArrayDriver.hxx>
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_Persistent.hxx>
#include <XmlLDrivers_FormatVersion.hxx>
IMPLEMENT_DOMSTRING (AttributeIDString, "bytearrattguid")
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_ByteArrayDriver,XmlMDF_ADriver)
@@ -129,7 +131,7 @@ Standard_Boolean XmlMDataStd_ByteArrayDriver::Paste(const XmlObjMgt_Persistent&
Standard_Boolean aDelta(Standard_False);
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= XML_LDRIVERS_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{

View File

@@ -195,7 +195,7 @@ Standard_Boolean XmlMDataStd_ExtStringArrayDriver::Paste
// Read delta-flag.
Standard_Boolean aDelta(Standard_False);
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= XML_LDRIVERS_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{
@@ -240,7 +240,7 @@ void XmlMDataStd_ExtStringArrayDriver::Paste (const Handle(TDF_Attribute)& theSo
// 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() >= XML_LDRIVERS_VERSION_8)
{
// Preferrable symbols for the separator: - _ . : ^ ~
// Don't use a space as a separator: XML low-level parser sometimes "eats" it.

View File

@@ -22,6 +22,7 @@
#include <TColStd_PackedMapOfInteger.hxx>
#include <TDataStd_IntPackedMap.hxx>
#include <TDF_Attribute.hxx>
#include <XmlLDrivers_FormatVersion.hxx>
#include <XmlMDataStd.hxx>
#include <XmlMDataStd_IntPackedMapDriver.hxx>
#include <XmlMDF_ADriver.hxx>
@@ -106,7 +107,7 @@ Standard_Boolean XmlMDataStd_IntPackedMapDriver::Paste
if(Ok) {
Standard_Boolean aDelta(Standard_False);
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= XML_LDRIVERS_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{

View File

@@ -20,6 +20,7 @@
#include <Standard_Type.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDF_Attribute.hxx>
#include <XmlLDrivers_FormatVersion.hxx>
#include <XmlMDataStd.hxx>
#include <XmlMDataStd_IntegerArrayDriver.hxx>
#include <XmlObjMgt.hxx>
@@ -129,7 +130,7 @@ Standard_Boolean XmlMDataStd_IntegerArrayDriver::Paste
}
Standard_Boolean aDelta(Standard_False);
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= XML_LDRIVERS_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{

View File

@@ -23,6 +23,7 @@
#include <TColStd_HArray1OfReal.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDF_Attribute.hxx>
#include <XmlLDrivers_FormatVersion.hxx>
#include <XmlMDataStd.hxx>
#include <XmlMDataStd_RealArrayDriver.hxx>
#include <XmlObjMgt.hxx>
@@ -140,7 +141,7 @@ Standard_Boolean XmlMDataStd_RealArrayDriver::Paste
}
Standard_Boolean aDelta(Standard_False);
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= XML_LDRIVERS_VERSION_3) {
Standard_Integer aDeltaValue;
if (!anElement.getAttribute(::IsDeltaOn()).GetInteger(aDeltaValue))
{

View File

@@ -118,7 +118,7 @@ void XmlMDataStd_TreeNodeDriver::Paste
// 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() < XML_LDRIVERS_VERSION_8)
{
Standard_Character aGuidStr [40];
Standard_PCharacter pGuidStr=aGuidStr;

View File

@@ -370,7 +370,7 @@ void XmlMNaming_NamedShapeDriver::WriteShapeSection (XmlObjMgt_Element& theEleme
// Add text to the "shapes" element
if (myShapeSet.NbShapes() > 0) {
myShapeSet.SetFormatNb(2);
myShapeSet.SetFormatNb(TopTools_ShapeSet::THE_CURRENT_VERSION);
LDOM_OSStream aStream (16 * 1024);
// ostrstream aStream;
// aStream.rdbuf() -> setbuf (0, 16380);

View File

@@ -23,6 +23,7 @@
#include <TNaming_Name.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Naming.hxx>
#include <XmlLDrivers_FormatVersion.hxx>
#include <XmlMNaming_NamingDriver.hxx>
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_Persistent.hxx>
@@ -174,7 +175,7 @@ Standard_Boolean XmlMNaming_NamingDriver::Paste
}
aNgName.Index(aNb);
//
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 3) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= XML_LDRIVERS_VERSION_4) {
XmlObjMgt_DOMString aDomEntry = anElem.getAttribute(::ContextLabelString());
if (aDomEntry != NULL)
{
@@ -203,8 +204,8 @@ Standard_Boolean XmlMNaming_NamingDriver::Paste
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() >= XML_LDRIVERS_VERSION_5 &&
theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() < XML_LDRIVERS_VERSION_7) {
// Orientation processing - converting from old format
Handle(TNaming_NamedShape) aNS;
if (aNg->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
@@ -223,7 +224,7 @@ Standard_Boolean XmlMNaming_NamingDriver::Paste
}
}
}
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 6) {
if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() >= XML_LDRIVERS_VERSION_7) {
aDOMStr = anElem.getAttribute(::OrientString());
if (!aDOMStr.GetInteger(aNb))
{

View File

@@ -21,6 +21,7 @@
#include <TopLoc_Location.hxx>
#include <TopTools_LocationSet.hxx>
#include <XCAFDoc_Location.hxx>
#include <XmlLDrivers_FormatVersion.hxx>
#include <XmlMNaming.hxx>
#include <XmlMXCAFDoc_LocationDriver.hxx>
#include <XmlObjMgt.hxx>
@@ -149,7 +150,7 @@ Standard_Boolean XmlMXCAFDoc_LocationDriver::Translate
return Standard_False;
Standard_Integer aFileVer = theMap.GetHeaderData()->StorageVersion().IntegerValue();
if( aFileVer > 5 && myLocations == 0 )
if( aFileVer >= XML_LDRIVERS_VERSION_6 && myLocations == 0 )
{
return Standard_False;
}
@@ -157,7 +158,7 @@ Standard_Boolean XmlMXCAFDoc_LocationDriver::Translate
Standard_Integer aPower;
Handle(TopLoc_Datum3D) aDatum;
if( aFileVer > 5 )
if( aFileVer >= XML_LDRIVERS_VERSION_6 )
{
// Get Location ID
Standard_Integer anId;

View File

@@ -0,0 +1,23 @@
puts "=========="
puts "0031136: BinXCAF persistence loses normals from triangulation-only Faces"
puts "=========="
puts ""
pload MODELING XDE OCAF VISUALIZATION
source $env(CSF_OCCTSamplesPath)/tcl/cad.tcl
trinfo res
wavefront res $imagedir/${test_image}
readobj o $imagedir/${test_image}.obj
# binary format
set test_image_bbrep ${test_image}_bbrep
binsave o $imagedir/${test_image_bbrep}.bbrep
binrestore $imagedir/${test_image_bbrep}.bbrep b1
vclear
vclose ALL
vinit v1/v1
vbottom
vdisplay -dispMode 1 b1
vfit
vrenderparams -shadingModel phong
checkview -screenshot -3d -path ${imagedir}/${test_image_bbrep}.png

View File

@@ -0,0 +1,24 @@
puts "=========="
puts "0031136: BinXCAF persistence loses normals from triangulation-only Faces"
puts "=========="
puts ""
pload MODELING XDE OCAF VISUALIZATION
source $env(CSF_OCCTSamplesPath)/tcl/cad.tcl
trinfo res
wavefront res $imagedir/${test_image}
readobj o $imagedir/${test_image}.obj
# ASCII format
set test_image_brep ${test_image}_brep
save o $imagedir/${test_image_brep}.brep
restore $imagedir/${test_image_brep}.brep b2
vclear
vclose ALL
vinit v1/v1
vbottom
vdisplay -dispMode 1 b2
vfit
vrenderparams -shadingModel phong
checkview -screenshot -3d -path ${imagedir}/${test_image_brep}.png

View File

@@ -0,0 +1,27 @@
puts "=========="
puts "0031136: BinXCAF persistence loses normals from triangulation-only Faces"
puts "=========="
puts ""
pload MODELING XDE OCAF VISUALIZATION
source $env(CSF_OCCTSamplesPath)/tcl/cad.tcl
trinfo res
wavefront res $imagedir/${test_image}
readobj o $imagedir/${test_image}.obj
# XBF format
set test_image_XBF ${test_image}_XBF
XNewDoc D1
XAddShape D1 o
XSave D1 $imagedir/${test_image_XBF}.xbf
Close D1
XOpen $imagedir/${test_image_XBF}.xbf D2
vclear
vclose ALL
vinit v1/v1
vbottom
XDisplay -dispMode 1 D2
Close D2
vfit
vrenderparams -shadingModel phong
checkview -screenshot -3d -path ${imagedir}/${test_image_XBF}.png