1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +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 TDocStd, 4 for BRep Shape and 3 for Binary BRep Shape)
theWithNormals parameter added to BRepTools::Write()
IsWithNormals()/SetWithNormals() function added to BRepTools_ShapeSet
-normals/-noNormals option added to StoreTriangulation DRAW command
-normals/-noNormals option added to writebrep DRAW command
Tests for writing to brep/binary brep/BinXCaf/XmlXCaf added
Test for StoreTriangulation options -normals/-noNormals added
This commit is contained in:
asuraven
2020-11-17 20:37:01 +03:00
committed by bugmaster
parent 6fab0b3428
commit 9f45d35b6b
40 changed files with 703 additions and 209 deletions

View File

@@ -93,6 +93,51 @@ void BinDrivers_DocumentStorageDriver::SetWithTriangles (const Handle(Message_Me
aShapesDriver->SetWithTriangles (theWithTriangulation);
}
//=======================================================================
//function : IsWithNormals
//purpose :
//=======================================================================
Standard_Boolean BinDrivers_DocumentStorageDriver::IsWithNormals() const
{
if (myDrivers.IsNull())
{
return Standard_False;
}
Handle(BinMDF_ADriver) aDriver;
myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver);
Handle(BinMNaming_NamedShapeDriver) aShapesDriver = Handle(BinMNaming_NamedShapeDriver)::DownCast(aDriver);
return !aShapesDriver.IsNull()
&& aShapesDriver->IsWithNormals();
}
//=======================================================================
//function : SetWithNormals
//purpose :
//=======================================================================
void BinDrivers_DocumentStorageDriver::SetWithNormals(const Handle(Message_Messenger)& theMessageDriver,
const Standard_Boolean theWithNormals)
{
if (myDrivers.IsNull())
{
myDrivers = AttributeDrivers(theMessageDriver);
}
if (myDrivers.IsNull())
{
return;
}
Handle(BinMDF_ADriver) aDriver;
myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver);
Handle(BinMNaming_NamedShapeDriver) aShapesDriver = Handle(BinMNaming_NamedShapeDriver)::DownCast(aDriver);
if (aShapesDriver.IsNull())
{
throw Standard_NotImplemented("Internal Error - TNaming_NamedShape is not found!");
}
aShapesDriver->SetWithNormals(theWithNormals);
}
//=======================================================================
//function : WriteShapeSection
//purpose : Implements WriteShapeSection
@@ -100,7 +145,7 @@ void BinDrivers_DocumentStorageDriver::SetWithTriangles (const Handle(Message_Me
void BinDrivers_DocumentStorageDriver::WriteShapeSection
(BinLDrivers_DocumentSection& theSection,
Standard_OStream& theOS,
const Standard_Integer theDocVer,
const TDocStd_FormatVersion theDocVer,
const Message_ProgressRange& theRange)
{
const Standard_Size aShapesSectionOffset = (Standard_Size) theOS.tellp();
@@ -112,7 +157,7 @@ void BinDrivers_DocumentStorageDriver::WriteShapeSection
OCC_CATCH_SIGNALS
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
Handle(BinMNaming_NamedShapeDriver)::DownCast (aDriver);
aNamedShapeDriver->WriteShapeSection (theOS, theRange);
aNamedShapeDriver->WriteShapeSection (theOS, theDocVer, theRange);
}
catch(Standard_Failure const& anException) {
TCollection_ExtendedString anErrorStr ("BinDrivers_DocumentStorageDriver, Shape Section :");

View File

@@ -46,15 +46,20 @@ public:
Standard_EXPORT virtual void WriteShapeSection
(BinLDrivers_DocumentSection& theDocSection,
Standard_OStream& theOS,
const Standard_Integer theDocVer,
const TDocStd_FormatVersion theDocVer,
const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
//! Return true if shape should be stored with triangles.
Standard_EXPORT Standard_Boolean IsWithTriangles() const;
//! Return true if shape should be stored with triangulation normals.
Standard_EXPORT Standard_Boolean IsWithNormals() const;
//! Set if triangulation should be stored or not.
Standard_EXPORT void SetWithTriangles (const Handle(Message_Messenger)& theMessageDriver,
const Standard_Boolean theWithTriangulation);
//! Set if triangulation should be stored with normals or not.
Standard_EXPORT void SetWithNormals(const Handle(Message_Messenger)& theMessageDriver,
const Standard_Boolean theWithTriangulation);
DEFINE_STANDARD_RTTIEXT(BinDrivers_DocumentStorageDriver,BinLDrivers_DocumentStorageDriver)