MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0031324Community[OCCT] OCCT:Data Exchangepublic2020-01-28 15:082020-01-29 16:09
ReporterBenjaminBihler 
Assigned Togka 
PrioritynormalSeverityminor 
StatusresolvedResolutionopen 
PlatformMinGw64OSWindowsOS Version7
Product Version[OCCT] 7.5.0* 
Target Version[OCCT] 7.5.0*Fixed in Version 
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 number
Attached Files? file icon doc_740.cbf (16,993 bytes) 2020-01-29 11:55
xml file icon doc_740.xml (13,896 bytes) 2020-01-29 13:16

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

-  Notes
(0090139)
git (administrator)
2020-01-29 14:42

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.
(0090149)
kgv (developer)
2020-01-29 16:09

Patch is ready for review.

- 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 View Revisions
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 View Revisions
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


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker