From 0904aa6395c6e00d07ffa83ae21334236b0eb51b Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 19 Sep 2019 15:13:42 +0300 Subject: [PATCH] 0030949: Foundation Classes - Dump improvement for OCCT classes 1. new file Standard_Dump to prepare and parse Dump in JSON format for OCCT objects 2. some presentations cover the proposed dump functionality. 3. 'bounding', 'vaspects' has '-dumpJson' field to see the DumpJson result 4. Bnd_Box constructor with min/max points is implemented to use Dump of this class in Dump BVH_Box 5. Limitation (some classes of Graphic3d, Prs3d has not full filling for DumpJson) --- dox/dev_guides/debug/debug.md | 58 +++++ src/AIS/AIS_InteractiveObject.cxx | 13 + src/AIS/AIS_InteractiveObject.hxx | 2 + src/BRepTest/BRepTest_BasicCommands.cxx | 32 ++- src/BVH/BVH_Box.hxx | 9 + src/BVH/BVH_Tree.hxx | 37 +++ src/BVH/BVH_Types.hxx | 28 +++ src/Bnd/Bnd_Box.cxx | 28 +++ src/Bnd/Bnd_Box.hxx | 9 + src/Bnd/Bnd_OBB.cxx | 19 ++ src/Bnd/Bnd_OBB.hxx | 4 + src/Bnd/Bnd_Range.cxx | 15 +- src/Bnd/Bnd_Range.hxx | 3 + src/Graphic3d/FILES | 1 + src/Graphic3d/Graphic3d_Aspects.cxx | 23 ++ src/Graphic3d/Graphic3d_Aspects.hxx | 3 + src/Graphic3d/Graphic3d_Group.cxx | 12 + src/Graphic3d/Graphic3d_Group.hxx | 3 + src/Graphic3d/Graphic3d_PolygonOffset.cxx | 29 +++ src/Graphic3d/Graphic3d_PolygonOffset.hxx | 5 + src/OpenGl/OpenGl_Aspects.cxx | 12 + src/OpenGl/OpenGl_Aspects.hxx | 3 + src/OpenGl/OpenGl_Group.cxx | 13 + src/OpenGl/OpenGl_Group.hxx | 3 + src/Prs3d/Prs3d_ArrowAspect.cxx | 14 ++ src/Prs3d/Prs3d_ArrowAspect.hxx | 3 + src/Prs3d/Prs3d_BasicAspect.hxx | 5 + src/Prs3d/Prs3d_DatumAspect.cxx | 20 ++ src/Prs3d/Prs3d_DatumAspect.hxx | 3 + src/Prs3d/Prs3d_DimensionAspect.cxx | 26 ++ src/Prs3d/Prs3d_DimensionAspect.hxx | 3 + src/Prs3d/Prs3d_Drawer.cxx | 11 + src/Prs3d/Prs3d_Drawer.hxx | 3 + src/Prs3d/Prs3d_LineAspect.cxx | 13 + src/Prs3d/Prs3d_LineAspect.hxx | 3 + src/Prs3d/Prs3d_PlaneAspect.cxx | 27 ++ src/Prs3d/Prs3d_PlaneAspect.hxx | 3 + src/Prs3d/Prs3d_PointAspect.cxx | 13 + src/Prs3d/Prs3d_PointAspect.hxx | 3 + src/Prs3d/Prs3d_ShadingAspect.cxx | 12 + src/Prs3d/Prs3d_ShadingAspect.hxx | 3 + src/Prs3d/Prs3d_TextAspect.cxx | 18 ++ src/Prs3d/Prs3d_TextAspect.hxx | 3 + src/PrsMgr/PrsMgr_PresentableObject.cxx | 19 ++ src/PrsMgr/PrsMgr_PresentableObject.hxx | 3 + src/Quantity/Quantity_Color.cxx | 11 + src/Quantity/Quantity_Color.hxx | 3 + src/Quantity/Quantity_ColorRGBA.cxx | 13 + src/Quantity/Quantity_ColorRGBA.hxx | 3 + src/SelectMgr/SelectMgr_BaseFrustum.cxx | 18 ++ src/SelectMgr/SelectMgr_BaseFrustum.hxx | 5 + src/SelectMgr/SelectMgr_EntityOwner.cxx | 14 ++ src/SelectMgr/SelectMgr_EntityOwner.hxx | 3 + src/SelectMgr/SelectMgr_SelectableObject.cxx | 13 + src/SelectMgr/SelectMgr_SelectableObject.hxx | 3 + src/SelectMgr/SelectMgr_ViewClipRange.cxx | 15 ++ src/SelectMgr/SelectMgr_ViewClipRange.hxx | 5 + src/SelectMgr/SelectMgr_ViewerSelector.cxx | 23 ++ src/SelectMgr/SelectMgr_ViewerSelector.hxx | 3 + src/Standard/FILES | 2 + src/Standard/Standard_Dump.cxx | 224 +++++++++++++++++ src/Standard/Standard_Dump.hxx | 245 +++++++++++++++++++ src/TopLoc/TopLoc_Datum3D.cxx | 11 + src/TopLoc/TopLoc_Datum3D.hxx | 3 + src/TopLoc/TopLoc_ItemLocation.cxx | 15 ++ src/TopLoc/TopLoc_ItemLocation.hxx | 4 + src/TopLoc/TopLoc_Location.cxx | 13 + src/TopLoc/TopLoc_Location.hxx | 3 + src/TopoDS/TopoDS_Shape.cxx | 15 ++ src/TopoDS/TopoDS_Shape.hxx | 3 + src/TopoDS/TopoDS_TShape.cxx | 12 + src/TopoDS/TopoDS_TShape.hxx | 3 + src/ViewerTest/ViewerTest.cxx | 48 +++- src/XCAFPrs/XCAFPrs_Style.cxx | 18 ++ src/XCAFPrs/XCAFPrs_Style.hxx | 3 + src/gp/gp_Mat.cxx | 9 + src/gp/gp_Mat.hxx | 3 + src/gp/gp_Trsf.cxx | 16 ++ src/gp/gp_Trsf.hxx | 4 + src/gp/gp_XYZ.cxx | 9 + src/gp/gp_XYZ.hxx | 5 + tests/bugs/modalg_7/bug30949 | 18 ++ tests/bugs/vis/bug30949 | 34 +++ 83 files changed, 1420 insertions(+), 4 deletions(-) create mode 100644 src/Graphic3d/Graphic3d_PolygonOffset.cxx create mode 100644 src/Standard/Standard_Dump.cxx create mode 100644 src/Standard/Standard_Dump.hxx create mode 100644 tests/bugs/modalg_7/bug30949 create mode 100644 tests/bugs/vis/bug30949 diff --git a/dox/dev_guides/debug/debug.md b/dox/dev_guides/debug/debug.md index d48434f09f..5a5c9f1ae3 100644 --- a/dox/dev_guides/debug/debug.md +++ b/dox/dev_guides/debug/debug.md @@ -136,6 +136,64 @@ const char* GeomTools_Dump (void* theHandlePtr) Dump geometric object to cout. - *theHandlePtr* -- a pointer to the geometric variable (Handle to *Geom_Geometry* or *Geom2d_Curve* or descendant) to be set. + +@section occt_debug_dump_json Dump OCCT objects into Json + +Many OCCT classes may dump the current state into the stream. This stream contains the information about the class field into the field value/s. +It is possible to prepare recursive dump using corresponded macro for class fields. The depth of this recursion is defined by parameter of the dump. +The object defines What parameters should be presented in the Dump. The usual way is to dump all object fields. + +@subsection occt_debug_dump_json_object Implementation in object + +Steps to prepare dump of the object into json: + +1. Create method DumpJson. The method should accept the output steam and the depth for the fields dump. +Depth, equal to zero means that only fields of this class should be dumped. Default value -1 means that whole tree of dump will be built recursively calling dump of all fields. + +2. Put into the first row of the method DUMP_CLASS_BEGIN. This macro creates a local variable, that will open Json structure on start, and close on exit from this method. + +3. Add several macro to store field values. + +The following macro are defined to cover the object parameters into json format: + +| Name | Result in json | +| :-------------------------- | :--------| +| DUMP_FIELD_VALUE_NUMERICAL | "field": value | +| DUMP_FIELD_VALUE_STRING | "field": "value" | +| DUMP_FIELD_VALUE_POINTER | "field": "pointer address" | +| DUMP_FIELD_VALUES_DUMPED | "field": { fesult of field->DumpJson(...) } | +| DUMP_FIELD_VALUES_NUMERICAL | "field": [value_1, ..., value_n] +| DUMP_FIELD_VALUES_STRING | "field": ["value_1", ..., "value_n"] +| DUMP_FIELD_VALUES_BY_KIND | "kind": { result of kind::DumpJson(...) } | + +@subsection occt_debug_dump_json_draw Using in DRAW + +In DRAW, key '-dumpJson' is used to dump an object. +It is implemented in 'vaspect' and 'boundingbox' commands. + +Json output for Bnd_OBB (using command 'bounding v -obb -dumpJson'): + +~~~~~ +"Bnd_OBB": { + "Center": { + "gp_XYZ": [1, 2, 3] + }, + "Axes[0]": { + "gp_XYZ:" [1, 0, 0] + }, + "Axes[1]": { + "gp_XYZ:" [0, 1, 0] + }, + "Axes[2]": { + "gp_XYZ:" [0, 0, 1] + }, + "HDims[0]": 0, + "HDims[1]": 0, + "HDims[2]": 0, + "IsAABox": 1, +} +~~~~~ + @section occt_debug_vstudio Using Visual Studio debugger @subsection occt_debug_vstudio_command Command window diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index ccca7490ea..892bab3a64 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -143,3 +143,16 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect()); } } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void AIS_InteractiveObject::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, AIS_InteractiveObject); + + DUMP_FIELD_VALUES_BY_KIND (theOStream, theDepth, SelectMgr_SelectableObject); + DUMP_FIELD_VALUE_POINTER (theOStream, myCTXPtr); + DUMP_FIELD_VALUE_POINTER (theOStream, myOwner); +} diff --git a/src/AIS/AIS_InteractiveObject.hxx b/src/AIS/AIS_InteractiveObject.hxx index 4ca80616ed..ec9b48de08 100644 --- a/src/AIS/AIS_InteractiveObject.hxx +++ b/src/AIS/AIS_InteractiveObject.hxx @@ -118,6 +118,8 @@ public: Standard_DEPRECATED("Deprecated method, results might be undefined") Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect); + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; protected: //! The TypeOfPresention3d means that the interactive object diff --git a/src/BRepTest/BRepTest_BasicCommands.cxx b/src/BRepTest/BRepTest_BasicCommands.cxx index eb913e11ee..3e104a3333 100644 --- a/src/BRepTest/BRepTest_BasicCommands.cxx +++ b/src/BRepTest/BRepTest_BasicCommands.cxx @@ -55,6 +55,9 @@ #include #include #include + +#include + #include Standard_IMPORT Draw_Viewer dout; @@ -498,6 +501,7 @@ static Standard_Integer BoundBox(Draw_Interpretor& theDI, Bnd_Box anAABB; Standard_Boolean doPrint = Standard_False; + Standard_Boolean doDumpJson = Standard_False; Standard_Boolean useOldSyntax = Standard_False; Standard_Boolean isOBB = Standard_False; Standard_Boolean isTriangulationReq = Standard_True; @@ -532,6 +536,10 @@ static Standard_Integer BoundBox(Draw_Interpretor& theDI, { doPrint = Standard_True; } + else if (anArgCase == "-dumpjson") + { + doDumpJson = Standard_True; + } else if (anArgCase == "-save" && anArgIter + 6 < theNArg && anOutVars[0].IsEmpty()) @@ -601,7 +609,7 @@ static Standard_Integer BoundBox(Draw_Interpretor& theDI, } // enable printing (old syntax) if neither saving to shape nor to DRAW variables is requested - if (! doPrint && anOutVars[0].IsEmpty() && aResShapeName.IsEmpty()) + if (! doPrint && ! doDumpJson && anOutVars[0].IsEmpty() && aResShapeName.IsEmpty()) { doPrint = Standard_True; useOldSyntax = Standard_True; @@ -636,6 +644,15 @@ static Standard_Integer BoundBox(Draw_Interpretor& theDI, << "Half Z: " << anOBB.ZHSize() << "\n"; } + if (doDumpJson) + { + Standard_SStream aStream; + anOBB.DumpJson (aStream); + + theDI << "Oriented bounding box\n"; + theDI << Standard_Dump::FormatJson (aStream); + } + if (hasToDraw && !anOBB.IsVoid()) { @@ -703,6 +720,15 @@ static Standard_Integer BoundBox(Draw_Interpretor& theDI, } } + if (doDumpJson) + { + Standard_SStream aStream; + anAABB.DumpJson (aStream); + + theDI << "Bounding box\n"; + theDI << Standard_Dump::FormatJson (aStream); + } + // save DRAW variables if (!anOutVars[0].IsEmpty()) { @@ -1475,7 +1501,7 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands) theCommands.Add ("bounding", "bounding {shape | xmin ymin zmin xmax ymax zmax}" "\n\t\t: [-obb] [-noTriangulation] [-optimal] [-extToler]" - "\n\t\t: [-dump] [-shape name] [-nodraw] [-finitePart]" + "\n\t\t: [-dump] [-print] [-dumpJson] [-shape name] [-nodraw] [-finitePart]" "\n\t\t: [-save xmin ymin zmin xmax ymax zmax]" "\n\t\t:" "\n\t\t: Computes a bounding box. Two types of the source data are supported:" @@ -1493,8 +1519,10 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands) "\n\t\t:" "\n\t\t: Output options:" "\n\t\t: -dump Prints the information about computed Bounding Box." + "\n\t\t: -print Prints the information about computed Bounding Box." "\n\t\t: It is enabled by default (with plain old syntax for AABB)" "\n\t\t: if neither -shape nor -save is specified." + "\n\t\t: -dumpJson Prints DumpJson information about Bounding Box." "\n\t\t: -shape Stores computed box as solid in DRAW variable with specified name." "\n\t\t: -save Stores min and max coordinates of AABB in specified variables." "\n\t\t: -noDraw Avoid drawing resulting Bounding Box in DRAW viewer." diff --git a/src/BVH/BVH_Box.hxx b/src/BVH/BVH_Box.hxx index 920c278a41..0f0ad86b31 100644 --- a/src/BVH/BVH_Box.hxx +++ b/src/BVH/BVH_Box.hxx @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -108,6 +109,14 @@ public: //! Returns center of bounding box along the given axis. T Center (const Standard_Integer theAxis) const; + //! Dumps the content of me into the stream + void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const + { + (void)theDepth; + DUMP_CLASS_BEGIN (theOStream, BVH_Box); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsValid()); + } + public: //! Checks if the Box is out of the other box. diff --git a/src/BVH/BVH_Tree.hxx b/src/BVH/BVH_Tree.hxx index a223d14b30..ec27b6f512 100644 --- a/src/BVH/BVH_Tree.hxx +++ b/src/BVH/BVH_Tree.hxx @@ -27,6 +27,13 @@ class BVH_TreeBaseTransient : public Standard_Transient DEFINE_STANDARD_RTTIEXT(BVH_TreeBaseTransient, Standard_Transient) protected: BVH_TreeBaseTransient() {} + + //! Dumps the content of me into the stream + virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const { (void)theOStream; (void)theDepth; } + + //! Dumps the content of me into the stream + virtual void DumpNode (const int theNodeIndex, Standard_OStream& theOStream, const Standard_Integer theDepth) const + { (void)theNodeIndex; (void)theOStream; (void)theDepth; } }; //! Stores parameters of bounding volume hierarchy (BVH). @@ -178,6 +185,36 @@ public: //! @name methods for accessing serialized tree data return myMaxPointBuffer; } + //! Dumps the content of me into the stream + virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE + { + DUMP_CLASS_BEGIN (theOStream, BVH_TreeBase); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDepth); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, Length()); + + for (Standard_Integer aNodeIdx = 0; aNodeIdx < Length(); ++aNodeIdx) + { + DumpNode (aNodeIdx, theOStream, theDepth); + } + } + + //! Dumps the content of node into the stream + virtual void DumpNode (const int theNodeIndex, Standard_OStream& theOStream, const Standard_Integer theDepth) const Standard_OVERRIDE + { + DUMP_CLASS_BEGIN (theOStream, BVH_TreeNode); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, theNodeIndex); + + Bnd_Box aBndBox = BVH::ToBndBox (MinPoint (theNodeIndex), MaxPoint (theNodeIndex)); + Bnd_Box* aPointer = &aBndBox; + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aPointer); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, BegPrimitive (theNodeIndex)); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, EndPrimitive (theNodeIndex)); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, Level (theNodeIndex)); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsOuter (theNodeIndex)); + } + public: //! @name protected fields //! Array of node data records. diff --git a/src/BVH/BVH_Types.hxx b/src/BVH/BVH_Types.hxx index 6cbf7ae916..1776f1681b 100644 --- a/src/BVH/BVH_Types.hxx +++ b/src/BVH/BVH_Types.hxx @@ -21,10 +21,12 @@ #include +#include #include #include #include #include +#include #include // GCC supports shrink function only in C++11 mode @@ -57,6 +59,32 @@ namespace BVH typedef NCollection_Vec3 Type; }; + template Bnd_Box ToBndBox (const T& theMin, const T& theMax) + { + return Bnd_Box (gp_Pnt (theMin, 0., 0.), gp_Pnt (theMax, 0., 0.)); + } + + template Bnd_Box ToBndBox (const NCollection_Vec2& theMin, + const NCollection_Vec2& theMax) + { + return Bnd_Box (gp_Pnt (theMin.x(), theMin.y(), 0.), + gp_Pnt (theMax.x(), theMax.y(), 0.)); + } + + template Bnd_Box ToBndBox (const NCollection_Vec3& theMin, + const NCollection_Vec3& theMax) + { + return Bnd_Box (gp_Pnt (theMin.x(), theMin.y(), theMin.z()), + gp_Pnt (theMax.x(), theMax.y(), theMax.z())); + } + + template Bnd_Box ToBndBox (const NCollection_Vec4& theMin, + const NCollection_Vec4& theMax) + { + return Bnd_Box (gp_Pnt (theMin.x(), theMin.y(), theMin.z()), + gp_Pnt (theMax.x(), theMax.y(), theMax.z())); + } + template struct VectorType { typedef NCollection_Vec4 Type; diff --git a/src/Bnd/Bnd_Box.cxx b/src/Bnd/Bnd_Box.cxx index 1b4ab44b53..ce7a6afe9e 100644 --- a/src/Bnd/Bnd_Box.cxx +++ b/src/Bnd/Bnd_Box.cxx @@ -21,6 +21,7 @@ #include #include #include +#include // set the flag to one #define ClearVoidFlag() ( Flags &= ~VoidMask ) @@ -43,6 +44,18 @@ Bnd_Box::Bnd_Box() SetVoid(); } +//======================================================================= +//function : Bnd_Box +//purpose : +//======================================================================= +Bnd_Box::Bnd_Box (const gp_Pnt theMin, const gp_Pnt theMax) +: Gap (0.0) +{ + SetVoid(); + Update (theMin.X(), theMin.Y(), theMin.Z(), theMax.X(), theMax.Y(), theMax.Z()); +} + + //======================================================================= //function : Set //purpose : @@ -957,3 +970,18 @@ void Bnd_Box::Dump () const std::cout << "\n Gap : " << Gap; std::cout << "\n"; } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Bnd_Box::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, Bnd_Box); + + DUMP_FIELD_VALUES_NUMERICAL (theOStream, "CornerMin", 3, Xmin, Ymin, Zmin) + DUMP_FIELD_VALUES_NUMERICAL (theOStream, "CornerMax", 3, Xmax, Ymax, Zmax) + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, Gap); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, Flags); +} diff --git a/src/Bnd/Bnd_Box.hxx b/src/Bnd/Bnd_Box.hxx index 834338f5bf..4d220df02a 100644 --- a/src/Bnd/Bnd_Box.hxx +++ b/src/Bnd/Bnd_Box.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -69,6 +70,11 @@ public: //! The constructed box is qualified Void. Its gap is null. Standard_EXPORT Bnd_Box(); + //! Creates a bounding box, it contains: + //! - minimum/maximum point of bouning box, + //! The constructed box is qualified Void. Its gap is null. + Standard_EXPORT Bnd_Box (const gp_Pnt theMin, const gp_Pnt theMax); + //! Sets this bounding box so that it covers the whole of 3D space. //! It is infinitely long in all directions. void SetWhole() { Flags = WholeMask; } @@ -296,6 +302,9 @@ public: && Xmax >= Xmin; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: //! Bit flags. diff --git a/src/Bnd/Bnd_OBB.cxx b/src/Bnd/Bnd_OBB.cxx index 6fd3dc700e..b237bee2c1 100644 --- a/src/Bnd/Bnd_OBB.cxx +++ b/src/Bnd/Bnd_OBB.cxx @@ -24,6 +24,7 @@ #include #include +#include #include //! Auxiliary class to select from the points stored in @@ -1022,3 +1023,21 @@ void Bnd_OBB::Add(const Bnd_OBB& theOther) } } +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Bnd_OBB::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Bnd_OBB); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCenter); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myAxes[0]); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myAxes[1]); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myAxes[2]); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHDims[0]); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHDims[1]); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHDims[2]); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAABox); +} diff --git a/src/Bnd/Bnd_OBB.hxx b/src/Bnd/Bnd_OBB.hxx index ffed615cca..7844eaecfd 100644 --- a/src/Bnd/Bnd_OBB.hxx +++ b/src/Bnd/Bnd_OBB.hxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -281,6 +282,9 @@ public: //! (which it was created from) and theP. Standard_EXPORT void Add(const gp_Pnt& theP); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: void ProcessOnePoint(const gp_Pnt& theP) diff --git a/src/Bnd/Bnd_Range.cxx b/src/Bnd/Bnd_Range.cxx index 63d0961343..2fb63e87c7 100644 --- a/src/Bnd/Bnd_Range.cxx +++ b/src/Bnd/Bnd_Range.cxx @@ -15,6 +15,7 @@ #include +#include //======================================================================= //function : Common @@ -174,4 +175,16 @@ void Bnd_Range::Split(const Standard_Real theVal, { theList.Append(Bnd_Range(aValPrev, myLast)); } -} \ No newline at end of file +} + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Bnd_Range::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, Bnd_Range); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFirst); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLast); +} diff --git a/src/Bnd/Bnd_Range.hxx b/src/Bnd/Bnd_Range.hxx index 0c006d27d9..74767ec08e 100644 --- a/src/Bnd/Bnd_Range.hxx +++ b/src/Bnd/Bnd_Range.hxx @@ -256,6 +256,9 @@ public: return ((myFirst == theOther.myFirst) && (myLast == theOther.myLast)); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: Standard_Real myFirst; //!< Start of range diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index 6ac062deca..4e1e2b8517 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -110,6 +110,7 @@ Graphic3d_NameOfTexture2D.hxx Graphic3d_NameOfTextureEnv.hxx Graphic3d_NameOfTexturePlane.hxx Graphic3d_NMapOfTransient.hxx +Graphic3d_PolygonOffset.cxx Graphic3d_PolygonOffset.hxx Graphic3d_PriorityDefinitionError.hxx Graphic3d_RenderingMode.hxx diff --git a/src/Graphic3d/Graphic3d_Aspects.cxx b/src/Graphic3d/Graphic3d_Aspects.cxx index b8d12a4937..c36a5ad966 100644 --- a/src/Graphic3d/Graphic3d_Aspects.cxx +++ b/src/Graphic3d/Graphic3d_Aspects.cxx @@ -12,6 +12,7 @@ // commercial license or contractual agreement. #include +#include IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient) @@ -60,3 +61,25 @@ void Graphic3d_Aspects::SetTextureMap (const Handle(Graphic3d_TextureMap)& theTe myTextureSet = new Graphic3d_TextureSet (theTexture); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Graphic3d_Aspects::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Graphic3d_Aspects); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myInteriorColor); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBackInteriorColor); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myEdgeColor); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPolygonOffset); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToSkipFirstEdge); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDistinguishMaterials); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawEdges); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawSilhouette); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToSuppressBackFaces); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToMapTexture); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsTextZoomable); +} diff --git a/src/Graphic3d/Graphic3d_Aspects.hxx b/src/Graphic3d/Graphic3d_Aspects.hxx index 70aa6a2779..adf5ea396c 100644 --- a/src/Graphic3d/Graphic3d_Aspects.hxx +++ b/src/Graphic3d/Graphic3d_Aspects.hxx @@ -477,6 +477,9 @@ public: && myIsTextZoomable == theOther.myIsTextZoomable; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: Handle(Graphic3d_ShaderProgram) myProgram; diff --git a/src/Graphic3d/Graphic3d_Group.cxx b/src/Graphic3d/Graphic3d_Group.cxx index 4e7966d60b..98de527eff 100644 --- a/src/Graphic3d/Graphic3d_Group.cxx +++ b/src/Graphic3d/Graphic3d_Group.cxx @@ -447,3 +447,15 @@ void Graphic3d_Group::AddText (const Handle(Graphic3d_Text)& theTextParams, Update(); } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Graphic3d_Group::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, Graphic3d_Group); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsClosed); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myContainsFacet); +} diff --git a/src/Graphic3d/Graphic3d_Group.hxx b/src/Graphic3d/Graphic3d_Group.hxx index 1e6fde6f47..9bff85e900 100644 --- a/src/Graphic3d/Graphic3d_Group.hxx +++ b/src/Graphic3d/Graphic3d_Group.hxx @@ -276,6 +276,9 @@ public: const Standard_Boolean theHasOwnAnchor = Standard_True); + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: //! Creates a group in the structure . diff --git a/src/Graphic3d/Graphic3d_PolygonOffset.cxx b/src/Graphic3d/Graphic3d_PolygonOffset.cxx new file mode 100644 index 0000000000..b7148fc99b --- /dev/null +++ b/src/Graphic3d/Graphic3d_PolygonOffset.cxx @@ -0,0 +1,29 @@ +// Copyright (c) 2016 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Graphic3d_PolygonOffset::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, Graphic3d_PolygonOffset); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, Mode); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, Factor); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, Units); +} diff --git a/src/Graphic3d/Graphic3d_PolygonOffset.hxx b/src/Graphic3d/Graphic3d_PolygonOffset.hxx index 6bc5d09297..0926e2ce69 100644 --- a/src/Graphic3d/Graphic3d_PolygonOffset.hxx +++ b/src/Graphic3d/Graphic3d_PolygonOffset.hxx @@ -15,6 +15,7 @@ #define _Graphic3d_PolygonOffset_HeaderFile #include +#include //! Polygon offset parameters. struct Graphic3d_PolygonOffset @@ -33,6 +34,10 @@ struct Graphic3d_PolygonOffset && Factor == theOther.Factor && Units == theOther.Units; } + + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + }; #endif // _Graphic3d_PolygonOffset_HeaderFile diff --git a/src/OpenGl/OpenGl_Aspects.cxx b/src/OpenGl/OpenGl_Aspects.cxx index 6eae505d74..2d962dafac 100644 --- a/src/OpenGl/OpenGl_Aspects.cxx +++ b/src/OpenGl/OpenGl_Aspects.cxx @@ -110,3 +110,15 @@ void OpenGl_Aspects::Release (OpenGl_Context* theContext) myResSprite.Release (theContext); myResProgram.Release (theContext); } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void OpenGl_Aspects::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, OpenGl_Aspects); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspect.get()); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myShadingModel); +} diff --git a/src/OpenGl/OpenGl_Aspects.hxx b/src/OpenGl/OpenGl_Aspects.hxx index 9e881dfebc..d767038689 100644 --- a/src/OpenGl/OpenGl_Aspects.hxx +++ b/src/OpenGl/OpenGl_Aspects.hxx @@ -89,6 +89,9 @@ public: //! Update presentation aspects parameters after their modification. virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: //! OpenGl resources diff --git a/src/OpenGl/OpenGl_Group.cxx b/src/OpenGl/OpenGl_Group.cxx index a6a8afa13b..56cbf2e6f2 100644 --- a/src/OpenGl/OpenGl_Group.cxx +++ b/src/OpenGl/OpenGl_Group.cxx @@ -338,3 +338,16 @@ void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx) OpenGl_Element::Destroy (theGlCtx.get(), myAspects); } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void OpenGl_Group::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, OpenGl_Group); + + DUMP_FIELD_VALUES_BY_KIND (theOStream, theDepth, Graphic3d_Group); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspects); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsRaytracable); +} diff --git a/src/OpenGl/OpenGl_Group.hxx b/src/OpenGl/OpenGl_Group.hxx index 9000821e64..29e04ec97e 100644 --- a/src/OpenGl/OpenGl_Group.hxx +++ b/src/OpenGl/OpenGl_Group.hxx @@ -99,6 +99,9 @@ public: //! Is the group ray-tracable (contains ray-tracable elements)? Standard_Boolean IsRaytracable() const { return myIsRaytracable; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Standard_EXPORT virtual ~OpenGl_Group(); diff --git a/src/Prs3d/Prs3d_ArrowAspect.cxx b/src/Prs3d/Prs3d_ArrowAspect.cxx index dcd3b0204c..7b86782146 100644 --- a/src/Prs3d/Prs3d_ArrowAspect.cxx +++ b/src/Prs3d/Prs3d_ArrowAspect.cxx @@ -15,6 +15,7 @@ #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ArrowAspect, Prs3d_BasicAspect) @@ -65,3 +66,16 @@ void Prs3d_ArrowAspect::SetAngle (const Standard_Real theAngle) || theAngle >= M_PI / 2.0, "Prs3d_ArrowAspect::SetAngle() - angle out of range"); myAngle = theAngle; } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_ArrowAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_ArrowAspect); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get()); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAngle); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLength); +} diff --git a/src/Prs3d/Prs3d_ArrowAspect.hxx b/src/Prs3d/Prs3d_ArrowAspect.hxx index 6489b5a0db..7aeb351a51 100644 --- a/src/Prs3d/Prs3d_ArrowAspect.hxx +++ b/src/Prs3d/Prs3d_ArrowAspect.hxx @@ -57,6 +57,9 @@ public: void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { myArrowAspect = theAspect; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Handle(Graphic3d_AspectLine3d) myArrowAspect; diff --git a/src/Prs3d/Prs3d_BasicAspect.hxx b/src/Prs3d/Prs3d_BasicAspect.hxx index 7578c71a20..604b53dacf 100644 --- a/src/Prs3d/Prs3d_BasicAspect.hxx +++ b/src/Prs3d/Prs3d_BasicAspect.hxx @@ -17,6 +17,7 @@ #define _Prs3d_BasicAspect_HeaderFile #include +#include #include #include @@ -25,6 +26,10 @@ class Prs3d_BasicAspect : public Standard_Transient { DEFINE_STANDARD_RTTIEXT(Prs3d_BasicAspect, Standard_Transient) + + //! Dumps the content of me into the stream + virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const = 0; + }; DEFINE_STANDARD_HANDLE(Prs3d_BasicAspect, Standard_Transient) diff --git a/src/Prs3d/Prs3d_DatumAspect.cxx b/src/Prs3d/Prs3d_DatumAspect.cxx index 5afab0e8d7..4ce08e37c4 100644 --- a/src/Prs3d/Prs3d_DatumAspect.cxx +++ b/src/Prs3d/Prs3d_DatumAspect.cxx @@ -14,6 +14,8 @@ #include +#include + IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect) // ======================================================================= @@ -167,3 +169,21 @@ Prs3d_DatumParts Prs3d_DatumAspect::ArrowPartForAxis (Prs3d_DatumParts thePart) } return Prs3d_DP_None; } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_DatumAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_DatumAspect); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get()); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPointAspect.get()); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get()); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAxes); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawLabels); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawArrows); +} + diff --git a/src/Prs3d/Prs3d_DatumAspect.hxx b/src/Prs3d/Prs3d_DatumAspect.hxx index 69bb3c2ced..3bb247c2a2 100644 --- a/src/Prs3d/Prs3d_DatumAspect.hxx +++ b/src/Prs3d/Prs3d_DatumAspect.hxx @@ -153,6 +153,9 @@ public: //! Returns type of arrow for a type of axis Standard_EXPORT Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart) const; + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + private: Prs3d_DatumAxes myAxes; Standard_Boolean myToDrawLabels; diff --git a/src/Prs3d/Prs3d_DimensionAspect.cxx b/src/Prs3d/Prs3d_DimensionAspect.cxx index 6e1141f9cd..066d7c0a66 100755 --- a/src/Prs3d/Prs3d_DimensionAspect.cxx +++ b/src/Prs3d/Prs3d_DimensionAspect.cxx @@ -16,6 +16,7 @@ #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DimensionAspect, Prs3d_BasicAspect) @@ -59,3 +60,28 @@ void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor) myTextAspect->SetColor (theColor); myArrowAspect->SetColor (theColor); } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_DimensionAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_DimensionAspect); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myLineAspect.get()); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get()); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get()); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myValueStringFormat); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myExtensionSize); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myArrowTailSize); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myArrowOrientation); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextHPosition); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextVPosition); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDisplayUnits); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsText3d); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsTextShaded); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsArrows3d); +} + diff --git a/src/Prs3d/Prs3d_DimensionAspect.hxx b/src/Prs3d/Prs3d_DimensionAspect.hxx index c6b80ac099..9f90573eb4 100644 --- a/src/Prs3d/Prs3d_DimensionAspect.hxx +++ b/src/Prs3d/Prs3d_DimensionAspect.hxx @@ -115,6 +115,9 @@ public: //! Returns format. const TCollection_AsciiString& ValueStringFormat() const { return myValueStringFormat; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Handle(Prs3d_LineAspect) myLineAspect; diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index bf474f3eb2..a2599fc195 100644 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -26,6 +26,7 @@ #include #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes) @@ -1409,3 +1410,13 @@ bool Prs3d_Drawer::SetShadingModel (Graphic3d_TypeOfShadingModel theModel, return isUpdateNeeded; } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_Drawer::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_Drawer); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myShadingAspect.get()); +} diff --git a/src/Prs3d/Prs3d_Drawer.hxx b/src/Prs3d/Prs3d_Drawer.hxx index 292a87a846..967b11834b 100644 --- a/src/Prs3d/Prs3d_Drawer.hxx +++ b/src/Prs3d/Prs3d_Drawer.hxx @@ -891,6 +891,9 @@ public: Standard_EXPORT bool SetShadingModel (Graphic3d_TypeOfShadingModel theModel, bool theToOverrideDefaults = false); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: Handle(Prs3d_Drawer) myLink; diff --git a/src/Prs3d/Prs3d_LineAspect.cxx b/src/Prs3d/Prs3d_LineAspect.cxx index b648b1026a..b2ecce5c8d 100644 --- a/src/Prs3d/Prs3d_LineAspect.cxx +++ b/src/Prs3d/Prs3d_LineAspect.cxx @@ -14,6 +14,8 @@ #include +#include + IMPLEMENT_STANDARD_RTTIEXT(Prs3d_LineAspect, Prs3d_BasicAspect) // ======================================================================= @@ -27,3 +29,14 @@ Prs3d_LineAspect::Prs3d_LineAspect (const Quantity_Color& theColor, { // } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_LineAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_LineAspect); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspect.get()); +} + diff --git a/src/Prs3d/Prs3d_LineAspect.hxx b/src/Prs3d/Prs3d_LineAspect.hxx index cb20cfb647..e6e61d7626 100644 --- a/src/Prs3d/Prs3d_LineAspect.hxx +++ b/src/Prs3d/Prs3d_LineAspect.hxx @@ -63,6 +63,9 @@ public: void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { myAspect = theAspect; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Handle(Graphic3d_AspectLine3d) myAspect; diff --git a/src/Prs3d/Prs3d_PlaneAspect.cxx b/src/Prs3d/Prs3d_PlaneAspect.cxx index 8d71bb33bc..34c720c86f 100644 --- a/src/Prs3d/Prs3d_PlaneAspect.cxx +++ b/src/Prs3d/Prs3d_PlaneAspect.cxx @@ -14,6 +14,8 @@ #include +#include + IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PlaneAspect, Prs3d_BasicAspect) // ======================================================================= @@ -37,3 +39,28 @@ Prs3d_PlaneAspect::Prs3d_PlaneAspect() { // } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_PlaneAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_PlaneAspect); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myEdgesAspect.get()); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myIsoAspect.get()); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get()); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myArrowsLength); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myArrowsSize); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myArrowsAngle); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPlaneXLength); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPlaneYLength); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsoDistance); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDrawCenterArrow); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDrawEdgesArrows); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDrawEdges); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDrawIso); +} + diff --git a/src/Prs3d/Prs3d_PlaneAspect.hxx b/src/Prs3d/Prs3d_PlaneAspect.hxx index 4833059bc7..35e3f6d056 100644 --- a/src/Prs3d/Prs3d_PlaneAspect.hxx +++ b/src/Prs3d/Prs3d_PlaneAspect.hxx @@ -96,6 +96,9 @@ public: //! Returns the distance between isoparameters used in the display of planes. Standard_Real IsoDistance() const { return myIsoDistance; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Handle(Prs3d_LineAspect) myEdgesAspect; diff --git a/src/Prs3d/Prs3d_PointAspect.cxx b/src/Prs3d/Prs3d_PointAspect.cxx index b69b01689f..e87564e4bd 100644 --- a/src/Prs3d/Prs3d_PointAspect.cxx +++ b/src/Prs3d/Prs3d_PointAspect.cxx @@ -14,6 +14,8 @@ #include +#include + IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PointAspect, Prs3d_BasicAspect) // ======================================================================= @@ -40,3 +42,14 @@ Prs3d_PointAspect::Prs3d_PointAspect (const Quantity_Color& theColor, { // } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_PointAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_PointAspect); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspect.get()); +} + diff --git a/src/Prs3d/Prs3d_PointAspect.hxx b/src/Prs3d/Prs3d_PointAspect.hxx index 7c2fcd3c70..0c0150b1a1 100644 --- a/src/Prs3d/Prs3d_PointAspect.hxx +++ b/src/Prs3d/Prs3d_PointAspect.hxx @@ -61,6 +61,9 @@ public: //! Returns marker's texture. const Handle(Graphic3d_MarkerImage)& GetTexture() const { return myAspect->GetMarkerImage(); } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Handle(Graphic3d_AspectMarker3d) myAspect; diff --git a/src/Prs3d/Prs3d_ShadingAspect.cxx b/src/Prs3d/Prs3d_ShadingAspect.cxx index 3e2ea06d8e..90bde95e8a 100644 --- a/src/Prs3d/Prs3d_ShadingAspect.cxx +++ b/src/Prs3d/Prs3d_ShadingAspect.cxx @@ -18,6 +18,7 @@ #include #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ShadingAspect, Prs3d_BasicAspect) @@ -168,3 +169,14 @@ Standard_Real Prs3d_ShadingAspect::Transparency (const Aspect_TypeOfFacingModel } return 0.0; } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_ShadingAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_ShadingAspect); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspect.get()); +} + diff --git a/src/Prs3d/Prs3d_ShadingAspect.hxx b/src/Prs3d/Prs3d_ShadingAspect.hxx index 8510621a31..202a4b740f 100644 --- a/src/Prs3d/Prs3d_ShadingAspect.hxx +++ b/src/Prs3d/Prs3d_ShadingAspect.hxx @@ -62,6 +62,9 @@ public: void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) { myAspect = theAspect; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Handle(Graphic3d_AspectFillArea3d) myAspect; diff --git a/src/Prs3d/Prs3d_TextAspect.cxx b/src/Prs3d/Prs3d_TextAspect.cxx index d194818103..d56c469e5b 100644 --- a/src/Prs3d/Prs3d_TextAspect.cxx +++ b/src/Prs3d/Prs3d_TextAspect.cxx @@ -17,6 +17,7 @@ #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(Prs3d_TextAspect, Prs3d_BasicAspect) @@ -47,3 +48,20 @@ Prs3d_TextAspect::Prs3d_TextAspect (const Handle(Graphic3d_AspectText3d)& theAsp { // } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Prs3d_TextAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Prs3d_TextAspect); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get()); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHeight); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHorizontalJustification); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVerticalJustification); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOrientation); +} + diff --git a/src/Prs3d/Prs3d_TextAspect.hxx b/src/Prs3d/Prs3d_TextAspect.hxx index cf59e1aefa..185a37f21f 100644 --- a/src/Prs3d/Prs3d_TextAspect.hxx +++ b/src/Prs3d/Prs3d_TextAspect.hxx @@ -97,6 +97,9 @@ public: void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect = theAspect; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Handle(Graphic3d_AspectText3d) myTextAspect; diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index b3730f08d8..145261cf0d 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -837,3 +837,22 @@ void PrsMgr_PresentableObject::PolygonOffsets (Standard_Integer& theMode, myDrawer->ShadingAspect()->Aspect()->PolygonOffsets (theMode, theFactor, theUnits); } } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void PrsMgr_PresentableObject::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, PrsMgr_PresentableObject); + + DUMP_FIELD_VALUE_POINTER (theOStream, myParent); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOwnWidth); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, hasOwnColor); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, hasOwnMaterial); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myInfiniteState); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsMutable); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnPresentations); +} diff --git a/src/PrsMgr/PrsMgr_PresentableObject.hxx b/src/PrsMgr/PrsMgr_PresentableObject.hxx index 39676b151e..5d657189ee 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.hxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.hxx @@ -479,6 +479,9 @@ public: //! @name simplified presentation properties API //! Clears settings provided by the drawing tool aDrawer. Standard_EXPORT virtual void UnsetAttributes(); + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + public: //! @name deprecated methods //! gives the list of modes which are flagged "to be updated". diff --git a/src/Quantity/Quantity_Color.cxx b/src/Quantity/Quantity_Color.cxx index ae29401215..9b0d81baf4 100644 --- a/src/Quantity/Quantity_Color.cxx +++ b/src/Quantity/Quantity_Color.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -3924,3 +3925,13 @@ void call_rgbhls (float r, float g, float b, float& h, float& l, float& s) if (h < 0.0) h += 360.0; } } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Quantity_Color::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, Quantity_Color); + DUMP_FIELD_VALUES_NUMERICAL (theOStream, "RGB", 3, MyRed, MyGreen, MyBlue) +} diff --git a/src/Quantity/Quantity_Color.hxx b/src/Quantity/Quantity_Color.hxx index 77fbf22f82..b221dabdb5 100644 --- a/src/Quantity/Quantity_Color.hxx +++ b/src/Quantity/Quantity_Color.hxx @@ -270,6 +270,9 @@ Standard_Boolean operator == (const Quantity_Color& Other) const //! Internal test Standard_EXPORT static void Test(); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: //! Converts HLS components into RGB ones. diff --git a/src/Quantity/Quantity_ColorRGBA.cxx b/src/Quantity/Quantity_ColorRGBA.cxx index b7ade567a5..54cab09e89 100644 --- a/src/Quantity/Quantity_ColorRGBA.cxx +++ b/src/Quantity/Quantity_ColorRGBA.cxx @@ -16,6 +16,7 @@ #include #include +#include #include @@ -198,3 +199,15 @@ bool Quantity_ColorRGBA::ColorFromHex (const char* const theHexColorString, const ColorInteger aColorComponentBase = isShort ? THE_HEX_COLOR_COMPONENT_SHORT_BASE : THE_HEX_COLOR_COMPONENT_BASE; return convertIntegerToColorRGBA (aHexColorInteger, aColorComponentBase, hasAlphaComponent, theColor); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Quantity_ColorRGBA::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, Quantity_ColorRGBA); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myRgb); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAlpha); +} diff --git a/src/Quantity/Quantity_ColorRGBA.hxx b/src/Quantity/Quantity_ColorRGBA.hxx index c67cd52489..a1e0709626 100644 --- a/src/Quantity/Quantity_ColorRGBA.hxx +++ b/src/Quantity/Quantity_ColorRGBA.hxx @@ -121,6 +121,9 @@ public: Quantity_ColorRGBA& theColor, const bool theAlphaComponentIsOff = false); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: static void myTestSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); } diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.cxx b/src/SelectMgr/SelectMgr_BaseFrustum.cxx index f01a825c0e..b9e843a838 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.cxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.cxx @@ -15,6 +15,10 @@ #include +#include + +#include + IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient) //======================================================================= @@ -245,3 +249,17 @@ gp_Pnt SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) c { return gp_Pnt (RealLast(), RealLast(), RealLast()); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void SelectMgr_BaseFrustum::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, SelectMgr_BaseFrustum); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPixelTolerance); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsOrthographic); + DUMP_FIELD_VALUE_POINTER (theOStream, myBuilder); + DUMP_FIELD_VALUE_POINTER (theOStream, myCamera); +} diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.hxx b/src/SelectMgr/SelectMgr_BaseFrustum.hxx index 95062200c2..9295db486d 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.hxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.hxx @@ -28,6 +28,8 @@ #include #include +#include + //! This class is an interface for different types of selecting frustums, //! defining different selection types, like point, box or polyline //! selection. It contains signatures of functions for detection of @@ -171,6 +173,9 @@ public: return; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient) protected: diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cxx b/src/SelectMgr/SelectMgr_EntityOwner.cxx index d537c01dd6..1448da7639 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.cxx @@ -82,3 +82,17 @@ void SelectMgr_EntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationMa mySelectable->HilightOwnerWithColor (thePM, theStyle, this); } } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void SelectMgr_EntityOwner::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, SelectMgr_EntityOwner); + + DUMP_FIELD_VALUE_POINTER (theOStream, mySelectable); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, mypriority); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsSelected); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFromDecomposition); +} diff --git a/src/SelectMgr/SelectMgr_EntityOwner.hxx b/src/SelectMgr/SelectMgr_EntityOwner.hxx index 3e96e0f51a..8e59aa12cf 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.hxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.hxx @@ -187,6 +187,9 @@ public: //! Sets flag indicating this owner points to a part of object (TRUE) or to entire object (FALSE). void SetComesFromDecomposition (const Standard_Boolean theIsFromDecomposition) { myFromDecomposition = theIsFromDecomposition; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + public: //! Sets the selectable object. diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cxx b/src/SelectMgr/SelectMgr_SelectableObject.cxx index 4980ecf7b6..dc739249ca 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.cxx @@ -548,3 +548,16 @@ const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwne { return THE_NULL_ENTITYOWNER; } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void SelectMgr_SelectableObject::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, SelectMgr_SelectableObject); + + DUMP_FIELD_VALUES_BY_KIND (theOStream, theDepth, PrsMgr_PresentableObject); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGlobalSelMode); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight); +} diff --git a/src/SelectMgr/SelectMgr_SelectableObject.hxx b/src/SelectMgr/SelectMgr_SelectableObject.hxx index 2da46a4120..73885090a2 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.hxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.hxx @@ -169,6 +169,9 @@ public: //! Returns common entity owner if the object is an assembly Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const; + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + public: //! Begins the iteration scanning for sensitive primitives. diff --git a/src/SelectMgr/SelectMgr_ViewClipRange.cxx b/src/SelectMgr/SelectMgr_ViewClipRange.cxx index d820ecd080..1c2f418da0 100644 --- a/src/SelectMgr/SelectMgr_ViewClipRange.cxx +++ b/src/SelectMgr/SelectMgr_ViewClipRange.cxx @@ -102,3 +102,18 @@ void SelectMgr_ViewClipRange::AddClippingPlanes (const Graphic3d_SequenceOfHClip } } } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void SelectMgr_ViewClipRange::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, SelectMgr_ViewClipRange); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUnclipRange); + for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter) + { + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myClipRanges[aRangeIter]); + } +} diff --git a/src/SelectMgr/SelectMgr_ViewClipRange.hxx b/src/SelectMgr/SelectMgr_ViewClipRange.hxx index b2f012474b..16e5949778 100644 --- a/src/SelectMgr/SelectMgr_ViewClipRange.hxx +++ b/src/SelectMgr/SelectMgr_ViewClipRange.hxx @@ -18,6 +18,8 @@ #include #include +#include +#include #include @@ -117,6 +119,9 @@ public: //! Adds a clipping sub-range (for clipping chains). void AddClipSubRange (const Bnd_Range& theRange) { myClipRanges.push_back (theRange); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: std::vector myClipRanges; diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 9e467d2df6..e85c0d8321 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -1046,3 +1046,26 @@ void SelectMgr_ViewerSelector::AllowOverlapDetection (const Standard_Boolean the { mySelectingVolumeMgr.AllowOverlapDetection (theIsToAllow); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void SelectMgr_ViewerSelector::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, SelectMgr_ViewerSelector); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, preferclosest); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToUpdateTolerance); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, mystored.Extent()); + + Standard_Integer aNbOfSelected = 0; + for (SelectMgr_SelectableObjectSet::Iterator aSelectableIt (mySelectableObjects); aSelectableIt.More(); aSelectableIt.Next()) + { + aNbOfSelected++; + } + DUMP_FIELD_VALUE_NUMERICAL (theOStream, aNbOfSelected); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTolerances.Tolerance()); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTolerances.CustomTolerance()); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZLayerOrderMap.Size()); +} diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.hxx b/src/SelectMgr/SelectMgr_ViewerSelector.hxx index 70b032cd1c..b23098ff74 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.hxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.hxx @@ -209,6 +209,9 @@ public: //! mark both included and overlapped entities as matched Standard_EXPORT void AllowOverlapDetection (const Standard_Boolean theIsToAllow); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + public: //! Begins an iteration scanning for the owners detected at a position in the view. diff --git a/src/Standard/FILES b/src/Standard/FILES index 01ca8000ee..84ad0eccd4 100755 --- a/src/Standard/FILES +++ b/src/Standard/FILES @@ -24,6 +24,8 @@ Standard_DimensionError.hxx Standard_DimensionMismatch.hxx Standard_DivideByZero.hxx Standard_DomainError.hxx +Standard_Dump.cxx +Standard_Dump.hxx Standard_ErrorHandler.cxx Standard_ErrorHandler.hxx Standard_ExtCharacter.hxx diff --git a/src/Standard/Standard_Dump.cxx b/src/Standard/Standard_Dump.cxx new file mode 100644 index 0000000000..97072fb072 --- /dev/null +++ b/src/Standard/Standard_Dump.cxx @@ -0,0 +1,224 @@ +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +Standard_DumpSentry::Standard_DumpSentry (Standard_OStream& theOStream, const char* theClassName) +: myOStream (&theOStream) +{ + (*myOStream) << "\"" << theClassName << "\": {"; +} + +// ======================================================================= +// function : Destructor +// purpose : +// ======================================================================= +Standard_DumpSentry::~Standard_DumpSentry() +{ + (*myOStream) << "}"; +} + +// ======================================================================= +// function : EndsWith +// purpose : +// ======================================================================= +Standard_Boolean Standard_Dump::EndsWith (const Standard_OStream& theOStream, + const TCollection_AsciiString& theEndString) +{ + Standard_SStream aStream; + aStream << theOStream.rdbuf(); + TCollection_AsciiString aStreamStr = Standard_Dump::Text (aStream); + return aStreamStr.EndsWith (theEndString); +} + +//======================================================================= +//function : DumpKeyToClass +//purpose : +//======================================================================= +void Standard_Dump::DumpKeyToClass (Standard_OStream& theOStream, + const char* theKey, + const TCollection_AsciiString& theField) +{ + if (!Standard_Dump::EndsWith (theOStream, "{")) + theOStream << ", "; + theOStream << "\"" << theKey << "\": {" << theField << "}"; +} + +//======================================================================= +//function : DumpCharacterValues +//purpose : +//======================================================================= +void Standard_Dump::DumpCharacterValues (Standard_OStream& theOStream, int theCount, ...) +{ + va_list vl; + va_start(vl, theCount); + for(int i = 0; i < theCount; ++i) + { + if (i > 0) + theOStream << ", "; + theOStream << "\"" << va_arg(vl, char*) << "\""; + } + va_end(vl); +} + +//======================================================================= +//function : DumpRealValues +//purpose : +//======================================================================= +void Standard_Dump::DumpRealValues (Standard_OStream& theOStream, int theCount, ...) +{ + va_list vl; + va_start(vl, theCount); + for(int i = 0; i < theCount; ++i) + { + if (i > 0) + theOStream << ", "; + theOStream << va_arg(vl, Standard_Real); + } + va_end(vl); +} + +// ======================================================================= +// function : GetPointerInfo +// purpose : +// ======================================================================= +TCollection_AsciiString Standard_Dump::GetPointerInfo (const Handle(Standard_Transient)& thePointer, + const bool isShortInfo) +{ + if (thePointer.IsNull()) + return TCollection_AsciiString(); + + return GetPointerInfo (thePointer.get(), isShortInfo); +} + +// ======================================================================= +// function : GetPointerInfo +// purpose : +// ======================================================================= +TCollection_AsciiString Standard_Dump::GetPointerInfo (const void* thePointer, const bool isShortInfo) +{ + std::ostringstream aPtrStr; + aPtrStr << thePointer; + if (!isShortInfo) + return aPtrStr.str().c_str(); + + TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str()); + for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++) + { + if (anInfoPtr.Value(aSymbolId) != '0') + { + anInfoPtr = anInfoPtr.SubString (aSymbolId, anInfoPtr.Length()); + anInfoPtr.Prepend (GetPointerPrefix()); + return anInfoPtr; + } + } + return aPtrStr.str().c_str(); +} + +// ======================================================================= +// DumpFieldToName +// ======================================================================= +void Standard_Dump::DumpFieldToName (const char* theField, const char*& theName) +{ + theName = theField; + + if (theName[0] == '&') + { + theName = theName + 1; + } + if (::LowerCase (theName[0]) == 'm' && theName[1] == 'y') + { + theName = theName + 2; + } +} + +// ======================================================================= +// Text +// ======================================================================= +TCollection_AsciiString Standard_Dump::Text (const Standard_SStream& theStream) +{ + return TCollection_AsciiString (theStream.str().c_str()); +} + +// ======================================================================= +// FormatJson +// ======================================================================= +TCollection_AsciiString Standard_Dump::FormatJson (const Standard_SStream& theStream, + const Standard_Integer theIndent) +{ + TCollection_AsciiString aStreamStr = Text (theStream); + TCollection_AsciiString anIndentStr; + for (Standard_Integer anIndentId = 0; anIndentId < theIndent; anIndentId++) + anIndentStr.AssignCat (' '); + + TCollection_AsciiString aText; + + Standard_Integer anIndentCount = 0; + Standard_Boolean isMassiveValues = Standard_False; + for (Standard_Integer anIndex = 1; anIndex < aStreamStr.Length(); anIndex++) + { + Standard_Character aSymbol = aStreamStr.Value (anIndex); + if (aSymbol == '{') + { + anIndentCount++; + + aText += aSymbol; + aText += '\n'; + + for (int anIndent = 0; anIndent < anIndentCount; anIndent++) + aText += anIndentStr; + } + else if (aSymbol == '}') + { + anIndentCount--; + + aText += '\n'; + for (int anIndent = 0; anIndent < anIndentCount; anIndent++) + aText += anIndentStr; + aText += aSymbol; + } + else if (aSymbol == '[') + { + isMassiveValues = Standard_True; + aText += aSymbol; + } + else if (aSymbol == ']') + { + isMassiveValues = Standard_False; + aText += aSymbol; + } + else if (aSymbol == ',') + { + if (!isMassiveValues) + { + aText += aSymbol; + aText += '\n'; + for (int anIndent = 0; anIndent < anIndentCount; anIndent++) + aText += anIndentStr; + if (anIndex + 1 < aStreamStr.Length() && aStreamStr.Value (anIndex + 1) == ' ') + anIndex++; // skip empty value after comma + } + else + aText += aSymbol; + } + else + aText += aSymbol; + } + return aText; +} diff --git a/src/Standard/Standard_Dump.hxx b/src/Standard/Standard_Dump.hxx new file mode 100644 index 0000000000..6cb7dd7b21 --- /dev/null +++ b/src/Standard/Standard_Dump.hxx @@ -0,0 +1,245 @@ +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Standard_Dump_HeaderFile +#define _Standard_Dump_HeaderFile + +#include +#include + +class Standard_DumpSentry; + +//! The file contains interface to prepare dump output for OCCT objects. Format of the dump is JSON. +//! To prepare this output, implement method Dump in the object and use macro functions from this file. +//! Macros have one parameter for both, key and the value. It is a field of the current class. Macro has internal analyzer that +//! uses the variable name to generate key. If the parameter has prefix symbols "&", "*" and "my", it is cut. +//! +//! - DUMP_FIELD_VALUE_NUMERICAL. Use it for fields of numerical C++ types, like int, float, double. It creates a pair "key", "value", +//! - DUMP_FIELD_VALUE_STRING. Use it for char* type. It creates a pair "key", "value", +//! - DUMP_FIELD_VALUE_POINTER. Use it for pointer fields. It creates a pair "key", "value", where the value is the pointer address, +//! - DUMP_FIELD_VALUES_DUMPED. Use it for fields that has own Dump implementation. It expects the pointer to the class instance. +//! It creates "key": { result of dump of the field } +//! - DUMP_FIELD_VALUES_NUMERICAL. Use it for unlimited list of fields of C++ double type. +//! It creates massive of values [value_1, value_2, ...] +//! - DUMP_FIELD_VALUES_STRING. Use it for unlimited list of fields of TCollection_AsciiString types. +//! It creates massive of values ["value_1", "value_2", ...] +//! - DUMP_FIELD_VALUES_BY_KIND. Use if Dump implementation of the class is virtual, to perform ClassName::Dump() of the parent class, +//! expected parameter is the parent class name. +//! It creates "key": { result of dump of the field } +//! - DUMP_VECTOR_CLASS. Use it as a single row in some object dump to have one row in output. +//! It's possible to use it without necessity of DUMP_CLASS_BEGIN call. +//! It creates massive of values [value_1, value_2, ...] +//! +//! The Dump result prepared by these macros is an output stream, it is not arranged with spaces and line feed. +//! To have output in a more readable way, use ConvertToAlignedString method for obtained stream. + +//! Converts the class type into a string value +#define CLASS_NAME(theClass) #theClass + +//! @def DUMP_CLASS_BEGIN +//! Creates an instance of Sentry to cover the current Dump implementation with keys of start and end. +//! This row should be inserted before other macros. The end key will be added by the sentry remove, +//! (exit of the method). +#define DUMP_CLASS_BEGIN(theOStream, theName) \ + Standard_DumpSentry aSentry (theOStream, CLASS_NAME(theName)); \ + +//! @def DUMP_FIELD_VALUE_NUMERICAL +//! Append into output value: "Name": Field +#define DUMP_FIELD_VALUE_NUMERICAL(theOStream, theField) \ +{ \ + const char* aName = NULL; \ + Standard_Dump::DumpFieldToName (#theField, aName); \ + if (!Standard_Dump::EndsWith (theOStream, "{")) \ + theOStream << ", "; \ + theOStream << "\"" << aName << "\": " << theField; \ +} + +//! @def DUMP_FIELD_VALUE_STRING +//! Append into output value: "Name": "Field" +#define DUMP_FIELD_VALUE_STRING(theOStream, theField) \ +{ \ + const char* aName = NULL; \ + Standard_Dump::DumpFieldToName (#theField, aName); \ + if (!Standard_Dump::EndsWith (theOStream, "{")) \ + theOStream << ", "; \ + theOStream << "\"" << aName << "\": \"" << theField << "\""; \ +} + +//! @def DUMP_FIELD_VALUE_POINTER +//! Append into output value: "Name": "address of the pointer" +#define DUMP_FIELD_VALUE_POINTER(theOStream, theField) \ +{ \ + const char* aName = NULL; \ + Standard_Dump::DumpFieldToName (#theField, aName); \ + if (!Standard_Dump::EndsWith (theOStream, "{")) \ + theOStream << ", "; \ + theOStream << "\"" << aName << "\": \"" << Standard_Dump::GetPointerInfo (theField) << "\""; \ +} + +//! @def DUMP_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 DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, theField) \ +{ \ + if (theDepth != 0) \ + { \ + Standard_SStream aFieldStream; \ + if ((theField) != NULL) \ + (theField)->DumpJson (aFieldStream, theDepth - 1); \ + const char* aName = NULL; \ + Standard_Dump::DumpFieldToName (#theField, aName); \ + Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \ + } \ +} + +//! @def 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. +#define DUMP_FIELD_VALUES_NUMERICAL(theOStream, theName, theCount, ...) \ +{ \ + if (!Standard_Dump::EndsWith (theOStream, "{")) \ + theOStream << ", "; \ + theOStream << "\"" << theName << "\": ["; \ + Standard_Dump::DumpRealValues (theOStream, theCount, __VA_ARGS__);\ + theOStream << "]"; \ +} + +//! @def DUMP_FIELD_VALUES_STRING +//! 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. +#define DUMP_FIELD_VALUES_STRING(theOStream, theName, theCount, ...) \ +{ \ + if (!Standard_Dump::EndsWith (theOStream, "{")) \ + theOStream << ", "; \ + theOStream << "\"" << theName << "\": ["; \ + Standard_Dump::DumpCharacterValues (theOStream, theCount, __VA_ARGS__);\ + theOStream << "]"; \ +} + +//! @def DUMP_FIELD_VALUES_BY_KIND +//! Append into output value: "Name": { field dumped values } +//! It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump. +//! Use this macro for parent of the current class. +//! The macros is recursive. Recursive is stoped when the depth value becomes equal to zero. +//! Depth = -1 is the default value, dump here is unlimited. +#define DUMP_FIELD_VALUES_BY_KIND(theOStream, theDepth, theField) \ +{ \ + if (theDepth != 0) \ + { \ + Standard_SStream aFieldStream; \ + theField::DumpJson (aFieldStream, theDepth - 1); \ + const char* aName = NULL; \ + Standard_Dump::DumpFieldToName (#theField, aName); \ + Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \ + } \ +} + +//! @def DUMP_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 DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump. +#define DUMP_VECTOR_CLASS(theOStream, theName, theCount, ...) \ +{ \ + theOStream << "\"" << CLASS_NAME(theName) << "\": ["; \ + Standard_Dump::DumpRealValues (theOStream, theCount, __VA_ARGS__);\ + theOStream << "]"; \ +} + +//! @brief Simple sentry class providing convenient interface to dump. +//! Appends start and last rows in dump with class name key. +//! An example of the using: for ClassName, the result is: "ClassName" { ... } +//! Create instance of that class in the first row of Dump. +class Standard_DumpSentry +{ +public: + //! Constructor - add parameters of start class name definition in the stream + Standard_EXPORT Standard_DumpSentry (Standard_OStream& theOStream, const char* theClassName); + + //! Destructor - add parameters of stop class name definition in the stream + Standard_EXPORT ~Standard_DumpSentry(); + +private: + Standard_OStream* myOStream; //!< modified stream +}; + +//! This interface has some tool methods for stream (in JSON format) processing. +class Standard_Dump +{ +public: + //! Converts stream value to string value. The result is original stream value. + //! @param theStream source value + //! @return text presentation + Standard_EXPORT static TCollection_AsciiString Text (const Standard_SStream& theStream); + + //! Converts stream value to string value. Improves the text presentation with the following cases: + //! - for '{' append after '\n' and indent to the next value, increment current indent value + //! - for '}' append '\n' and current indent before it, decrement indent value + //! - for ',' append after '\n' and indent to the next value. If the current symbol is in massive container [], do nothing + //! @param theStream source value + //! @param theIndent count of ' ' symbols to apply hierarchical indent of the text values + //! @return text presentation + Standard_EXPORT static TCollection_AsciiString FormatJson (const Standard_SStream& theStream, const Standard_Integer theIndent = 3); + + //! Determines whether the end of this stream matches the specified string. + //! @param theStream source value + //! @param theEndString text value to find + //! @return true if matches + static Standard_EXPORT Standard_Boolean EndsWith (const Standard_OStream& theOStream, + const TCollection_AsciiString& theEndString); + + //! Returns default prefix added for each pointer info string if short presentation of pointer used + Standard_EXPORT static TCollection_AsciiString GetPointerPrefix() { return "0x"; } + + //! Convert handle pointer to address of the pointer. If the handle is NULL, the result is an empty string. + //! @param thePointer a pointer + //! @param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped + //! @return the string value + Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer, + const bool isShortInfo = true); + + //! Convert pointer to address of the pointer. If the handle is NULL, the result is an empty string. + //! @param thePointer a pointer + //! @param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped + //! @return the string value + Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const void* thePointer, + const bool isShortInfo = true); + + //! Append into output value: "Name": { Field } + //! @param theOStream [out] stream to be fill with values + //! @param theKey a source value + //! @param theField stream value + Standard_EXPORT static void DumpKeyToClass (Standard_OStream& theOStream, + const char* theKey, + const TCollection_AsciiString& theField); + + //! Unite values in one value using template: "value_1", "value_2", ..., "value_n" + //! @param theOStream [out] stream to be fill with values + //! @param theCount numer of values + Standard_EXPORT static void DumpCharacterValues (Standard_OStream& theOStream, int theCount, ...); + + //! Unite values in one value using template: value_1, value_2, ..., value_n + //! @param theOStream [out] stream to be fill with values + //! @param theCount numer of values + Standard_EXPORT static void DumpRealValues (Standard_OStream& theOStream, int theCount, ...); + + //! 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 + //! @param theName [out] an updated name + Standard_EXPORT static void DumpFieldToName (const char* theField, const char*& theName); +}; + +#endif // _Standard_Dump_HeaderFile diff --git a/src/TopLoc/TopLoc_Datum3D.cxx b/src/TopLoc/TopLoc_Datum3D.cxx index 03984f7161..b6ac226582 100644 --- a/src/TopLoc/TopLoc_Datum3D.cxx +++ b/src/TopLoc/TopLoc_Datum3D.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include IMPLEMENT_STANDARD_RTTIEXT(TopLoc_Datum3D,Standard_Transient) @@ -41,6 +42,16 @@ TopLoc_Datum3D::TopLoc_Datum3D (const gp_Trsf& T) : { } +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void TopLoc_Datum3D::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, TopLoc_Datum3D); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myTrsf); +} + //======================================================================= //function : ShallowDump //purpose : diff --git a/src/TopLoc/TopLoc_Datum3D.hxx b/src/TopLoc/TopLoc_Datum3D.hxx index b1f589d201..8c145a7752 100644 --- a/src/TopLoc/TopLoc_Datum3D.hxx +++ b/src/TopLoc/TopLoc_Datum3D.hxx @@ -53,6 +53,9 @@ public: const gp_Trsf& Transformation() const; + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! Writes the contents of this Datum3D to the stream S. Standard_EXPORT void ShallowDump (Standard_OStream& S) const; diff --git a/src/TopLoc/TopLoc_ItemLocation.cxx b/src/TopLoc/TopLoc_ItemLocation.cxx index c994bbd36a..b9699a396b 100644 --- a/src/TopLoc/TopLoc_ItemLocation.cxx +++ b/src/TopLoc/TopLoc_ItemLocation.cxx @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -32,3 +33,17 @@ TopLoc_ItemLocation::TopLoc_ItemLocation myTrsf (D->Transformation().Powered (P)) { } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void TopLoc_ItemLocation::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, TopLoc_ItemLocation); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myTrsf); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDatum.get()); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPower); +} diff --git a/src/TopLoc/TopLoc_ItemLocation.hxx b/src/TopLoc/TopLoc_ItemLocation.hxx index f2e117b390..90cc4103fc 100644 --- a/src/TopLoc/TopLoc_ItemLocation.hxx +++ b/src/TopLoc/TopLoc_ItemLocation.hxx @@ -22,6 +22,7 @@ #include #include +#include #include class TopLoc_Datum3D; class TopLoc_Location; @@ -49,6 +50,9 @@ public: //! Sets the exponent to

Standard_EXPORT TopLoc_ItemLocation(const Handle(TopLoc_Datum3D)& D, const Standard_Integer P); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + friend class TopLoc_Location; friend class TopLoc_SListOfItemLocation; diff --git a/src/TopLoc/TopLoc_Location.cxx b/src/TopLoc/TopLoc_Location.cxx index 21c9f81e70..4033b4c3e9 100644 --- a/src/TopLoc/TopLoc_Location.cxx +++ b/src/TopLoc/TopLoc_Location.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -230,6 +231,18 @@ Standard_Boolean TopLoc_Location::IsDifferent return !IsEqual(Other); } +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void TopLoc_Location::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, TopLoc_Location); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Transformation()); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsIdentity()); +} + //======================================================================= //function : ShallowDump //purpose : diff --git a/src/TopLoc/TopLoc_Location.hxx b/src/TopLoc/TopLoc_Location.hxx index 0eec93b46b..dbc8b4fd4f 100644 --- a/src/TopLoc/TopLoc_Location.hxx +++ b/src/TopLoc/TopLoc_Location.hxx @@ -142,6 +142,9 @@ Standard_Boolean operator != (const TopLoc_Location& Other) const return IsDifferent(Other); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! Prints the contents of on the stream . Standard_EXPORT void ShallowDump (Standard_OStream& S) const; diff --git a/src/TopoDS/TopoDS_Shape.cxx b/src/TopoDS/TopoDS_Shape.cxx index 513703947c..a280b5d3f0 100644 --- a/src/TopoDS/TopoDS_Shape.cxx +++ b/src/TopoDS/TopoDS_Shape.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -33,3 +34,17 @@ Standard_Integer TopoDS_Shape::HashCode (const Standard_Integer theUpperBound) c const Standard_Integer aHL = myLocation.HashCode (theUpperBound); return ::HashCode (aHS ^ aHL, theUpperBound); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void TopoDS_Shape::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, TopoDS_Shape); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTShape.get()); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myLocation); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOrient); +} diff --git a/src/TopoDS/TopoDS_Shape.hxx b/src/TopoDS/TopoDS_Shape.hxx index ea05cb600f..f9f8a30132 100644 --- a/src/TopoDS/TopoDS_Shape.hxx +++ b/src/TopoDS/TopoDS_Shape.hxx @@ -280,6 +280,9 @@ public: void TShape (const Handle(TopoDS_TShape)& theTShape) { myTShape = theTShape; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: Handle(TopoDS_TShape) myTShape; diff --git a/src/TopoDS/TopoDS_TShape.cxx b/src/TopoDS/TopoDS_TShape.cxx index 01ecb142e3..36b3101c4b 100644 --- a/src/TopoDS/TopoDS_TShape.cxx +++ b/src/TopoDS/TopoDS_TShape.cxx @@ -17,4 +17,16 @@ #include #include +#include + IMPLEMENT_STANDARD_RTTIEXT(TopoDS_TShape,Standard_Transient) + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void TopoDS_TShape::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_CLASS_BEGIN (theOStream, TopoDS_TShape); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFlags); +} diff --git a/src/TopoDS/TopoDS_TShape.hxx b/src/TopoDS/TopoDS_TShape.hxx index 27932d635b..342436d358 100644 --- a/src/TopoDS/TopoDS_TShape.hxx +++ b/src/TopoDS/TopoDS_TShape.hxx @@ -126,6 +126,9 @@ public: //! @sa TopoDS_Iterator for accessing sub-shapes Standard_Integer NbChildren() const { return myShapes.Size(); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + friend class TopoDS_Iterator; friend class TopoDS_Builder; diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 8805ea57ef..7e36331147 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -2282,7 +2282,7 @@ struct ViewerTest_AspectsChangeSet //function : VAspects //purpose : //============================================================================== -static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, +static Standard_Integer VAspects (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) { @@ -2333,6 +2333,9 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, // parse syntax of legacy commands bool toParseAliasArgs = false; + Standard_Boolean toDump = 0; + Standard_Boolean toCompactDump = 0; + Standard_Integer aDumpDepth = -1; if (aCmdName == "vsetwidth") { if (aNames.IsEmpty() @@ -3284,6 +3287,25 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, aChangeSet->ToSetTypeOfEdge = -1; aChangeSet->TypeOfEdge = Aspect_TOL_SOLID; } + else if (anArg == "-dumpjson") + { + toDump = Standard_True; + } + else if (anArg == "-dumpcompact") + { + toCompactDump = Standard_False; + if (++anArgIter >= theArgNb && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toCompactDump)) + ++anArgIter; + } + else if (anArg == "-dumpdepth") + { + if (++anArgIter >= theArgNb) + { + std::cout << "Error: wrong syntax at " << anArg << "\n"; + return 1; + } + aDumpDepth = Draw::Atoi (theArgVec[anArgIter]); + } else { std::cout << "Error: wrong syntax at " << anArg << "\n"; @@ -3344,6 +3366,16 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, aCtx->Redisplay (aPrs, Standard_False); } } + if (toDump) + { + Standard_SStream aStream; + aDrawer->DumpJson (aStream, aDumpDepth); + + if (toCompactDump) + theDI << Standard_Dump::Text (aStream); + else + theDI << Standard_Dump::FormatJson (aStream); + } return 0; } @@ -3497,6 +3529,16 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/, { aPrs->SynchronizeAspects(); } + + if (toDump) + { + Standard_SStream aStream; + aDrawer->DumpJson (aStream); + + theDI << aName << ": \n"; + theDI << Standard_Dump::FormatJson (aStream); + theDI << "\n"; + } } } return 0; @@ -6619,6 +6661,10 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "\n\t\t: [-setDrawEdges {0|1}] [-setEdgeType LineType] [-setEdgeColor R G B] [-setQuadEdges {0|1}]" "\n\t\t: [-setDrawSilhouette {0|1}]" "\n\t\t: [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]" + "\n\t\t: [-dumpJson]" + "\n\t\t: [-dumpCompact {0|1}]" + "\n\t\t: [-dumpDepth depth]" + "\n\t\t: [-freeBoundary {off/on | 0/1}]" "\n\t\t: Manage presentation properties of all, selected or named objects." "\n\t\t: When -subshapes is specified than following properties will be" "\n\t\t: assigned to specified sub-shapes." diff --git a/src/XCAFPrs/XCAFPrs_Style.cxx b/src/XCAFPrs/XCAFPrs_Style.cxx index 0a0c52f933..3dda9fbfdf 100644 --- a/src/XCAFPrs/XCAFPrs_Style.cxx +++ b/src/XCAFPrs/XCAFPrs_Style.cxx @@ -15,6 +15,8 @@ #include +#include + //======================================================================= //function : XCAFPrs_Style //purpose : @@ -67,3 +69,19 @@ void XCAFPrs_Style::UnSetColorCurv() myHasColorCurv = Standard_False; myColorCurv.SetValues (Quantity_NOC_YELLOW); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void XCAFPrs_Style::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, XCAFPrs_Style); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColorSurf); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColorCurv); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasColorSurf); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasColorCurv); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsVisible); +} diff --git a/src/XCAFPrs/XCAFPrs_Style.hxx b/src/XCAFPrs/XCAFPrs_Style.hxx index 214a0bdcfa..d6e7afbc27 100644 --- a/src/XCAFPrs/XCAFPrs_Style.hxx +++ b/src/XCAFPrs/XCAFPrs_Style.hxx @@ -121,6 +121,9 @@ public: return theS1.IsEqual (theS2); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: Quantity_ColorRGBA myColorSurf; diff --git a/src/gp/gp_Mat.cxx b/src/gp/gp_Mat.cxx index cb106686fc..a490822ea5 100644 --- a/src/gp/gp_Mat.cxx +++ b/src/gp/gp_Mat.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #define M00 ((Standard_Real*)M)[0] #define M01 ((Standard_Real*)M)[1] @@ -268,3 +269,11 @@ void gp_Mat::Power (const Standard_Integer N) } } +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void gp_Mat::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_VECTOR_CLASS (theOStream, gp_Mat, 9, Mat00, Mat01, Mat02, Mat10, Mat11, Mat12, Mat20, Mat21, Mat22); +} diff --git a/src/gp/gp_Mat.hxx b/src/gp/gp_Mat.hxx index 16fc2f2144..d327280a65 100644 --- a/src/gp/gp_Mat.hxx +++ b/src/gp/gp_Mat.hxx @@ -255,6 +255,9 @@ public: //! Transposes the matrix. A(j, i) -> A (i, j) Standard_NODISCARD gp_Mat Transposed() const; + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + friend class gp_XYZ; friend class gp_Trsf; diff --git a/src/gp/gp_Trsf.cxx b/src/gp/gp_Trsf.cxx index 6401493575..857aaec35e 100644 --- a/src/gp/gp_Trsf.cxx +++ b/src/gp/gp_Trsf.cxx @@ -34,6 +34,7 @@ #include #include #include +#include //======================================================================= //function : gp_Trsf @@ -849,3 +850,18 @@ void gp_Trsf::Orthogonalize() matrix = aTM; } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void gp_Trsf::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + DUMP_CLASS_BEGIN (theOStream, gp_Trsf); + + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &loc); + DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &matrix); + + DUMP_FIELD_VALUE_NUMERICAL (theOStream, shape); + DUMP_FIELD_VALUE_NUMERICAL (theOStream, scale); +} diff --git a/src/gp/gp_Trsf.hxx b/src/gp/gp_Trsf.hxx index ebb05bfbd3..85e258c67f 100644 --- a/src/gp/gp_Trsf.hxx +++ b/src/gp/gp_Trsf.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include class Standard_ConstructionError; @@ -349,6 +350,9 @@ void operator *= (const gp_Trsf& T) theMat.SetValue (3, 3, static_cast (1)); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + friend class gp_GTrsf; protected: diff --git a/src/gp/gp_XYZ.cxx b/src/gp/gp_XYZ.cxx index 7bf550dcec..f588dfd484 100644 --- a/src/gp/gp_XYZ.cxx +++ b/src/gp/gp_XYZ.cxx @@ -17,6 +17,7 @@ #include #include #include +#include Standard_Boolean gp_XYZ::IsEqual (const gp_XYZ& Other, const Standard_Real Tolerance) const { @@ -33,3 +34,11 @@ Standard_Boolean gp_XYZ::IsEqual (const gp_XYZ& Other, return Standard_True; } +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void gp_XYZ::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + DUMP_VECTOR_CLASS (theOStream, gp_XYZ, 3, x, y, z) +} diff --git a/src/gp/gp_XYZ.hxx b/src/gp/gp_XYZ.hxx index 1ecb7d2605..bc2ebdb135 100644 --- a/src/gp/gp_XYZ.hxx +++ b/src/gp/gp_XYZ.hxx @@ -22,6 +22,9 @@ #include #include #include + +#include + class Standard_ConstructionError; class Standard_OutOfRange; class gp_Mat; @@ -324,6 +327,8 @@ public: void SetLinearForm (const gp_XYZ& XYZ1, const gp_XYZ& XYZ2); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; protected: diff --git a/tests/bugs/modalg_7/bug30949 b/tests/bugs/modalg_7/bug30949 new file mode 100644 index 0000000000..da10909580 --- /dev/null +++ b/tests/bugs/modalg_7/bug30949 @@ -0,0 +1,18 @@ +puts "=============" +puts "0030949: Foundation Classes - Dump improvement for OCCT classes" +puts "=============" + +set px 1 +set py 2 +set pz 3 + +vertex vv $px $py $pz +set log [bounding vv -obb -dumpJson] + +if {![regexp {"gp_XYZ": \[+([-0-9.+eE]+)\, +([-0-9.+eE]+)\, +([-0-9.+eE]+)} $log full xc yc zc]} { + puts "Error in DumpJson." +} + +checkreal "XC" $xc $px 1.0e-7 0.0 +checkreal "YC" $yc $py 1.0e-7 0.0 +checkreal "ZC" $zc $pz 1.0e-7 0.0 diff --git a/tests/bugs/vis/bug30949 b/tests/bugs/vis/bug30949 new file mode 100644 index 0000000000..af10a78980 --- /dev/null +++ b/tests/bugs/vis/bug30949 @@ -0,0 +1,34 @@ +puts "=============" +puts "0030949: Foundation Classes - Dump improvement for OCCT classes" +puts "=============" + +pload VISUALIZATION +vinit View1 + +set pred 0.329 +set pgreen 0.224 +set pblue 0.027 + +set dump_aligned_off [vaspects -defaults -dumpJson -dumpCompact on] + +if {![regexp {"RGB": \[+([-0-9.+eE]+)\, +([-0-9.+eE]+)\, +([-0-9.+eE]+)\]} $dump_aligned_off full cred cgreen cblue]} { + puts "Error in Dump. Wrong format of output." +} + +checkreal "Cred" $cred $pred 1.0e-7 0.0 +checkreal "Cgreen" $cgreen $pgreen 1.0e-7 0.0 +checkreal "Cblue" $cblue $pblue 1.0e-7 0.0 + + +set dump_aligned_off_deep [vaspects -defaults -dumpJson -dumpCompact on -dumpDepth 2] + +if {[regexp {\[+([-0-9.+eE]+)\, +([-0-9.+eE]+)\, +([-0-9.+eE]+)\]} dump_aligned_off_deep full cred cgreen cblue]} { + puts "Error in Dump. Wrong deep of output" +} + + +puts "Aligned Dump of vaspects:" +set dump_aligned_on [vaspects -defaults -dumpJson] + +puts "Aligned Dump of vaspects (deep = 2):" +set dump_aligned_on_deep [vaspects -defaults -dumpJson -dumpCompact off -dumpDepth 2] -- 2.20.1