1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0026348: Visualization, TKOpenGl - eliminate invalid NULL checks for transformation matrix

Graphic3d_CStructure::Transformation - use Graphic3d_Mat4 instead of plain arrays.
Drop duplicating field OpenGl_Structure::myTransformation (copy of Graphic3d_CStructure::Transformation).
Drop unused property Graphic3d_CStructure::Composition and Graphic3d_Structure::Composition().
This commit is contained in:
osa
2015-11-24 15:26:34 +03:00
committed by bugmaster
parent f486f64d86
commit 6bd94e0de9
12 changed files with 32 additions and 163 deletions

View File

@@ -435,39 +435,13 @@ Standard_Boolean Graphic3d_Structure::IsVisible() const
return myCStructure->visible ? Standard_True : Standard_False;
}
//=============================================================================
//function : IsRotated
//purpose :
//=============================================================================
Standard_Boolean Graphic3d_Structure::IsRotated() const
{
// A somewhat light test !
return myCStructure->Transformation[0][1] != 0.0
|| myCStructure->Transformation[0][2] != 0.0
|| myCStructure->Transformation[1][0] != 0.0
|| myCStructure->Transformation[1][2] != 0.0
|| myCStructure->Transformation[2][0] != 0.0
|| myCStructure->Transformation[2][1] != 0.0;
}
//=============================================================================
//function : IsTransformed
//purpose :
//=============================================================================
Standard_Boolean Graphic3d_Structure::IsTransformed() const
{
Standard_Boolean aResult = Standard_False;
for (Standard_Integer i = 0; i <= 3 && !aResult; ++i)
{
for (Standard_Integer j = 0; j <= 3 && !aResult; ++j)
{
if (i == j)
aResult = myCStructure->Transformation[i][j] != 1.0;
else
aResult = myCStructure->Transformation[i][j] != 0.0;
}
}
return aResult;
return !myCStructure->Transformation.IsIdentity();
}
//=============================================================================
@@ -1500,15 +1474,6 @@ void Graphic3d_Structure::DisconnectAll (const Graphic3d_TypeOfConnection theTyp
}
}
//=============================================================================
//function : Composition
//purpose :
//=============================================================================
Graphic3d_TypeOfComposition Graphic3d_Structure::Composition() const
{
return myCStructure->Composition;
}
//=============================================================================
//function : SetTransform
//purpose :
@@ -1537,17 +1502,17 @@ void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& theMat
Graphic3d_TransformError::Raise ("Transform : not a 4x4 matrix");
}
const Standard_Boolean wasTransformed = IsTransformed();
switch (theType)
{
case Graphic3d_TOC_REPLACE:
{
myCStructure->Composition = Graphic3d_TOC_REPLACE;
// Update of CStructure
for (Standard_Integer i = 0; i <= 3; ++i)
{
for (Standard_Integer j = 0; j <= 3; ++j)
{
myCStructure->Transformation[i][j] = float (theMatrix (lr + i, lc + j));
myCStructure->Transformation.ChangeValue (i, j) = float (theMatrix (lr + i, lc + j));
aNewTrsf (i, j) = theMatrix (lr + i, lc + j);
}
}
@@ -1555,7 +1520,6 @@ void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& theMat
}
case Graphic3d_TOC_POSTCONCATENATE:
{
myCStructure->Composition = Graphic3d_TOC_POSTCONCATENATE;
// To simplify management of indices
for (Standard_Integer i = 0; i <= 3; ++i)
{
@@ -1573,7 +1537,7 @@ void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& theMat
aNewTrsf (i, j) = 0.0;
for (Standard_Integer k = 0; k <= 3; ++k)
{
valueoldtrsf = myCStructure->Transformation[i][k];
valueoldtrsf = myCStructure->Transformation.GetValue (i, k);
valuetrsf = aMatrix44 (k, j);
valuenewtrsf = aNewTrsf (i, j) + valueoldtrsf * valuetrsf;
aNewTrsf (i, j) = valuenewtrsf;
@@ -1586,7 +1550,7 @@ void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& theMat
{
for (Standard_Integer j = 0; j <= 3; ++j)
{
myCStructure->Transformation[i][j] = float (aNewTrsf (i, j));
myCStructure->Transformation.ChangeValue (i, j) = float (aNewTrsf (i, j));
}
}
break;
@@ -1594,7 +1558,7 @@ void Graphic3d_Structure::SetTransform (const TColStd_Array2OfReal& theMat
}
// If transformation, no validation of hidden already calculated parts
if (IsRotated())
if (IsTransformed() || (!IsTransformed() && wasTransformed))
{
ReCompute();
}
@@ -1624,7 +1588,7 @@ void Graphic3d_Structure::Transform (TColStd_Array2OfReal& theMatrix) const
{
for (Standard_Integer j = 0; j <= 3; ++j)
{
theMatrix (lr + i, lc + j) = myCStructure->Transformation[i][j];
theMatrix (lr + i, lc + j) = myCStructure->Transformation.GetValue (i, j);
}
}
}
@@ -2251,7 +2215,7 @@ void Graphic3d_Structure::GraphicTransform (const TColStd_Array2OfReal& theMatri
{
for (Standard_Integer j = 0; j <= 3; ++j)
{
myCStructure->Transformation[i][j] = float (theMatrix (i, j));
myCStructure->Transformation.ChangeValue (i, j) = float (theMatrix (i, j));
}
}
myCStructure->UpdateTransformation();