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)
Dump geometric object to cout.
- *theHandlePtr* -- a pointer to the geometric variable (<i>Handle</i> 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 <b>DumpJson</b>. 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 <b>DUMP_CLASS_BEGIN</b>. 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
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);
+}
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
#include <Draw_Marker3D.hxx>
#include <Draw_MarkerShape.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
+
+#include <Standard_Dump.hxx>
+
#include <stdio.h>
Standard_IMPORT Draw_Viewer dout;
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;
{
doPrint = Standard_True;
}
+ else if (anArgCase == "-dumpjson")
+ {
+ doDumpJson = Standard_True;
+ }
else if (anArgCase == "-save"
&& anArgIter + 6 < theNArg
&& anOutVars[0].IsEmpty())
}
// 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;
<< "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())
{
}
}
+ if (doDumpJson)
+ {
+ Standard_SStream aStream;
+ anAABB.DumpJson (aStream);
+
+ theDI << "Bounding box\n";
+ theDI << Standard_Dump::FormatJson (aStream);
+ }
+
// save DRAW variables
if (!anOutVars[0].IsEmpty())
{
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:"
"\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."
#include <BVH_Constants.hxx>
#include <BVH_Types.hxx>
#include <Standard_ShortReal.hxx>
+#include <Standard_Dump.hxx>
#include <limits>
//! 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.
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).
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.
#include <vector>
+#include <Bnd_Box.hxx>
#include <NCollection_Mat4.hxx>
#include <NCollection_Vec2.hxx>
#include <NCollection_Vec3.hxx>
#include <NCollection_Vector.hxx>
+#include <Standard_OStream.hxx>
#include <Standard_Type.hxx>
// GCC supports shrink function only in C++11 mode
typedef NCollection_Vec3<T> Type;
};
+ template<class T> Bnd_Box ToBndBox (const T& theMin, const T& theMax)
+ {
+ return Bnd_Box (gp_Pnt (theMin, 0., 0.), gp_Pnt (theMax, 0., 0.));
+ }
+
+ template<class T> Bnd_Box ToBndBox (const NCollection_Vec2<T>& theMin,
+ const NCollection_Vec2<T>& theMax)
+ {
+ return Bnd_Box (gp_Pnt (theMin.x(), theMin.y(), 0.),
+ gp_Pnt (theMax.x(), theMax.y(), 0.));
+ }
+
+ template<class T> Bnd_Box ToBndBox (const NCollection_Vec3<T>& theMin,
+ const NCollection_Vec3<T>& theMax)
+ {
+ return Bnd_Box (gp_Pnt (theMin.x(), theMin.y(), theMin.z()),
+ gp_Pnt (theMax.x(), theMax.y(), theMax.z()));
+ }
+
+ template<class T> Bnd_Box ToBndBox (const NCollection_Vec4<T>& theMin,
+ const NCollection_Vec4<T>& theMax)
+ {
+ return Bnd_Box (gp_Pnt (theMin.x(), theMin.y(), theMin.z()),
+ gp_Pnt (theMax.x(), theMax.y(), theMax.z()));
+ }
+
template<class T> struct VectorType<T, 4>
{
typedef NCollection_Vec4<T> Type;
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <Standard_ConstructionError.hxx>
+#include <Standard_Dump.hxx>
// set the flag to one
#define ClearVoidFlag() ( Flags &= ~VoidMask )
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 :
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);
+}
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
+#include <gp_Pnt.hxx>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
//! 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; }
&& 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.
#include <NCollection_Array1.hxx>
#include <Precision.hxx>
+#include <Standard_Dump.hxx>
#include <TColStd_Array1OfReal.hxx>
//! Auxiliary class to select from the points stored in
}
}
+//=======================================================================
+//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);
+}
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
#include <Standard_Boolean.hxx>
+#include <Standard_OStream.hxx>
#include <Bnd_Box.hxx>
#include <gp_Ax3.hxx>
//! (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)
#include <Bnd_Range.hxx>
+#include <Standard_Dump.hxx>
//=======================================================================
//function : Common
{
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);
+}
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
Graphic3d_NameOfTextureEnv.hxx
Graphic3d_NameOfTexturePlane.hxx
Graphic3d_NMapOfTransient.hxx
+Graphic3d_PolygonOffset.cxx
Graphic3d_PolygonOffset.hxx
Graphic3d_PriorityDefinitionError.hxx
Graphic3d_RenderingMode.hxx
// commercial license or contractual agreement.
#include <Graphic3d_Aspects.hxx>
+#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient)
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);
+}
&& 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;
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);
+}
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 <AStructure>.
--- /dev/null
+// 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 <Graphic3d_PolygonOffset.hxx>
+
+#include <Standard_Dump.hxx>
+
+//=======================================================================
+//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);
+}
#define _Graphic3d_PolygonOffset_HeaderFile
#include <Aspect_PolygonOffsetMode.hxx>
+#include <Standard_OStream.hxx>
//! Polygon offset parameters.
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
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);
+}
//! 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
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);
+}
//! 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();
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_InvalidAngle.hxx>
+#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ArrowAspect, Prs3d_BasicAspect)
|| 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);
+}
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;
#define _Prs3d_BasicAspect_HeaderFile
#include <Standard.hxx>
+#include <Standard_OStream.hxx>
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
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)
#include <Prs3d_DatumAspect.hxx>
+#include <Standard_Dump.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
// =======================================================================
}
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);
+}
+
//! 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;
#include <Aspect_TypeOfLine.hxx>
#include <Graphic3d_AspectText3d.hxx>
+#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DimensionAspect, Prs3d_BasicAspect)
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);
+}
+
//! 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;
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_TextAspect.hxx>
+#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes)
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());
+}
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;
#include <Prs3d_LineAspect.hxx>
+#include <Standard_Dump.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_LineAspect, Prs3d_BasicAspect)
// =======================================================================
{
//
}
+
+// =======================================================================
+// 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());
+}
+
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;
#include <Prs3d_PlaneAspect.hxx>
+#include <Standard_Dump.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PlaneAspect, Prs3d_BasicAspect)
// =======================================================================
{
//
}
+
+// =======================================================================
+// 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);
+}
+
//! 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;
#include <Prs3d_PointAspect.hxx>
+#include <Standard_Dump.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PointAspect, Prs3d_BasicAspect)
// =======================================================================
{
//
}
+
+// =======================================================================
+// 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());
+}
+
//! 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;
#include <Graphic3d_MaterialAspect.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Type.hxx>
+#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ShadingAspect, Prs3d_BasicAspect)
}
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());
+}
+
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;
#include <Prs3d_TextAspect.hxx>
#include <Font_NameOfFont.hxx>
+#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_TextAspect, Prs3d_BasicAspect)
{
//
}
+
+// =======================================================================
+// 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);
+}
+
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;
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);
+}
//! 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".
#include <Quantity_ColorRGBA.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_OutOfRange.hxx>
+#include <Standard_Dump.hxx>
#include <TCollection_AsciiString.hxx>
#include <string.h>
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)
+}
//! 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.
#include <Quantity_ColorRGBA.hxx>
#include <Graphic3d_Vec4.hxx>
+#include <Standard_Dump.hxx>
#include <algorithm>
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);
+}
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)); }
#include <SelectMgr_BaseFrustum.hxx>
+#include <Message.hxx>
+
+#include <Standard_Dump.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
//=======================================================================
{
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);
+}
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
+#include <Standard_OStream.hxx>
+
//! 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
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:
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);
+}
//! 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.
{
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);
+}
//! 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.
}
}
}
+
+// =======================================================================
+// 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]);
+ }
+}
#include <Bnd_Range.hxx>
#include <Standard_TypeDef.hxx>
+#include <Standard_OStream.hxx>
+#include <Standard_Dump.hxx>
#include <vector>
//! 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<Bnd_Range> myClipRanges;
{
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());
+}
//! 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.
Standard_DimensionMismatch.hxx
Standard_DivideByZero.hxx
Standard_DomainError.hxx
+Standard_Dump.cxx
+Standard_Dump.hxx
Standard_ErrorHandler.cxx
Standard_ErrorHandler.hxx
Standard_ExtCharacter.hxx
--- /dev/null
+// 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 <Standard_Dump.hxx>
+
+#include <stdarg.h>
+
+// =======================================================================
+// 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;
+}
--- /dev/null
+// 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 <Standard_SStream.hxx>
+#include <TCollection_AsciiString.hxx>
+
+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
#include <Standard_ConstructionError.hxx>
#include <Standard_Stream.hxx>
#include <Standard_Type.hxx>
+#include <Standard_Dump.hxx>
#include <TopLoc_Datum3D.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TopLoc_Datum3D,Standard_Transient)
{
}
+//=======================================================================
+//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 :
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;
#include <TopLoc_Datum3D.hxx>
+#include <Standard_Dump.hxx>
#include <TopLoc_ItemLocation.hxx>
#include <TopLoc_Location.hxx>
#include <TopLoc_SListOfItemLocation.hxx>
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);
+}
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
+#include <Standard_OStream.hxx>
#include <gp_Trsf.hxx>
class TopLoc_Datum3D;
class TopLoc_Location;
//! Sets the exponent to <P>
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;
#include <gp_Trsf.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_NoSuchObject.hxx>
+#include <Standard_Dump.hxx>
#include <TopLoc_Datum3D.hxx>
#include <TopLoc_ItemLocation.hxx>
#include <TopLoc_Location.hxx>
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 :
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 <me> on the stream <s>.
Standard_EXPORT void ShallowDump (Standard_OStream& S) const;
#include <Standard_DomainError.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_TypeMismatch.hxx>
+#include <Standard_Dump.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_TShape.hxx>
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);
+}
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;
#include <TopoDS_TShape.hxx>
#include <TopoDS_Shape.hxx>
+#include <Standard_Dump.hxx>
+
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);
+}
//! @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;
//function : VAspects
//purpose :
//==============================================================================
-static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
+static Standard_Integer VAspects (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
{
// 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()
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";
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;
}
{
aPrs->SynchronizeAspects();
}
+
+ if (toDump)
+ {
+ Standard_SStream aStream;
+ aDrawer->DumpJson (aStream);
+
+ theDI << aName << ": \n";
+ theDI << Standard_Dump::FormatJson (aStream);
+ theDI << "\n";
+ }
}
}
return 0;
"\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."
#include <XCAFPrs_Style.hxx>
+#include <Standard_Dump.hxx>
+
//=======================================================================
//function : XCAFPrs_Style
//purpose :
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);
+}
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;
#include <gp_XYZ.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_OutOfRange.hxx>
+#include <Standard_Dump.hxx>
#define M00 ((Standard_Real*)M)[0]
#define M01 ((Standard_Real*)M)[1]
}
}
+//=======================================================================
+//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);
+}
//! 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;
#include <gp_XYZ.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_OutOfRange.hxx>
+#include <Standard_Dump.hxx>
//=======================================================================
//function : gp_Trsf
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);
+}
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Handle.hxx>
+#include <Standard_OStream.hxx>
#include <Standard_Real.hxx>
class Standard_ConstructionError;
theMat.SetValue (3, 3, static_cast<T> (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:
#include <gp_XYZ.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_OutOfRange.hxx>
+#include <Standard_Dump.hxx>
Standard_Boolean gp_XYZ::IsEqual (const gp_XYZ& Other,
const Standard_Real Tolerance) const {
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)
+}
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
+
+#include <Standard_OStream.hxx>
+
class Standard_ConstructionError;
class Standard_OutOfRange;
class gp_Mat;
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:
--- /dev/null
+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
--- /dev/null
+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]