Archived issue #0031324
[Regression to OCCT 7.4.0] Data Exchange - Cannot read BinOcaf document with colour
Description
It seems as if an error has been introduced with [revision removed].
I create a simple BinOcaf document containing a vertex and a presentation with white color using OCCT 7.4.0. This document cannot be read in after the commit named above.
A Standard_OutOfRange failure is thrown in Quantity_Color::valuesOf(...), since a color with the value 516 is passed to that method, but the highest possible Quantity_NameOfColor value is 508 (Quantity_NOC_WHITE).
I create a simple BinOcaf document containing a vertex and a presentation with white color using OCCT 7.4.0. This document cannot be read in after the commit named above.
A Standard_OutOfRange failure is thrown in Quantity_Color::valuesOf(...), since a color with the value 516 is passed to that method, but the highest possible Quantity_NameOfColor value is 508 (Quantity_NOC_WHITE).
Steps to reproduce
Making document:
Reading document:
Please adjust the setting of CSF_StandardDefaults and CSF_PluginDefaults.
Document creation program (OCCT before [revision removed]):
#include <TDocStd_Document.hxx>
#include <AppStd_Application.hxx>
#include <TDataStd_Name.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <V3d_Viewer.hxx>
#include <TPrsStd_AISViewer.hxx>
#include <TDataStd_Name.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <TPrsStd_AISPresentation.hxx>
int main(int, char**)
{
#if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) || \
defined(__MINGW64__))
_putenv("CSF_StandardDefaults=C:/Libraries/OpenCascade/occt/src/StdResource");
_putenv("CSF_PluginDefaults=C:/Libraries/OpenCascade/occt/src/StdResource");
#else
setenv("CSF_StandardDefaults", resourceDirectory.c_str(), 1);
setenv("CSF_PluginDefaults", resourceDirectory.c_str(), 1);
#endif
Handle(TDocStd_Application) app = new AppStd_Application;
Handle(TDocStd_Document) doc;
app->NewDocument("BinOcaf", doc);
Handle(Aspect_DisplayConnection) displayConnection;
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || \
defined(MACOSX_USE_GLX))
displayConnection = new Aspect_DisplayConnection(getenv("DISPLAY"));
#endif
Handle(OpenGl_GraphicDriver) graphicDriver = new OpenGl_GraphicDriver(displayConnection);
Handle(V3d_Viewer) viewer = new V3d_Viewer(
graphicDriver);
viewer->SetDefaultLights();
viewer->SetLightOn();
TDF_Label root = doc->Main().Root();
Handle(TPrsStd_AISViewer) viewerAttribute;
// Create AisViewer instance
if (!TPrsStd_AISViewer::Find(root, viewerAttribute))
{
viewerAttribute = TPrsStd_AISViewer::New(root, viewer);
}
TDF_Label label = doc->Main().NewChild();
Handle(TDataStd_Name) nameAttribute = TDataStd_Name::Set(label,
TCollection_ExtendedString("Test"));
TNaming_Builder builder(label);
TopoDS_Vertex vertex = BRepBuilderAPI_MakeVertex(gp_Pnt());
builder.Generated(vertex);
Handle(TPrsStd_AISPresentation) presentation = TPrsStd_AISPresentation::Set(
label, TNaming_NamedShape::GetID());
presentation->SetColor(Quantity_NOC_WHITE);
// Set surface appearance to colored plastic to prevent excessive shine
presentation->SetMaterial(Graphic3d_NameOfMaterial::Graphic3d_NOM_PLASTIC);
presentation->SetMode(AIS_Shaded);
presentation->Display(Standard_True);
// TPrsStd_AISViewer::Update(label);
PCDM_StoreStatus status = app->SaveAs(doc, TCollection_ExtendedString(
"Example.cbf"));
std::cout << "Status: " << status << std::endl;
if( status != PCDM_SS_OK)
{
std::cerr << "Store error!" << std::endl;
}
else
{
std::cout << "Document is stored." << std::endl;
}
}
Document reading program (fails from [revision removed] on):
#include <TDocStd_Document.hxx>
#include <AppStd_Application.hxx>
#include <TDataStd_Name.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <V3d_Viewer.hxx>
#include <TPrsStd_AISViewer.hxx>
int main(int, char**)
{
#if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) || \
defined(__MINGW64__))
_putenv("CSF_StandardDefaults=C:/Libraries/OpenCascade/occt/src/StdResource");
_putenv("CSF_PluginDefaults=C:/Libraries/OpenCascade/occt/src/StdResource");
#else
setenv("CSF_StandardDefaults", resourceDirectory.c_str(), 1);
setenv("CSF_PluginDefaults", resourceDirectory.c_str(), 1);
#endif
Handle(TDocStd_Application) app = new AppStd_Application;
Handle(TDocStd_Document) doc;
app->Open(TCollection_ExtendedString("Example.cbf"), doc);
Handle(Aspect_DisplayConnection) displayConnection;
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || \
defined(MACOSX_USE_GLX))
displayConnection = new Aspect_DisplayConnection(getenv("DISPLAY"));
#endif
Handle(OpenGl_GraphicDriver) graphicDriver = new OpenGl_GraphicDriver(displayConnection);
Handle(V3d_Viewer) viewer = new V3d_Viewer(
graphicDriver);
viewer->SetDefaultLights();
viewer->SetLightOn();
TDF_Label root = doc->Main().Root();
Handle(TPrsStd_AISViewer) viewerAttribute;
// Create AisViewer instance
if (!TPrsStd_AISViewer::Find(root, viewerAttribute))
{
viewerAttribute = TPrsStd_AISViewer::New(root, viewer);
}
}
pload MODELING VISUALIZATION OCAF NewDocument D BinOcaf #NewDocument D XmlOcaf box b1 0 0 0 1 1 1 box b2 2 0 0 1 1 1 box b3 4 0 0 1 1 1 set aLab1 [ImportShape D 0:2 b1 Box1] set aLab2 [ImportShape D 0:3 b2 Box2] set aLab3 [ImportShape D 0:4 b3 Box3] AISInitViewer D vsetdispmode 1 AISSet D $aLab1 NS AISSet D $aLab2 NS AISSet D $aLab3 NS AISDisplay D $aLab1 AISDisplay D $aLab2 AISDisplay D $aLab3 vfit AISColor D $aLab1 22; # old blue AISColor D $aLab2 412; # old red AISColor D $aLab3 516; # old white #AISColor D $aLab1 BLUE #AISColor D $aLab2 RED #AISColor D $aLab3 WHITE SaveAs D doc.cbf #SaveAs D doc.xml
Reading document:
pload MODELING VISUALIZATION OCAF
catch { Close D }
Open doc.cbf D
AISInitViewer D
vsetdispmode 1
vfit
vreadpixel 100 150 -rgb -name; # BLUE3
vreadpixel 200 200 -rgb -name; # RED3
vreadpixel 300 300 -rgb -name; # LIGHTGRAY
Please adjust the setting of CSF_StandardDefaults and CSF_PluginDefaults.
Document creation program (OCCT before [revision removed]):
#include <TDocStd_Document.hxx>
#include <AppStd_Application.hxx>
#include <TDataStd_Name.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <V3d_Viewer.hxx>
#include <TPrsStd_AISViewer.hxx>
#include <TDataStd_Name.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <TPrsStd_AISPresentation.hxx>
int main(int, char**)
{
#if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) || \
defined(__MINGW64__))
_putenv("CSF_StandardDefaults=C:/Libraries/OpenCascade/occt/src/StdResource");
_putenv("CSF_PluginDefaults=C:/Libraries/OpenCascade/occt/src/StdResource");
#else
setenv("CSF_StandardDefaults", resourceDirectory.c_str(), 1);
setenv("CSF_PluginDefaults", resourceDirectory.c_str(), 1);
#endif
Handle(TDocStd_Application) app = new AppStd_Application;
Handle(TDocStd_Document) doc;
app->NewDocument("BinOcaf", doc);
Handle(Aspect_DisplayConnection) displayConnection;
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || \
defined(MACOSX_USE_GLX))
displayConnection = new Aspect_DisplayConnection(getenv("DISPLAY"));
#endif
Handle(OpenGl_GraphicDriver) graphicDriver = new OpenGl_GraphicDriver(displayConnection);
Handle(V3d_Viewer) viewer = new V3d_Viewer(
graphicDriver);
viewer->SetDefaultLights();
viewer->SetLightOn();
TDF_Label root = doc->Main().Root();
Handle(TPrsStd_AISViewer) viewerAttribute;
// Create AisViewer instance
if (!TPrsStd_AISViewer::Find(root, viewerAttribute))
{
viewerAttribute = TPrsStd_AISViewer::New(root, viewer);
}
TDF_Label label = doc->Main().NewChild();
Handle(TDataStd_Name) nameAttribute = TDataStd_Name::Set(label,
TCollection_ExtendedString("Test"));
TNaming_Builder builder(label);
TopoDS_Vertex vertex = BRepBuilderAPI_MakeVertex(gp_Pnt());
builder.Generated(vertex);
Handle(TPrsStd_AISPresentation) presentation = TPrsStd_AISPresentation::Set(
label, TNaming_NamedShape::GetID());
presentation->SetColor(Quantity_NOC_WHITE);
// Set surface appearance to colored plastic to prevent excessive shine
presentation->SetMaterial(Graphic3d_NameOfMaterial::Graphic3d_NOM_PLASTIC);
presentation->SetMode(AIS_Shaded);
presentation->Display(Standard_True);
// TPrsStd_AISViewer::Update(label);
PCDM_StoreStatus status = app->SaveAs(doc, TCollection_ExtendedString(
"Example.cbf"));
std::cout << "Status: " << status << std::endl;
if( status != PCDM_SS_OK)
{
std::cerr << "Store error!" << std::endl;
}
else
{
std::cout << "Document is stored." << std::endl;
}
}
Document reading program (fails from [revision removed] on):
#include <TDocStd_Document.hxx>
#include <AppStd_Application.hxx>
#include <TDataStd_Name.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <V3d_Viewer.hxx>
#include <TPrsStd_AISViewer.hxx>
int main(int, char**)
{
#if (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) || \
defined(__MINGW64__))
_putenv("CSF_StandardDefaults=C:/Libraries/OpenCascade/occt/src/StdResource");
_putenv("CSF_PluginDefaults=C:/Libraries/OpenCascade/occt/src/StdResource");
#else
setenv("CSF_StandardDefaults", resourceDirectory.c_str(), 1);
setenv("CSF_PluginDefaults", resourceDirectory.c_str(), 1);
#endif
Handle(TDocStd_Application) app = new AppStd_Application;
Handle(TDocStd_Document) doc;
app->Open(TCollection_ExtendedString("Example.cbf"), doc);
Handle(Aspect_DisplayConnection) displayConnection;
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || \
defined(MACOSX_USE_GLX))
displayConnection = new Aspect_DisplayConnection(getenv("DISPLAY"));
#endif
Handle(OpenGl_GraphicDriver) graphicDriver = new OpenGl_GraphicDriver(displayConnection);
Handle(V3d_Viewer) viewer = new V3d_Viewer(
graphicDriver);
viewer->SetDefaultLights();
viewer->SetLightOn();
TDF_Label root = doc->Main().Root();
Handle(TPrsStd_AISViewer) viewerAttribute;
// Create AisViewer instance
if (!TPrsStd_AISViewer::Find(root, viewerAttribute))
{
viewerAttribute = TPrsStd_AISViewer::New(root, viewer);
}
}
Public activity
10 archived notes
Participants are labeled by their role within this record.
Branch [archived branch] has been created by Commenter 3.
[revision removed]
Detailed log of new commits:
Author: Commenter 3
Date: Wed Jan 29 13:18:01 2020 +0300
0031324: Data Exchange - Cannot read BinOcaf document with colour
BinMDataXtd_PresentationDriver and XmlMDataXtd_PresentationDriver have been corrected
to convert old (OCCT 7.4.0) Quantity_NameOfColor enumeration values to new ones.
The writers have been modified to avoid storing color as enumeration index.
TPrsStd package has been marked deprecated.
[revision removed]
Detailed log of new commits:
Author: Commenter 3
Date: Wed Jan 29 13:18:01 2020 +0300
0031324: Data Exchange - Cannot read BinOcaf document with colour
BinMDataXtd_PresentationDriver and XmlMDataXtd_PresentationDriver have been corrected
to convert old (OCCT 7.4.0) Quantity_NameOfColor enumeration values to new ones.
The writers have been modified to avoid storing color as enumeration index.
TPrsStd package has been marked deprecated.
Patch is ready for review.
Branches CR21324 were reviewed
As has been discussed with Andrey, it is proposed to revert changes in persistence format within the patch.
Branch [archived branch] has been created by Commenter 3.
[revision removed]
Detailed log of new commits:
Author: Commenter 3
Date: Wed Jan 29 13:18:01 2020 +0300
0031324: Data Exchange - Cannot read BinOcaf document with colour
BinMDataXtd_PresentationDriver and XmlMDataXtd_PresentationDriver have been corrected
to convert old (OCCT 7.4.0) Quantity_NameOfColor enumeration values to new ones.
[revision removed]
Detailed log of new commits:
Author: Commenter 3
Date: Wed Jan 29 13:18:01 2020 +0300
0031324: Data Exchange - Cannot read BinOcaf document with colour
BinMDataXtd_PresentationDriver and XmlMDataXtd_PresentationDriver have been corrected
to convert old (OCCT 7.4.0) Quantity_NameOfColor enumeration values to new ones.
Updated patch is ready for review in OCCT branch CR31324_1.
http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31324_1-master-KGV
http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31324_1-master-KGV
Branch CR31234_1 was reviewed
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.
Number of compiler warnings:
No new/fixed warnings
Regressions/Differences/Improvements:
No regressions/differences
CPU differences:
Debian80-64:
OCCT
Total CPU difference: 17322.48000000014 / 17160.470000000118 [+0.94%]
Products
Total CPU difference: 11882.560000000085 / 11820.020000000079 [+0.53%]
Windows-64-VC14:
OCCT
Total CPU difference: 18716.078125 / 18725.125 [-0.05%]
Products
Total CPU difference: 13242.09375 / 13316.109375 [-0.56%]
Image differences :
No differences that require special attention
Memory differences :
No differences that require special attention
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.
Number of compiler warnings:
No new/fixed warnings
Regressions/Differences/Improvements:
No regressions/differences
CPU differences:
Debian80-64:
OCCT
Total CPU difference: 17322.48000000014 / 17160.470000000118 [+0.94%]
Products
Total CPU difference: 11882.560000000085 / 11820.020000000079 [+0.53%]
Windows-64-VC14:
OCCT
Total CPU difference: 18716.078125 / 18725.125 [-0.05%]
Products
Total CPU difference: 13242.09375 / 13316.109375 [-0.56%]
Image differences :
No differences that require special attention
Memory differences :
No differences that require special attention
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Related records