diff --git a/src/XCAFAnimObjects/XCAFAnimObjects_Operation.hxx b/src/XCAFAnimObjects/XCAFAnimObjects_Operation.hxx index 6ffc4de710..d14d124881 100644 --- a/src/XCAFAnimObjects/XCAFAnimObjects_Operation.hxx +++ b/src/XCAFAnimObjects/XCAFAnimObjects_Operation.hxx @@ -40,7 +40,7 @@ public: const NCollection_Array1& TimeStamps() const { return myTimeStamps; } //! - bool HasTimeStamps() const { return myTimeStamps.IsEmpty(); } + bool HasTimeStamps() const { return !myTimeStamps.IsEmpty(); } //! Standard_EXPORT virtual XCAFAnimObjects_OperationType GetType() const = 0; diff --git a/src/XCAFAnimObjects/XCAFAnimObjects_Orient.cxx b/src/XCAFAnimObjects/XCAFAnimObjects_Orient.cxx index b9efcd4f4e..e90b07a0e9 100644 --- a/src/XCAFAnimObjects/XCAFAnimObjects_Orient.cxx +++ b/src/XCAFAnimObjects/XCAFAnimObjects_Orient.cxx @@ -44,14 +44,14 @@ XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const NCollection_Array1& theGeneralPresentation, const NCollection_Array1& theTimeStamps) : XCAFAnimObjects_Operation(theTimeStamps), - myOrientPresentation(1, theGeneralPresentation.RowLength()) + myOrientPresentation(1, theGeneralPresentation.NbRows()) { - if (theGeneralPresentation.ColLength() != 4) + if (theGeneralPresentation.NbColumns() != 4) { Message::SendWarning() << "Warning: XCAFAnimObjects_Orient: Incorrect Quaternion general presentation"; return; } - for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++) + for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++) { gp_Quaternion aQuat(theGeneralPresentation.Value(aRowInd, 1), theGeneralPresentation.Value(aRowInd, 2), diff --git a/src/XCAFAnimObjects/XCAFAnimObjects_Rotate.cxx b/src/XCAFAnimObjects/XCAFAnimObjects_Rotate.cxx index b9a78f2545..54837e3757 100644 --- a/src/XCAFAnimObjects/XCAFAnimObjects_Rotate.cxx +++ b/src/XCAFAnimObjects/XCAFAnimObjects_Rotate.cxx @@ -69,7 +69,7 @@ XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const NCollection_Array2& { aNbDouble = 1; } - if (theGeneralPresentation.ColLength() != aNbDouble) + if (theGeneralPresentation.NbColumns() != aNbDouble) { Message::SendWarning() << "Warning: XCAFAnimObjects_Rotate: Incorrect Rotate presentation"; } diff --git a/src/XCAFAnimObjects/XCAFAnimObjects_Scale.cxx b/src/XCAFAnimObjects/XCAFAnimObjects_Scale.cxx index 5204fe7ae6..fdbd2f3d40 100644 --- a/src/XCAFAnimObjects/XCAFAnimObjects_Scale.cxx +++ b/src/XCAFAnimObjects/XCAFAnimObjects_Scale.cxx @@ -43,14 +43,14 @@ XCAFAnimObjects_Scale::XCAFAnimObjects_Scale(const NCollection_Array1& t XCAFAnimObjects_Scale::XCAFAnimObjects_Scale(const NCollection_Array2& theGeneralPresentation, const NCollection_Array1& theTimeStamps) : XCAFAnimObjects_Operation(theTimeStamps), - myScalePresentation(1, theGeneralPresentation.RowLength()) + myScalePresentation(1, theGeneralPresentation.NbRows()) { - if (theGeneralPresentation.ColLength() != 3) + if (theGeneralPresentation.NbColumns() != 3) { Message::SendWarning() << "Warning: XCAFAnimObjects_Scale: Incorrect XYZ general presentation"; return; } - for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++) + for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++) { gp_XYZ aXYZ(theGeneralPresentation.Value(aRowInd, 1), theGeneralPresentation.Value(aRowInd, 2), diff --git a/src/XCAFAnimObjects/XCAFAnimObjects_Skew.cxx b/src/XCAFAnimObjects/XCAFAnimObjects_Skew.cxx index 19e562c610..4090c64025 100644 --- a/src/XCAFAnimObjects/XCAFAnimObjects_Skew.cxx +++ b/src/XCAFAnimObjects/XCAFAnimObjects_Skew.cxx @@ -19,7 +19,7 @@ //function : XCAFAnimObjects_Skew //purpose : //======================================================================= -XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const Skew& theSkew) : +XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const gp_XYZ& theSkew) : XCAFAnimObjects_Operation(false), mySkewPresentation(1, 1) { @@ -30,7 +30,7 @@ XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const Skew& theSkew) : //function : XCAFAnimObjects_Skew //purpose : //======================================================================= -XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array1& theSkew, +XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array1& theSkew, const NCollection_Array1& theTimeStamps) : XCAFAnimObjects_Operation(theTimeStamps), mySkewPresentation(theSkew) @@ -43,22 +43,18 @@ XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array1& theSk XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array2& theGeneralPresentation, const NCollection_Array1& theTimeStamps) : XCAFAnimObjects_Operation(theTimeStamps), - mySkewPresentation(1, theGeneralPresentation.RowLength()) + mySkewPresentation(1, theGeneralPresentation.NbRows()) { - if (theGeneralPresentation.ColLength() != 7) + if (theGeneralPresentation.NbColumns() != 3) { Message::SendWarning() << "Warning: XCAFAnimObjects_Skew: Incorrect Skew general presentation"; return; } - for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++) + for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); 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)} }; + gp_XYZ aSkew(theGeneralPresentation.Value(aRowInd, 1), + theGeneralPresentation.Value(aRowInd, 2), + theGeneralPresentation.Value(aRowInd, 3)); mySkewPresentation.SetValue(aRowInd, aSkew); } } @@ -78,18 +74,14 @@ XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const Handle(XCAFAnimObjects_Skew)& t //======================================================================= NCollection_Array2 XCAFAnimObjects_Skew::GeneralPresentation() const { - NCollection_Array2 aRes(1, mySkewPresentation.Length(), 1, 7); + NCollection_Array2 aRes(1, mySkewPresentation.Length(), 1, 3); for (int aRowInd = 1; aRowInd <= mySkewPresentation.Length(); aRowInd++) { - const Skew& aSkew = mySkewPresentation.Value(aRowInd); + const gp_XYZ& 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()); + aRes.SetValue(aRowInd, 1, aSkew.X()); + aRes.SetValue(aRowInd, 2, aSkew.Y()); + aRes.SetValue(aRowInd, 3, aSkew.Z()); } return aRes; } \ No newline at end of file diff --git a/src/XCAFAnimObjects/XCAFAnimObjects_Skew.hxx b/src/XCAFAnimObjects/XCAFAnimObjects_Skew.hxx index 844c6794ed..40e615a6f4 100644 --- a/src/XCAFAnimObjects/XCAFAnimObjects_Skew.hxx +++ b/src/XCAFAnimObjects/XCAFAnimObjects_Skew.hxx @@ -15,8 +15,8 @@ #define _XCAFAnimObjects_Skew_HeaderFile #include -#include -#include +#include + //! class XCAFAnimObjects_Skew : public XCAFAnimObjects_Operation @@ -24,18 +24,10 @@ class XCAFAnimObjects_Skew : public XCAFAnimObjects_Operation public: //! - struct Skew - { - double Angle = 0.; //!< - gp_Dir Axis1; //!< - gp_Dir Axis2; //!< - }; + Standard_EXPORT XCAFAnimObjects_Skew(const gp_XYZ& theSkew); //! - Standard_EXPORT XCAFAnimObjects_Skew(const Skew& theSkew); - - //! - Standard_EXPORT XCAFAnimObjects_Skew(const NCollection_Array1& theSkew, + Standard_EXPORT XCAFAnimObjects_Skew(const NCollection_Array1& theSkew, const NCollection_Array1& theTimeStamps); //! @@ -55,11 +47,11 @@ public: Standard_EXPORT NCollection_Array2 GeneralPresentation() const Standard_OVERRIDE; //! - const NCollection_Array1& SkewPresentation() const { return mySkewPresentation; } + const NCollection_Array1& SkewPresentation() const { return mySkewPresentation; } private: - NCollection_Array1 mySkewPresentation; //!< + NCollection_Array1 mySkewPresentation; //!< }; #endif // _XCAFAnimObjects_Skew_HeaderFile diff --git a/src/XCAFAnimObjects/XCAFAnimObjects_Transform.cxx b/src/XCAFAnimObjects/XCAFAnimObjects_Transform.cxx index 00ebfee6e8..3acb81ad43 100644 --- a/src/XCAFAnimObjects/XCAFAnimObjects_Transform.cxx +++ b/src/XCAFAnimObjects/XCAFAnimObjects_Transform.cxx @@ -43,33 +43,32 @@ XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const NCollection_Array1& theGeneralPresentation, const NCollection_Array1& theTimeStamps) : XCAFAnimObjects_Operation(theTimeStamps), - myTransformPresentation(1, theGeneralPresentation.RowLength()) + myTransformPresentation(1, theGeneralPresentation.NbRows()) { - if (theGeneralPresentation.ColLength() != 16) + if (theGeneralPresentation.NbColumns() != 16) { Message::SendWarning() << "Warning: XCAFAnimObjects_Transform: Incorrect Mat4x4 general presentation"; return; } - for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++) + for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++) { NCollection_Mat4 aTransform; - aTransform.SetRow(1, NCollection_Vec4(theGeneralPresentation.Value(aRowInd, 1), + aTransform.SetRow(0, NCollection_Vec4(theGeneralPresentation.Value(aRowInd, 1), theGeneralPresentation.Value(aRowInd, 2), theGeneralPresentation.Value(aRowInd, 3), theGeneralPresentation.Value(aRowInd, 4))); - aTransform.SetRow(2, NCollection_Vec4(theGeneralPresentation.Value(aRowInd, 5), + aTransform.SetRow(1, NCollection_Vec4(theGeneralPresentation.Value(aRowInd, 5), theGeneralPresentation.Value(aRowInd, 6), theGeneralPresentation.Value(aRowInd, 7), theGeneralPresentation.Value(aRowInd, 8))); - aTransform.SetRow(3, NCollection_Vec4(theGeneralPresentation.Value(aRowInd, 9), + aTransform.SetRow(2, NCollection_Vec4(theGeneralPresentation.Value(aRowInd, 9), theGeneralPresentation.Value(aRowInd, 10), theGeneralPresentation.Value(aRowInd, 11), theGeneralPresentation.Value(aRowInd, 12))); - aTransform.SetRow(4, NCollection_Vec4(theGeneralPresentation.Value(aRowInd, 13), + aTransform.SetRow(3, NCollection_Vec4(theGeneralPresentation.Value(aRowInd, 13), theGeneralPresentation.Value(aRowInd, 14), theGeneralPresentation.Value(aRowInd, 15), theGeneralPresentation.Value(aRowInd, 16))); - myTransformPresentation.SetValue(aRowInd, aTransform); } } @@ -94,22 +93,22 @@ NCollection_Array2 XCAFAnimObjects_Transform::GeneralPresentation() cons { const NCollection_Mat4& 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)); + aRes.SetValue(aRowInd, 1, aTransform.GetValue(0, 0)); + aRes.SetValue(aRowInd, 2, aTransform.GetValue(0, 1)); + aRes.SetValue(aRowInd, 3, aTransform.GetValue(0, 2)); + aRes.SetValue(aRowInd, 4, aTransform.GetValue(0, 3)); + aRes.SetValue(aRowInd, 5, aTransform.GetValue(1, 0)); + aRes.SetValue(aRowInd, 6, aTransform.GetValue(1, 1)); + aRes.SetValue(aRowInd, 7, aTransform.GetValue(1, 2)); + aRes.SetValue(aRowInd, 8, aTransform.GetValue(1, 3)); + aRes.SetValue(aRowInd, 9, aTransform.GetValue(2, 0)); + aRes.SetValue(aRowInd, 10, aTransform.GetValue(2, 1)); + aRes.SetValue(aRowInd, 11, aTransform.GetValue(2, 2)); + aRes.SetValue(aRowInd, 12, aTransform.GetValue(2, 3)); + aRes.SetValue(aRowInd, 13, aTransform.GetValue(3, 0)); + aRes.SetValue(aRowInd, 14, aTransform.GetValue(3, 1)); + aRes.SetValue(aRowInd, 15, aTransform.GetValue(3, 2)); + aRes.SetValue(aRowInd, 16, aTransform.GetValue(3, 3)); } return aRes; } \ No newline at end of file diff --git a/src/XCAFAnimObjects/XCAFAnimObjects_Translate.cxx b/src/XCAFAnimObjects/XCAFAnimObjects_Translate.cxx index 6eaefac25e..81467e69b5 100644 --- a/src/XCAFAnimObjects/XCAFAnimObjects_Translate.cxx +++ b/src/XCAFAnimObjects/XCAFAnimObjects_Translate.cxx @@ -44,14 +44,14 @@ XCAFAnimObjects_Translate::XCAFAnimObjects_Translate(const NCollection_Array1& theGeneralPresentation, const NCollection_Array1& theTimeStamps) : XCAFAnimObjects_Operation(theTimeStamps), - myTranslatePresentation(1, theGeneralPresentation.RowLength()) + myTranslatePresentation(1, theGeneralPresentation.NbRows()) { - if (theGeneralPresentation.ColLength() != 3) + if (theGeneralPresentation.NbColumns() != 3) { Message::SendWarning() << "Warning: XCAFAnimObjects_Translate: Incorrect XYZ general presentation"; return; } - for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++) + for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++) { gp_XYZ aXYZ(theGeneralPresentation.Value(aRowInd, 1), theGeneralPresentation.Value(aRowInd, 2), diff --git a/src/XCAFDoc/XCAFDoc_Animation.cxx b/src/XCAFDoc/XCAFDoc_Animation.cxx index 92510103f1..eff1b5f53a 100644 --- a/src/XCAFDoc/XCAFDoc_Animation.cxx +++ b/src/XCAFDoc/XCAFDoc_Animation.cxx @@ -377,7 +377,7 @@ Handle(XCAFAnimObjects_AnimObject) XCAFDoc_Animation::GetObject() const { continue; } - TCollection_AsciiString aOperName = aOperNameAttr->Get(); + const TCollection_AsciiString aOperName = aOperNameAttr->Get(); aNewOperObj = new XCAFAnimObjects_CustomOperation(aValuesArr, aTimeStampsArr, aOperName); break; } diff --git a/src/XCAFDoc/XCAFDoc_DocumentTool.cxx b/src/XCAFDoc/XCAFDoc_DocumentTool.cxx index af6ffd69b3..7b3cad6692 100644 --- a/src/XCAFDoc/XCAFDoc_DocumentTool.cxx +++ b/src/XCAFDoc/XCAFDoc_DocumentTool.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,7 @@ Handle(XCAFDoc_DocumentTool) XCAFDoc_DocumentTool::Set(const TDF_Label& L, XCAFDoc_NotesTool::Set(NotesLabel(L)); XCAFDoc_ViewTool::Set(ViewsLabel(L)); XCAFDoc_ClippingPlaneTool::Set(ClippingPlanesLabel(L)); + XCAFDoc_AnimationTool::Set(AnimationlLabel(L)); } return A; } @@ -237,6 +239,17 @@ TDF_Label XCAFDoc_DocumentTool::VisMaterialLabel (const TDF_Label& theLabel) return aLabel; } +//======================================================================= +//function : AnimationlLabel +//purpose : +//======================================================================= +TDF_Label XCAFDoc_DocumentTool::AnimationlLabel(const TDF_Label& theLabel) +{ + TDF_Label aLabel = DocLabel(theLabel).FindChild(18, Standard_True); + TDataStd_Name::Set(aLabel, "Animation"); + return aLabel; +} + //======================================================================= //function : ShapeTool //purpose : @@ -294,6 +307,15 @@ Handle(XCAFDoc_VisMaterialTool) XCAFDoc_DocumentTool::VisMaterialTool (const TDF return XCAFDoc_VisMaterialTool::Set (VisMaterialLabel (theLabel)); } +//======================================================================= +//function : AnimationTool +//purpose : +//======================================================================= +Handle(XCAFDoc_AnimationTool) XCAFDoc_DocumentTool::AnimationTool(const TDF_Label& theLabel) +{ + return XCAFDoc_AnimationTool::Set(AnimationlLabel(theLabel)); +} + //======================================================================= //function : CheckVisMaterialTool //purpose : @@ -308,12 +330,26 @@ Standard_Boolean XCAFDoc_DocumentTool::CheckVisMaterialTool(const TDF_Label& the return aLabel.IsAttribute(XCAFDoc_VisMaterialTool::GetID()); } +//======================================================================= +//function : CheckAnimationTool +//purpose : +//======================================================================= +Standard_Boolean XCAFDoc_DocumentTool::CheckAnimationTool(const TDF_Label& theAcces) +{ + TDF_Label aLabel = DocLabel(theAcces).FindChild(18, Standard_False); + if (aLabel.IsNull()) + { + return Standard_False; + } + return aLabel.IsAttribute(XCAFDoc_AnimationTool::GetID()); +} + //======================================================================= //function : LayerTool //purpose : //======================================================================= -Handle(XCAFDoc_LayerTool) XCAFDoc_DocumentTool::LayerTool (const TDF_Label& acces) +Handle(XCAFDoc_LayerTool) XCAFDoc_DocumentTool::LayerTool (const TDF_Label& acces) { return XCAFDoc_LayerTool::Set(LayersLabel(acces)); } diff --git a/src/XCAFDoc/XCAFDoc_DocumentTool.hxx b/src/XCAFDoc/XCAFDoc_DocumentTool.hxx index 6993815937..ac0dff91db 100644 --- a/src/XCAFDoc/XCAFDoc_DocumentTool.hxx +++ b/src/XCAFDoc/XCAFDoc_DocumentTool.hxx @@ -26,6 +26,7 @@ class Standard_GUID; class TDF_Label; class TDocStd_Document; +class XCAFDoc_AnimationTool; class XCAFDoc_ShapeTool; class XCAFDoc_ColorTool; class XCAFDoc_ClippingPlaneTool; @@ -92,6 +93,9 @@ public: //! Returns sub-label of DocLabel() with tag 10. Standard_EXPORT static TDF_Label VisMaterialLabel (const TDF_Label& theLabel); + //! Returns sub-label of DocLabel() with tag 18. + Standard_EXPORT static TDF_Label AnimationlLabel(const TDF_Label& theLabel); + //! Creates (if it does not exist) ShapeTool attribute on ShapesLabel(). Standard_EXPORT static Handle(XCAFDoc_ShapeTool) ShapeTool (const TDF_Label& acces); @@ -110,10 +114,17 @@ public: //! Should not be confused with MaterialTool() defining physical/manufacturing materials. Standard_EXPORT static Handle(XCAFDoc_VisMaterialTool) VisMaterialTool (const TDF_Label& theLabel); + //! Creates (if it does not exist) XCAFDoc_AnimationTool attribute on AnimationLabell(). + Standard_EXPORT static Handle(XCAFDoc_AnimationTool) AnimationTool(const TDF_Label& theLabel); + //! Checks for the VisMaterialTool attribute on the label's document //! Returns TRUE if Tool exists, ELSE if it has not been created Standard_EXPORT static Standard_Boolean CheckVisMaterialTool(const TDF_Label& theAcces); + //! Checks for the AnimationTool attribute on the label's document + //! Returns TRUE if Tool exists, ELSE if it has not been created + Standard_EXPORT static Standard_Boolean CheckAnimationTool(const TDF_Label& theAcces); + //! Creates (if it does not exist) LayerTool attribute on LayersLabel(). Standard_EXPORT static Handle(XCAFDoc_LayerTool) LayerTool (const TDF_Label& acces);