]> OCCT Git - occt-copy.git/commitdiff
0031326: Foundation Classes - Init from Json for base OCCT classes
authornds <nds@opencascade.com>
Wed, 12 Feb 2020 20:35:54 +0000 (23:35 +0300)
committernds <nds@opencascade.com>
Wed, 12 Feb 2020 22:31:00 +0000 (01:31 +0300)
(cherry picked from commit 55b405ba591587b3456d77e0d406a117e8ded286)

23 files changed:
src/BVH/BVH_Box.hxx
src/Bnd/Bnd_Box.cxx
src/Bnd/Bnd_Box.hxx
src/Quantity/Quantity_Color.cxx
src/Quantity/Quantity_Color.hxx
src/Quantity/Quantity_ColorRGBA.cxx
src/Quantity/Quantity_ColorRGBA.hxx
src/Standard/Standard_Dump.cxx
src/Standard/Standard_Dump.hxx
src/gp/gp_Ax1.cxx
src/gp/gp_Ax1.hxx
src/gp/gp_Ax2.cxx
src/gp/gp_Ax2.hxx
src/gp/gp_Ax3.cxx
src/gp/gp_Ax3.hxx
src/gp/gp_Dir.cxx
src/gp/gp_Dir.hxx
src/gp/gp_Pnt.cxx
src/gp/gp_Pnt.hxx
src/gp/gp_Trsf.cxx
src/gp/gp_Trsf.hxx
src/gp/gp_XYZ.cxx
src/gp/gp_XYZ.hxx

index 4d70b9e998d2273d73328c401538a7cdefa3b1c6..6e9d907a8059c19e8499b79d7b62b51a919a6b05 100644 (file)
@@ -207,6 +207,51 @@ public:
     }
   }
 
+  //! Inits the content of me into the stream
+  Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+  {
+    Standard_Integer aPos = theStreamPos;
+
+    Standard_Integer isInited = 0;
+    OCCT_INIT_FIELD_VALUE_INTEGER (theSStream, aPos, isInited);
+    myIsInited = isInited != 0;
+
+    int n = Min (N, 3);
+    if (n == 1)
+    {
+      Standard_Real aValue;
+      OCCT_INIT_FIELD_VALUE_REAL (theSStream, aPos, aValue);
+      myMinPoint[0] = (T)aValue;
+    }
+    if (n == 2)
+    {
+      Standard_Real aValue1, aValue2;
+      OCCT_INIT_VECTOR_CLASS (theSStream, "MinPoint", aPos, n, &aValue1, &aValue2);
+      myMinPoint[0] = (T)aValue1;
+      myMinPoint[1] = (T)aValue2;
+
+      OCCT_INIT_VECTOR_CLASS (theSStream, "MaxPoint", aPos, n, &aValue1, &aValue2);
+      myMaxPoint[0] = (T)aValue1;
+      myMaxPoint[1] = (T)aValue2;
+    }
+    if (n == 3)
+    {
+      Standard_Real aValue1, aValue2, aValue3;
+      OCCT_INIT_VECTOR_CLASS (theSStream, "MinPoint", aPos, n, &aValue1, &aValue2, &aValue3);
+      myMinPoint[0] = (T)aValue1;
+      myMinPoint[1] = (T)aValue2;
+      myMinPoint[2] = (T)aValue3;
+
+      OCCT_INIT_VECTOR_CLASS (theSStream, "MaxPoint", aPos, n, &aValue1, &aValue2, &aValue3);
+      myMaxPoint[0] = (T)aValue1;
+      myMaxPoint[1] = (T)aValue2;
+      myMaxPoint[2] = (T)aValue3;
+    }
+
+    theStreamPos = aPos;
+    return Standard_True;
+  }
+
 public:
 
   //! Checks if the Box is out of the other box.
index cb4fbedad97f770a8fae69aa2c904d7a3b3183dd..18f1f228a57e0e1d61d8008cc4a3dfa94b831eea 100644 (file)
@@ -983,3 +983,21 @@ void Bnd_Box::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Gap)
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Flags)
 }
+
+//=======================================================================
+//function : InitFromJson
+//purpose  : 
+//=======================================================================
+Standard_Boolean Bnd_Box::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+
+  OCCT_INIT_VECTOR_CLASS (theSStream, "CornerMin", aPos, 3, &Xmin, &Ymin, &Zmin)
+  OCCT_INIT_VECTOR_CLASS (theSStream, "CornerMax", aPos, 3, &Xmax, &Ymax, &Zmax)
+
+  OCCT_INIT_FIELD_VALUE_REAL (theSStream, aPos, Gap);
+  OCCT_INIT_FIELD_VALUE_INTEGER (theSStream, aPos, Flags);
+
+  theStreamPos = aPos;
+  return Standard_True;
+}
index b716902f07620056412ec2db118fe45be4846018..31af29518e4a8fe837eb48c489769b55a65551bb 100644 (file)
@@ -305,6 +305,9 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
+
 protected:
 
   //! Bit flags.
index d61a6097d164e915ecb61bfec3089d9575ca5cae..90226a361977629bdca16eec2b32982fbe5043d8 100644 (file)
@@ -609,3 +609,17 @@ void Quantity_Color::DumpJson (Standard_OStream& theOStream, Standard_Integer) c
 {
   OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "RGB", 3, myRgb.r(), myRgb.g(), myRgb.b())
 }
+
+//=======================================================================
+//function : InitFromJson
+//purpose  : 
+//=======================================================================
+Standard_Boolean Quantity_Color::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+  Standard_Real  aRed, aGreen, aBlue;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "RGB", aPos, 3, &aRed, &aGreen, &aBlue)
+
+  SetValues ((Standard_ShortReal)aRed, (Standard_ShortReal)aGreen, (Standard_ShortReal)aBlue, Quantity_TOC_RGB);
+  return Standard_True;
+}
index a413e2f23da5db3b5415d13f51096c5fb3e32b64..e15fb00c49661ef7a25c0c56202e64d83c146605 100644 (file)
@@ -345,6 +345,9 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
+
 private:
 
   //! Returns the values of a predefined color according to the mode.
index 80016d8b7e0eabfce65f0436a7f22cfeedc51180..42cd8f4b7088f958d78b33cb6400ca25ad0bd9cd 100644 (file)
@@ -208,3 +208,18 @@ void Quantity_ColorRGBA::DumpJson (Standard_OStream& theOStream, Standard_Intege
 {
   OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "RGBA", 4, myRgb.Red(), myRgb.Green(), myRgb.Blue(), myAlpha)
 }
+
+//=======================================================================
+//function : InitFromJson
+//purpose  : 
+//=======================================================================
+Standard_Boolean Quantity_ColorRGBA::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+
+  Standard_Real aRed, aGreen, aBlue, anAlpha;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "RGBA", aPos, 4, &aRed, &aGreen, &aBlue, &anAlpha)
+
+  SetValues ((Standard_ShortReal)aRed, (Standard_ShortReal)aGreen, (Standard_ShortReal)aBlue, (Standard_ShortReal)anAlpha);
+  return Standard_True;
+}
index bf4e47b211d483e92a1fbcc9d711e561279d11e3..7823262791fcb4431fa9010c49d583b90c9e9ee7 100644 (file)
@@ -158,6 +158,9 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
+
 private:
 
   static void myTestSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); }
index e897901d97b5f866d722e764d5e03cb6e17f66a7..4f030678dc18ae99fa4bd5cf5d138888dc4cca5f 100644 (file)
@@ -74,6 +74,139 @@ void Standard_Dump::DumpRealValues (Standard_OStream& theOStream, int theCount,
   va_end(vl);
 }
 
+//=======================================================================
+//function : ProcessStreamName
+//purpose  : 
+//=======================================================================
+Standard_Boolean Standard_Dump::ProcessStreamName (const Standard_SStream& theStream,
+                                                   const TCollection_AsciiString& theName,
+                                                   Standard_Integer& theStreamPos)
+{
+  TCollection_AsciiString aText = Text (theStream);
+  if (aText.IsEmpty())
+    return Standard_False;
+
+  if (aText.Length () < theStreamPos)
+    return Standard_False;
+
+  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 aKeyName = TCollection_AsciiString (JsonKeyToString (Standard_JsonKey_Quote))
+    + theName
+    + TCollection_AsciiString (JsonKeyToString (Standard_JsonKey_Quote))
+    + JsonKeyToString (Standard_JsonKey_SeparatorKeyToValue);
+  Standard_Boolean aResult = aSubText.StartsWith (aKeyName);
+  if (aResult)
+    theStreamPos += aKeyName.Length();
+
+  return aResult;
+}
+
+//=======================================================================
+//function : ProcessFieldName
+//purpose  : 
+//=======================================================================
+Standard_Boolean Standard_Dump::ProcessFieldName (const Standard_SStream& theStream,
+                                                  const TCollection_AsciiString& theName,
+                                                  Standard_Integer& theStreamPos)
+{
+  TCollection_AsciiString aText = Text (theStream);
+  if (aText.IsEmpty())
+    return Standard_False;
+
+  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 aName = Standard_Dump::DumpFieldToName (theName.ToCString());
+  TCollection_AsciiString aKeyName = TCollection_AsciiString (JsonKeyToString (Standard_JsonKey_Quote))
+    + aName
+    + TCollection_AsciiString (JsonKeyToString (Standard_JsonKey_Quote))
+    + JsonKeyToString (Standard_JsonKey_SeparatorKeyToValue);
+
+  Standard_Boolean aResult = aSubText.StartsWith (aKeyName);
+  if (aResult)
+    theStreamPos += aKeyName.Length();
+
+  return aResult;
+}
+
+//=======================================================================
+//function : InitRealValues
+//purpose  : 
+//=======================================================================
+Standard_Boolean Standard_Dump::InitRealValues (const Standard_SStream& theStream,
+                                                Standard_Integer& theStreamPos,
+                                                int theCount, ...)
+{
+  Standard_Integer aStreamPos = theStreamPos + JsonKeyLength (Standard_JsonKey_OpenContainer);
+
+  TCollection_AsciiString aText = Text (theStream);
+  TCollection_AsciiString aSubText = aText.SubString (aStreamPos, aText.Length());
+
+  va_list  vl;
+  va_start(vl, theCount);
+  aStreamPos = 1;
+  Standard_Integer aClosePos = aSubText.Location (JsonKeyToString (Standard_JsonKey_CloseContainer), aStreamPos, aSubText.Length());
+  for(int i = 0; i < theCount; ++i)
+  {
+    Standard_Integer aNextPos = (i < theCount-1) ? aSubText.Location (JsonKeyToString (Standard_JsonKey_SeparatorValueToValue), aStreamPos, aSubText.Length())
+      : aClosePos;
+
+    TCollection_AsciiString aValueText = aSubText.SubString (aStreamPos, aNextPos - 1);
+
+    if (!aValueText.IsRealValue())
+      return Standard_False;
+
+    Standard_Real aValue = aValueText.RealValue();
+    *(va_arg(vl, Standard_Real*)) = aValue;
+
+    aStreamPos = aNextPos + JsonKeyLength (Standard_JsonKey_SeparatorValueToValue);
+  }
+  va_end(vl);
+  aClosePos = aText.Location (JsonKeyToString (Standard_JsonKey_CloseContainer), theStreamPos, aText.Length());
+  theStreamPos = aClosePos + JsonKeyLength (Standard_JsonKey_CloseContainer);
+
+  return Standard_True;
+}
+
+//=======================================================================
+//function : InitValue
+//purpose  : 
+//=======================================================================
+Standard_Boolean Standard_Dump::InitValue (const Standard_SStream& theStream,
+                                           Standard_Integer& theStreamPos,
+                                           TCollection_AsciiString& theValue)
+{
+  Standard_Integer aStreamPos = theStreamPos;
+
+  TCollection_AsciiString aText = Text (theStream);
+  TCollection_AsciiString aSubText = aText.SubString (aStreamPos, aText.Length());
+
+  aStreamPos = 1;
+  Standard_Integer aNextPos = aSubText.Location (JsonKeyToString (Standard_JsonKey_SeparatorValueToValue), aStreamPos, aSubText.Length());
+  Standard_JsonKey aNextKey = Standard_JsonKey_SeparatorValueToValue;
+
+  Standard_Integer aCloseChildPos = aSubText.Location (JsonKeyToString (Standard_JsonKey_CloseChild), aStreamPos, aSubText.Length());
+  Standard_Boolean isUseClosePos = (aNextPos > 0 && aCloseChildPos > 0 && aCloseChildPos < aNextPos) || !aNextPos;
+  if (isUseClosePos)
+  {
+    aNextPos = aCloseChildPos;
+    aNextKey = Standard_JsonKey_CloseChild;
+  }
+
+  theValue = aNextPos ? aSubText.SubString (aStreamPos, aNextPos - 1) : aSubText;
+  theStreamPos = aNextPos ? (theStreamPos + (aNextPos - aStreamPos) + JsonKeyLength (aNextKey)) : aText.Length();
+  return Standard_True;
+}
+
 // =======================================================================
 // function : GetPointerInfo
 // purpose :
index 2c1e989cbbadb9ce96c4eda8252e1924b21f4047..7a2cd7b0cec952704fd2f2b405ce3d2d6ed1304d 100644 (file)
   theOStream << "\"" << aName << "\": " << theField; \
 }
 
+//! @def OCCT_INIT_FIELD_VALUE_REAL
+//! Append vector values into output value: "Name": [value_1, value_2, ...]
+//! This macro is intended to have only one row for dumped object in Json.
+//! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump.
+#define OCCT_INIT_FIELD_VALUE_REAL(theOStream, theStreamPos, theField) \
+{ \
+  Standard_Integer aStreamPos = theStreamPos; \
+  if (!Standard_Dump::ProcessFieldName (theOStream, #theField, aStreamPos)) \
+    return Standard_False; \
+  TCollection_AsciiString aValueText; \
+  if (!Standard_Dump::InitValue (theOStream, aStreamPos, aValueText) || !aValueText.IsRealValue()) \
+    return Standard_False; \
+  theField = aValueText.RealValue(); \
+  theStreamPos = aStreamPos; \
+}
+
+//! @def OCCT_INIT_FIELD_VALUE_NUMERICAL
+//! Append vector values into output value: "Name": [value_1, value_2, ...]
+//! This macro is intended to have only one row for dumped object in Json.
+//! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump.
+#define OCCT_INIT_FIELD_VALUE_INTEGER(theOStream, theStreamPos, theField) \
+{ \
+  Standard_Integer aStreamPos = theStreamPos; \
+  if (!Standard_Dump::ProcessFieldName (theOStream, #theField, aStreamPos)) \
+    return Standard_False; \
+  TCollection_AsciiString aValueText; \
+  if (!Standard_Dump::InitValue (theOStream, aStreamPos, aValueText) || !aValueText.IsIntegerValue()) \
+    return Standard_False; \
+  theField = aValueText.IntegerValue(); \
+  theStreamPos = aStreamPos; \
+}
+
 //! @def OCCT_DUMP_FIELD_VALUE_STRING
 //! Append into output value: "Name": "Field"
 #define OCCT_DUMP_FIELD_VALUE_STRING(theOStream, theField) \
   } \
 }
 
+//! @def OCCT_INIT_FIELD_VALUES_DUMPED
+//! Append into output value: "Name": { field dumped values }
+//! It computes Dump of the fields. The expected field is a pointer.
+//! Use this macro for fields of the dumped class which has own Dump implementation.
+//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
+//! Depth = -1 is the default value, dump here is unlimited.
+#define OCCT_INIT_FIELD_VALUES_DUMPED(theSStream, theStreamPos, theField) \
+{ \
+  if ((theField) == NULL || !(theField)->InitFromJson (theSStream, theStreamPos)) \
+    return Standard_False; \
+}
+
 //! @def OCCT_DUMP_FIELD_VALUES_NUMERICAL
 //! Append real values into output values in an order: [value_1, value_2, ...]
 //! It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump.
   theOStream << "]"; \
 }
 
+//! @def OCCT_INIT_VECTOR_CLASS
+//! Append vector values into output value: "Name": [value_1, value_2, ...]
+//! This macro is intended to have only one row for dumped object in Json.
+//! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump.
+#define OCCT_INIT_VECTOR_CLASS(theOStream, theName, theStreamPos, theCount, ...) \
+{ \
+  Standard_Integer aStreamPos = theStreamPos; \
+  if (!Standard_Dump::ProcessStreamName (theOStream, theName, aStreamPos)) \
+    return Standard_False; \
+  if (!Standard_Dump::InitRealValues (theOStream, aStreamPos, theCount, __VA_ARGS__)) \
+    return Standard_False; \
+  theStreamPos = aStreamPos; \
+}
+
 //! Kind of key in Json string
 enum Standard_JsonKey
 {
@@ -280,6 +338,38 @@ public:
   //! @param theCount numer of values
   Standard_EXPORT static void DumpRealValues (Standard_OStream& theOStream, int theCount, ...);
 
+  //! Check whether the parameter name is equal to the name in the stream at position
+  //! @param theSStream stream with values
+  //! @param theName stream key value
+  //! @param theStreamPos current position in the stream
+  Standard_EXPORT static Standard_Boolean ProcessStreamName (const Standard_SStream& theStream,
+                                                             const TCollection_AsciiString& theName,
+                                                             Standard_Integer& theStreamPos);
+
+  //! Check whether the field name is equal to the name in the stream at position
+  //! @param theSStream stream with values
+  //! @param theName stream key field value
+  //! @param theStreamPos current position in the stream
+  Standard_EXPORT static Standard_Boolean ProcessFieldName (const Standard_SStream& theStream,
+                                                             const TCollection_AsciiString& theName,
+                                                             Standard_Integer& theStreamPos);
+
+  //! Unite values in one value using template: value_1, value_2, ..., value_n
+  //! @param theSStream stream with values
+  //! @param theStreamPos current position in the stream
+  //! @param theCount numer of values
+  Standard_EXPORT static Standard_Boolean InitRealValues (const Standard_SStream& theStream,
+                                                          Standard_Integer& theStreamPos,
+                                                          int theCount, ...);
+
+  //! Returns real value
+  //! @param theSStream stream with values
+  //! @param theStreamPos current position in the stream
+  //! @param theValue stream value
+  Standard_EXPORT static Standard_Boolean InitValue (const Standard_SStream& theStream,
+                                                     Standard_Integer& theStreamPos,
+                                                     TCollection_AsciiString& theValue);
+
   //! Convert field name into dump text value, removes "&" and "my" prefixes
   //! An example, for field myValue, theName is Value, for &myCLass, the name is Class
   //! @param theField a source value 
index 3ee0231b34f08b33f255e5ba292a661c7615bd7e..378c714395b2cf58b6dc085468c52f11c8f70861 100644 (file)
@@ -90,3 +90,17 @@ void gp_Ax1::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
   OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, loc.X(), loc.Y(), loc.Z())
   OCCT_DUMP_VECTOR_CLASS (theOStream, "Direction", 3, vdir.X(), vdir.Y(), vdir.Z())
 }
+
+Standard_Boolean gp_Ax1::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+
+  gp_XYZ& anXYZLoc = loc.ChangeCoord();
+  OCCT_INIT_VECTOR_CLASS (theSStream, "Location", aPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3))
+  gp_XYZ aDir;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "Direction", aPos, 3, &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3))
+  SetDirection (aDir);
+
+  theStreamPos = aPos;
+  return Standard_True;
+}
index f71a0829fe931812af13557830a4989836df2fa4..0d9b3683ee683c98525f96381f3e4e6ebd664863 100644 (file)
@@ -208,7 +208,8 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
-
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
 
 protected:
 
index ba8e7b155d56607e6d149ed3f8cbfdac08de227c..b16071f7fdffe0d4b1b7e61d44d4d9b731a7d6a9 100644 (file)
@@ -122,3 +122,28 @@ void gp_Ax2::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
   OCCT_DUMP_VECTOR_CLASS (theOStream, "XDirection", 3, vxdir.X(), vxdir.Y(), vxdir.Z())
   OCCT_DUMP_VECTOR_CLASS (theOStream, "YDirection", 3, vydir.X(), vydir.Y(), vydir.Z())
 }
+
+Standard_Boolean gp_Ax2::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+
+  gp_XYZ anXYZLoc;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "Location", aPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3))
+  SetLocation (anXYZLoc);
+
+  gp_XYZ aDir;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "Direction", aPos, 3, &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3))
+  gp_XYZ aXDir;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "XDirection", aPos, 3, &aXDir.ChangeCoord (1), &aXDir.ChangeCoord (2), &aXDir.ChangeCoord (3))
+  gp_XYZ anYDir;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "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;
+
+  theStreamPos = aPos;
+  return Standard_True;
+}
index 1586dfed73254f679566d863bef48a6304c2f280..50b243c8ac936d9caabc0937b5193f6902f2acc7 100644 (file)
@@ -326,6 +326,9 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
+
 
 
 protected:
index ec5e8b7c4d622c0c175fdbab940b6b1eaaf64601..93e6d357579ebe3a211f3245eaacfec8691021a1 100644 (file)
@@ -115,3 +115,25 @@ void gp_Ax3::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
   OCCT_DUMP_VECTOR_CLASS (theOStream, "XDirection", 3, XDirection().X(), XDirection().Y(), XDirection().Z())
   OCCT_DUMP_VECTOR_CLASS (theOStream, "YDirection", 3, YDirection().X(), YDirection().Y(), YDirection().Z())
 }
+
+Standard_Boolean  gp_Ax3::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+
+  gp_XYZ anXYZLoc;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "Location", aPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3))
+  SetLocation (anXYZLoc);
+
+  gp_XYZ aDir;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "Direction", aPos, 3, &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3))
+  gp_XYZ aXDir;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "XDirection", aPos, 3, &aXDir.ChangeCoord (1), &aXDir.ChangeCoord (2), &aXDir.ChangeCoord (3))
+  gp_XYZ anYDir;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "YDirection", aPos, 3, &anYDir.ChangeCoord (1), &anYDir.ChangeCoord (2), &anYDir.ChangeCoord (3))
+
+  SetXDirection (aXDir);
+  SetYDirection (anYDir);
+
+  theStreamPos = aPos;
+  return Standard_True;
+}
index 50068bea7bced15dcdb96d1937f162a8fb961971..6424a14012c8eee8852f7c9dc7df214a2a5bc59f 100644 (file)
@@ -293,7 +293,8 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
-
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
 
 protected:
 
index 0714a34e6bb029279de1ac9e590a416892180d70..68b57b9a1b6d5c5465640bd73f74a3cf0f56818d 100644 (file)
@@ -144,3 +144,13 @@ void gp_Dir::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
 {
   OCCT_DUMP_VECTOR_CLASS (theOStream, "gp_Dir", 3, coord.X(), coord.Y(), coord.Z())
 }
+
+Standard_Boolean gp_Dir::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+
+  OCCT_INIT_VECTOR_CLASS (theSStream, "gp_Dir", aPos, 3, &coord.ChangeCoord (1), &coord.ChangeCoord (2), &coord.ChangeCoord (3))
+
+  theStreamPos = aPos;
+  return Standard_True;
+}
index 0892155c000c193e2f5f16ad30a0f38affabb84c..8322c2a6219ad162647567d62d018f030dad1c67 100644 (file)
@@ -266,6 +266,8 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
 
 
 protected:
index 10a9b5d4345e5a3feb44ed985b9899e530fd4d15..e4541aeeb449181e1383c4ec2ed9913e64aea327 100644 (file)
@@ -90,3 +90,13 @@ void gp_Pnt::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
 {
   OCCT_DUMP_VECTOR_CLASS (theOStream, "gp_Pnt", 3, coord.X(), coord.Y(), coord.Z())
 }
+
+Standard_Boolean gp_Pnt::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+
+  OCCT_INIT_VECTOR_CLASS (theSStream, "gp_Pnt", aPos, 3, &coord.ChangeCoord (1), &coord.ChangeCoord (2), &coord.ChangeCoord (3))
+
+  theStreamPos = aPos;
+  return Standard_True;
+}
index b9c4b5c0870406826923e4dd7197cfb2e00ac76d..3211e6a9b10230d4f3a1f36d2c4c10806f76829d 100644 (file)
@@ -177,7 +177,8 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
-
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
 
 protected:
 
index 9a4e299de50089a563d7532f318496f7c70b58fa..f673419efaef2187159fcc4e4426ec8bc11db12c 100644 (file)
@@ -864,3 +864,37 @@ void gp_Trsf::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, shape)
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, scale)
 }
+
+//=======================================================================
+//function : InitFromJson
+//purpose  : 
+//=======================================================================
+Standard_Boolean  gp_Trsf::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+
+  gp_XYZ anXYZLoc;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "Location", aPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3))
+  SetTranslation (anXYZLoc);
+
+  Standard_Real mymatrix[3][3];
+  OCCT_INIT_VECTOR_CLASS (theSStream, "Matrix", aPos, 9, &mymatrix[0][0], &mymatrix[0][1], &mymatrix[0][2],
+                                                         &mymatrix[1][0], &mymatrix[1][1], &mymatrix[1][2],
+                                                         &mymatrix[2][0], &mymatrix[2][1], &mymatrix[2][2])
+  for (int i = 0; i < 3; i++)
+  {
+    for (int j = 0; j < 3; j++)
+    {
+      matrix.SetValue (i + 1, j + 1, mymatrix[i][j]);
+    }
+  }
+
+  Standard_Real myshape;
+  OCCT_INIT_FIELD_VALUE_INTEGER (theSStream, aPos, myshape);
+  shape = (gp_TrsfForm)((Standard_Integer)myshape);
+
+  OCCT_INIT_FIELD_VALUE_REAL (theSStream, aPos, scale);
+
+  theStreamPos = aPos;
+  return Standard_True;
+}
index 82c15e91c1dfb91235db521143cd789a0322f2be..8aed8279358eb740316263b8f1793aa23e1e0a89 100644 (file)
@@ -353,6 +353,9 @@ void operator *= (const gp_Trsf& T)
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
+
 friend class gp_GTrsf;
 
 protected:
index 0599ad950e4d1f031b92b5aca5e124fdcc971541..06e20730e985258bc6e2b65335d2253267fc08a9 100644 (file)
@@ -42,3 +42,17 @@ void gp_XYZ::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
 {
   OCCT_DUMP_VECTOR_CLASS (theOStream, "gp_XYZ", 3, x, y, z)
 }
+
+//=======================================================================
+//function : InitFromJson
+//purpose  : 
+//=======================================================================
+Standard_Boolean gp_XYZ::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
+{
+  Standard_Integer aPos = theStreamPos;
+  OCCT_INIT_VECTOR_CLASS (theSStream, "gp_XYZ", aPos, 3, &x, &y, &z)
+
+  theStreamPos = aPos;
+  return Standard_True;
+}
+
index e3b49d82eca65d20622cc67880d4c5079fe05b27..b6cf952c4f33a80d446918e4ec41e2b4c8739010 100644 (file)
@@ -330,6 +330,9 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
+  //! Inits the content of me into the stream
+  Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
+
 protected: