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:
@@ -28,7 +28,6 @@ Graphic3d_CStructure::Graphic3d_CStructure (const Handle(Graphic3d_StructureMana
|
||||
myZLayer (Graphic3d_ZLayerId_Default),
|
||||
Priority (Structure_MAX_PRIORITY / 2),
|
||||
PreviousPriority (Structure_MAX_PRIORITY / 2),
|
||||
Composition (Graphic3d_TOC_REPLACE),
|
||||
ContainsFacet (0),
|
||||
IsInfinite (0),
|
||||
stick (0),
|
||||
@@ -40,14 +39,6 @@ Graphic3d_CStructure::Graphic3d_CStructure (const Handle(Graphic3d_StructureMana
|
||||
Is2dText (Standard_False),
|
||||
myGraphicDriver (theManager->GraphicDriver())
|
||||
{
|
||||
for (Standard_Integer i = 0; i <= 3; ++i)
|
||||
{
|
||||
for (Standard_Integer j = 0; j <= 3; ++j)
|
||||
{
|
||||
Transformation[i][j] = (i == j) ? 1.0f : 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
ContextLine.IsDef = 1,
|
||||
ContextFillArea.IsDef = 1,
|
||||
ContextMarker.IsDef = 1,
|
||||
|
@@ -129,8 +129,7 @@ public:
|
||||
|
||||
CALL_DEF_COLOR HighlightColor;
|
||||
|
||||
float Transformation[4][4];
|
||||
Graphic3d_TypeOfComposition Composition;
|
||||
Graphic3d_Mat4 Transformation;
|
||||
|
||||
int ContainsFacet;
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -284,10 +284,6 @@ public:
|
||||
//! Returns the highlight indicator for the structure <me>.
|
||||
Standard_EXPORT virtual Standard_Boolean IsHighlighted() const;
|
||||
|
||||
//! Returns Standard_True if the structure <me> is rotated.
|
||||
//! <=> The transformation != Identity, != Scale, != Translation.
|
||||
Standard_EXPORT Standard_Boolean IsRotated() const;
|
||||
|
||||
//! Returns Standard_True if the structure <me> is transformed.
|
||||
//! <=> The transformation != Identity.
|
||||
Standard_EXPORT Standard_Boolean IsTransformed() const;
|
||||
@@ -376,11 +372,7 @@ public:
|
||||
Standard_EXPORT void SetHLRValidation (const Standard_Boolean AFlag);
|
||||
|
||||
Standard_EXPORT Standard_Boolean HLRValidation() const;
|
||||
|
||||
//! Returns the type of composition applied to matrices
|
||||
//! of transformation of <me>.
|
||||
Standard_EXPORT Graphic3d_TypeOfComposition Composition() const;
|
||||
|
||||
|
||||
//! Modifies the current local modelling transformation
|
||||
//! in the structure <me>.
|
||||
//!
|
||||
|
Reference in New Issue
Block a user