DiscussionsIssue archiveOCCT:Visualization

Archived issue #0031326

Foundation Classes - Init from Json for base OCCT classes

Open CASCADEOCCT:Visualizationclosed31 public notes

Search issues

Description

Some OCCT classes have DumpJson into a stream.
It's proposed to be able to fulfill an instance of the object by the stream.
Result is the object and a boolean state about success.

Public activity

31 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Tue Jan 28 18:28:00 2020 +0300

    0031326: Foundation Classes - Init from Json for base OCCT classes
02Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Tue Jan 28 18:28:00 2020 +0300

    0031326: Foundation Classes - Init from Json for base OCCT classes
03Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]
04Author
Dear Kirill,

could you please review patch.
Jenkins job: http://jenkins-test-12.nnov.opencascade.com/view/CR31326_1-master-NDS/view/COMPARE/
please, note that patch is based on fix for 31313.

Thank you in advance, Natalia
05Commenter 3
+  Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+  {

Please move method implementation after class declaration.

+  //! Inits the content of me into the stream

...from the stream.

+Standard_Boolean  gp_Ax3::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
...
+Standard_Boolean  gp_Trsf::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)

Double space.

+  Standard_Real mymatrix[3][3];
...
+  Standard_Real myshape;

aMatrix, aShape.

+Standard_Boolean Standard_Dump::ProcessStreamName (const Standard_SStream& theStream,
+                                                   const TCollection_AsciiString& theName,
+                                                   Standard_Integer& theStreamPos)
+{
+  TCollection_AsciiString aText = Text (theStream);

This conception looks very confusing.
Why not just read from JSON loaded into TCollection_AsciiString?

+  if (aSubText.StartsWith (JsonKeyToString (Standard_JsonKey_SeparatorValueToValue)))

Adding "StartsWithAt()" taking position would allow avoiding creation of redundant copy.
06Author
Dear Kirill,

Something is not clear:
1. < This conception looks very confusing.
Why not just read from JSON loaded into TCollection_AsciiString? >

Here, is it expected that parameter of this method is not a stream but a text?

2. << Adding "StartsWithAt()"... >>

 TCollection_AsciiString has no StartsWithAt(). Could you please explain in more detail what do you mean here?
07Commenter 3
> Here, is it expected that parameter of this method is not a stream but a text?
Yes, it makes no sense passing stream everywhere, to read it entirely into string.

+  TCollection_AsciiString aSubText = aText.SubString (theStreamPos, aText.Length());
+  if (aSubText.StartsWith (JsonKeyToString (Standard_JsonKey_SeparatorValueToValue)))
+  {
+    theStreamPos += JsonKeyLength (Standard_JsonKey_SeparatorValueToValue);
+    aSubText = aText.SubString (theStreamPos, aText.Length());
+  }

> TCollection_AsciiString has no StartsWithAt(). Could you please explain in more detail what do you mean here?
if (theText.StartsWithAt (", ", theStreamPos))
{
  theStreamPos += JsonKeyLength (Standard_JsonKey_SeparatorValueToValue);
}
TCollection_AsciiString aSubText = aText.SubString (theStreamPos, aText.Length());
08Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


No new revisions were added by this update.
09Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Feb 12 23:35:54 2020 +0300

    0031326: Foundation Classes - Init from Json for base OCCT classes

10Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Feb 12 23:35:54 2020 +0300

    0031326: Foundation Classes - Init from Json for base OCCT classes
11Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Sep 5 11:58:19 2020 +0300

    initFromJSon using during convet stream into presentation

Author: Author
Date: Wed Feb 12 23:35:54 2020 +0300

    0031326: Foundation Classes - Init from Json for base OCCT classes
    
    (cherry picked from [revision removed])
    (cherry picked from [revision removed])
12Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Sep 5 12:39:24 2020 +0300

    using BRepPreviewAPI_MakeBox to prepare box.

13Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Sep 5 12:41:19 2020 +0300

    0031326: Foundation Classes - Init from Json for base OCCT classes
14Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sun Sep 6 08:40:01 2020 +0300

    correction for remark about stream in ProcessStreamName

15Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
16Author
Dear Kirill,

could you please review.

[signature removed]Natalia
17Commenter 3
+    if (n == 1)
+    {
+    }
+    if (n == 2)
...
+    if (n == 3)

else if

+  //! @param theSStream stream with values
+  //! @param theStreamPos current position in the stream
+  //! @param theValue stream value

Please add [in]/[out] modifiers.

+  gp_XYZ aDir;
+  OCCT_INIT_VECTOR_CLASS (aStreamStr, "Direction", aPos, 3,
+                          &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3))
+  gp_XYZ aXDir;
+  OCCT_INIT_VECTOR_CLASS (aStreamStr, "XDirection", aPos, 3,
+                          &aXDir.ChangeCoord (1), &aXDir.ChangeCoord (2), &aXDir.ChangeCoord (3))
+  gp_XYZ anYDir;
+  OCCT_INIT_VECTOR_CLASS (aStreamStr, "YDirection", aPos, 3,
+                          &anYDir.ChangeCoord (1), &anYDir.ChangeCoord (2), &anYDir.ChangeCoord (3))
+
+  SetXDirection (aXDir);
+  SetYDirection (anYDir);
+
+  if (!Direction().IsEqual (aDir, Precision::Confusion()))
+    return Standard_False;

gp_Ax2/gp_Ax3 initialization code using independent methods SetXDirection()/SetYDirection() doesn't look correct as they perform correction of input vector basing on current state...

+  Standard_Real mymatrix[3][3];
...
+  Standard_Real myshape;
+  OCCT_INIT_FIELD_VALUE_INTEGER (aStreamStr, aPos, myshape);

Unexpected "my" prefix for local variables.
18Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Tue Sep 8 00:06:56 2020 +0300

    remarks correction.

19Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Tue Sep 8 00:16:32 2020 +0300

    0031326: Foundation Classes - Init from Json for base OCCT classes
    
    InitFromJson method implementation for some simple classes.
    OCCT_INIT_* defines introduction to do automatic parsing of the stream into values.
    Inspector is extended to visualize objects created on the dump stream if it might be created.
20Author
Dear Kirill,

remarks are corrected, please review.

[signature removed]Natalia
21Commenter 3
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);

Shouldn't it be "from the stream"?
22Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
23Author
corrected, please check.
24Author
OCCT: CR31326_6
PRODUCTS: NOT
25Commenter 1
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: 17333.360000000142 / 17325.800000000123 [+0.04%]
Products
Total CPU difference: 12056.720000000096 / 12079.64000000011 [-0.19%]
Windows-64-VC14:
OCCT
Total CPU difference: 18817.921875 / 18792.46875 [+0.14%]
Products
Total CPU difference: 13294.09375 / 13274.75 [+0.15%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
26Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
27Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
28Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
29Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
30Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
31Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]

Related records