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

// Continued expansion of Animation storage functionality

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
This commit is contained in:
dpasukhi 2023-05-27 14:04:02 +01:00 committed by oan
parent 5ad8acb354
commit 2ffca9595b
24 changed files with 801 additions and 342 deletions

View File

@ -11,122 +11,23 @@
// 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
//function : XCAFAnimObjects_AnimObject
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_AnimationTool::ID() const
{
return GetID();
}
//=======================================================================
//function : BaseLabel
//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)
{}

View File

@ -11,73 +11,49 @@
// 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 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 XCAFAnimObjects_AnimObject(const Handle(XCAFAnimObjects_AnimObject)& theObject);
DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_AnimationTool,TDataStd_GenericEmpty)
//!
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; }
//!
NCollection_List<Handle(XCAFAnimObjects_Operation)>& ChangeOrderedOperations() { return myOrderedOperations; }
private:
XCAFAnimObjects_InterpolationType myInterpolationType;
NCollection_List<Handle(XCAFAnimObjects_Operation)> myOrderedOperations;
};
#endif // _XCAFDoc_AnimationTool_HeaderFile
#endif // _XCAFAnimObjects_AnimObject_HeaderFile

View 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)
{}

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

View 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)
{}

View File

@ -14,13 +14,15 @@
#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; //!<

View 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 :

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

View File

@ -19,80 +19,68 @@
//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);
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 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);
}
//=======================================================================
//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)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Rotate: Incorrect Quaternion general presentation";
return;
aNbDouble = 2;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
if (theRotateType >= XCAFAnimObjects_Rotate_Type_X &&
theRotateType <= XCAFAnimObjects_Rotate_Type_Z)
{
gp_Quaternion aQuat(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3),
theGeneralPresentation.Value(aRowInd, 4));
myRotatePresentation.SetValue(aRowInd, aQuat);
aNbDouble = 1;
}
if (theGeneralPresentation.ColLength() != aNbDouble)
{
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)
{}

View 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
};
public:
//!
Standard_EXPORT XCAFAnimObjects_Rotate(const gp_XYZ& theRotate);
//!
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

View 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 :

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

View 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 :

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

View 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 :

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

View 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 :

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

View 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 :

View 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

View File

@ -13,92 +13,384 @@
#include <XCAFDoc_Animation.hxx>
#include <TDF_RelocationTable.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_RealArray.hxx>
#include <TNaming_Builder.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TopoDS.hxx>
#include <XCAFDimTolObjects_DimensionObject.hxx>
#include <TNaming_Tool.hxx>
#include <TDF_Label.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 <XCAFAnimObjects_Rotate.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <XCAFAnimObjects_AnimObject.hxx>
IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_Animation, TDataStd_GenericEmpty)
enum ChildLab
{
ChildLab_Begin = 1,
ChildLab_Type = ChildLab_Begin,
ChildLab_End
};
//=======================================================================
//function : XCAFDoc_Animation
//purpose :
//=======================================================================
XCAFDoc_Animation::XCAFDoc_Animation()
namespace
{
//=======================================================================
//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;
}
//=======================================================================
//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 :
//=======================================================================
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;
}

View File

@ -13,50 +13,39 @@
#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;
}

View 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.
//
@ -14,25 +15,8 @@
#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;
DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_AnimationTool,TDataStd_GenericEmpty)
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_AnimationTool, TDataStd_GenericEmpty)
private:
};

View 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.
//