]> OCCT Git - occt.git/commitdiff
// Continued expansion of Animation storage functionality
authordpasukhi <dpasukhi@opencascade.com>
Sat, 27 May 2023 13:04:02 +0000 (14:04 +0100)
committeroan <oan@opencascade.com>
Mon, 4 Sep 2023 10:10:46 +0000 (11:10 +0100)
Updated Operation classes to smart pointer classes
First iteration of Animation getting and setting object
First version of XCAF tool to deal with Animation
Implemented new GUID for clear definition of Animation attributes

24 files changed:
src/XCAFAnimObjects/XCAFAnimObjects_AnimObject.cxx
src/XCAFAnimObjects/XCAFAnimObjects_AnimObject.hxx
src/XCAFAnimObjects/XCAFAnimObjects_CustomOperation.cxx
src/XCAFAnimObjects/XCAFAnimObjects_CustomOperation.hxx
src/XCAFAnimObjects/XCAFAnimObjects_Operation.cxx
src/XCAFAnimObjects/XCAFAnimObjects_Operation.hxx
src/XCAFAnimObjects/XCAFAnimObjects_Orient.cxx
src/XCAFAnimObjects/XCAFAnimObjects_Orient.hxx
src/XCAFAnimObjects/XCAFAnimObjects_Rotate.cxx
src/XCAFAnimObjects/XCAFAnimObjects_Rotate.hxx
src/XCAFAnimObjects/XCAFAnimObjects_Scale.cxx
src/XCAFAnimObjects/XCAFAnimObjects_Scale.hxx
src/XCAFAnimObjects/XCAFAnimObjects_Skew.cxx
src/XCAFAnimObjects/XCAFAnimObjects_Skew.hxx
src/XCAFAnimObjects/XCAFAnimObjects_Transform.cxx
src/XCAFAnimObjects/XCAFAnimObjects_Transform.hxx
src/XCAFAnimObjects/XCAFAnimObjects_Translate.cxx
src/XCAFAnimObjects/XCAFAnimObjects_Translate.hxx
src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_Animation.cxx
src/XCAFDoc/XCAFDoc_AnimationTool.cxx
src/XCAFDoc/XCAFDoc_AnimationTool.hxx
src/XCAFDoc/XCAFDoc_Area.cxx

index 81462a47a404bdb37e09701ad4cb55f3052481ac..2ccd75712bacf6145d29322208862466d76540ed 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <XCAFDoc_AnimationTool.hxx>
+#include <XCAFAnimObjects_AnimObject.hxx>
 
-#include <BRep_Builder.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TCollection_HAsciiString.hxx>
-#include <TColStd_SequenceOfHAsciiString.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_TreeNode.hxx>
-#include <TDataStd_UAttribute.hxx>
-#include <TDF_Attribute.hxx>
-#include <TDF_ChildIDIterator.hxx>
-#include <TDF_ChildIterator.hxx>
-#include <TDF_Label.hxx>
-#include <TDF_LabelMap.hxx>
-#include <TDF_LabelSequence.hxx>
-#include <TDF_RelocationTable.hxx>
-#include <TDF_Tool.hxx>
-#include <TDocStd_Document.hxx>
-#include <TNaming_Builder.hxx>
-#include <TNaming_Tool.hxx>
-#include <TopLoc_IndexedMapOfLocation.hxx>
-#include <TopLoc_Location.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_MapOfOrientedShape.hxx>
-#include <XCAFDoc.hxx>
-#include <XCAFDoc_GraphNode.hxx>
-#include <XCAFDoc_Location.hxx>
-#include <XCAFDoc_ShapeMapTool.hxx>
-
-IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(XCAFDoc_AnimationTool, TDataStd_GenericEmpty, "xcaf", "AnimationTool")
+IMPLEMENT_STANDARD_RTTIEXT(XCAFAnimObjects_AnimObject, Standard_Transient)
 
 //=======================================================================
-//function : GetID
+//function : XCAFAnimObjects_AnimObject
 //purpose  :
 //=======================================================================
-const Standard_GUID& XCAFDoc_AnimationTool::GetID()
-{
-  static Standard_GUID ShapeToolID("9E9914DD-154A-4E17-B89B-3E33CCF67BD0");
-  return ShapeToolID;
-}
-
-//=======================================================================
-//function : Set
-//purpose  :
-//=======================================================================
-Handle(XCAFDoc_AnimationTool) XCAFDoc_AnimationTool::Set(const TDF_Label& theLabel)
-{
-  Handle(XCAFDoc_AnimationTool) anAnimTool;
-  if (!theLabel.FindAttribute(XCAFDoc_AnimationTool::GetID(), anAnimTool)) {
-    anAnimTool = new XCAFDoc_AnimationTool();
-    theLabel.AddAttribute(anAnimTool);
-  }
-  return anAnimTool;
-}
-
-//=======================================================================
-//function : Constructor
-//purpose  :
-//=======================================================================
-XCAFDoc_AnimationTool::XCAFDoc_AnimationTool()
+XCAFAnimObjects_AnimObject::XCAFAnimObjects_AnimObject() :
+  myInterpolationType(XCAFAnimObjects_InterpolationType_Step)
 {}
 
 //=======================================================================
-//function : ID
-//purpose  :
-//=======================================================================
-const Standard_GUID& XCAFDoc_AnimationTool::ID() const
-{
-  return GetID();
-}
-
-//=======================================================================
-//function : BaseLabel
+//function : XCAFAnimObjects_AnimObject
 //purpose  :
 //=======================================================================
-TDF_Label XCAFDoc_AnimationTool::BaseLabel() const
-{
-  return Label();
-}
-
-//=======================================================================
-//function : Dump
-//purpose  :
-//=======================================================================
-Standard_OStream& XCAFDoc_AnimationTool::Dump(Standard_OStream& theOStream,
-                                              const Standard_Boolean theDepth) const
-{
-  (void)theOStream;
-  (void)theDepth;
-}
-
-//=======================================================================
-//function : Dump
-//purpose  :
-//=======================================================================
-Standard_OStream& XCAFDoc_AnimationTool::Dump(Standard_OStream& theDumpLog) const
-{
-  TDF_Attribute::Dump(theDumpLog);
-  Dump(theDumpLog, Standard_False);
-  return theDumpLog;
-}
-
-//=======================================================================
-//function : DumpJson
-//purpose  :
-//=======================================================================
-void XCAFDoc_AnimationTool::DumpJson(Standard_OStream& theOStream,
-                                     Standard_Integer theDepth) const
-{
-  (void)theOStream;
-  (void)theDepth;
-}
+XCAFAnimObjects_AnimObject::XCAFAnimObjects_AnimObject(const Handle(XCAFAnimObjects_AnimObject)& theObject) :
+  myInterpolationType(XCAFAnimObjects_InterpolationType_Step),
+  myOrderedOperations(theObject->myOrderedOperations)
+{}
index 93a3dc1163e4a899822fd2f13fb62cd6bd52b5cd..ea58f74be73a2647b01100332f651e07ce8ebe8b 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#ifndef _XCAFDoc_AnimationTool_HeaderFile
-#define _XCAFDoc_AnimationTool_HeaderFile
+#ifndef _XCAFAnimObjects_AnimObject_HeaderFile
+#define _XCAFAnimObjects_AnimObject_HeaderFile
 
-#include <Standard.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+#include <NCollection_List.hxx>
+#include <XCAFAnimObjects_InterpolationType.hxx>
 
-#include <XCAFDoc_DataMapOfShapeLabel.hxx>
-#include <Standard_Boolean.hxx>
-#include <TDataStd_NamedData.hxx>
-#include <TDataStd_GenericEmpty.hxx>
-#include <TDF_LabelMap.hxx>
-#include <TDF_LabelSequence.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_OStream.hxx>
-#include <TColStd_SequenceOfHAsciiString.hxx>
-#include <TDF_AttributeSequence.hxx>
-#include <TopTools_SequenceOfShape.hxx>
+class XCAFAnimObjects_Operation;
 
-class Standard_GUID;
-class TDF_Label;
-class TopoDS_Shape;
-class TopLoc_Location;
-class XCAFDoc_GraphNode;
-
-//! A tool to store shapes in an XDE
-//! document in the form of assembly structure, and to maintain this structure.
-//! Attribute containing Shapes section of DECAF document.
-//! Provide tools for management of Shapes section.
-//! The API provided by this class allows to work with this
-//! structure regardless of its low-level implementation.
-//! All the shapes are stored on child labels of a main label which is
-//! XCAFDoc_DocumentTool::LabelShapes(). The label for assembly also has
-//! sub-labels, each of which represents the instance of
-//! another shape in that assembly (component). Such sub-label
-//! stores reference to the label of the original shape in the form
-//! of TDataStd_TreeNode with GUID XCAFDoc::ShapeRefGUID(), and its
-//! location encapsulated into the NamedShape.
-//! For correct work with an XDE document, it is necessary to use
-//! methods for analysis and methods for working with shapes.
-class XCAFDoc_AnimationTool : public TDataStd_GenericEmpty
+//!
+class XCAFAnimObjects_AnimObject : public Standard_Transient
 {
+public:
+  DEFINE_STANDARD_RTTIEXT(XCAFAnimObjects_AnimObject, Standard_Transient)
 
 public:
 
-  Standard_EXPORT static const Standard_GUID& GetID();
-  
-  //! Create (if not exist) ShapeTool from XCAFDoc on <L>.
-  Standard_EXPORT static Handle(XCAFDoc_AnimationTool) Set (const TDF_Label& theLabel);
-  
-  //! Creates an empty tool
-  //! Creates a tool to work with a document <Doc>
-  //! Attaches to label XCAFDoc::LabelShapes()
-  Standard_EXPORT XCAFDoc_AnimationTool();
-  
-  //! returns the label under which shapes are stored
-  Standard_EXPORT TDF_Label BaseLabel() const;
-  
-  Standard_EXPORT Standard_OStream& Dump (Standard_OStream& theOStream, const Standard_Boolean theDepth) const;
+  //! 
+  Standard_EXPORT XCAFAnimObjects_AnimObject();
+
+  //! 
+  Standard_EXPORT XCAFAnimObjects_AnimObject(const Handle(XCAFAnimObjects_AnimObject)& theObject);
+
+  //!
+  void AppendNewOperation(const Handle(XCAFAnimObjects_Operation)& theOperation) { myOrderedOperations.Append(theOperation); }
+
+  //!
+  XCAFAnimObjects_InterpolationType GetInterpolationType() const { return myInterpolationType; }
+
+  //!
+  void SetInterpolationType(const XCAFAnimObjects_InterpolationType theType) { myInterpolationType = theType; }
+
+  //! 
+  const NCollection_List<Handle(XCAFAnimObjects_Operation)>& GetOrderedOperations() const { return myOrderedOperations; }
 
-  Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& theOStream) const Standard_OVERRIDE;
-  
-  Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
-  
-  //! Dumps the content of me into the stream
-  Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+  //! 
+  NCollection_List<Handle(XCAFAnimObjects_Operation)>& ChangeOrderedOperations() { return myOrderedOperations; }
 
-  DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_AnimationTool,TDataStd_GenericEmpty)
+private:
 
+  XCAFAnimObjects_InterpolationType myInterpolationType;
+  NCollection_List<Handle(XCAFAnimObjects_Operation)> myOrderedOperations;
 };
 
-#endif // _XCAFDoc_AnimationTool_HeaderFile
+#endif // _XCAFAnimObjects_AnimObject_HeaderFile
index 86be349ccb7db99ade314f74430c81224fd1d7d5..8c0ca84586503b104f031d1116eb564f84a3bc87 100644 (file)
@@ -40,3 +40,13 @@ XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(const NCollecti
   myTypeName(theCustomTypeName),
   myPresentation(thePresentation)
 {}
+
+//=======================================================================
+//function : XCAFAnimObjects_CustomOperation
+//purpose  :
+//=======================================================================
+XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(const Handle(XCAFAnimObjects_CustomOperation)& theOperation) :
+  XCAFAnimObjects_Operation(theOperation),
+  myTypeName(theOperation->myTypeName),
+  myPresentation(theOperation->myPresentation)
+{}
index 9fe53c66323768859fa7ae8eb120b8e3ff7b37ad..0b9de855578bdd87f22b69be662738c2dbf65033 100644 (file)
@@ -32,6 +32,9 @@ public:
                                                   const NCollection_Array1<double>& theTimeStamps,
                                                   const TCollection_AsciiString& theCustomTypeName);
 
+  //!
+  Standard_EXPORT XCAFAnimObjects_CustomOperation(const Handle(XCAFAnimObjects_CustomOperation)& theOperation);
+
   //! 
   XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Custom; }
 
index 5bf1ee7b3c2a375152a039e3990d18ded2468bb3..b745640f8d754251d55906dc570b6124d193480f 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <XCAFAnimObjects_Operation.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(XCAFAnimObjects_Operation, Standard_Transient)
+
 //=======================================================================
 //function : XCAFAnimObjects_Operation
 //purpose  :
@@ -30,3 +32,12 @@ XCAFAnimObjects_Operation::XCAFAnimObjects_Operation(const NCollection_Array1<do
   myIsInverse(theIsInverse),
   myTimeStamps(theTimeStamps)
 {}
+
+//=======================================================================
+//function : XCAFAnimObjects_Operation
+//purpose  :
+//=======================================================================
+XCAFAnimObjects_Operation::XCAFAnimObjects_Operation(const Handle(XCAFAnimObjects_Operation)& theOperation) :
+  myIsInverse(theOperation->myIsInverse),
+  myTimeStamps(theOperation->myTimeStamps)
+{}
index a550b467086bd9865038e87a5fbf3512712526bf..6ffc4de7103e9c3c5f8ffbb54cb1df7a6f08b933 100644 (file)
 #ifndef _XCAFAnimObjects_Operation_HeaderFile
 #define _XCAFAnimObjects_Operation_HeaderFile
 
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
 #include <NCollection_Array1.hxx>
 #include <NCollection_Array2.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <XCAFAnimObjects_OperationType.hxx>
 
 //! 
-class XCAFAnimObjects_Operation
+class XCAFAnimObjects_Operation : public Standard_Transient
 {
 public:
 
@@ -31,6 +33,9 @@ public:
   Standard_EXPORT XCAFAnimObjects_Operation(const NCollection_Array1<double>& theTimeStamps,
                                             const bool theIsInverse = false);
 
+  //!
+  Standard_EXPORT XCAFAnimObjects_Operation(const Handle(XCAFAnimObjects_Operation)& theOperation);
+
   //! 
   const NCollection_Array1<double>& TimeStamps() const { return myTimeStamps; }
 
@@ -52,6 +57,8 @@ public:
   //! 
   Standard_EXPORT virtual NCollection_Array2<double> GeneralPresentation() const = 0;
 
+  DEFINE_STANDARD_RTTIEXT(XCAFAnimObjects_Operation, Standard_Transient)
+
 private:
   bool myIsInverse; //!
   NCollection_Array1<double> myTimeStamps; //!< 
index 1a36a7b7077f312865cf2c1e23b0fcd99a2e0fa4..9375fa9236b64e12048ed519849980c8affb238d 100644 (file)
@@ -61,6 +61,15 @@ XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const NCollection_Array2<double>&
   }
 }
 
+//=======================================================================
+//function : XCAFAnimObjects_Orient
+//purpose  :
+//=======================================================================
+XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const Handle(XCAFAnimObjects_Orient)& theOperation) :
+  XCAFAnimObjects_Operation(theOperation),
+  myOrientPresentation(theOperation->myOrientPresentation)
+{}
+
 //=======================================================================
 //function : GeneralPresentation
 //purpose  :
index 7549ba265194f0d0a029ab5359060e156e916936..98993f46c8b246e48ca13bac2d65f15eaa954580 100644 (file)
@@ -33,6 +33,9 @@ public:
   Standard_EXPORT XCAFAnimObjects_Orient(const NCollection_Array2<double>& theGeneralPresentation,
                                          const NCollection_Array1<double>& theTimeStamps);
 
+  //!
+  Standard_EXPORT XCAFAnimObjects_Orient(const Handle(XCAFAnimObjects_Orient)& theOperation);
+
   //! 
   XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Orient; }
 
index 7a7c85ac9e450e84bec85f6a74317c7478933d37..f6c2d89737cb76c45c20334d8868ea4021997ae4 100644 (file)
 //function : XCAFAnimObjects_Rotate
 //purpose  :
 //=======================================================================
-XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const gp_Quaternion& theRotate) :
+XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const NCollection_Array1<double>& theRotate,
+                                               const NCollection_Array1<double>& theTimeStamps,
+                                               const XCAFAnimObjects_Rotate_Type theRotateType) :
   XCAFAnimObjects_Operation(false),
-  myRotatePresentation(1, 1)
+  myRotateType(theRotateType),
+  myRotatePresentation(1, 1, theRotate.Lower(), theRotate.Upper())
 {
-  myRotatePresentation.SetValue(1, theRotate);
-}
-
-//=======================================================================
-//function : XCAFAnimObjects_Rotate
-//purpose  :
-//=======================================================================
-XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const gp_XYZ& theRotate) :
-  XCAFAnimObjects_Operation(false),
-  myRotatePresentation(1, 1)
-{
-  // Convert angles from degrees to radians and create quaternions for each rotation.
-  gp_Quaternion aQuaternionX(gp_Dir(1, 0, 0), theRotate.X() * M_PI / 180.0);
-  gp_Quaternion aQuaternionY(gp_Dir(0, 1, 0), theRotate.Y() * M_PI / 180.0);
-  gp_Quaternion aQuaternionZ(gp_Dir(0, 0, 1), theRotate.Z() * M_PI / 180.0);
-
-  // Combine the rotations. The order depends on the rotation order in the original Euler angles.
-  gp_Quaternion aCombinedQuaternion = aQuaternionX * aQuaternionY * aQuaternionZ;
-
-  myRotatePresentation.SetValue(1, aCombinedQuaternion);
+  for (int anInd = theRotate.Lower(); anInd <= theRotate.Upper(); anInd++)
+  {
+    myRotatePresentation.SetValue(1, anInd, theRotate.Value(anInd));
+  }
+  Standard_Integer aNbDouble = 3;
+  if (theRotateType >= XCAFAnimObjects_Rotate_Type_XY &&
+      theRotateType <= XCAFAnimObjects_Rotate_Type_ZY)
+  {
+    aNbDouble = 2;
+  }
+  if (theRotateType >= XCAFAnimObjects_Rotate_Type_X &&
+      theRotateType <= XCAFAnimObjects_Rotate_Type_Z)
+  {
+    aNbDouble = 1;
+  }
+  if (theRotate.Length() != aNbDouble)
+  {
+    Message::SendWarning() << "Warning: XCAFAnimObjects_Rotate: Incorrect Rotate presentation";
+  }
 }
 
-//=======================================================================
-//function : XCAFAnimObjects_Rotate
-//purpose  :
-//=======================================================================
-XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const NCollection_Array1<gp_Quaternion>& theRotate,
-                                               const NCollection_Array1<double>& theTimeStamps) :
-  XCAFAnimObjects_Operation(theTimeStamps),
-  myRotatePresentation(theRotate)
-{}
-
 //=======================================================================
 //function : XCAFAnimObjects_Rotate
 //purpose  :
 //=======================================================================
 XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const NCollection_Array2<double>& theGeneralPresentation,
-                                               const NCollection_Array1<double>& theTimeStamps) :
+                                               const NCollection_Array1<double>& theTimeStamps,
+                                               const XCAFAnimObjects_Rotate_Type theRotateType) :
   XCAFAnimObjects_Operation(false),
-  myRotatePresentation(1, theGeneralPresentation.RowLength())
+  myRotateType(theRotateType),
+  myRotatePresentation(theGeneralPresentation)
 {
-  if (theGeneralPresentation.ColLength() != 4)
+  Standard_Integer aNbDouble = 3;
+  if (theRotateType >= XCAFAnimObjects_Rotate_Type_XY &&
+      theRotateType <= XCAFAnimObjects_Rotate_Type_ZY)
+  {
+    aNbDouble = 2;
+  }
+  if (theRotateType >= XCAFAnimObjects_Rotate_Type_X &&
+      theRotateType <= XCAFAnimObjects_Rotate_Type_Z)
   {
-    Message::SendWarning() << "Warning: XCAFAnimObjects_Rotate: Incorrect Quaternion general presentation";
-    return;
+    aNbDouble = 1;
   }
-  for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
+  if (theGeneralPresentation.ColLength() != aNbDouble)
   {
-    gp_Quaternion aQuat(theGeneralPresentation.Value(aRowInd, 1),
-                        theGeneralPresentation.Value(aRowInd, 2),
-                        theGeneralPresentation.Value(aRowInd, 3),
-                        theGeneralPresentation.Value(aRowInd, 4));
-    myRotatePresentation.SetValue(aRowInd, aQuat);
+    Message::SendWarning() << "Warning: XCAFAnimObjects_Rotate: Incorrect Rotate presentation";
   }
 }
 
 //=======================================================================
-//function : GeneralPresentation
+//function : XCAFAnimObjects_Rotate
 //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());
-  }
-}
+XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const Handle(XCAFAnimObjects_Rotate)& theOperation) :
+  XCAFAnimObjects_Operation(theOperation),
+  myRotateType(theOperation->myRotateType),
+  myRotatePresentation(theOperation->myRotatePresentation)
+{}
index e7483dd36657f864db15072e8f87af85265a482f..70b4610eadba4ca146f8130c13571cd38399ee67 100644 (file)
@@ -23,34 +23,62 @@ class XCAFAnimObjects_Rotate : public XCAFAnimObjects_Operation
 public:
 
   //! 
-  Standard_EXPORT XCAFAnimObjects_Rotate(const gp_Quaternion& theRotate);
+  enum XCAFAnimObjects_Rotate_Type
+  {
+    XCAFAnimObjects_Rotate_Type_XYZ = 0,
+    XCAFAnimObjects_Rotate_Type_XZY,
+    XCAFAnimObjects_Rotate_Type_YZX,
+    XCAFAnimObjects_Rotate_Type_YXZ,
+    XCAFAnimObjects_Rotate_Type_ZXY,
+    XCAFAnimObjects_Rotate_Type_ZYX,
+    XCAFAnimObjects_Rotate_Type_XY,
+    XCAFAnimObjects_Rotate_Type_XZ,
+    XCAFAnimObjects_Rotate_Type_YX,
+    XCAFAnimObjects_Rotate_Type_YZ,
+    XCAFAnimObjects_Rotate_Type_ZX,
+    XCAFAnimObjects_Rotate_Type_ZY,
+    XCAFAnimObjects_Rotate_Type_X,
+    XCAFAnimObjects_Rotate_Type_Y,
+    XCAFAnimObjects_Rotate_Type_Z
+  };
 
-  //! 
-  Standard_EXPORT XCAFAnimObjects_Rotate(const gp_XYZ& theRotate);
+public:
 
   //! 
-  Standard_EXPORT XCAFAnimObjects_Rotate(const NCollection_Array1<gp_Quaternion>& theRotate,
-                                         const NCollection_Array1<double>& theTimeStamps);
+  Standard_EXPORT XCAFAnimObjects_Rotate(const NCollection_Array1<double>& theRotate,
+                                         const NCollection_Array1<double>& theTimeStamps,
+                                         const XCAFAnimObjects_Rotate_Type theRotateType = XCAFAnimObjects_Rotate_Type_XYZ);
 
   //! 
   Standard_EXPORT XCAFAnimObjects_Rotate(const NCollection_Array2<double>& theGeneralPresentation,
-                                         const NCollection_Array1<double>& theTimeStamps);
+                                         const NCollection_Array1<double>& theTimeStamps,
+                                         const XCAFAnimObjects_Rotate_Type theRotateType = XCAFAnimObjects_Rotate_Type_XYZ);
+
+  //!
+  Standard_EXPORT XCAFAnimObjects_Rotate(const Handle(XCAFAnimObjects_Rotate)& theOperation);
 
   //! 
   XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Rotate; }
 
+  //! 
+  XCAFAnimObjects_Rotate_Type GetRotateType() const { return myRotateType; }
+
+  //! 
+  void SetRotateType(const XCAFAnimObjects_Rotate_Type theRotateType) { myRotateType = theRotateType; }
+
   //! 
   TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return "Rotate"; }
 
   //! 
-  Standard_EXPORT NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE;
+  NCollection_Array2<double> GeneralPresentation() const { return myRotatePresentation; }
 
   //! 
-  const NCollection_Array1<gp_Quaternion>& RotatePresentation() const { return myRotatePresentation; }
+  const NCollection_Array2<double>& RotatePresentation() const { return myRotatePresentation; }
 
 private:
 
-  NCollection_Array1<gp_Quaternion> myRotatePresentation; //!< 
+  XCAFAnimObjects_Rotate_Type myRotateType; //!< 
+  NCollection_Array2<double> myRotatePresentation; //!< 
 };
 
 #endif // _XCAFAnimObjects_Rotate_HeaderFile
index 0a4e61d17dc2e33eafd56fec5555056d36fbe35f..56903d97ac6182c53e2232833f1869097d6039b6 100644 (file)
@@ -59,6 +59,15 @@ XCAFAnimObjects_Scale::XCAFAnimObjects_Scale(const NCollection_Array2<double>& t
   }
 }
 
+//=======================================================================
+//function : XCAFAnimObjects_Scale
+//purpose  :
+//=======================================================================
+XCAFAnimObjects_Scale::XCAFAnimObjects_Scale(const Handle(XCAFAnimObjects_Scale)& theOperation) :
+  XCAFAnimObjects_Operation(theOperation),
+  myScalePresentation(theOperation->myScalePresentation)
+{}
+
 //=======================================================================
 //function : GeneralPresentation
 //purpose  :
index 9e4250349ebe1a9cb628d41de213ca8c639e84c0..05ca6d1e5af62535b7297d62cbefde0d68aa66c6 100644 (file)
@@ -33,6 +33,9 @@ public:
   Standard_EXPORT XCAFAnimObjects_Scale(const NCollection_Array2<double>& theGeneralPresentation,
                                         const NCollection_Array1<double>& theTimeStamps);
 
+  //!
+  Standard_EXPORT XCAFAnimObjects_Scale(const Handle(XCAFAnimObjects_Scale)& theOperation);
+
   //! 
   XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Scale; }
 
index 09a8586f627899377124f384434ac2ade73e8cda..694927f92ca919eae26a1fe6f65bfaeecb79a30d 100644 (file)
@@ -63,6 +63,15 @@ XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array2<double>& the
   }
 }
 
+//=======================================================================
+//function : XCAFAnimObjects_Skew
+//purpose  :
+//=======================================================================
+XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const Handle(XCAFAnimObjects_Skew)& theOperation) :
+  XCAFAnimObjects_Operation(theOperation),
+  mySkewPresentation(theOperation->mySkewPresentation)
+{}
+
 //=======================================================================
 //function : GeneralPresentation
 //purpose  :
index b08728874ce7c9dbed70e477281f8164b86509cd..844c6794edaae15b9ccae924705ba6faf0f9d5ab 100644 (file)
@@ -42,6 +42,9 @@ public:
   Standard_EXPORT XCAFAnimObjects_Skew(const NCollection_Array2<double>& theGeneralPresentation,
                                        const NCollection_Array1<double>& theTimeStamps);
 
+  //!
+  Standard_EXPORT XCAFAnimObjects_Skew(const Handle(XCAFAnimObjects_Skew)& theOperation);
+
   //! 
   XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Skew; }
 
index ca0e5d3c05909c45d1e72f9f3030cc04a28239ed..e14ae4f02d225823b21193a81c513e7b7e21ec9b 100644 (file)
@@ -74,6 +74,15 @@ XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const NCollection_Array2<do
   }
 }
 
+//=======================================================================
+//function : XCAFAnimObjects_Transform
+//purpose  :
+//=======================================================================
+XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const Handle(XCAFAnimObjects_Transform)& theOperation) :
+  XCAFAnimObjects_Operation(theOperation),
+  myTransformPresentation(theOperation->myTransformPresentation)
+{}
+
 //=======================================================================
 //function : GeneralPresentation
 //purpose  :
index c23b54e35e353b484b0fe390fc4963e7b3bf8719..53aa252bbfffb34f7ac773d944eefcaa0017751d 100644 (file)
@@ -33,6 +33,9 @@ public:
   Standard_EXPORT XCAFAnimObjects_Transform(const NCollection_Array2<double>& theGeneralPresentation,
                                             const NCollection_Array1<double>& theTimeStamps);
 
+  //!
+  Standard_EXPORT XCAFAnimObjects_Transform(const Handle(XCAFAnimObjects_Transform)& theOperation);
+
   //! 
   XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Transform; }
 
index d5484eabbb783e05ae8c0bdb2992cc6cbe23ae5d..8a001f38dec3b2d0e7cabd58ebe8ca77f5818fa4 100644 (file)
@@ -60,6 +60,15 @@ XCAFAnimObjects_Translate::XCAFAnimObjects_Translate(const NCollection_Array2<do
   }
 }
 
+//=======================================================================
+//function : XCAFAnimObjects_Translate
+//purpose  :
+//=======================================================================
+XCAFAnimObjects_Translate::XCAFAnimObjects_Translate(const Handle(XCAFAnimObjects_Translate)& theOperation) :
+  XCAFAnimObjects_Operation(theOperation),
+  myTranslatePresentation(theOperation->myTranslatePresentation)
+{}
+
 //=======================================================================
 //function : GeneralPresentation
 //purpose  :
index 3988505fec8b93765f925006c039ebfc989e76d2..4d43d140ecc8daeb4f1060f168c6dcf3c2bcce27 100644 (file)
@@ -33,6 +33,9 @@ public:
   Standard_EXPORT XCAFAnimObjects_Translate(const NCollection_Array2<double>& theGeneralPresentation,
                                             const NCollection_Array1<double>& theTimeStamps);
 
+  //!
+  Standard_EXPORT XCAFAnimObjects_Translate(const Handle(XCAFAnimObjects_Translate)& theOperation);
+
   //! 
   XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE { return XCAFAnimObjects_OperationType_Translate; }
 
index 9faf73353ccced7a74487a7a0834ea95cf8ad8c5..d39cea97f29f43e437640c0c8b851d783dd21f55 100644 (file)
@@ -322,6 +322,16 @@ const Standard_GUID& XCAFDoc::LockGUID()
   return ID;
 }
 
+//=======================================================================
+//function : AnimRefShapeGUID
+//purpose  :
+//=======================================================================
+const Standard_GUID& XCAFDoc::AnimRefShapeGUID()
+{
+  static const Standard_GUID ID("0BE692B6-2E38-4FDC-A349-27615CF8784F");
+  return ID;
+}
+
 //=======================================================================
 //function : AttributeInfo
 //purpose  :
index 442c060ac037af0cb53e2c9e2f6fafa1a37a5944..5ee9ab455207b551a72dc76c114c890b7e3a3981 100644 (file)
@@ -114,6 +114,9 @@ public:
   //! Returns GUID for UAttribute identifying lock flag
   Standard_EXPORT static const Standard_GUID& LockGUID();
 
+  //! Return GUIDs for TreeNode representing connections Animation-Shape
+  Standard_EXPORT static const Standard_GUID& AnimRefShapeGUID();
+
   //! Prints attribute information into a string.
   //! @param theAtt an XDE attribute
   //! @return the generated info value
index b82722b8a23cca076090680fb7323db759d5072a..d5ad8aac777d658aaf0cd369753411016f2ce09c 100644 (file)
 
 #include <XCAFDoc_Animation.hxx>
 
-#include <TDF_RelocationTable.hxx>
+#include <TDF_Label.hxx>
+#include <Standard_GUID.hxx>
+#include <TDataStd_Name.hxx>
 #include <TDF_ChildIterator.hxx>
-#include <XCAFDoc.hxx>
-#include <TDataStd_TreeNode.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
 #include <TDataStd_Integer.hxx>
-#include <TDataStd_IntegerArray.hxx>
-#include <TDataStd_ExtStringArray.hxx>
-#include <TDataStd_Real.hxx>
+#include <TDataStd_UAttribute.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <XCAFAnimObjects_Rotate.hxx>
 #include <TDataStd_RealArray.hxx>
-#include <TNaming_Builder.hxx>
-#include <TColStd_HArray1OfReal.hxx>
-#include <TopoDS.hxx>
-#include <XCAFDimTolObjects_DimensionObject.hxx>
-#include <TNaming_Tool.hxx>
-#include <TDataStd_Name.hxx>
+#include <TDataStd_IntegerArray.hxx>
+#include <XCAFAnimObjects_AnimObject.hxx>
 
 IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_Animation, TDataStd_GenericEmpty)
-enum ChildLab
+
+namespace
 {
-  ChildLab_Begin = 1,
-  ChildLab_Type = ChildLab_Begin,
+  //=======================================================================
+  //function : AnimRotateRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimRotateRefGUID()
+  {
+    static const Standard_GUID ID("09135874-3B7E-4379-8BDB-E781422B8DD7");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimCustomRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimCustomRefGUID()
+  {
+    static const Standard_GUID ID("1D0BC396-328D-45CC-B968-FD58DB7109A0");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimOrientRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimOrientRefGUID()
+  {
+    static const Standard_GUID ID("F601BE38-D3F8-4594-90C8-04B790ACD08A");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimScaleRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimScaleRefGUID()
+  {
+    static const Standard_GUID ID("40602308-A430-4912-A480-66DF8788338B");
+    return ID;
+  }
 
-  ChildLab_End
-};
+  //=======================================================================
+  //function : AnimSkewRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimSkewRefGUID()
+  {
+    static const Standard_GUID ID("9A260C95-B2D6-472D-AEB4-D802C7528FEE");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimTransformRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimTransformRefGUID()
+  {
+    static const Standard_GUID ID("F26898A6-C7A8-4FC8-B328-4B442F935E7A");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimTranslateRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimTranslateRefGUID()
+  {
+    static const Standard_GUID ID("A8777A51-B13E-417A-82A0-6176246DD441");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimInterpolationRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimInterpolationRefGUID()
+  {
+    static const Standard_GUID ID("4C565EBB-70C2-4934-B451-0B45C3460412");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimInvertRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimInvertRefGUID()
+  {
+    static const Standard_GUID ID("7898D79A-6CCE-434C-A494-A37FC1931CC2");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimInvertRefGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimValuesDimensionGUID()
+  {
+    static const Standard_GUID ID("95CBDC47-5A79-4229-9851-B6F04EAEE482");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimValuesGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimValuesGUID()
+  {
+    static const Standard_GUID ID("C3CDFA73-1C9B-4674-BCAA-D1B7038AFE86");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimValuesGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimTimeStampsValuesGUID()
+  {
+    static const Standard_GUID ID("AAF6F1A2-F764-4A4B-8984-BF7CF09B7646");
+    return ID;
+  }
+
+  //=======================================================================
+  //function : AnimValuesGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& AnimRotateSubTypeGUID()
+  {
+    static const Standard_GUID ID("A1E22D67-CD3E-4F8D-BD75-1DF04EF45266");
+    return ID;
+  }
+}
 
 //=======================================================================
 //function : XCAFDoc_Animation
-//purpose  : 
+//purpose  :
 //=======================================================================
 XCAFDoc_Animation::XCAFDoc_Animation()
-{
-}
+{}
 
 //=======================================================================
 //function : GetID
-//purpose  : 
+//purpose  :
 //=======================================================================
 const Standard_GUID& XCAFDoc_Animation::GetID()
 {
-  static Standard_GUID DGTID("58ed092c-44de-11d8-8776-001083004c77");
-  //static Standard_GUID ID("efd212e9-6dfd-11d4-b9c8-0060b0ee281b");
+  static Standard_GUID DGTID("D755686B-872E-421E-8871-E98BE8051644");
   return DGTID;
-  //return ID;
 }
 
 //=======================================================================
 //function : Set
-//purpose  : 
+//purpose  :
 //=======================================================================
 Handle(XCAFDoc_Animation) XCAFDoc_Animation::Set(const TDF_Label& theLabel)
 {
-  Handle(XCAFDoc_Animation) A;
-  if (!theLabel.FindAttribute(XCAFDoc_Animation::GetID(), A)) {
-    A = new XCAFDoc_Animation();
-    theLabel.AddAttribute(A);
+  Handle(XCAFDoc_Animation) anAnimAttr;
+  if (!theLabel.FindAttribute(XCAFDoc_Animation::GetID(), anAnimAttr)) {
+    anAnimAttr = new XCAFDoc_Animation();
+    theLabel.AddAttribute(anAnimAttr);
   }
-  return A;
+  return anAnimAttr;
 }
 
 //=======================================================================
 //function : SetObject
-//purpose  : 
+//purpose  :
 //=======================================================================
 void XCAFDoc_Animation::SetObject(const Handle(XCAFAnimObjects_AnimObject)& theObject)
 {
   Backup();
 
+  // Setting name
+  const static TCollection_ExtendedString anObjName("Animation");
+  TDataStd_Name::Set(Label(), anObjName);
+
+  // Setting Interpolation type
+  TDataStd_Integer::Set(Label(), AnimInterpolationRefGUID(), theObject->GetInterpolationType());
+
+  Standard_Integer anOperInd = 1;
+  // Setting ordered operations
+  for (NCollection_List<Handle(XCAFAnimObjects_Operation)>::Iterator anIter(theObject->GetOrderedOperations());
+       anIter.More(); anIter.Next(), anOperInd++)
+  {
+    const TDF_Label aChild = Label().FindChild(anOperInd, true);
+    aChild.ForgetAllAttributes(); // Clear old values
+
+    const Handle(XCAFAnimObjects_Operation)& anOperation = anIter.Value();
+    // Setting inverse flag
+    if (anOperation->IsInverse())
+    {
+      TDataStd_UAttribute::Set(aChild, AnimInvertRefGUID());
+    }
+    // Setting operation type and name
+    TDataStd_Name::Set(aChild, anOperation->GetTypeName());
+    switch (anOperation->GetType())
+    {
+      case XCAFAnimObjects_OperationType_Custom:
+        TDataStd_UAttribute::Set(aChild, AnimCustomRefGUID());
+        break;
+      case XCAFAnimObjects_OperationType_Orient:
+        TDataStd_UAttribute::Set(aChild, AnimOrientRefGUID());
+        break;
+      case XCAFAnimObjects_OperationType_Rotate:
+      {
+        TDataStd_UAttribute::Set(aChild, AnimRotateRefGUID());
+        const Handle(XCAFAnimObjects_Rotate) aRotate = Handle(XCAFAnimObjects_Rotate)::DownCast(anOperation);
+        TDataStd_Integer::Set(aChild, AnimRotateSubTypeGUID(), aRotate->GetRotateType());
+        break;
+      }
+      case XCAFAnimObjects_OperationType_Scale:
+        TDataStd_UAttribute::Set(aChild, AnimScaleRefGUID());
+        break;
+      case XCAFAnimObjects_OperationType_Skew:
+        TDataStd_UAttribute::Set(aChild, AnimSkewRefGUID());
+        break;
+      case XCAFAnimObjects_OperationType_Transform:
+        TDataStd_UAttribute::Set(aChild, AnimTransformRefGUID());
+        break;
+      case XCAFAnimObjects_OperationType_Translate:
+        TDataStd_UAttribute::Set(aChild, AnimTranslateRefGUID());
+        break;
+    }
+    // Setting operation values
+    const NCollection_Array2<double> anOperPresentation = anOperation->GeneralPresentation();
+    Handle(TDataStd_IntegerArray) aDimArr = TDataStd_IntegerArray::Set(aChild, AnimValuesDimensionGUID(), 1, 2);
+    aDimArr->SetValue(1, anOperPresentation.RowLength());
+    aDimArr->SetValue(2, anOperPresentation.ColLength());
+    const int aNbValues = anOperPresentation.Length();
+    Handle(TDataStd_RealArray) aValuesArr = TDataStd_RealArray::Set(aChild, AnimValuesGUID(), 1, aNbValues);
+    int anOperValueInd = 1;
+    for (NCollection_Array2<double>::Iterator aOperValIter(anOperPresentation);
+         aOperValIter.More(); aOperValIter.Next())
+    {
+      aValuesArr->SetValue(anOperValueInd++, aOperValIter.Value());
+    }
+    if (anOperation->HasTimeStamps())
+    {
+      const NCollection_Array1<double>& aTimeStamps = anOperation->TimeStamps();
+      Handle(TDataStd_RealArray) aTimeStampsAttr =
+        TDataStd_RealArray::Set(aChild, AnimTimeStampsValuesGUID(), aTimeStamps.Lower(), aTimeStamps.Upper());
+      for (int aTimeStampInd = 1; aTimeStampInd <= aTimeStamps.Length(); aTimeStampInd++)
+      {
+        aTimeStampsAttr->SetValue(aTimeStampInd, aTimeStamps.Value(aTimeStampInd));
+      }
+    }
+  }
 }
 
 //=======================================================================
 //function : GetObject
-//purpose  : 
+//purpose  :
 //=======================================================================
 Handle(XCAFAnimObjects_AnimObject) XCAFDoc_Animation::GetObject()  const
 {
   Handle(XCAFAnimObjects_AnimObject) anObj = new XCAFAnimObjects_AnimObject();
-
+  Handle(TDataStd_Integer) anIntType;
+  if (Label().FindAttribute(AnimInterpolationRefGUID(), anIntType))
+  {
+    const XCAFAnimObjects_InterpolationType aType =
+      static_cast<XCAFAnimObjects_InterpolationType>(anIntType->Get());
+    anObj->SetInterpolationType(aType);
+  }
+  NCollection_List<Handle(XCAFAnimObjects_Operation)> anOrderedOperations;
+  for (TDF_ChildIterator aChildIterator(Label());
+       aChildIterator.More(); aChildIterator.Next())
+  {
+    const TDF_Label& anOperL = aChildIterator.Value();
+    XCAFAnimObjects_OperationType anOperType = XCAFAnimObjects_OperationType_Custom;
+    Handle(TDataStd_UAttribute) anOperTypeAttr;
+    if (anOperL.FindAttribute(AnimCustomRefGUID(), anOperTypeAttr))
+    {
+      anOperType = XCAFAnimObjects_OperationType_Custom;
+    }
+    else if (anOperL.FindAttribute(AnimOrientRefGUID(), anOperTypeAttr))
+    {
+      anOperType = XCAFAnimObjects_OperationType_Orient;
+    }
+    else if (anOperL.FindAttribute(AnimRotateRefGUID(), anOperTypeAttr))
+    {
+      anOperType = XCAFAnimObjects_OperationType_Rotate;
+    }
+    else if (anOperL.FindAttribute(AnimScaleRefGUID(), anOperTypeAttr))
+    {
+      anOperType = XCAFAnimObjects_OperationType_Scale;
+    }
+    else if (anOperL.FindAttribute(AnimSkewRefGUID(), anOperTypeAttr))
+    {
+      anOperType = XCAFAnimObjects_OperationType_Skew;
+    }
+    else if (anOperL.FindAttribute(AnimTransformRefGUID(), anOperTypeAttr))
+    {
+      anOperType = XCAFAnimObjects_OperationType_Transform;
+    }
+    else if (anOperL.FindAttribute(AnimTranslateRefGUID(), anOperTypeAttr))
+    {
+      anOperType = XCAFAnimObjects_OperationType_Translate;
+    }
+    if (anOperTypeAttr.IsNull())
+    {
+      continue;
+    }
+    Handle(TDataStd_IntegerArray) aDimArr;
+    if (!anOperL.FindAttribute(AnimValuesDimensionGUID(), aDimArr))
+    {
+      continue;
+    }
+    Handle(TDataStd_RealArray) aTimeStampsAttr;
+    anOperL.FindAttribute(AnimTimeStampsValuesGUID(), aTimeStampsAttr);
+    Handle(TDataStd_UAttribute) anInvertAttr;
+    const bool anIsInvert = anOperL.FindAttribute(AnimInvertRefGUID(), anInvertAttr);
+    Handle(XCAFAnimObjects_Operation) aNewOperObj;
+    switch (anOperType)
+    {
+      case XCAFAnimObjects_OperationType_Custom:
+      {
+        Handle(TDataStd_Name) aOperNameAttr;
+        if (!anOperL.FindAttribute(TDataStd_Name::GetID(), aOperNameAttr))
+        {
+          continue;
+        }
+        TCollection_AsciiString aOperName = aOperNameAttr->Get();
+        break;
+      }
+      case XCAFAnimObjects_OperationType_Orient:
+      {
+        break;
+      }
+      case XCAFAnimObjects_OperationType_Rotate:
+      {
+        Handle(TDataStd_Integer) aRotateTypeAttr;
+        if (!anOperL.FindAttribute(AnimRotateSubTypeGUID(), aRotateTypeAttr))
+        {
+          continue;
+        }
+        const XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate_Type aRotateType =
+          static_cast<XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate_Type>(aRotateTypeAttr->Get());
+        break;
+      }
+      case XCAFAnimObjects_OperationType_Scale:
+      {
+        break;
+      }
+      case XCAFAnimObjects_OperationType_Skew:
+      {
+        break;
+      }
+      case XCAFAnimObjects_OperationType_Transform:
+      {
+        break;
+      }
+      case XCAFAnimObjects_OperationType_Translate:
+      {
+        break;
+      }
+    }
+  }
   return anObj;
 }
 
 //=======================================================================
 //function : ID
-//purpose  : 
+//purpose  :
 //=======================================================================
-
 const Standard_GUID& XCAFDoc_Animation::ID() const
 {
   return GetID();
@@ -110,5 +402,6 @@ const Standard_GUID& XCAFDoc_Animation::ID() const
 //=======================================================================
 void XCAFDoc_Animation::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
 {
-
+  (void)theOStream;
+  (void)theDepth;
 }
index 81462a47a404bdb37e09701ad4cb55f3052481ac..6f6927a6fa18e208808cee0a9dc0c0804e39a539 100644 (file)
 
 #include <XCAFDoc_AnimationTool.hxx>
 
-#include <BRep_Builder.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TCollection_HAsciiString.hxx>
-#include <TColStd_SequenceOfHAsciiString.hxx>
+#include <Standard_GUID.hxx>
 #include <TDataStd_Name.hxx>
-#include <TDataStd_TreeNode.hxx>
-#include <TDataStd_UAttribute.hxx>
-#include <TDF_Attribute.hxx>
-#include <TDF_ChildIDIterator.hxx>
 #include <TDF_ChildIterator.hxx>
-#include <TDF_Label.hxx>
-#include <TDF_LabelMap.hxx>
-#include <TDF_LabelSequence.hxx>
-#include <TDF_RelocationTable.hxx>
-#include <TDF_Tool.hxx>
-#include <TDocStd_Document.hxx>
-#include <TNaming_Builder.hxx>
-#include <TNaming_Tool.hxx>
-#include <TopLoc_IndexedMapOfLocation.hxx>
-#include <TopLoc_Location.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_MapOfOrientedShape.hxx>
 #include <XCAFDoc.hxx>
+#include <TDataStd_TreeNode.hxx>
 #include <XCAFDoc_GraphNode.hxx>
-#include <XCAFDoc_Location.hxx>
-#include <XCAFDoc_ShapeMapTool.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_UAttribute.hxx>
+#include <XCAFDoc_Animation.hxx>>
 
 IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(XCAFDoc_AnimationTool, TDataStd_GenericEmpty, "xcaf", "AnimationTool")
 
+namespace
+{
+  //=======================================================================
+  //function : GetGlobalFPSGUID
+  //purpose  :
+  //=======================================================================
+  const Standard_GUID& GetGlobalFPSGUID()
+  {
+    static Standard_GUID aGlobalFPSID("C7E7AF70-2FB3-40FD-BD38-CC79D9343D7A");
+    return aGlobalFPSID;
+  }
+}
+
 //=======================================================================
 //function : GetID
 //purpose  :
 //=======================================================================
 const Standard_GUID& XCAFDoc_AnimationTool::GetID()
 {
-  static Standard_GUID ShapeToolID("9E9914DD-154A-4E17-B89B-3E33CCF67BD0");
-  return ShapeToolID;
+  static Standard_GUID anAnimationToolID("9E9914DD-154A-4E17-B89B-3E33CCF67BD0");
+  return anAnimationToolID;
 }
 
 //=======================================================================
@@ -66,7 +55,8 @@ const Standard_GUID& XCAFDoc_AnimationTool::GetID()
 Handle(XCAFDoc_AnimationTool) XCAFDoc_AnimationTool::Set(const TDF_Label& theLabel)
 {
   Handle(XCAFDoc_AnimationTool) anAnimTool;
-  if (!theLabel.FindAttribute(XCAFDoc_AnimationTool::GetID(), anAnimTool)) {
+  if (!theLabel.FindAttribute(XCAFDoc_AnimationTool::GetID(), anAnimTool))
+  {
     anAnimTool = new XCAFDoc_AnimationTool();
     theLabel.AddAttribute(anAnimTool);
   }
@@ -98,12 +88,166 @@ TDF_Label XCAFDoc_AnimationTool::BaseLabel() const
   return Label();
 }
 
+//=======================================================================
+//function : IsAnimation
+//purpose  :
+//=======================================================================
+bool XCAFDoc_AnimationTool::IsAnimation(const TDF_Label& theLabel) const
+{
+  Handle(XCAFDoc_Animation) anAnimAtr;
+  if (theLabel.FindAttribute(XCAFDoc_Animation::GetID(), anAnimAtr))
+  {
+    return true;
+  }
+  return false;
+}
+
+//=======================================================================
+//function : SetAnimation
+//purpose  :
+//=======================================================================
+void XCAFDoc_AnimationTool::SetAnimation(const TDF_Label& theShLabel,
+                                         const TDF_Label& theAnimLabel) const
+{
+  // set reference
+  Handle(TDataStd_TreeNode) aRefNode, aMainNode;
+  aMainNode = TDataStd_TreeNode::Set(theAnimLabel, XCAFDoc::AnimRefShapeGUID());
+  aRefNode = TDataStd_TreeNode::Set(theShLabel, XCAFDoc::AnimRefShapeGUID());
+  aRefNode->Remove();
+  aMainNode->Prepend(aRefNode);
+}
+
+//=======================================================================
+//function : GetGlobalFPS
+//purpose  :
+//=======================================================================
+bool XCAFDoc_AnimationTool::GetGlobalFPS(double& theFPS) const
+{
+  Handle(TDataStd_Real) aFPSAttr;
+  if (BaseLabel().FindAttribute(GetGlobalFPSGUID(), aFPSAttr))
+  {
+    theFPS = aFPSAttr->Get();
+    return true;
+  }
+  return false;
+}
+
+//=======================================================================
+//function : SetGlobalFPS
+//purpose  :
+//=======================================================================
+void XCAFDoc_AnimationTool::SetGlobalFPS(const double theFPS) const
+{
+  Handle(TDataStd_Real) aFPSAttr;
+  if (BaseLabel().FindAttribute(GetGlobalFPSGUID(), aFPSAttr))
+  {
+    aFPSAttr->Set(theFPS);
+    return;
+  }
+  TDataStd_Real::Set(BaseLabel(), GetGlobalFPSGUID(), theFPS);
+}
+
+//=======================================================================
+//function : GetAnimationLabels
+//purpose  :
+//=======================================================================
+void XCAFDoc_AnimationTool::GetAnimationLabels(TDF_LabelSequence& theLabels) const
+{
+  theLabels.Clear();
+  for (TDF_ChildIterator aChildIterator(Label());
+       aChildIterator.More(); aChildIterator.Next())
+  {
+    TDF_Label aL = aChildIterator.Value();
+    if (IsAnimation(aL))
+    {
+      theLabels.Append(aL);
+    }
+  }
+}
+
+//=======================================================================
+//function : GetRefAnimationLabels
+//purpose  :
+//=======================================================================
+bool XCAFDoc_AnimationTool::GetRefAnimationLabel(const TDF_Label& theShLabel,
+                                                 TDF_Label& theAnimLabel) const
+{
+  Handle(TDataStd_TreeNode) aNode;
+  if (!theShLabel.FindAttribute(XCAFDoc::AnimRefShapeGUID(), aNode) ||
+      !aNode->HasFather())
+  {
+    return false;
+  }
+  theAnimLabel = aNode->Father()->Label();
+  return true;
+}
+
+//=======================================================================
+//function : GetRefShapeLabel
+//purpose  :
+//=======================================================================
+bool XCAFDoc_AnimationTool::GetRefShapeLabel(const TDF_Label& theAnimLabel,
+                                             TDF_Label& theShLabel) const
+{
+  Handle(TDataStd_TreeNode) aNode;
+  if (!theAnimLabel.FindAttribute(XCAFDoc::AnimRefShapeGUID(), aNode) ||
+      !aNode->Label().IsNull())
+  {
+    return false;
+  }
+  theShLabel = aNode->Label();
+  return true;
+}
+
+//=======================================================================
+//function : AddAnimation
+//purpose  :
+//=======================================================================
+TDF_Label XCAFDoc_AnimationTool::AddAnimation() const
+{
+  TDF_Label anAnimL;
+  TDF_TagSource aTag;
+  anAnimL = aTag.NewChild(Label());
+  Handle(XCAFDoc_Animation) aTol = XCAFDoc_Animation::Set(anAnimL);
+  TCollection_AsciiString aStr = "Animation";
+  TDataStd_Name::Set(anAnimL, aStr);
+  return anAnimL;
+}
+
+//=======================================================================
+//function : IsLocked
+//purpose  :
+//=======================================================================
+bool XCAFDoc_AnimationTool::IsLocked(const TDF_Label& theAnimLabel) const
+{
+  Handle(TDataStd_UAttribute) anAttr;
+  return theAnimLabel.FindAttribute(XCAFDoc::LockGUID(), anAttr);
+}
+
+//=======================================================================
+//function : Unlock
+//purpose  :
+//=======================================================================
+void XCAFDoc_AnimationTool::Lock(const TDF_Label& theAnimLabel) const
+{
+  TDataStd_UAttribute::Set(theAnimLabel, XCAFDoc::LockGUID());
+}
+
+//=======================================================================
+//function : Unlock
+//purpose  :
+//=======================================================================
+void XCAFDoc_AnimationTool::Unlock(const TDF_Label& theAnimLabel) const
+{
+  theAnimLabel.ForgetAttribute(XCAFDoc::LockGUID());
+}
+
 //=======================================================================
 //function : Dump
 //purpose  :
 //=======================================================================
 Standard_OStream& XCAFDoc_AnimationTool::Dump(Standard_OStream& theOStream,
-                                              const Standard_Boolean theDepth) const
+                                              const bool theDepth) const
 {
   (void)theOStream;
   (void)theDepth;
@@ -116,7 +260,7 @@ Standard_OStream& XCAFDoc_AnimationTool::Dump(Standard_OStream& theOStream,
 Standard_OStream& XCAFDoc_AnimationTool::Dump(Standard_OStream& theDumpLog) const
 {
   TDF_Attribute::Dump(theDumpLog);
-  Dump(theDumpLog, Standard_False);
+  Dump(theDumpLog, false);
   return theDumpLog;
 }
 
index 93a3dc1163e4a899822fd2f13fb62cd6bd52b5cd..f67809d02ff65e80ff7ea6e9a037f8561ce4ac47 100644 (file)
@@ -1,4 +1,5 @@
 // Copyright (c) 2023 OPEN CASCADE SAS
+// Copyright (c) 2023 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //
 #ifndef _XCAFDoc_AnimationTool_HeaderFile
 #define _XCAFDoc_AnimationTool_HeaderFile
 
-#include <Standard.hxx>
-
-#include <XCAFDoc_DataMapOfShapeLabel.hxx>
-#include <Standard_Boolean.hxx>
-#include <TDataStd_NamedData.hxx>
 #include <TDataStd_GenericEmpty.hxx>
-#include <TDF_LabelMap.hxx>
 #include <TDF_LabelSequence.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_OStream.hxx>
-#include <TColStd_SequenceOfHAsciiString.hxx>
-#include <TDF_AttributeSequence.hxx>
-#include <TopTools_SequenceOfShape.hxx>
-
-class Standard_GUID;
-class TDF_Label;
-class TopoDS_Shape;
-class TopLoc_Location;
-class XCAFDoc_GraphNode;
 
 //! A tool to store shapes in an XDE
 //! document in the form of assembly structure, and to maintain this structure.
@@ -55,28 +39,67 @@ class XCAFDoc_AnimationTool : public TDataStd_GenericEmpty
 public:
 
   Standard_EXPORT static const Standard_GUID& GetID();
-  
+
   //! Create (if not exist) ShapeTool from XCAFDoc on <L>.
-  Standard_EXPORT static Handle(XCAFDoc_AnimationTool) Set (const TDF_Label& theLabel);
-  
+  Standard_EXPORT static Handle(XCAFDoc_AnimationTool) Set(const TDF_Label& theLabel);
+
   //! Creates an empty tool
   //! Creates a tool to work with a document <Doc>
   //! Attaches to label XCAFDoc::LabelShapes()
   Standard_EXPORT XCAFDoc_AnimationTool();
-  
+
   //! returns the label under which shapes are stored
   Standard_EXPORT TDF_Label BaseLabel() const;
-  
-  Standard_EXPORT Standard_OStream& Dump (Standard_OStream& theOStream, const Standard_Boolean theDepth) const;
 
-  Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& theOStream) const Standard_OVERRIDE;
-  
+  //!
+  Standard_EXPORT bool IsAnimation(const TDF_Label& theLabel) const;
+
+  //!
+  Standard_EXPORT void SetAnimation(const TDF_Label& theShLabel,
+                                    const TDF_Label& theAnimLabel) const;
+
+  //!
+  Standard_EXPORT bool GetGlobalFPS(double& theFPS) const;
+
+  //!
+  Standard_EXPORT void SetGlobalFPS(const double theFPS) const;
+
+  //! Returns a sequence of Animation labels currently stored
+  //! in the Animation table.
+  Standard_EXPORT void GetAnimationLabels(TDF_LabelSequence& theLabels) const;
+
+  //! Returns Animation label defined for shape.
+  Standard_EXPORT bool GetRefAnimationLabel(const TDF_Label& theShLabel,
+                                            TDF_Label& theAnimLabel) const;
+
+  //! Returns Animation label defined for shape.
+  Standard_EXPORT bool GetRefShapeLabel(const TDF_Label& theAnimLabel,
+                                        TDF_Label& theShLabel) const;
+
+  //! Adds a animation definition to the Animation table and returns its label.
+  Standard_EXPORT TDF_Label AddAnimation() const;
+
+  //! Returns true if the given Animation is marked as locked.
+  Standard_EXPORT bool IsLocked(const TDF_Label& theAnimLabel) const;
+
+  //! Mark the given Animation as locked.
+  Standard_EXPORT void Lock(const TDF_Label& theAnimLabel) const;
+
+  //! Unlock the given Animation.
+  Standard_EXPORT void Unlock(const TDF_Label& theAnimLabel) const;
+
+  Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOStream, const bool theDepth) const;
+
+  Standard_EXPORT virtual Standard_OStream& Dump(Standard_OStream& theOStream) const Standard_OVERRIDE;
+
   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
-  
+
   //! Dumps the content of me into the stream
-  Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+  Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
+  DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_AnimationTool, TDataStd_GenericEmpty)
 
-  DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_AnimationTool,TDataStd_GenericEmpty)
+private:
 
 };
 
index 725b51805a0e96c1533f44537f25e5a6285ab33d..47d05bc1563bf102db349eb8412f8543dc3522ef 100644 (file)
@@ -1,4 +1,6 @@
-// Copyright (c) 2000-2023 OPEN CASCADE SAS
+// Created on: 2000-09-08
+// Created by: data exchange team
+// Copyright (c) 2000-2014 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //