1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Coding - Apply .clang-format formatting #286

Update empty method guards to new style with regex (see PR).
Used clang-format 18.1.8.
New actions to validate code formatting is added.
Update .clang-format with disabling of include sorting.
  It is temporary changes, then include will be sorted.
Apply formatting for /src and /tools folder.
The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
dpasukhi
2025-01-25 20:15:22 +00:00
parent dbba6f1289
commit a5a7b3185b
14005 changed files with 1273539 additions and 1195567 deletions

View File

@@ -11,7 +11,7 @@
// 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.
// commercial license or contractual agreement.
#include <inspector/Convert_Tools.hxx>
#include <inspector/Convert_TransientShape.hxx>
@@ -36,119 +36,126 @@
// function : ReadShape
// purpose :
// =======================================================================
TopoDS_Shape Convert_Tools::ReadShape (const TCollection_AsciiString& theFileName)
TopoDS_Shape Convert_Tools::ReadShape(const TCollection_AsciiString& theFileName)
{
TopoDS_Shape aShape;
BRep_Builder aBuilder;
BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
BRepTools::Read(aShape, theFileName.ToCString(), aBuilder);
return aShape;
}
//=======================================================================
//function : ConvertStreamToPresentations
//purpose :
// function : ConvertStreamToPresentations
// purpose :
//=======================================================================
void Convert_Tools::ConvertStreamToPresentations (const Standard_SStream& theSStream,
const Standard_Integer theStartPos,
const Standard_Integer /*theLastPos*/,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
void Convert_Tools::ConvertStreamToPresentations(
const Standard_SStream& theSStream,
const Standard_Integer theStartPos,
const Standard_Integer /*theLastPos*/,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
{
int aStartPos = theStartPos;
gp_XYZ aPoint;
if (aPoint.InitFromJson (theSStream, aStartPos))
if (aPoint.InitFromJson(theSStream, aStartPos))
{
thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPoint)));
thePresentations.Append(new Convert_TransientShape(BRepBuilderAPI_MakeVertex(aPoint)));
return;
}
gp_Pnt aPnt;
if (aPnt.InitFromJson (theSStream, aStartPos))
if (aPnt.InitFromJson(theSStream, aStartPos))
{
thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPnt)));
thePresentations.Append(new Convert_TransientShape(BRepBuilderAPI_MakeVertex(aPnt)));
return;
}
gp_Dir aDir;
if (aDir.InitFromJson (theSStream, aStartPos))
if (aDir.InitFromJson(theSStream, aStartPos))
{
gp_Lin aLin (gp::Origin(), aDir);
Handle(Geom_Line) aGeomLine = new Geom_Line (aLin);
CreatePresentation (aGeomLine, thePresentations);
gp_Lin aLin(gp::Origin(), aDir);
Handle(Geom_Line) aGeomLine = new Geom_Line(aLin);
CreatePresentation(aGeomLine, thePresentations);
return;
}
gp_Ax2 anAx2;
if (anAx2.InitFromJson (theSStream, aStartPos))
if (anAx2.InitFromJson(theSStream, aStartPos))
{
Handle(Geom_Plane) aGeomPlane = new Geom_Plane (gp_Ax3 (anAx2));
CreatePresentation (aGeomPlane, thePresentations);
Handle(Geom_Plane) aGeomPlane = new Geom_Plane(gp_Ax3(anAx2));
CreatePresentation(aGeomPlane, thePresentations);
return;
}
gp_Ax3 anAx3; // should be after gp_Ax2
if (anAx3.InitFromJson (theSStream, aStartPos))
if (anAx3.InitFromJson(theSStream, aStartPos))
{
Handle(Geom_Plane) aGeomPlane = new Geom_Plane (anAx3);
CreatePresentation (aGeomPlane, thePresentations);
Handle(Geom_Plane) aGeomPlane = new Geom_Plane(anAx3);
CreatePresentation(aGeomPlane, thePresentations);
return;
}
// should be after gp_Ax3
gp_Ax1 anAxis;
if (anAxis.InitFromJson (theSStream, aStartPos))
if (anAxis.InitFromJson(theSStream, aStartPos))
{
thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeEdge (anAxis.Location(), anAxis.Location().Coord() + anAxis.Direction().XYZ())));
thePresentations.Append(new Convert_TransientShape(
BRepBuilderAPI_MakeEdge(anAxis.Location(),
anAxis.Location().Coord() + anAxis.Direction().XYZ())));
return;
}
gp_Trsf aTrsf;
if (aTrsf.InitFromJson (theSStream, aStartPos))
if (aTrsf.InitFromJson(theSStream, aStartPos))
{
CreatePresentation (aTrsf, thePresentations);
CreatePresentation(aTrsf, thePresentations);
return;
}
Bnd_Box aBox;
if (aBox.InitFromJson (theSStream, aStartPos))
if (aBox.InitFromJson(theSStream, aStartPos))
{
TopoDS_Shape aShape;
if (Convert_Tools::CreateShape (aBox, aShape))
thePresentations.Append (new Convert_TransientShape (aShape));
if (Convert_Tools::CreateShape(aBox, aShape))
thePresentations.Append(new Convert_TransientShape(aShape));
return;
}
Select3D_BndBox3d aSelectBndBox;
if (aSelectBndBox.InitFromJson (theSStream, aStartPos))
if (aSelectBndBox.InitFromJson(theSStream, aStartPos))
{
TopoDS_Shape aShape;
gp_Pnt aPntMin = gp_Pnt (aSelectBndBox.CornerMin().x(), aSelectBndBox.CornerMin().y(), aSelectBndBox.CornerMin().z());
gp_Pnt aPntMax = gp_Pnt (aSelectBndBox.CornerMax().x(), aSelectBndBox.CornerMax().y(), aSelectBndBox.CornerMax().z());
if (CreateBoxShape (aPntMin, aPntMax, aShape))
thePresentations.Append (new Convert_TransientShape (aShape));
gp_Pnt aPntMin = gp_Pnt(aSelectBndBox.CornerMin().x(),
aSelectBndBox.CornerMin().y(),
aSelectBndBox.CornerMin().z());
gp_Pnt aPntMax = gp_Pnt(aSelectBndBox.CornerMax().x(),
aSelectBndBox.CornerMax().y(),
aSelectBndBox.CornerMax().z());
if (CreateBoxShape(aPntMin, aPntMax, aShape))
thePresentations.Append(new Convert_TransientShape(aShape));
return;
}
}
//=======================================================================
//function : ConvertStreamToColor
//purpose :
// function : ConvertStreamToColor
// purpose :
//=======================================================================
Standard_Boolean Convert_Tools::ConvertStreamToColor (const Standard_SStream& theSStream,
Quantity_Color& theColor)
Standard_Boolean Convert_Tools::ConvertStreamToColor(const Standard_SStream& theSStream,
Quantity_Color& theColor)
{
Standard_Integer aStartPos = 1;
Standard_Integer aStartPos = 1;
Quantity_ColorRGBA aColorRGBA;
if (aColorRGBA.InitFromJson (theSStream, aStartPos))
if (aColorRGBA.InitFromJson(theSStream, aStartPos))
{
theColor = aColorRGBA.GetRGB();
return Standard_True;
}
Quantity_Color aColor;
if (aColor.InitFromJson (theSStream, aStartPos))
if (aColor.InitFromJson(theSStream, aStartPos))
{
theColor = aColor;
return Standard_True;
@@ -158,28 +165,28 @@ Standard_Boolean Convert_Tools::ConvertStreamToColor (const Standard_SStream& th
}
//=======================================================================
//function : CreateShape
//purpose :
// function : CreateShape
// purpose :
//=======================================================================
Standard_Boolean Convert_Tools::CreateShape (const Bnd_Box& theBoundingBox, TopoDS_Shape& theShape)
Standard_Boolean Convert_Tools::CreateShape(const Bnd_Box& theBoundingBox, TopoDS_Shape& theShape)
{
if (theBoundingBox.IsVoid() || theBoundingBox.IsWhole())
return Standard_False;
Standard_Real aXmin, anYmin, aZmin, aXmax, anYmax, aZmax;
theBoundingBox.Get (aXmin, anYmin, aZmin, aXmax, anYmax, aZmax);
theBoundingBox.Get(aXmin, anYmin, aZmin, aXmax, anYmax, aZmax);
gp_Pnt aPntMin = gp_Pnt (aXmin, anYmin, aZmin);
gp_Pnt aPntMax = gp_Pnt (aXmax, anYmax, aZmax);
gp_Pnt aPntMin = gp_Pnt(aXmin, anYmin, aZmin);
gp_Pnt aPntMax = gp_Pnt(aXmax, anYmax, aZmax);
return CreateBoxShape (aPntMin, aPntMax, theShape);
return CreateBoxShape(aPntMin, aPntMax, theShape);
}
//=======================================================================
//function : CreateShape
//purpose :
// function : CreateShape
// purpose :
//=======================================================================
Standard_Boolean Convert_Tools::CreateShape (const Bnd_OBB& theBoundingBox, TopoDS_Shape& theShape)
Standard_Boolean Convert_Tools::CreateShape(const Bnd_OBB& theBoundingBox, TopoDS_Shape& theShape)
{
if (theBoundingBox.IsVoid())
return Standard_False;
@@ -187,92 +194,101 @@ Standard_Boolean Convert_Tools::CreateShape (const Bnd_OBB& theBoundingBox, Topo
TColgp_Array1OfPnt anArrPnts(0, 8);
theBoundingBox.GetVertex(&anArrPnts(0));
BRep_Builder aBuilder;
BRep_Builder aBuilder;
TopoDS_Compound aCompound;
aBuilder.MakeCompound (aCompound);
aBuilder.MakeCompound(aCompound);
aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(1))));
aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(2))));
aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(1)), gp_Pnt (anArrPnts.Value(3))));
aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(2)), gp_Pnt (anArrPnts.Value(3))));
aBuilder.Add(aCompound,
BRepBuilderAPI_MakeEdge(gp_Pnt(anArrPnts.Value(0)), gp_Pnt(anArrPnts.Value(1))));
aBuilder.Add(aCompound,
BRepBuilderAPI_MakeEdge(gp_Pnt(anArrPnts.Value(0)), gp_Pnt(anArrPnts.Value(2))));
aBuilder.Add(aCompound,
BRepBuilderAPI_MakeEdge(gp_Pnt(anArrPnts.Value(1)), gp_Pnt(anArrPnts.Value(3))));
aBuilder.Add(aCompound,
BRepBuilderAPI_MakeEdge(gp_Pnt(anArrPnts.Value(2)), gp_Pnt(anArrPnts.Value(3))));
theShape = aCompound;
return Standard_True;
}
//=======================================================================
//function : CreateBoxShape
//purpose :
// function : CreateBoxShape
// purpose :
//=======================================================================
Standard_Boolean Convert_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax, TopoDS_Shape& theShape)
Standard_Boolean Convert_Tools::CreateBoxShape(const gp_Pnt& thePntMin,
const gp_Pnt& thePntMax,
TopoDS_Shape& theShape)
{
BRepPreviewAPI_MakeBox aMakeBox;
aMakeBox.Init (thePntMin, thePntMax);
aMakeBox.Init(thePntMin, thePntMax);
theShape = aMakeBox.Shape();
return Standard_True;
}
//=======================================================================
//function : CreatePresentation
//purpose :
// function : CreatePresentation
// purpose :
//=======================================================================
void Convert_Tools::CreatePresentation (const Handle(Geom_Line)& theLine,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
void Convert_Tools::CreatePresentation(
const Handle(Geom_Line)& theLine,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
{
Handle(AIS_Line) aLinePrs = new AIS_Line (theLine);
aLinePrs->SetColor (Quantity_NOC_TOMATO);
thePresentations.Append (aLinePrs);
Handle(AIS_Line) aLinePrs = new AIS_Line(theLine);
aLinePrs->SetColor(Quantity_NOC_TOMATO);
thePresentations.Append(aLinePrs);
}
//=======================================================================
//function : CreatePresentation
//purpose :
// function : CreatePresentation
// purpose :
//=======================================================================
void Convert_Tools::CreatePresentation (const Handle(Geom_Plane)& thePlane,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
void Convert_Tools::CreatePresentation(
const Handle(Geom_Plane)& thePlane,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
{
Handle(AIS_Plane) aPlanePrs = new AIS_Plane (thePlane);
Handle(AIS_Plane) aPlanePrs = new AIS_Plane(thePlane);
aPlanePrs->Attributes()->SetPlaneAspect (new Prs3d_PlaneAspect());
Handle (Prs3d_PlaneAspect) aPlaneAspect = aPlanePrs->Attributes()->PlaneAspect();
aPlaneAspect->SetPlaneLength (100, 100);
aPlaneAspect->SetDisplayCenterArrow (Standard_True);
aPlaneAspect->SetDisplayEdgesArrows (Standard_True);
aPlaneAspect->SetArrowsSize (100);
aPlaneAspect->SetArrowsLength (100);
aPlaneAspect->SetDisplayCenterArrow (Standard_True);
aPlaneAspect->SetDisplayEdges (Standard_True);
aPlanePrs->Attributes()->SetPlaneAspect(new Prs3d_PlaneAspect());
Handle(Prs3d_PlaneAspect) aPlaneAspect = aPlanePrs->Attributes()->PlaneAspect();
aPlaneAspect->SetPlaneLength(100, 100);
aPlaneAspect->SetDisplayCenterArrow(Standard_True);
aPlaneAspect->SetDisplayEdgesArrows(Standard_True);
aPlaneAspect->SetArrowsSize(100);
aPlaneAspect->SetArrowsLength(100);
aPlaneAspect->SetDisplayCenterArrow(Standard_True);
aPlaneAspect->SetDisplayEdges(Standard_True);
aPlanePrs->SetColor (Quantity_NOC_WHITE);
aPlanePrs->SetTransparency (0);
aPlanePrs->SetColor(Quantity_NOC_WHITE);
aPlanePrs->SetTransparency(0);
thePresentations.Append (aPlanePrs);
thePresentations.Append(aPlanePrs);
}
//=======================================================================
//function : CreatePresentation
//purpose :
// function : CreatePresentation
// purpose :
//=======================================================================
void Convert_Tools::CreatePresentation (const gp_Trsf& theTrsf,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
void Convert_Tools::CreatePresentation(
const gp_Trsf& theTrsf,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
{
Bnd_Box aBox (gp_Pnt(), gp_Pnt(10., 10., 10));
Bnd_Box aBox(gp_Pnt(), gp_Pnt(10., 10., 10));
TopoDS_Shape aBoxShape;
if (!Convert_Tools::CreateShape (aBox, aBoxShape))
if (!Convert_Tools::CreateShape(aBox, aBoxShape))
return;
Handle(AIS_Shape) aSourcePrs = new AIS_Shape (aBoxShape);
aSourcePrs->Attributes()->SetAutoTriangulation (Standard_False);
aSourcePrs->SetColor (Quantity_NOC_WHITE);
aSourcePrs->SetTransparency (0.5);
thePresentations.Append (aSourcePrs);
Handle(AIS_Shape) aSourcePrs = new AIS_Shape(aBoxShape);
aSourcePrs->Attributes()->SetAutoTriangulation(Standard_False);
aSourcePrs->SetColor(Quantity_NOC_WHITE);
aSourcePrs->SetTransparency(0.5);
thePresentations.Append(aSourcePrs);
Handle(AIS_Shape) aTransformedPrs = new AIS_Shape (aBoxShape);
aTransformedPrs->Attributes()->SetAutoTriangulation (Standard_False);
aTransformedPrs->SetColor (Quantity_NOC_TOMATO);
aTransformedPrs->SetTransparency (0.5);
aTransformedPrs->SetLocalTransformation (theTrsf);
thePresentations.Append (aTransformedPrs);
Handle(AIS_Shape) aTransformedPrs = new AIS_Shape(aBoxShape);
aTransformedPrs->Attributes()->SetAutoTriangulation(Standard_False);
aTransformedPrs->SetColor(Quantity_NOC_TOMATO);
aTransformedPrs->SetTransparency(0.5);
aTransformedPrs->SetLocalTransformation(theTrsf);
thePresentations.Append(aTransformedPrs);
}

View File

@@ -11,7 +11,7 @@
// 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.
// commercial license or contractual agreement.
#ifndef Convert_Tools_H
#define Convert_Tools_H
@@ -30,7 +30,7 @@
#include <Standard_Dump.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_SStream.hxx>
#include <Standard_WarningsDisable.hxx>
@@ -50,60 +50,64 @@ public:
//! Reads Shape using BREP reader
//! \param theFileName a file name
//! \return shape or NULL
Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
Standard_EXPORT static TopoDS_Shape ReadShape(const TCollection_AsciiString& theFileName);
//! Creates shape presentations on the stream if possible. Tries to init some OCCT base for a new presentation
//! \param theStream source of presentation
//! \param thePresentations container to collect new presentations
Standard_EXPORT static void ConvertStreamToPresentations (const Standard_SStream& theSStream,
const Standard_Integer theStartPos,
const Standard_Integer theLastPos,
NCollection_List<Handle(Standard_Transient)>& thePresentations);
//! Creates shape presentations on the stream if possible. Tries to init some OCCT base for a new
//! presentation \param theStream source of presentation \param thePresentations container to
//! collect new presentations
Standard_EXPORT static void ConvertStreamToPresentations(
const Standard_SStream& theSStream,
const Standard_Integer theStartPos,
const Standard_Integer theLastPos,
NCollection_List<Handle(Standard_Transient)>& thePresentations);
//! Converts stream to color if possible. It processes Quantity_Color, Quantity_ColorRGBA
//! \param theStream source of presentation
//! \param[out] theColor converted color
//! \returns true if done
Standard_EXPORT static Standard_Boolean ConvertStreamToColor (const Standard_SStream& theSStream,
Quantity_Color& theColor);
Standard_EXPORT static Standard_Boolean ConvertStreamToColor(const Standard_SStream& theSStream,
Quantity_Color& theColor);
//! Creates box shape
//! \param theBoundingBox box shape parameters
//! \return created shape
Standard_EXPORT static Standard_Boolean CreateShape (const Bnd_Box& theBoundingBox, TopoDS_Shape& theShape);
Standard_EXPORT static Standard_Boolean CreateShape(const Bnd_Box& theBoundingBox,
TopoDS_Shape& theShape);
//! Creates box shape
//! \param theBoundingBox box shape parameters
//! \return created shape
Standard_EXPORT static Standard_Boolean CreateShape (const Bnd_OBB& theBoundingBox, TopoDS_Shape& theShape);
Standard_EXPORT static Standard_Boolean CreateShape(const Bnd_OBB& theBoundingBox,
TopoDS_Shape& theShape);
//! Creates box shape
//! \param thePntMin minimum point on the bounding box
//! \param thePntMax maximum point on the bounding box
//! \return created shape
Standard_EXPORT static Standard_Boolean CreateBoxShape (const gp_Pnt& thePntMin,
const gp_Pnt& thePntMax,
TopoDS_Shape& theShape);
Standard_EXPORT static Standard_Boolean CreateBoxShape(const gp_Pnt& thePntMin,
const gp_Pnt& thePntMax,
TopoDS_Shape& theShape);
//! Creates presentation AIS_Line
//! \param theLine source line
//! \param thePresentations container to collect new presentations
Standard_EXPORT static void CreatePresentation (const Handle(Geom_Line)& theLine,
Standard_EXPORT static void CreatePresentation(
const Handle(Geom_Line)& theLine,
NCollection_List<Handle(Standard_Transient)>& thePresentations);
//! Creates presentation AIS_Plane
//! \param thePlane source plane
//! \param thePresentations container to collect new presentations
Standard_EXPORT static void CreatePresentation (const Handle(Geom_Plane)& thePlane,
Standard_EXPORT static void CreatePresentation(
const Handle(Geom_Plane)& thePlane,
NCollection_List<Handle(Standard_Transient)>& thePresentations);
//! Creates two presentations base on gp_Trsf: box in initial place and transformed box
//! \param thePlane source plane
//! \param thePresentations container to collect new presentations
Standard_EXPORT static void CreatePresentation (const gp_Trsf& theTrsf,
Standard_EXPORT static void CreatePresentation(
const gp_Trsf& theTrsf,
NCollection_List<Handle(Standard_Transient)>& thePresentations);
};
#endif

View File

@@ -11,7 +11,7 @@
// 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.
// commercial license or contractual agreement.
#ifndef Convert_TransientShape_H
#define Convert_TransientShape_H
@@ -29,9 +29,8 @@
class Convert_TransientShape : public Standard_Transient
{
public:
//! Constructor
Convert_TransientShape (const TopoDS_Shape& theShape) { SetShape (theShape); }
Convert_TransientShape(const TopoDS_Shape& theShape) { SetShape(theShape); }
//! Destructor
virtual ~Convert_TransientShape() {}
@@ -40,12 +39,12 @@ public:
const TopoDS_Shape Shape() const { return myShape; }
//! Fills current shape
void SetShape (const TopoDS_Shape& theShape) { myShape = theShape; }
void SetShape(const TopoDS_Shape& theShape) { myShape = theShape; }
DEFINE_STANDARD_RTTI_INLINE (Convert_TransientShape, Standard_Transient)
DEFINE_STANDARD_RTTI_INLINE(Convert_TransientShape, Standard_Transient)
private:
TopoDS_Shape myShape; //!< the shape
};
#endif
#endif