Skip to content

Commit

Permalink
Coding - Fixing clang-tidy warnings #207
Browse files Browse the repository at this point in the history
First iteration for fixing warnings for:
- TKernel
- TKMath
- TKGeomBase
  • Loading branch information
dpasukhi committed Dec 22, 2024
1 parent 0ffcc44 commit f7dea47
Show file tree
Hide file tree
Showing 35 changed files with 94 additions and 162 deletions.
3 changes: 1 addition & 2 deletions src/Adaptor3d/Adaptor3d_CurveOnSurface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ static void FindBounds(const TColStd_Array1OfReal& Arr,
if((N!=Bound1)&&(N!=Bound2)) {
if(Abs(Der) > Tol ) {
if(Der>0) {Bound1=N;Bound2= N+1;}
else
if(Der<0){Bound1=N-1;Bound2=N;}
else {Bound1=N-1;Bound2=N;}
DerNull = Standard_False;
}
if(Abs(Der) <=Tol ) {
Expand Down
11 changes: 4 additions & 7 deletions src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5917,7 +5917,6 @@ int mma2er2_(integer *ndjacu,
integer i2rdu, i2rdv;
doublereal errnu, errnv;
integer ii, nd, jj, nu, nv;
doublereal bid0, bid1;

/* **********************************************************************
*/
Expand Down Expand Up @@ -6031,12 +6030,11 @@ int mma2er2_(integer *ndjacu,
/* ---------------- by U, the degree by V is fixed to NV -----------------
*/

bid0 = 0.;
if (nv > *mindgv) {
bid0 = xmaxjv[nv - i2rdv];
doublereal bid0 = xmaxjv[nv - i2rdv];
i__1 = *ndimen;
for (nd = 1; nd <= i__1; ++nd) {
bid1 = 0.;
doublereal bid1 = 0.;
i__2 = nu;
for (ii = i2rdu; ii <= i__2; ++ii) {
bid1 += (d__1 = patjac[ii + (nv + nd * patjac_dim2) *
Expand All @@ -6056,12 +6054,11 @@ int mma2er2_(integer *ndjacu,
/* ---------------- by V, the degree by U is fixed to NU -----------------
*/

bid0 = 0.;
if (nu > *mindgu) {
bid0 = xmaxju[nu - i2rdu];
doublereal bid0 = xmaxju[nu - i2rdu];
i__1 = *ndimen;
for (nd = 1; nd <= i__1; ++nd) {
bid1 = 0.;
doublereal bid1 = 0.;
i__2 = nv;
for (jj = i2rdv; jj <= i__2; ++jj) {
bid1 += (d__1 = patjac[nu + (jj + nd * patjac_dim2) *
Expand Down
5 changes: 2 additions & 3 deletions src/AdvApprox/AdvApprox_ApproxAFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void AdvApprox_ApproxAFunction::Approximation(
Standard_Integer& ErrorCode)
{
// Standard_Real EpsPar = Precision::Confusion();
Standard_Integer IDIM, NUPIL,TheDeg;
Standard_Integer NUPIL,TheDeg;
#ifdef OCCT_DEBUG
Standard_Integer NDIMEN = TotalDimension;
#endif
Expand All @@ -440,7 +440,7 @@ void AdvApprox_ApproxAFunction::Approximation(

//--> La dimension totale doit etre la somme des dimensions des
// sous-espaces
IDIM=0;
Standard_Integer IDIM=0;
for ( Standard_Integer I=1; I<=TotalNumSS; I++) {IDIM += LocalDimension(I);}
if (IDIM != TotalDimension)
{ErrorCode=1;
Expand Down Expand Up @@ -510,7 +510,6 @@ void AdvApprox_ApproxAFunction::Approximation(

//---------- Calcul du degre de la courbe et de l' erreur max ----------

IDIM=0;
NumCoeffPerCurveArray(NumCurves + 1)=0;

// L'erreur doit etre satisfaite sur tous les sous-espaces sinon, on decoupe
Expand Down
10 changes: 4 additions & 6 deletions src/AppDef/AppDef_LinearCriteria.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,12 @@ void AppDef_LinearCriteria::BuildCache(const Standard_Integer Element)
{
Standard_Real t;
Standard_Real UFirst, ULast;
Standard_Integer ipnt;

UFirst = myCurve->Knots()(Element);
ULast = myCurve->Knots()(Element + 1);

IF = 0;
for(ipnt = myParameters->Lower(); ipnt <= myParameters->Upper(); ipnt++) {
for(Standard_Integer ipnt = myParameters->Lower(); ipnt <= myParameters->Upper(); ipnt++) {
t = myParameters->Value(ipnt);
if((t > UFirst && t <= ULast) || (Element == 1 && t == UFirst)) {
if (IF == 0) IF=ipnt;
Expand All @@ -770,11 +769,10 @@ void AppDef_LinearCriteria::BuildCache(const Standard_Integer Element)

if (IF != 0) {
Handle(PLib_Base) myBase = myCurve->Base();
Standard_Integer order = myBase->WorkDegree()+1, ii;
Standard_Integer order = myBase->WorkDegree()+1;
myCache = new TColStd_HArray1OfReal (1, (IL-IF+1)*(order));

ii =1;
for(ipnt = IF, ii=1; ipnt <= IL; ipnt++, ii+=order) {

for(Standard_Integer ipnt = IF, ii=1; ipnt <= IL; ipnt++, ii+=order) {
Standard_Real * cache = &myCache->ChangeValue(ii);
TColStd_Array1OfReal BasicValue(cache[0], 0, order-1);
t = myParameters->Value(ipnt);
Expand Down
11 changes: 4 additions & 7 deletions src/AppDef/AppDef_Variational.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void AppDef_Variational::Approximate()

//---------------------------------------------------------------------

Standard_Integer jp2d,jp3d,index,ipole,
Standard_Integer jp2d,jp3d,ipole,
NbElem = TheCurve->NbElements();

TColgp_Array1OfPnt TabP3d(1, Max(1,myNbP3d));
Expand All @@ -468,9 +468,6 @@ void AppDef_Variational::Approximate()

gp_Pnt2d P2d;
gp_Pnt P3d;

index=0;

{
Handle(TColStd_HArray2OfReal) PolynomialIntervalsPtr =
new TColStd_HArray2OfReal(1,NbElem,1,2) ;
Expand Down Expand Up @@ -549,7 +546,7 @@ void AppDef_Variational::Approximate()

for (ipole=PolesPtr->LowerRow();ipole<=PolesPtr->UpperRow();ipole++)
{
index=PolesPtr->LowerCol();
Standard_Integer index = PolesPtr->LowerCol();
/* if(myNbP2d !=0 )
{
for (jp2d=1;jp2d<=myNbP2d;jp2d++)
Expand Down Expand Up @@ -1150,7 +1147,7 @@ void AppDef_Variational::TheMotor(

Handle(TColStd_HArray1OfReal) CurrentTi, NewTi, OldTi;
Handle(TColStd_HArray2OfInteger) Dependence;
Standard_Boolean lestim, lconst, ToOptim, iscut;
Standard_Boolean lestim, ToOptim, iscut;
Standard_Boolean isnear = Standard_False, again = Standard_True;
Standard_Integer NbEst, ICDANA, NumPnt, Iter;
Standard_Integer MaxNbEst =5;
Expand Down Expand Up @@ -1198,7 +1195,7 @@ void AppDef_Variational::TheMotor(

// (1) Loop Optimization / Estimation
lestim = Standard_True;
lconst = Standard_True;
Standard_Boolean lconst = Standard_True;
NbEst = 0;

J->SetCurve(CCurrent);
Expand Down
2 changes: 0 additions & 2 deletions src/BSplCLib/BSplCLib.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2913,8 +2913,6 @@ BSplCLib::SolveBandedSystem(const math_Matrix& Matrix,
if ( Abs(divizor) > Toler )
Inverse = 1.0e0 / divizor ;
else {
Inverse = 1.0e0;
// std::cout << " BSplCLib::SolveBandedSystem() : zero determinant " << std::endl;
ReturnCode = 1;
goto FINISH;
}
Expand Down
29 changes: 14 additions & 15 deletions src/BSplCLib/BSplCLib_BzSyntaxes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,25 @@
// knots for bezier (using stack allocation)
//=======================================================================

class BSplCLib_BezierArrays
class BSplCLib_BezierArrays
{
public:
BSplCLib_BezierArrays (Standard_Integer Degree)
: knots (aKnots[0], 1, 2), mults (aMults[0], 1, 2)
{
aKnots[0] = 0.;
aKnots[1] = 1.;
aMults[0] = aMults[1] = Degree + 1;
}

private:
Standard_Real aKnots[2];
public:
BSplCLib_BezierArrays(Standard_Integer Degree)
: aKnots{0., 1.},
aMults{Degree + 1, Degree + 1},
knots(aKnots[0], 1, 2),
mults(aMults[0], 1, 2)
{}

private:
Standard_Real aKnots[2];
Standard_Integer aMults[2];
public:

public:
TColStd_Array1OfReal knots;
TColStd_Array1OfInteger mults;
};

//=======================================================================
//function : IncreaseDegree
//purpose :
Expand Down
1 change: 1 addition & 0 deletions src/BndLib/BndLib_Add2dCurve.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class BndLib_Box2dCurve {

void PerformOptimal(const Standard_Real Tol);

// Keep myT1 and myT2 unchanged
void Clear();

Standard_Integer ErrorStatus() const;
Expand Down
7 changes: 2 additions & 5 deletions src/Convert/Convert_ConicToBSplineCurve.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,7 @@ void Convert_ConicToBSplineCurve::BuildCosAndSin(
temp_degree,
pivot_index_problem,
num_flat_knots,
num_knots,
order ;
num_knots;

if (Parameterisation != Convert_TgtThetaOver2 &&
Parameterisation != Convert_RationalC1) {
Expand Down Expand Up @@ -682,10 +681,9 @@ void Convert_ConicToBSplineCurve::BuildCosAndSin(


Degree = 4 ;
order = Degree + 1 ;
num_knots = 5 ;
num_flat_knots = (Degree -1) * num_knots + 2 * 2 ;
num_poles = num_flat_knots - order ;
num_poles = num_flat_knots - Degree - 1 ;
num_periodic_poles = num_poles - 2 ;
TColStd_Array1OfReal flat_knots(1,num_flat_knots) ;
CosNumeratorPtr =
Expand Down Expand Up @@ -721,7 +719,6 @@ void Convert_ConicToBSplineCurve::BuildCosAndSin(
KnotsPtr->SetValue(ii, (ii-1) * half_pi) ;
MultsPtr->SetValue(ii, Degree-1) ;
}
order = degree + 1 ;

TColStd_Array1OfReal parameters(1,num_poles) ;
TColgp_Array1OfPnt poles_array(1,num_poles) ;
Expand Down
5 changes: 2 additions & 3 deletions src/Extrema/Extrema_ExtPElS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,15 @@ void Extrema_ExtPElS::Perform(const gp_Pnt& P,
gp_Pnt Pp = P.Translated(OZ.Multiplied(-Zp));
gp_Vec OPp(O, Pp);
if (OPp.SquareMagnitude() < Tol * Tol) return;
Standard_Real B, U1, V1, U2, V2;
Standard_Real U1, V1, U2, V2;
Standard_Boolean Same = DirZ.Dot(MP) >= 0.0;
U1 = gp_Vec(Pos.XDirection()).AngleWithRef(OPp,myZ); //-M_PI<U1<M_PI
if (U1 > -ExtPElS_MyEps && U1 < ExtPElS_MyEps) { U1 = 0.; }
B = MP.Angle(DirZ);
if (!Same) { U1 += M_PI; }
U2 = U1 + M_PI;
if (U1 < 0.) { U1 += 2. * M_PI; }
if (U2 > 2.*M_PI) { U2 -= 2. * M_PI; }
B = MP.Angle(DirZ);
Standard_Real B = MP.Angle(DirZ);
A = Abs(A);
Standard_Real L = sqrt(L2);
if (!Same) {
Expand Down
33 changes: 15 additions & 18 deletions src/Extrema/Extrema_GenExtPS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,6 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::ComputeEdgeParameters

void Extrema_GenExtPS::BuildGrid(const gp_Pnt &thePoint)
{
Standard_Integer NoU, NoV;

//if grid was already built skip its creation
if (!myInit) {
//build parametric grid in case of a complex surface geometry (BSpline and Bezier surfaces)
Expand All @@ -534,7 +532,7 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt &thePoint)
U0 = U0/2. + myumin;
myUParams = new TColStd_HArray1OfReal(1,myusample );
Standard_Real U = U0;
for ( NoU = 1 ; NoU <= myusample; NoU++, U += PasU)
for (Standard_Integer NoU = 1; NoU <= myusample; NoU++, U += PasU)
myUParams->SetValue(NoU, U);
}

Expand All @@ -547,17 +545,16 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt &thePoint)

myVParams = new TColStd_HArray1OfReal(1,myvsample );
Standard_Real V = V0;

for ( NoV = 1, V = V0; NoV <= myvsample; NoV++, V += PasV)
for (Standard_Integer NoV = 1; NoV <= myvsample; NoV++, V += PasV)
myVParams->SetValue(NoV, V);
}

//If flag was changed and extrema not reinitialized Extrema would fail
myPoints.Resize (0, myusample + 1, 0, myvsample + 1, false);
// Calculation of distances

for ( NoU = 1 ; NoU <= myusample; NoU++ ) {
for ( NoV = 1 ; NoV <= myvsample; NoV++) {
for (Standard_Integer NoU = 1 ; NoU <= myusample; NoU++ ) {
for (Standard_Integer NoV = 1 ; NoV <= myvsample; NoV++) {
gp_Pnt aP1 = myS->Value(myUParams->Value(NoU), myVParams->Value(NoV));
Extrema_POnSurfParams aParam
(myUParams->Value(NoU), myVParams->Value(NoV), aP1);
Expand All @@ -574,12 +571,12 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt &thePoint)

// Fill boundary with negative square distance.
// It is used for computation of Maximum.
for (NoV = 0; NoV <= myvsample + 1; NoV++) {
for (Standard_Integer NoV = 0; NoV <= myvsample + 1; NoV++) {
myPoints.ChangeValue(0, NoV).SetSqrDistance(-1.);
myPoints.ChangeValue(myusample + 1, NoV).SetSqrDistance(-1.);
}

for (NoU = 1; NoU <= myusample; NoU++) {
for (Standard_Integer NoU = 1; NoU <= myusample; NoU++) {
myPoints.ChangeValue(NoU, 0).SetSqrDistance(-1.);
myPoints.ChangeValue(NoU, myvsample + 1).SetSqrDistance(-1.);
}
Expand All @@ -589,8 +586,8 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt &thePoint)

// Compute distances to mesh.
// Step 1. Compute distances to nodes.
for ( NoU = 1 ; NoU <= myusample; NoU++ ) {
for ( NoV = 1 ; NoV <= myvsample; NoV++) {
for (Standard_Integer NoU = 1 ; NoU <= myusample; NoU++ ) {
for (Standard_Integer NoV = 1 ; NoV <= myvsample; NoV++) {
Extrema_POnSurfParams &aParam = myPoints.ChangeValue(NoU, NoV);

aParam.SetSqrDistance(thePoint.SquareDistance(aParam.Value()));
Expand All @@ -607,9 +604,9 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt &thePoint)
// Step 2. Compute distances to edges.
// Assume UEdge(i, j) = { Point(i, j); Point(i + 1, j ) }
// Assume VEdge(i, j) = { Point(i, j); Point(i, j + 1) }
for ( NoU = 1 ; NoU <= myusample; NoU++ )
for (Standard_Integer NoU = 1 ; NoU <= myusample; NoU++ )
{
for ( NoV = 1 ; NoV <= myvsample; NoV++)
for (Standard_Integer NoV = 1 ; NoV <= myvsample; NoV++)
{
const Extrema_POnSurfParams &aParam0 = myPoints.Value(NoU, NoV);

Expand Down Expand Up @@ -642,8 +639,8 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt &thePoint)
Standard_Real aDiffDist;
Standard_Boolean isOut;

for ( NoU = 1 ; NoU < myusample; NoU++ ) {
for ( NoV = 1 ; NoV < myvsample; NoV++) {
for (Standard_Integer NoU = 1 ; NoU < myusample; NoU++ ) {
for (Standard_Integer NoV = 1 ; NoV < myvsample; NoV++) {
const Extrema_POnSurfParams &aUE0 = myUEdgePntParams.Value(NoU, NoV);
const Extrema_POnSurfParams &aUE1 = myUEdgePntParams.Value(NoU, NoV+1);
const Extrema_POnSurfParams &aVE0 = myVEdgePntParams.Value(NoU, NoV);
Expand Down Expand Up @@ -703,12 +700,12 @@ void Extrema_GenExtPS::BuildGrid(const gp_Pnt &thePoint)
}

// Fill boundary with RealLast square distance.
for (NoV = 0; NoV <= myvsample; NoV++) {
for (Standard_Integer NoV = 0; NoV <= myvsample; NoV++) {
myFacePntParams.ChangeValue(0, NoV).SetSqrDistance(RealLast());
myFacePntParams.ChangeValue(myusample, NoV).SetSqrDistance(RealLast());
}

for (NoU = 1; NoU < myusample; NoU++) {
for (Standard_Integer NoU = 1; NoU < myusample; NoU++) {
myFacePntParams.ChangeValue(NoU, 0).SetSqrDistance(RealLast());
myFacePntParams.ChangeValue(NoU, myvsample).SetSqrDistance(RealLast());
}
Expand Down Expand Up @@ -840,7 +837,7 @@ void Extrema_GenExtPS::BuildTree()
Standard_Real U = U0, V = V0;
for ( NoU = 1 ; NoU <= myusample; NoU++, U += PasU)
myUParams->SetValue(NoU, U);
for ( NoV = 1, V = V0; NoV <= myvsample; NoV++, V += PasV)
for ( NoV = 1 ; NoV <= myvsample; NoV++, V += PasV)
myVParams->SetValue(NoV, V);

// Calculation of distances
Expand Down
Loading

0 comments on commit f7dea47

Please sign in to comment.