mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-13 14:27:08 +03:00
0027835: Application Framework, BinXCAF - handle correctly faces with NULL surface within BinTools_ShapeSet
BinTools_ShapeSet::AddGeometry() now writes NULL surface with 0 index. myWithTriangles is ignored for TopoDS_Face with NULL surface so that triangulation-only faces are not lost with defaults. Added Draw Harness command StoreTriangulation defining WithTriangulation flag for BinXCAF/BinOcaf storage drivers.
This commit is contained in:
@@ -86,15 +86,6 @@ BinTools_ShapeSet::BinTools_ShapeSet(const Standard_Boolean isWithTriangles)
|
||||
BinTools_ShapeSet::~BinTools_ShapeSet()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWithTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinTools_ShapeSet::SetWithTriangles(const Standard_Boolean isWithTriangles)
|
||||
{
|
||||
myWithTriangles = isWithTriangles;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetFormatNb
|
||||
//purpose :
|
||||
@@ -287,7 +278,9 @@ void BinTools_ShapeSet::AddGeometry(const TopoDS_Shape& S)
|
||||
Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(S.TShape());
|
||||
if (!TF->Surface().IsNull()) mySurfaces.Add(TF->Surface());
|
||||
|
||||
if (myWithTriangles) {
|
||||
if (myWithTriangles
|
||||
|| TF->Surface().IsNull())
|
||||
{
|
||||
Handle(Poly_Triangulation) Tr = TF->Triangulation();
|
||||
if (!Tr.IsNull()) myTriangulations.Add(Tr);
|
||||
}
|
||||
@@ -730,17 +723,19 @@ void BinTools_ShapeSet::WriteGeometry(const TopoDS_Shape& S,
|
||||
|
||||
Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(S.TShape());
|
||||
const TopoDS_Face& F = TopoDS::Face(S);
|
||||
|
||||
if (!(TF->Surface()).IsNull()) {
|
||||
Standard_Boolean aNatRes = (BRep_Tool::NaturalRestriction(F)) ? Standard_True : Standard_False;
|
||||
BinTools::PutBool(OS, aNatRes);
|
||||
|
||||
// Write the surface geometry
|
||||
BinTools::PutReal(OS, TF->Tolerance());
|
||||
BinTools::PutInteger(OS, mySurfaces.Index(TF->Surface()));
|
||||
BinTools::PutInteger(OS, Locations().Index(TF->Location()));
|
||||
}
|
||||
if (myWithTriangles) {
|
||||
Standard_Boolean aNatRes = (BRep_Tool::NaturalRestriction(F)) ? Standard_True : Standard_False;
|
||||
BinTools::PutBool (OS, aNatRes);
|
||||
BinTools::PutReal (OS, TF->Tolerance());
|
||||
BinTools::PutInteger (OS, !TF->Surface().IsNull()
|
||||
? mySurfaces.Index (TF->Surface())
|
||||
: 0);
|
||||
BinTools::PutInteger (OS, Locations().Index (TF->Location()));
|
||||
|
||||
if (myWithTriangles
|
||||
|| TF->Surface().IsNull())
|
||||
{
|
||||
if (!(TF->Triangulation()).IsNull()) {
|
||||
OS << (Standard_Byte) 2;
|
||||
// Write the triangulation
|
||||
@@ -1103,12 +1098,11 @@ void BinTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum T,
|
||||
BinTools::GetReal(IS, tol);
|
||||
BinTools::GetInteger(IS, s); //surface indx
|
||||
BinTools::GetInteger(IS, l); //location indx
|
||||
if (!mySurfaces.Surface(s).IsNull()) {
|
||||
myBuilder.UpdateFace(TopoDS::Face(S),
|
||||
mySurfaces.Surface(s),
|
||||
Locations().Location(l),tol);
|
||||
myBuilder.NaturalRestriction(TopoDS::Face(S),bval );
|
||||
}
|
||||
myBuilder.UpdateFace (F,
|
||||
s > 0 ? mySurfaces.Surface(s) : Handle(Geom_Surface)(),
|
||||
Locations().Location(l),
|
||||
tol);
|
||||
myBuilder.NaturalRestriction (F, bval);
|
||||
|
||||
Standard_Byte aByte = (Standard_Byte)IS.get();
|
||||
// cas triangulation
|
||||
|
@@ -49,10 +49,14 @@ public:
|
||||
Standard_EXPORT BinTools_ShapeSet(const Standard_Boolean isWithTriangles = Standard_False);
|
||||
|
||||
Standard_EXPORT virtual ~BinTools_ShapeSet();
|
||||
|
||||
//! Define if shape will be stored with triangles
|
||||
Standard_EXPORT void SetWithTriangles (const Standard_Boolean isWithTriangles);
|
||||
|
||||
|
||||
//! Return true if shape should be stored with triangles.
|
||||
Standard_Boolean IsWithTriangles() const { return myWithTriangles; }
|
||||
|
||||
//! Define if shape will be stored with triangles.
|
||||
//! Ignored (always written) if face defines only triangulation (no surface).
|
||||
void SetWithTriangles (const Standard_Boolean isWithTriangles) { myWithTriangles = isWithTriangles; }
|
||||
|
||||
Standard_EXPORT void SetFormatNb (const Standard_Integer theFormatNb);
|
||||
|
||||
//! two formats available for the moment:
|
||||
|
Reference in New Issue
Block a user