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

// implement conversion into/from array2

implement getting typeName
This commit is contained in:
dpasukhi
2023-05-25 10:47:15 +01:00
committed by oan
parent a0758a8002
commit 5ad8acb354
15 changed files with 383 additions and 30 deletions

View File

@@ -13,11 +13,13 @@
#include "XCAFAnimObjects_Transform.hxx"
#include <Message.hxx>
//=======================================================================
//function : XCAFAnimObjects_Transform
//purpose :
//=======================================================================
XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const gp_GTrsf& theTransform) :
XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const NCollection_Mat4<double>& theTransform) :
XCAFAnimObjects_Operation(false),
myTransformPresentation(1, 1)
{
@@ -28,8 +30,76 @@ XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const gp_GTrsf& theTransfor
//function : XCAFAnimObjects_Transform
//purpose :
//=======================================================================
XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const NCollection_Array1<gp_GTrsf>& theTransform,
XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const NCollection_Array1<NCollection_Mat4<double>>& theTransform,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(theTimeStamps),
myTransformPresentation(theTransform)
{}
//=======================================================================
//function : XCAFAnimObjects_Transform
//purpose :
//=======================================================================
XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(false),
myTransformPresentation(1, theGeneralPresentation.RowLength())
{
if (theGeneralPresentation.ColLength() != 16)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Transform: Incorrect Mat4x4 general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
{
NCollection_Mat4<double> aTransform;
aTransform.SetRow(1, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3),
theGeneralPresentation.Value(aRowInd, 4)));
aTransform.SetRow(2, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 5),
theGeneralPresentation.Value(aRowInd, 6),
theGeneralPresentation.Value(aRowInd, 7),
theGeneralPresentation.Value(aRowInd, 8)));
aTransform.SetRow(3, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 9),
theGeneralPresentation.Value(aRowInd, 10),
theGeneralPresentation.Value(aRowInd, 11),
theGeneralPresentation.Value(aRowInd, 12)));
aTransform.SetRow(4, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 13),
theGeneralPresentation.Value(aRowInd, 14),
theGeneralPresentation.Value(aRowInd, 15),
theGeneralPresentation.Value(aRowInd, 16)));
myTransformPresentation.SetValue(aRowInd, aTransform);
}
}
//=======================================================================
//function : GeneralPresentation
//purpose :
//=======================================================================
NCollection_Array2<double> XCAFAnimObjects_Transform::GeneralPresentation() const
{
NCollection_Array2<double> aRes(1, myTransformPresentation.Length(), 1, 16);
for (int aRowInd = 1; aRowInd <= myTransformPresentation.Length(); aRowInd++)
{
const NCollection_Mat4<double>& aTransform = myTransformPresentation.Value(aRowInd);
aRes.SetValue(aRowInd, 1, aTransform.GetValue(1, 1));
aRes.SetValue(aRowInd, 2, aTransform.GetValue(1, 2));
aRes.SetValue(aRowInd, 3, aTransform.GetValue(1, 3));
aRes.SetValue(aRowInd, 4, aTransform.GetValue(1, 4));
aRes.SetValue(aRowInd, 5, aTransform.GetValue(2, 1));
aRes.SetValue(aRowInd, 6, aTransform.GetValue(2, 2));
aRes.SetValue(aRowInd, 7, aTransform.GetValue(2, 3));
aRes.SetValue(aRowInd, 8, aTransform.GetValue(2, 4));
aRes.SetValue(aRowInd, 9, aTransform.GetValue(3, 1));
aRes.SetValue(aRowInd, 10, aTransform.GetValue(3, 2));
aRes.SetValue(aRowInd, 11, aTransform.GetValue(3, 3));
aRes.SetValue(aRowInd, 12, aTransform.GetValue(3, 4));
aRes.SetValue(aRowInd, 13, aTransform.GetValue(4, 1));
aRes.SetValue(aRowInd, 14, aTransform.GetValue(4, 2));
aRes.SetValue(aRowInd, 15, aTransform.GetValue(4, 3));
aRes.SetValue(aRowInd, 16, aTransform.GetValue(4, 4));
}
}