1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-06 10:36:12 +03:00

// completed base animation XCAF getting/setting object

Going to test on CAD format import
This commit is contained in:
dpasukhi 2023-05-28 13:18:14 +01:00 committed by oan
parent 2ffca9595b
commit ce13c99e9b
3 changed files with 56 additions and 15 deletions

View File

@ -13,17 +13,23 @@
#include <XCAFDoc_Animation.hxx> #include <XCAFDoc_Animation.hxx>
#include <TDF_Label.hxx>
#include <Standard_GUID.hxx> #include <Standard_GUID.hxx>
#include <TDataStd_Name.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_UAttribute.hxx>
#include <TCollection_ExtendedString.hxx> #include <TCollection_ExtendedString.hxx>
#include <XCAFAnimObjects_Rotate.hxx> #include <TDataStd_Integer.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_IntegerArray.hxx> #include <TDataStd_IntegerArray.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_UAttribute.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Label.hxx>
#include <XCAFAnimObjects_AnimObject.hxx> #include <XCAFAnimObjects_AnimObject.hxx>
#include <XCAFAnimObjects_CustomOperation.hxx>
#include <XCAFAnimObjects_Orient.hxx>
#include <XCAFAnimObjects_Rotate.hxx>
#include <XCAFAnimObjects_Scale.hxx>
#include <XCAFAnimObjects_Skew.hxx>
#include <XCAFAnimObjects_Transform.hxx>
#include <XCAFAnimObjects_Translate.hxx>
IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_Animation, TDataStd_GenericEmpty) IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_Animation, TDataStd_GenericEmpty)
@ -329,13 +335,36 @@ Handle(XCAFAnimObjects_AnimObject) XCAFDoc_Animation::GetObject() const
{ {
continue; continue;
} }
Handle(TDataStd_IntegerArray) aDimArr; Handle(TDataStd_IntegerArray) aDimAtrArr;
if (!anOperL.FindAttribute(AnimValuesDimensionGUID(), aDimArr)) if (!anOperL.FindAttribute(AnimValuesDimensionGUID(), aDimAtrArr) ||
aDimAtrArr->Length() != 2)
{ {
continue; continue;
} }
Handle(TDataStd_RealArray) aValuesAtrArr;
if (!anOperL.FindAttribute(AnimValuesGUID(), aValuesAtrArr) ||
(aDimAtrArr->Value(1) * aDimAtrArr->Value(2)) != aValuesAtrArr->Length())
{
continue;
}
NCollection_Array2<double> aValuesArr(1, aDimAtrArr->Value(1), 1, aDimAtrArr->Value(2));
int aValuesInd = 1;
for (NCollection_Array2<double>::Iterator aOperValIter(aValuesArr);
aOperValIter.More(); aOperValIter.Next(), aValuesInd++)
{
aOperValIter.ChangeValue() = aValuesAtrArr->Value(aValuesInd);
}
Handle(TDataStd_RealArray) aTimeStampsAttr; Handle(TDataStd_RealArray) aTimeStampsAttr;
anOperL.FindAttribute(AnimTimeStampsValuesGUID(), aTimeStampsAttr); NCollection_Array1<double> aTimeStampsArr;
if (anOperL.FindAttribute(AnimTimeStampsValuesGUID(), aTimeStampsAttr) &&
aTimeStampsAttr->Length() == aValuesArr.NbRows())
{
aTimeStampsArr.Resize(1, aTimeStampsAttr->Length(), false);
for (int anTimeStampInd = 1; anTimeStampInd <= aTimeStampsAttr->Length(); anTimeStampInd++)
{
aTimeStampsArr.SetValue(anTimeStampInd, aTimeStampsAttr->Value(anTimeStampInd));
}
}
Handle(TDataStd_UAttribute) anInvertAttr; Handle(TDataStd_UAttribute) anInvertAttr;
const bool anIsInvert = anOperL.FindAttribute(AnimInvertRefGUID(), anInvertAttr); const bool anIsInvert = anOperL.FindAttribute(AnimInvertRefGUID(), anInvertAttr);
Handle(XCAFAnimObjects_Operation) aNewOperObj; Handle(XCAFAnimObjects_Operation) aNewOperObj;
@ -349,10 +378,12 @@ Handle(XCAFAnimObjects_AnimObject) XCAFDoc_Animation::GetObject() const
continue; continue;
} }
TCollection_AsciiString aOperName = aOperNameAttr->Get(); TCollection_AsciiString aOperName = aOperNameAttr->Get();
aNewOperObj = new XCAFAnimObjects_CustomOperation(aValuesArr, aTimeStampsArr, aOperName);
break; break;
} }
case XCAFAnimObjects_OperationType_Orient: case XCAFAnimObjects_OperationType_Orient:
{ {
aNewOperObj = new XCAFAnimObjects_Orient(aValuesArr, aTimeStampsArr);
break; break;
} }
case XCAFAnimObjects_OperationType_Rotate: case XCAFAnimObjects_OperationType_Rotate:
@ -364,25 +395,35 @@ Handle(XCAFAnimObjects_AnimObject) XCAFDoc_Animation::GetObject() const
} }
const XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate_Type aRotateType = const XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate_Type aRotateType =
static_cast<XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate_Type>(aRotateTypeAttr->Get()); static_cast<XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate_Type>(aRotateTypeAttr->Get());
aNewOperObj = new XCAFAnimObjects_Rotate(aValuesArr, aTimeStampsArr, aRotateType);
break; break;
} }
case XCAFAnimObjects_OperationType_Scale: case XCAFAnimObjects_OperationType_Scale:
{ {
aNewOperObj = new XCAFAnimObjects_Scale(aValuesArr, aTimeStampsArr);
break; break;
} }
case XCAFAnimObjects_OperationType_Skew: case XCAFAnimObjects_OperationType_Skew:
{ {
aNewOperObj = new XCAFAnimObjects_Skew(aValuesArr, aTimeStampsArr);
break; break;
} }
case XCAFAnimObjects_OperationType_Transform: case XCAFAnimObjects_OperationType_Transform:
{ {
aNewOperObj = new XCAFAnimObjects_Transform(aValuesArr, aTimeStampsArr);
break; break;
} }
case XCAFAnimObjects_OperationType_Translate: case XCAFAnimObjects_OperationType_Translate:
{ {
aNewOperObj = new XCAFAnimObjects_Translate(aValuesArr, aTimeStampsArr);
break; break;
} }
} }
if (aNewOperObj.IsNull())
{
continue;
}
anOrderedOperations.Append(aNewOperObj);
} }
return anObj; return anObj;
} }

View File

@ -15,13 +15,13 @@
#include <Standard_GUID.hxx> #include <Standard_GUID.hxx>
#include <TDataStd_Name.hxx> #include <TDataStd_Name.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDataStd_UAttribute.hxx>
#include <TDF_ChildIterator.hxx> #include <TDF_ChildIterator.hxx>
#include <XCAFDoc.hxx> #include <XCAFDoc.hxx>
#include <TDataStd_TreeNode.hxx>
#include <XCAFDoc_GraphNode.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_UAttribute.hxx>
#include <XCAFDoc_Animation.hxx>> #include <XCAFDoc_Animation.hxx>>
#include <XCAFDoc_GraphNode.hxx>
IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(XCAFDoc_AnimationTool, TDataStd_GenericEmpty, "xcaf", "AnimationTool") IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(XCAFDoc_AnimationTool, TDataStd_GenericEmpty, "xcaf", "AnimationTool")

View File

@ -15,8 +15,8 @@
#ifndef _XCAFDoc_AnimationTool_HeaderFile #ifndef _XCAFDoc_AnimationTool_HeaderFile
#define _XCAFDoc_AnimationTool_HeaderFile #define _XCAFDoc_AnimationTool_HeaderFile
#include <TDataStd_GenericEmpty.hxx>
#include <TDF_LabelSequence.hxx> #include <TDF_LabelSequence.hxx>
#include <TDataStd_GenericEmpty.hxx>
//! A tool to store shapes in an XDE //! A tool to store shapes in an XDE
//! document in the form of assembly structure, and to maintain this structure. //! document in the form of assembly structure, and to maintain this structure.