1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-07-30 13:05:50 +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

@ -17,11 +17,9 @@
//function : XCAFAnimObjects_CustomOperation
//purpose :
//=======================================================================
XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(const int theObjectSize,
const TCollection_AsciiString& theCustomTypeName,
const NCollection_Array1<char>& thePresentation) :
XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(const NCollection_Array1<double>& thePresentation,
const TCollection_AsciiString& theCustomTypeName) :
XCAFAnimObjects_Operation(false),
myObjectSize(theObjectSize),
myTypeName(theCustomTypeName),
myPresentation(1, 1, thePresentation.Lower(), thePresentation.Upper())
{
@ -35,12 +33,10 @@ XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(const int theOb
//function : XCAFAnimObjects_CustomOperation
//purpose :
//=======================================================================
XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(const int theObjectSize,
const TCollection_AsciiString& theCustomTypeName,
const NCollection_Array2<char>& thePresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(const NCollection_Array2<double>& thePresentation,
const NCollection_Array1<double>& theTimeStamps,
const TCollection_AsciiString& theCustomTypeName) :
XCAFAnimObjects_Operation(theTimeStamps),
myObjectSize(theObjectSize),
myTypeName(theCustomTypeName),
myPresentation(thePresentation)
{}

View File

@ -24,33 +24,30 @@ class XCAFAnimObjects_CustomOperation : public XCAFAnimObjects_Operation
public:
//!
Standard_EXPORT XCAFAnimObjects_CustomOperation(const int theObjectSize,
const TCollection_AsciiString& theCustomTypeName,
const NCollection_Array1<char>& thePresentation);
Standard_EXPORT XCAFAnimObjects_CustomOperation(const NCollection_Array1<double>& thePresentation,
const TCollection_AsciiString& theCustomTypeName);
//!
Standard_EXPORT XCAFAnimObjects_CustomOperation(const int theObjectSize,
const TCollection_AsciiString& theCustomTypeName,
const NCollection_Array2<char>& thePresentation,
const NCollection_Array1<double>& theTimeStamps);
Standard_EXPORT XCAFAnimObjects_CustomOperation(const NCollection_Array2<double>& thePresentation,
const NCollection_Array1<double>& theTimeStamps,
const TCollection_AsciiString& theCustomTypeName);
//!
XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Custom; }
//!
int ObjectSize() const { return myObjectSize; }
NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE { return myPresentation; }
//!
const TCollection_AsciiString& CustomTypeName() const { return myTypeName; }
TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return myTypeName; }
//!
const NCollection_Array2<char>& CustomPresentation() const { return myPresentation; }
const NCollection_Array2<double>& CustomPresentation() const { return myPresentation; }
private:
int myObjectSize; //!<
TCollection_AsciiString myTypeName; //!<
NCollection_Array2<char> myPresentation; //!<
NCollection_Array2<double> myPresentation; //!<
};
#endif // _XCAFAnimObjects_CustomOperation_HeaderFile

View File

@ -15,6 +15,8 @@
#define _XCAFAnimObjects_Operation_HeaderFile
#include <NCollection_Array1.hxx>
#include <NCollection_Array2.hxx>
#include <TCollection_AsciiString.hxx>
#include <XCAFAnimObjects_OperationType.hxx>
//!
@ -38,12 +40,18 @@ public:
//!
Standard_EXPORT virtual XCAFAnimObjects_OperationType GetType() const = 0;
//!
Standard_EXPORT virtual TCollection_AsciiString GetTypeName() const = 0;
//!
bool IsInverse() const { return myIsInverse; }
//!
void SetInverse(const bool theIsInverse) { myIsInverse = theIsInverse; }
//!
Standard_EXPORT virtual NCollection_Array2<double> GeneralPresentation() const = 0;
private:
bool myIsInverse; //!
NCollection_Array1<double> myTimeStamps; //!<

View File

@ -13,13 +13,15 @@
#include <XCAFAnimObjects_Orient.hxx>
#include <Message.hxx>
//=======================================================================
//function : XCAFAnimObjects_Orient
//purpose :
//=======================================================================
XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const gp_Quaternion& theOrient) :
XCAFAnimObjects_Operation(false),
myOrientPresentation(1,1)
myOrientPresentation(1, 1)
{
myOrientPresentation.SetValue(1, theOrient);
}
@ -30,7 +32,49 @@ XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const gp_Quaternion& theOrient) :
//=======================================================================
XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const NCollection_Array1<gp_Quaternion>& theOrient,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(theTimeStamps),
myOrientPresentation(theOrient)
{}
//=======================================================================
//function : XCAFAnimObjects_Orient
//purpose :
//=======================================================================
XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(false),
myOrientPresentation(1, theGeneralPresentation.RowLength())
{
if (theGeneralPresentation.ColLength() != 4)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Orient: Incorrect Quaternion general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
{
gp_Quaternion aQuat(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3),
theGeneralPresentation.Value(aRowInd, 4));
myOrientPresentation.SetValue(aRowInd, aQuat);
}
}
//=======================================================================
//function : GeneralPresentation
//purpose :
//=======================================================================
NCollection_Array2<double> XCAFAnimObjects_Orient::GeneralPresentation() const
{
NCollection_Array2<double> aRes(1, myOrientPresentation.Length(), 1, 4);
for (int aRowInd = 1; aRowInd <= myOrientPresentation.Length(); aRowInd++)
{
const gp_Quaternion& aQuat = myOrientPresentation.Value(aRowInd);
aRes.SetValue(aRowInd, 1, aQuat.X());
aRes.SetValue(aRowInd, 2, aQuat.Y());
aRes.SetValue(aRowInd, 3, aQuat.Z());
aRes.SetValue(aRowInd, 4, aQuat.W());
}
}

View File

@ -29,9 +29,19 @@ public:
Standard_EXPORT XCAFAnimObjects_Orient(const NCollection_Array1<gp_Quaternion>& theOrient,
const NCollection_Array1<double>& theTimeStamps);
//!
Standard_EXPORT XCAFAnimObjects_Orient(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps);
//!
XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Orient; }
//!
TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return "Orient"; }
//!
Standard_EXPORT NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE;
//!
const NCollection_Array1<gp_Quaternion>& OrientPresentation() const { return myOrientPresentation; }

View File

@ -13,6 +13,8 @@
#include "XCAFAnimObjects_Rotate.hxx"
#include <Message.hxx>
//=======================================================================
//function : XCAFAnimObjects_Rotate
//purpose :
@ -52,3 +54,45 @@ XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const NCollection_Array1<gp_Quate
XCAFAnimObjects_Operation(theTimeStamps),
myRotatePresentation(theRotate)
{}
//=======================================================================
//function : XCAFAnimObjects_Rotate
//purpose :
//=======================================================================
XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(false),
myRotatePresentation(1, theGeneralPresentation.RowLength())
{
if (theGeneralPresentation.ColLength() != 4)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Rotate: Incorrect Quaternion general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
{
gp_Quaternion aQuat(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3),
theGeneralPresentation.Value(aRowInd, 4));
myRotatePresentation.SetValue(aRowInd, aQuat);
}
}
//=======================================================================
//function : GeneralPresentation
//purpose :
//=======================================================================
NCollection_Array2<double> XCAFAnimObjects_Rotate::GeneralPresentation() const
{
NCollection_Array2<double> aRes(1, myRotatePresentation.Length(), 1, 4);
for (int aRowInd = 1; aRowInd <= myRotatePresentation.Length(); aRowInd++)
{
const gp_Quaternion& aQuat = myRotatePresentation.Value(aRowInd);
aRes.SetValue(aRowInd, 1, aQuat.X());
aRes.SetValue(aRowInd, 2, aQuat.Y());
aRes.SetValue(aRowInd, 3, aQuat.Z());
aRes.SetValue(aRowInd, 4, aQuat.W());
}
}

View File

@ -32,9 +32,19 @@ public:
Standard_EXPORT XCAFAnimObjects_Rotate(const NCollection_Array1<gp_Quaternion>& theRotate,
const NCollection_Array1<double>& theTimeStamps);
//!
Standard_EXPORT XCAFAnimObjects_Rotate(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps);
//!
XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Rotate; }
//!
TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return "Rotate"; }
//!
Standard_EXPORT NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE;
//!
const NCollection_Array1<gp_Quaternion>& RotatePresentation() const { return myRotatePresentation; }

View File

@ -13,6 +13,8 @@
#include "XCAFAnimObjects_Scale.hxx"
#include <Message.hxx>
//=======================================================================
//function : XCAFAnimObjects_Scale
//purpose :
@ -33,3 +35,43 @@ XCAFAnimObjects_Scale::XCAFAnimObjects_Scale(const NCollection_Array1<gp_XYZ>& t
XCAFAnimObjects_Operation(theTimeStamps),
myScalePresentation(theScale)
{}
//=======================================================================
//function : XCAFAnimObjects_Scale
//purpose :
//=======================================================================
XCAFAnimObjects_Scale::XCAFAnimObjects_Scale(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(false),
myScalePresentation(1, theGeneralPresentation.RowLength())
{
if (theGeneralPresentation.ColLength() != 3)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Scale: Incorrect XYZ general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
{
gp_XYZ aXYZ(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3));
myScalePresentation.SetValue(aRowInd, aXYZ);
}
}
//=======================================================================
//function : GeneralPresentation
//purpose :
//=======================================================================
NCollection_Array2<double> XCAFAnimObjects_Scale::GeneralPresentation() const
{
NCollection_Array2<double> aRes(1, myScalePresentation.Length(), 1, 3);
for (int aRowInd = 1; aRowInd <= myScalePresentation.Length(); aRowInd++)
{
const gp_XYZ& aXYZ = myScalePresentation.Value(aRowInd);
aRes.SetValue(aRowInd, 1, aXYZ.X());
aRes.SetValue(aRowInd, 2, aXYZ.Y());
aRes.SetValue(aRowInd, 3, aXYZ.Z());
}
}

View File

@ -29,9 +29,19 @@ public:
Standard_EXPORT XCAFAnimObjects_Scale(const NCollection_Array1<gp_XYZ>& theScale,
const NCollection_Array1<double>& theTimeStamps);
//!
Standard_EXPORT XCAFAnimObjects_Scale(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps);
//!
XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Scale; }
//!
TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return "Scale"; }
//!
Standard_EXPORT NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE;
//!
const NCollection_Array1<gp_XYZ>& ScalePresentation() const { return myScalePresentation; }

View File

@ -13,6 +13,8 @@
#include "XCAFAnimObjects_Skew.hxx"
#include <Message.hxx>
//=======================================================================
//function : XCAFAnimObjects_Skew
//purpose :
@ -33,3 +35,51 @@ XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array1<Skew>& theSk
XCAFAnimObjects_Operation(theTimeStamps),
mySkewPresentation(theSkew)
{}
//=======================================================================
//function : XCAFAnimObjects_Skew
//purpose :
//=======================================================================
XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(false),
mySkewPresentation(1, theGeneralPresentation.RowLength())
{
if (theGeneralPresentation.ColLength() != 7)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Skew: Incorrect Skew general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
{
Skew aSkew{ theGeneralPresentation.Value(aRowInd, 1),
{theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3),
theGeneralPresentation.Value(aRowInd, 4) },
{theGeneralPresentation.Value(aRowInd, 5),
theGeneralPresentation.Value(aRowInd, 6),
theGeneralPresentation.Value(aRowInd, 7)} };
mySkewPresentation.SetValue(aRowInd, aSkew);
}
}
//=======================================================================
//function : GeneralPresentation
//purpose :
//=======================================================================
NCollection_Array2<double> XCAFAnimObjects_Skew::GeneralPresentation() const
{
NCollection_Array2<double> aRes(1, mySkewPresentation.Length(), 1, 7);
for (int aRowInd = 1; aRowInd <= mySkewPresentation.Length(); aRowInd++)
{
const Skew& aSkew = mySkewPresentation.Value(aRowInd);
aRes.SetValue(aRowInd, 1, aSkew.Angle);
aRes.SetValue(aRowInd, 2, aSkew.Axis1.X());
aRes.SetValue(aRowInd, 3, aSkew.Axis1.Y());
aRes.SetValue(aRowInd, 4, aSkew.Axis1.Z());
aRes.SetValue(aRowInd, 5, aSkew.Axis2.X());
aRes.SetValue(aRowInd, 6, aSkew.Axis2.Y());
aRes.SetValue(aRowInd, 7, aSkew.Axis2.Z());
}
}

View File

@ -38,9 +38,19 @@ public:
Standard_EXPORT XCAFAnimObjects_Skew(const NCollection_Array1<Skew>& theSkew,
const NCollection_Array1<double>& theTimeStamps);
//!
Standard_EXPORT XCAFAnimObjects_Skew(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps);
//!
XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Skew; }
//!
TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return "Skew"; }
//!
Standard_EXPORT NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE;
//!
const NCollection_Array1<Skew>& SkewPresentation() const { return mySkewPresentation; }

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));
}
}

View File

@ -15,7 +15,7 @@
#define _XCAFAnimObjects_Transform_HeaderFile
#include <XCAFAnimObjects_Operation.hxx>
#include <gp_GTrsf.hxx>
#include <NCollection_Mat4.hxx>
//!
class XCAFAnimObjects_Transform : public XCAFAnimObjects_Operation
@ -23,21 +23,31 @@ class XCAFAnimObjects_Transform : public XCAFAnimObjects_Operation
public:
//!
Standard_EXPORT XCAFAnimObjects_Transform(const gp_GTrsf& theTransform);
Standard_EXPORT XCAFAnimObjects_Transform(const NCollection_Mat4<double>& theTransform);
//!
Standard_EXPORT XCAFAnimObjects_Transform(const NCollection_Array1<gp_GTrsf>& theTransform,
Standard_EXPORT XCAFAnimObjects_Transform(const NCollection_Array1<NCollection_Mat4<double>>& theTransform,
const NCollection_Array1<double>& theTimeStamps);
//!
Standard_EXPORT XCAFAnimObjects_Transform(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps);
//!
XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Transform; }
//!
const NCollection_Array1<gp_GTrsf>& TransformPresentation() const { return myTransformPresentation; }
TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return "Transform"; }
//!
Standard_EXPORT NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE;
//!
const NCollection_Array1<NCollection_Mat4<double>>& TransformPresentation() const { return myTransformPresentation; }
private:
NCollection_Array1<gp_GTrsf> myTransformPresentation; //!<
NCollection_Array1<NCollection_Mat4<double>> myTransformPresentation; //!<
};
#endif // _XCAFAnimObjects_Transform_HeaderFile

View File

@ -13,6 +13,8 @@
#include "XCAFAnimObjects_Translate.hxx"
#include <Message.hxx>
//=======================================================================
//function : XCAFAnimObjects_Translate
//purpose :
@ -34,3 +36,43 @@ XCAFAnimObjects_Translate::XCAFAnimObjects_Translate(const NCollection_Array1<gp
XCAFAnimObjects_Operation(theTimeStamps),
myTranslatePresentation(theTranslate)
{}
//=======================================================================
//function : XCAFAnimObjects_Translate
//purpose :
//=======================================================================
XCAFAnimObjects_Translate::XCAFAnimObjects_Translate(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(false),
myTranslatePresentation(1, theGeneralPresentation.RowLength())
{
if (theGeneralPresentation.ColLength() != 3)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Translate: Incorrect XYZ general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
{
gp_XYZ aXYZ(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3));
myTranslatePresentation.SetValue(aRowInd, aXYZ);
}
}
//=======================================================================
//function : GeneralPresentation
//purpose :
//=======================================================================
NCollection_Array2<double> XCAFAnimObjects_Translate::GeneralPresentation() const
{
NCollection_Array2<double> aRes(1, myTranslatePresentation.Length(), 1, 3);
for (int aRowInd = 1; aRowInd <= myTranslatePresentation.Length(); aRowInd++)
{
const gp_XYZ& aXYZ = myTranslatePresentation.Value(aRowInd);
aRes.SetValue(aRowInd, 1, aXYZ.X());
aRes.SetValue(aRowInd, 2, aXYZ.Y());
aRes.SetValue(aRowInd, 3, aXYZ.Z());
}
}

View File

@ -29,9 +29,19 @@ public:
Standard_EXPORT XCAFAnimObjects_Translate(const NCollection_Array1<gp_XYZ>& theTranslate,
const NCollection_Array1<double>& theTimeStamps);
//!
Standard_EXPORT XCAFAnimObjects_Translate(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps);
//!
XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Translate; }
//!
TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return "Translate"; }
//!
Standard_EXPORT NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE;
//!
const NCollection_Array1<gp_XYZ>& TranslatePresentation() const { return myTranslatePresentation; }