MantisBT
Mantis Bug Tracker Workflow

View Revisions: Issue #31324 All Revisions ] Back to Issue ]
Summary 0031324: [Regression to OCCT 7.4.0] Data Exchange - Cannot read BinOcaf document with colour
Revision 2020-01-29 14:48 by kgv
Steps To Reproduce Making 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);
    }
}
Revision 2020-01-29 11:54 by kgv
Steps To Reproduce Making document:
pload MODELING VISUALIZATION OCAF
NewDocument D BinOcaf
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
SaveAs D doc.cbf


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);
    }
}
Revision 2020-01-28 15:08 by BenjaminBihler
Steps To Reproduce 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);
    }
}


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker