View Issue Details

IDProjectCategoryView StatusLast Update
0031324CommunityOCCT:Data Exchangepublic2020-12-02 17:12
ReporterBenjaminBihler Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformMinGw64OSWindows 
Product Version7.5.0 
Target Version7.5.0Fixed in Version7.5.0 
Summary0031324: [Regression to OCCT 7.4.0] Data Exchange - Cannot read BinOcaf document with colour
DescriptionIt seems as if an error has been introduced with commit aaf8d6a98d5aa23513bbb7f0e8528764e1e0ebb4.

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 ReproduceMaking document:
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 commit aaf8d6a98d5aa23513bbb7f0e8528764e1e0ebb4):

#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 commit aaf8d6a98d5aa23513bbb7f0e8528764e1e0ebb4 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);
    }
}
TagsNo tags attached.
Test case numberNot required

Attached Files

  • doc_740.cbf (16,993 bytes)
  • doc_740.xml (13,896 bytes)

Relationships

related to 0030969 closedapn Open CASCADE Coding Rules - refactor Quantity_Color.cxx color table definition 
related to 0027974 closedapn Open CASCADE Visualization, ray tracing - Improve ray tracing engine 

Activities

kgv

2020-01-29 11:55

developer  

doc_740.cbf (16,993 bytes)

kgv

2020-01-29 13:16

developer  

doc_740.xml (13,896 bytes)

git

2020-01-29 14:42

administrator   ~0090139

Branch CR31324 has been created by kgv.

SHA-1: 29631ac7eac8c4c22174ba720d37268a2dac014a


Detailed log of new commits:

Author: kgv
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.

kgv

2020-01-29 16:09

developer   ~0090149

Patch is ready for review.

gka

2020-06-03 11:33

developer   ~0092455

Branches CR21324 were reviewed

kgv

2020-06-04 10:32

developer   ~0092472

As has been discussed with Andrey, it is proposed to revert changes in persistence format within the patch.

git

2020-07-30 23:39

administrator   ~0093409

Branch CR31324_1 has been created by kgv.

SHA-1: b91ed98ebdf75d0e493ec71cfddc111799043e72


Detailed log of new commits:

Author: kgv
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.

kgv

2020-07-31 11:42

developer   ~0093411

Updated patch is ready for review in OCCT branch CR31324_1.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31324_1-master-KGV

gka

2020-08-18 19:47

developer   ~0093535

Branch CR31234_1 was reviewed

bugmaster

2020-08-22 16:01

administrator   ~0093588

Combination -
OCCT branch : IR-2020-08-21
master SHA - 1d99a2baaa614856d8ef8b0a9975af5c3bdf92c6
a206de37fbfa0bf71bd534ae47192bbec23b8522
Products branch : IR-2020-08-21 SHA - 9541102e96ff9ee3aeec6e3e32f20f63b3b38556
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

git

2020-08-22 16:12

administrator   ~0093605

Branch CR31324_1 has been deleted by inv.

SHA-1: b91ed98ebdf75d0e493ec71cfddc111799043e72

git

2020-08-22 16:12

administrator   ~0093606

Branch CR31324 has been deleted by inv.

SHA-1: 29631ac7eac8c4c22174ba720d37268a2dac014a

Related Changesets

occt: master 4254e741

2020-01-29 10:18:01

kgv


Committer: bugmaster Details Diff
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.
Affected Issues
0031324
mod - src/BinMDataXtd/BinMDataXtd_PresentationDriver.cxx Diff File
mod - src/TDataXtd/TDataXtd_Presentation.cxx Diff File
mod - src/TDataXtd/TDataXtd_Presentation.hxx Diff File
mod - src/XmlMDataXtd/XmlMDataXtd_PresentationDriver.cxx Diff File

Issue History

Date Modified Username Field Change
2020-01-28 15:08 BenjaminBihler New Issue
2020-01-28 15:08 BenjaminBihler Assigned To => gka
2020-01-28 15:08 BenjaminBihler Relationship added related to 0030969
2020-01-29 11:54 kgv Steps to Reproduce Updated
2020-01-29 11:55 kgv File Added: doc_740.cbf
2020-01-29 13:16 kgv File Added: doc_740.xml
2020-01-29 14:42 git Note Added: 0090139
2020-01-29 14:48 kgv Steps to Reproduce Updated
2020-01-29 14:52 kgv Relationship added related to 0027974
2020-01-29 16:09 kgv Note Added: 0090149
2020-01-29 16:09 kgv Status new => resolved
2020-06-03 11:33 gka Note Added: 0092455
2020-06-03 11:33 gka Assigned To gka => bugmaster
2020-06-03 11:33 gka Status resolved => reviewed
2020-06-04 10:32 kgv Note Added: 0092472
2020-06-04 10:32 kgv Assigned To bugmaster => kgv
2020-06-04 10:32 kgv Status reviewed => assigned
2020-07-30 23:39 git Note Added: 0093409
2020-07-31 11:42 kgv Note Added: 0093411
2020-07-31 11:42 kgv Assigned To kgv => gka
2020-07-31 11:42 kgv Status assigned => resolved
2020-08-18 19:47 gka Note Added: 0093535
2020-08-18 19:47 gka Assigned To gka => bugmaster
2020-08-18 19:47 gka Status resolved => reviewed
2020-08-22 16:01 bugmaster Note Added: 0093588
2020-08-22 16:01 bugmaster Status reviewed => tested
2020-08-22 16:02 bugmaster Test case number => Not required
2020-08-22 16:06 bugmaster Changeset attached => occt master 4254e741
2020-08-22 16:06 bugmaster Status tested => verified
2020-08-22 16:06 bugmaster Resolution open => fixed
2020-08-22 16:12 git Note Added: 0093605
2020-08-22 16:12 git Note Added: 0093606
2020-12-02 16:41 emo Fixed in Version => 7.5.0
2020-12-02 17:12 emo Status verified => closed