View Issue Details

IDProjectCategoryView StatusLast Update
0032820Open CASCADEOCCT:Data Exchangepublic2022-11-30 12:01
Reporterkgv Assigned Todpasukhi  
PrioritynormalSeverityfeature 
Status verifiedResolutionfixed 
Target Version7.7.0 
Summary0032820: Data Exchange - add VRML reader to XCAF document
Description0030115 introduced a tool for exporting XCAF document into VRML format, but there is still no symmetrical method for translation in opposite direction, which makes testing bugs like 0032819 difficult, although translation is relatively straightforward.

namespace
{
  //! Return string associated with VRML reader status.
  static const char* getVrmlErrorName (VrmlData_ErrorStatus theStatus)
  {
    switch (theStatus)
    {
      case VrmlData_StatusOK:              return "";
      case VrmlData_EmptyData:             return "EmptyData";
      case VrmlData_UnrecoverableError:    return "UnrecoverableError";
      case VrmlData_GeneralError:          return "GeneralError";
      case VrmlData_EndOfFile:             return "EndOfFile";
      case VrmlData_NotVrmlFile:           return "NotVrmlFile";
      case VrmlData_CannotOpenFile:        return "CannotOpenFile";
      case VrmlData_VrmlFormatError:       return "VrmlFormatError";
      case VrmlData_NumericInputError:     return "NumericInputError";
      case VrmlData_IrrelevantNumber:      return "IrrelevantNumber";
      case VrmlData_BooleanInputError:     return "BooleanInputError";
      case VrmlData_StringInputError:      return "StringInputError";
      case VrmlData_NodeNameUnknown:       return "NodeNameUnknown";
      case VrmlData_NonPositiveSize:       return "NonPositiveSize";
      case VrmlData_ReadUnknownNode:       return "ReadUnknownNode";
      case VrmlData_NonSupportedFeature:   return "NonSupportedFeature";
      case VrmlData_OutputStreamUndefined: return "OutputStreamUndefined";
      case VrmlData_NotImplemented:        return "NotImplemented";
    }
    return "UNKNOWN";
  }

  //! Process sub-shape.
  static void performMeshSubshape (RWMesh_NodeAttributeMap& theAttribMap,
                                   const VrmlData_DataMapOfShapeAppearance& theShapeAppMap,
                                   const TopoDS_Shape& theShape)
  {
    Handle(VrmlData_Appearance) anAppearance;
    if (theShapeAppMap.Find (theShape.TShape(), anAppearance))
    {
      if (!anAppearance.IsNull()
       && !anAppearance->Material().IsNull())
      {
        RWMesh_NodeAttributes aFaceAttribs;
        aFaceAttribs.Style.SetColorSurf (anAppearance->Material()->DiffuseColor());
        theAttribMap.Bind (theShape, aFaceAttribs);
      }
    }

    for (TopoDS_Iterator aSubShapeIter (theShape, true, false); aSubShapeIter.More(); aSubShapeIter.Next())
    {
      performMeshSubshape (theAttribMap, theShapeAppMap, aSubShapeIter.Value());
    }
  }
}

//! The VRML mesh reader.
class MyCafVrmlReader
{
  //! Read the mesh from specified file.
  bool performMesh (const TCollection_AsciiString& theFile,
                                            const Standard_Boolean theToProbe)
  {
    Standard_CLocaleSentry aLocaleSentry;
    std::ifstream aFile;
    OSD_OpenStream (aFile, theFile.ToCString(), std::ios::in | std::ios::binary);
    if (!aFile.is_open()
     || !aFile.good())
    {
      Message::SendFail (TCollection_AsciiString ("File '") + theFile + "' is not found");
      return false;
    }

    if (theToProbe)
    {
      return false; // unsupported
    }

    // determine file location to load associated files
    TCollection_AsciiString aFolder;
    {
      OSD_Path aPath (theFile);
      aPath.SetName ("");
      aPath.SetExtension ("");
      aPath.SystemName (aFolder);
    }

    VrmlData_Scene aScene;
    aScene.SetLinearScale (myUnitFactor);
    aScene.SetVrmlDir (aFolder);
    aScene << aFile;

    VrmlData_DataMapOfShapeAppearance aShapeAppMap;
    TopoDS_Shape aShape = aScene.GetShape (aShapeAppMap);
    if (!aShape.IsNull())
    {
      performMeshSubshape (myAttribMap, aShapeAppMap, aShape);
      myRootShapes.Append (aShape);
    }
    if (aScene.Status() != VrmlData_StatusOK
     || aShape.IsNull())
    {
      Message::SendFail (TCollection_AsciiString ("Error ") + getVrmlErrorName (aScene.Status())
                       + " occurred at line " + aScene.GetLineError()
                       + "\nwhile reading VRML file '" + theFile + "'");
      return false;
    }

    return true;
  }

protected:
  double myUnitFactor;  //!< length unit scale factor

};
Steps To ReproduceNot required
TagsNo tags attached.
Test case numberde_mesh/vrml_read/A1, A2, A3, A4

Attached Files

  • remarks_08_09_22.txt (4,212 bytes)

Relationships

related to 0032819 assigneddpasukhi Community Data Exchange - VrmlAPI_Writer does not write all colors 
parent of 0033190 testedbugmaster Open CASCADE Error on de_wrapper/configuration/A3 
child of 0030115 closedbugmaster Open CASCADE Data Exchange - Implementation of import from XCAF to VRML. 
Not all the children of this issue are yet resolved or closed.

Activities

git

2022-07-12 23:48

administrator   ~0109785

Branch CR32820 has been created by atychini.

SHA-1: d9d3fbf511678eda6cf185955df811f6673d3917


Detailed log of new commits:

Author: atychini
Date: Tue Jul 12 23:48:02 2022 +0300

    0032820: Data Exchange - add VRML reader to XCAF document
    
    Implementing VRML reader into XCAF document.

git

2022-07-13 13:12

administrator   ~0109796

Branch CR32820 has been updated forcibly by atychini.

SHA-1: 97d74810eeeb54cf8190564f52f46adf439395e2

atychini

2022-07-13 16:04

developer   ~0109797

Last edited: 2022-07-13 16:04

Dear @dpasukhi, please review branch CR32820
All tests are ok, see http://jenkins-test-08.nnov.opencascade.com/view/CR32820-master-atychini/view/ALL/

kgv

2022-07-13 16:27

developer   ~0109798

+  std::ifstream aFile;
+  OSD_OpenStream(aFile, theFile.ToCString(), std::ios::in | std::ios::binary);

Please use `OSD_FileSystem::DefaultFileSystem()`.

+  // determine file location to load associated files
+  TCollection_AsciiString aFolder;
+  {
+    OSD_Path aPath(theFile);
+    aPath.SetName("");
+    aPath.SetExtension("");
+    aPath.SystemName(aFolder);

Consider using `OSD_Path::FolderAndFileFromPath()` instead.

+
+class VrmlAPI_CafReader : public RWMesh_CafReader

Description is missing.

+      if (aFileUnitFactor <= 0.0)
+      {
+        Message::SendWarning() << "Warning: wrong length unit '" << aUnitStr << "'";
+      }

Invalid input should be a failure, not warning, I think.

+    if(aToUseExistingDoc)

`toUseExistingDoc` following OCCT name conventions.

+      Message::SendFail() << "Error: file reading failed '" << aFilePath;

Trailing open quote.

+  Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);

Unused variable.

-nocreatedoc

Looks like this option is mistreated.

+ReadVrml D $aFile
+XGetOneShape S_New D
+
+checktrinfo S_New -ref [trinfo S_Ref]
+
+Close D

It is essential making also screenshots of a document in 3D viewer and check colors are presented as expected.

+         "\n\t\t:   -memoryLimit    memory usage limit (in MiB)"

I don't see this option being implemented by new/old VRML reader logic, why it is exposed?

+         "\n\t\t:   -fileUnit       length unit of Vrml file content;"
+         "\n\t\t:   -memoryLimit    memory usage limit (in MiB)"
+         "\n\t\t:   -fileCoordSys   coordinate system defined by Vrml file; Yup when not specified."

Inconsistent separators in listing (".", ";", "").

+  //! Setting myUnitFactor to theUnitFactor
+  //! @param[in] theUnitFactor length unit scale factor
+  Standard_EXPORT void SetUnitFactor(const Standard_Real theUnitFactor);
+
+  //! Get the length unit scale factor
+  //! @return the length unit scale factor
+  Standard_EXPORT Standard_Real UnitFactor() const;

This property jeopardizes inheritance from RWMesh_CafReader and it's basic units conversion logic interface which is supposed to be used.

git

2022-07-18 11:46

administrator   ~0109851

Branch CR32820 has been updated forcibly by atychini.

SHA-1: f7e9e2f5a4d2d07cb9624e5299e892aee2134c4e

atychini

2022-07-20 09:43

developer   ~0109883

Dear dpasukhi, please review branch CR32820
Tests have completed successfully http://jenkins-test-08.nnov.opencascade.com/view/CR32820-master-atychini/view/ALL/

kgv

2022-07-20 17:55

developer   ~0109904

+      "(due to unexpected EOF, syntax error, memory limit)" << thePath;

Space is missing.

+      Message::SendFail() << "Error in the Vrml_Provider during reading the file " << thePath;

It is preferred to put file path into quotes.

+bool VrmlAPI_CafReader::performMesh(const TCollection_AsciiString& theFile,
+                                    const Message_ProgressRange&,
+                                    const Standard_Boolean)

Please don't ignore `theToProbe` parameter - return FALSE immediately if probing cannot be implemented.

git

2022-07-20 18:05

administrator   ~0109905

Branch CR32820 has been updated forcibly by atychini.

SHA-1: 715ed1bf5a17b1f2368d6de14c25c9dfe86d7de0

dpasukhi

2022-08-09 16:42

developer   ~0110159

Last edited: 2022-08-09 16:42

Remarks have been attached.
Please fix it.
remarks_08_09_22.txt (4,212 bytes)

git

2022-08-11 13:44

administrator   ~0110188

Branch CR32820 has been updated forcibly by atychini.

SHA-1: 07d0fafbbda351baf3fcb28cb0bce5d86d46a3aa

git

2022-08-12 14:01

administrator   ~0110214

Branch CR32820 has been updated forcibly by atychini.

SHA-1: 8522a1261912bd10f2d387bd4b48af5797950ee5

atychini

2022-08-12 14:05

developer   ~0110215

Dear dpasukhi, pleare review branch CR32820
There was one warning during MacOS compilation, I've rectified it.
Remarks have been fixed, all tests are ok: http://jenkins-test-08.nnov.opencascade.com/view/CR32820-master-atychini/view/COMPARE/

git

2022-09-22 15:03

administrator   ~0111185

Branch CR32820 has been updated forcibly by atychini.

SHA-1: 8f960eb826c0a726ac2607e48aa544c7a73df6a7

git

2022-09-22 15:04

administrator   ~0111186

Branch CR32820 has been updated forcibly by atychini.

SHA-1: 9826eb1a781adf1514023aa83d25a3aa5675d026

dpasukhi

2022-09-23 15:18

developer   ~0111212

Branch CR32820 has been reviewed

smoskvin

2022-09-25 13:31

administrator   ~0111247

Combination -
OCCT branch : IR-2022-09-23
master SHA - changes and them, and you can discard any commits you make in this
b3284f3ba911e4d18477ff1788ace3d7201a8827
changes and them, and you can discard any commits you make in this
e0ceb716c70188b98130b1550914140d0502a6f9
Products branch : IR-2022-09-23 SHA - f1708bcb12b969ae6e6578ab6d46bb65e135a733
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: 18666.730000000585 / 18776.180000000597 [-0.58%]
Products
Total CPU difference: 11867.75000000012 / 11959.870000000119 [-0.77%]
Windows-64-VC14:
OCCT
Total CPU difference: 20851.8125 / 20857.796875 [-0.03%]
Products
Total CPU difference: 14092.984375 / 14084.640625 [+0.06%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2022-09-25 13:40

administrator   ~0111252

Branch CR32820 has been deleted by mnt.

SHA-1: 9826eb1a781adf1514023aa83d25a3aa5675d026

Related Changesets

occt: master 5bde4773

2022-07-12 23:48:02

atychini


Committer: smoskvin Details Diff
0032820: Data Exchange - add VRML reader to XCAF document

Implementing VRML reader into XCAF document.
Updating DE_Wrapper according to VRML Reader.
Affected Issues
0032820
mod - src/TKVRML/EXTERNLIB Diff File
mod - src/Vrml/Vrml_ConfigurationNode.cxx Diff File
mod - src/Vrml/Vrml_ConfigurationNode.hxx Diff File
mod - src/Vrml/Vrml_Provider.cxx Diff File
mod - src/VrmlAPI/FILES Diff File
add - src/VrmlAPI/VrmlAPI_CafReader.cxx Diff File
add - src/VrmlAPI/VrmlAPI_CafReader.hxx Diff File
mod - src/XDEDRAW/XDEDRAW_Common.cxx Diff File
mod - tests/de_mesh/grids.list Diff File
add - tests/de_mesh/vrml_read/A1 Diff File
add - tests/de_mesh/vrml_read/A2 Diff File
add - tests/de_mesh/vrml_read/A3 Diff File
add - tests/de_mesh/vrml_read/A4 Diff File
add - tests/de_mesh/vrml_read/begin Diff File
mod - tests/de_wrapper/configuration/A3 Diff File
mod - tests/de_wrapper/vrml/A5 Diff File
mod - tests/de_wrapper/vrml/A6 Diff File

Issue History

Date Modified Username Field Change
2022-02-07 14:29 kgv New Issue
2022-02-07 14:29 kgv Assigned To => dpasukhi
2022-02-07 14:29 kgv Relationship added child of 0030115
2022-02-07 14:29 kgv Relationship added related to 0032819
2022-07-11 16:16 dpasukhi Assigned To dpasukhi => atychini
2022-07-12 23:48 git Note Added: 0109785
2022-07-13 13:12 git Note Added: 0109796
2022-07-13 16:03 atychini Assigned To atychini => dpasukhi
2022-07-13 16:03 atychini Status new => resolved
2022-07-13 16:03 atychini Steps to Reproduce Updated
2022-07-13 16:04 atychini Steps to Reproduce Updated
2022-07-13 16:04 atychini Note Added: 0109797
2022-07-13 16:04 atychini Note Edited: 0109797
2022-07-13 16:27 kgv Note Added: 0109798
2022-07-13 16:32 dpasukhi Assigned To dpasukhi => atychini
2022-07-13 16:32 dpasukhi Status resolved => assigned
2022-07-18 11:46 git Note Added: 0109851
2022-07-20 09:43 atychini Assigned To atychini => dpasukhi
2022-07-20 09:43 atychini Status assigned => resolved
2022-07-20 09:43 atychini Steps to Reproduce Updated
2022-07-20 09:43 atychini Note Added: 0109883
2022-07-20 17:55 kgv Note Added: 0109904
2022-07-20 18:05 git Note Added: 0109905
2022-08-09 16:42 dpasukhi Status resolved => assigned
2022-08-09 16:42 dpasukhi Note Added: 0110159
2022-08-09 16:42 dpasukhi File Added: remarks_08_09_22.txt
2022-08-09 16:42 dpasukhi Note Edited: 0110159
2022-08-09 16:43 dpasukhi Assigned To dpasukhi => atychini
2022-08-11 13:44 git Note Added: 0110188
2022-08-12 14:01 git Note Added: 0110214
2022-08-12 14:05 atychini Assigned To atychini => dpasukhi
2022-08-12 14:05 atychini Status assigned => resolved
2022-08-12 14:05 atychini Note Added: 0110215
2022-09-22 15:03 git Note Added: 0111185
2022-09-22 15:04 git Note Added: 0111186
2022-09-23 15:18 dpasukhi Assigned To dpasukhi => bugmaster
2022-09-23 15:18 dpasukhi Status resolved => reviewed
2022-09-23 15:18 dpasukhi Note Added: 0111212
2022-09-25 13:31 smoskvin Status reviewed => tested
2022-09-25 13:31 smoskvin Note Added: 0111247
2022-09-25 13:36 smoskvin Test case number => de_mesh/vrml_read/A1, A2, A3, A4
2022-09-25 13:38 smoskvin Changeset attached => occt master 5bde4773
2022-09-25 13:38 atychini Assigned To bugmaster => atychini
2022-09-25 13:38 atychini Status tested => verified
2022-09-25 13:38 atychini Resolution open => fixed
2022-09-25 13:40 git Note Added: 0111252
2022-11-03 13:14 dpasukhi Relationship added parent of 0033190
2022-11-30 12:01 dpasukhi Assigned To atychini => dpasukhi