1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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

@@ -24,10 +24,10 @@
// purpose :
// =======================================================================
Graphic3d_CullingTool::Graphic3d_CullingTool()
: myClipVerts (0, Graphic3d_Camera::FrustumVerticesNB),
myIsProjectionParallel (Standard_True),
myCamScale (1.0),
myPixelSize (1.0)
: myClipVerts(0, Graphic3d_Camera::FrustumVerticesNB),
myIsProjectionParallel(Standard_True),
myCamScale(1.0),
myPixelSize(1.0)
{
//
}
@@ -36,45 +36,46 @@ Graphic3d_CullingTool::Graphic3d_CullingTool()
// function : SetViewVolume
// purpose :
// =======================================================================
void Graphic3d_CullingTool::SetViewVolume (const Handle(Graphic3d_Camera)& theCamera,
const Graphic3d_Mat4d& theModelWorld)
void Graphic3d_CullingTool::SetViewVolume(const Handle(Graphic3d_Camera)& theCamera,
const Graphic3d_Mat4d& theModelWorld)
{
const bool hasModelTrsf = !theModelWorld.IsIdentity();
if (!myWorldViewProjState.IsChanged (theCamera->WorldViewProjState())
&& !hasModelTrsf)
if (!myWorldViewProjState.IsChanged(theCamera->WorldViewProjState()) && !hasModelTrsf)
{
return;
}
myIsProjectionParallel = theCamera->IsOrthographic();
const gp_Dir aCamDir = theCamera->Direction();
const gp_Dir aCamDir = theCamera->Direction();
myCamera = theCamera;
myProjectionMat = theCamera->ProjectionMatrix();
myWorldViewMat = theCamera->OrientationMatrix();
myWorldViewProjState = theCamera->WorldViewProjState();
myCamEye.SetValues (theCamera->Eye().X(), theCamera->Eye().Y(), theCamera->Eye().Z());
myCamDir.SetValues (aCamDir.X(), aCamDir.Y(), aCamDir.Z());
myCamEye.SetValues(theCamera->Eye().X(), theCamera->Eye().Y(), theCamera->Eye().Z());
myCamDir.SetValues(aCamDir.X(), aCamDir.Y(), aCamDir.Z());
if (hasModelTrsf)
{
Graphic3d_Mat4d aModelInv;
theModelWorld.Inverted (aModelInv);
myCamEye = (aModelInv * Graphic3d_Vec4d (myCamEye, 1.0)).xyz();
myCamDir = (aModelInv * Graphic3d_Vec4d (myCamDir, 0.0)).xyz();
theModelWorld.Inverted(aModelInv);
myCamEye = (aModelInv * Graphic3d_Vec4d(myCamEye, 1.0)).xyz();
myCamDir = (aModelInv * Graphic3d_Vec4d(myCamDir, 0.0)).xyz();
}
myCamScale = theCamera->IsOrthographic()
? theCamera->Scale()
: 2.0 * Tan (theCamera->FOVy() * M_PI / 360.0); // same as theCamera->Scale()/theCamera->Distance()
? theCamera->Scale()
: 2.0
* Tan(theCamera->FOVy() * M_PI
/ 360.0); // same as theCamera->Scale()/theCamera->Distance()
// Compute frustum points
theCamera->FrustumPoints (myClipVerts, theModelWorld);
theCamera->FrustumPoints(myClipVerts, theModelWorld);
// Compute frustum planes
// Vertices go in order:
// 0, 2, 1
const Standard_Integer aLookup1[] = { 0, 1, 0 };
const Standard_Integer aLookup2[] = { 0, 0, 1 };
Standard_Integer aShifts[] = { 0, 0, 0 };
const Standard_Integer aLookup1[] = {0, 1, 0};
const Standard_Integer aLookup2[] = {0, 0, 1};
Standard_Integer aShifts[] = {0, 0, 0};
// Planes go in order:
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
@@ -85,17 +86,18 @@ void Graphic3d_CullingTool::SetViewVolume (const Handle(Graphic3d_Camera)& theCa
Graphic3d_Vec3d aPlanePnts[3];
for (Standard_Integer aPntIter = 0; aPntIter < 3; ++aPntIter)
{
aShifts[aFaceIdx] = i;
aShifts[aFaceIdx] = i;
aShifts[(aFaceIdx + 1) % 3] = aLookup1[aPntIter];
aShifts[(aFaceIdx + 2) % 3] = aLookup2[aPntIter];
aPlanePnts[aPntIter] = myClipVerts[aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2]];
}
myClipPlanes[aFaceIdx * 2 + i].Origin = aPlanePnts[0];
myClipPlanes[aFaceIdx * 2 + i].Normal =
Graphic3d_Vec3d::Cross (aPlanePnts[1] - aPlanePnts[0],
aPlanePnts[2] - aPlanePnts[0]).Normalized() * (i == 0 ? -1.f : 1.f);
Graphic3d_Vec3d::Cross(aPlanePnts[1] - aPlanePnts[0], aPlanePnts[2] - aPlanePnts[0])
.Normalized()
* (i == 0 ? -1.f : 1.f);
}
}
}
@@ -104,35 +106,33 @@ void Graphic3d_CullingTool::SetViewVolume (const Handle(Graphic3d_Camera)& theCa
// function : SetViewportSize
// purpose :
// =======================================================================
void Graphic3d_CullingTool::SetViewportSize (Standard_Integer theViewportWidth,
Standard_Integer theViewportHeight,
Standard_Real theResolutionRatio)
void Graphic3d_CullingTool::SetViewportSize(Standard_Integer theViewportWidth,
Standard_Integer theViewportHeight,
Standard_Real theResolutionRatio)
{
myViewportHeight = theViewportHeight > 0 ? theViewportHeight : 1;
myViewportWidth = theViewportWidth > 0 ? theViewportWidth : 1;
myPixelSize = Max (theResolutionRatio / myViewportHeight,
theResolutionRatio / myViewportWidth);
myViewportWidth = theViewportWidth > 0 ? theViewportWidth : 1;
myPixelSize = Max(theResolutionRatio / myViewportHeight, theResolutionRatio / myViewportWidth);
}
// =======================================================================
// function : SignedPlanePointDistance
// purpose :
// =======================================================================
Standard_Real Graphic3d_CullingTool::SignedPlanePointDistance (const Graphic3d_Vec4d& theNormal,
const Graphic3d_Vec4d& thePnt)
Standard_Real Graphic3d_CullingTool::SignedPlanePointDistance(const Graphic3d_Vec4d& theNormal,
const Graphic3d_Vec4d& thePnt)
{
const Standard_Real aNormLength = std::sqrt (theNormal.x() * theNormal.x()
+ theNormal.y() * theNormal.y()
+ theNormal.z() * theNormal.z());
const Standard_Real aNormLength = std::sqrt(
theNormal.x() * theNormal.x() + theNormal.y() * theNormal.y() + theNormal.z() * theNormal.z());
if (aNormLength < gp::Resolution())
return 0.0;
const Standard_Real anInvNormLength = 1.0 / aNormLength;
const Standard_Real aD = theNormal.w() * anInvNormLength;
const Standard_Real anA = theNormal.x() * anInvNormLength;
const Standard_Real aB = theNormal.y() * anInvNormLength;
const Standard_Real aC = theNormal.z() * anInvNormLength;
const Standard_Real aD = theNormal.w() * anInvNormLength;
const Standard_Real anA = theNormal.x() * anInvNormLength;
const Standard_Real aB = theNormal.y() * anInvNormLength;
const Standard_Real aC = theNormal.z() * anInvNormLength;
return aD + (anA * thePnt.x() + aB * thePnt.y() + aC * thePnt.z());
}
@@ -140,15 +140,13 @@ Standard_Real Graphic3d_CullingTool::SignedPlanePointDistance (const Graphic3d_V
// function : SetCullingDistance
// purpose :
// =======================================================================
void Graphic3d_CullingTool::SetCullingDistance (CullingContext& theCtx,
Standard_Real theDistance) const
void Graphic3d_CullingTool::SetCullingDistance(CullingContext& theCtx,
Standard_Real theDistance) const
{
theCtx.DistCull = -1.0;
if (!myIsProjectionParallel)
{
theCtx.DistCull = theDistance > 0.0 && !Precision::IsInfinite (theDistance)
? theDistance
: -1.0;
theCtx.DistCull = theDistance > 0.0 && !Precision::IsInfinite(theDistance) ? theDistance : -1.0;
}
}
@@ -156,11 +154,10 @@ void Graphic3d_CullingTool::SetCullingDistance (CullingContext& theCtx,
// function : SetCullingSize
// purpose :
// =======================================================================
void Graphic3d_CullingTool::SetCullingSize (CullingContext& theCtx,
Standard_Real theSize) const
void Graphic3d_CullingTool::SetCullingSize(CullingContext& theCtx, Standard_Real theSize) const
{
theCtx.SizeCull2 = -1.0;
if (theSize > 0.0 && !Precision::IsInfinite (theSize))
if (theSize > 0.0 && !Precision::IsInfinite(theSize))
{
theCtx.SizeCull2 = myPixelSize * theSize;
theCtx.SizeCull2 *= myCamScale;
@@ -179,30 +176,32 @@ void Graphic3d_CullingTool::CacheClipPtsProjections()
for (Standard_Integer aPlaneIter = 0; aPlaneIter < PlanesNB - 1; aPlaneIter += anIncFactor)
{
Standard_Real aMaxProj = -std::numeric_limits<Standard_Real>::max();
Standard_Real aMinProj = std::numeric_limits<Standard_Real>::max();
for (Standard_Integer aCornerIter = 0; aCornerIter < Graphic3d_Camera::FrustumVerticesNB; ++aCornerIter)
Standard_Real aMinProj = std::numeric_limits<Standard_Real>::max();
for (Standard_Integer aCornerIter = 0; aCornerIter < Graphic3d_Camera::FrustumVerticesNB;
++aCornerIter)
{
Standard_Real aProjection = myClipVerts[aCornerIter].Dot (myClipPlanes[aPlaneIter].Normal);
aMaxProj = Max (aProjection, aMaxProj);
aMinProj = Min (aProjection, aMinProj);
Standard_Real aProjection = myClipVerts[aCornerIter].Dot(myClipPlanes[aPlaneIter].Normal);
aMaxProj = Max(aProjection, aMaxProj);
aMinProj = Min(aProjection, aMinProj);
}
myMaxClipProjectionPts[aPlaneIter] = aMaxProj;
myMinClipProjectionPts[aPlaneIter] = aMinProj;
}
// project frustum onto main axes
Graphic3d_Vec3d anAxes[] = { Graphic3d_Vec3d (1.0, 0.0, 0.0),
Graphic3d_Vec3d (0.0, 1.0, 0.0),
Graphic3d_Vec3d (0.0, 0.0, 1.0) };
Graphic3d_Vec3d anAxes[] = {Graphic3d_Vec3d(1.0, 0.0, 0.0),
Graphic3d_Vec3d(0.0, 1.0, 0.0),
Graphic3d_Vec3d(0.0, 0.0, 1.0)};
for (Standard_Integer aDim = 0; aDim < 3; ++aDim)
{
Standard_Real aMaxProj = -std::numeric_limits<Standard_Real>::max();
Standard_Real aMinProj = std::numeric_limits<Standard_Real>::max();
for (Standard_Integer aCornerIter = 0; aCornerIter < Graphic3d_Camera::FrustumVerticesNB; ++aCornerIter)
Standard_Real aMinProj = std::numeric_limits<Standard_Real>::max();
for (Standard_Integer aCornerIter = 0; aCornerIter < Graphic3d_Camera::FrustumVerticesNB;
++aCornerIter)
{
Standard_Real aProjection = myClipVerts[aCornerIter].Dot (anAxes[aDim]);
aMaxProj = Max (aProjection, aMaxProj);
aMinProj = Min (aProjection, aMinProj);
Standard_Real aProjection = myClipVerts[aCornerIter].Dot(anAxes[aDim]);
aMaxProj = Max(aProjection, aMaxProj);
aMinProj = Min(aProjection, aMinProj);
}
myMaxOrthoProjectionPts[aDim] = aMaxProj;
myMinOrthoProjectionPts[aDim] = aMinProj;