Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DataExchange/TKXCAF/PACKAGES.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Auto-generated list of packages for TKXCAF toolkit
set(OCCT_TKXCAF_LIST_OF_PACKAGES
XCAFAnimObjects
XCAFApp
XCAFDimTolObjects
XCAFNoteObjects
Expand Down
25 changes: 25 additions & 0 deletions src/DataExchange/TKXCAF/XCAFAnimObjects/FILES.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Source files for XCAFAnimObjects package
set(OCCT_XCAFAnimObjects_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")

set(OCCT_XCAFAnimObjects_FILES
XCAFAnimObjects_Object.cxx
XCAFAnimObjects_Object.hxx
XCAFAnimObjects_CustomOperation.cxx
XCAFAnimObjects_CustomOperation.hxx
XCAFAnimObjects_InterpolationType.hxx
XCAFAnimObjects_Operation.cxx
XCAFAnimObjects_Operation.hxx
XCAFAnimObjects_OperationType.hxx
XCAFAnimObjects_Orient.cxx
XCAFAnimObjects_Orient.hxx
XCAFAnimObjects_Rotate.cxx
XCAFAnimObjects_Rotate.hxx
XCAFAnimObjects_Scale.cxx
XCAFAnimObjects_Scale.hxx
XCAFAnimObjects_Skew.cxx
XCAFAnimObjects_Skew.hxx
XCAFAnimObjects_Transform.cxx
XCAFAnimObjects_Transform.hxx
XCAFAnimObjects_Translate.cxx
XCAFAnimObjects_Translate.hxx
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#include "XCAFAnimObjects_CustomOperation.hxx"

//=================================================================================================

XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(
const NCollection_Array1<double>& thePresentation,
const TCollection_AsciiString& theCustomTypeName)
: XCAFAnimObjects_Operation(false),
myTypeName(theCustomTypeName),
myPresentation(1, 1, thePresentation.Lower(), thePresentation.Upper())
{
for (int anInd = thePresentation.Lower(); anInd <= thePresentation.Upper(); anInd++)
{
myPresentation.SetValue(1, anInd, thePresentation.Value(anInd));
}
}

//=================================================================================================

XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(
const NCollection_Array2<double>& thePresentation,
const NCollection_Array1<double>& theTimeStamps,
const TCollection_AsciiString& theCustomTypeName)
: XCAFAnimObjects_Operation(theTimeStamps),
myTypeName(theCustomTypeName),
myPresentation(thePresentation)
{
}

//=================================================================================================

XCAFAnimObjects_CustomOperation::XCAFAnimObjects_CustomOperation(
const Handle(XCAFAnimObjects_CustomOperation)& theOperation)
: XCAFAnimObjects_Operation(theOperation),
myTypeName(theOperation->myTypeName),
myPresentation(theOperation->myPresentation)
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#ifndef _XCAFAnimObjects_CustomOperation_HeaderFile
#define _XCAFAnimObjects_CustomOperation_HeaderFile

#include <XCAFAnimObjects_Operation.hxx>
#include <NCollection_Array2.hxx>
#include <TCollection_AsciiString.hxx>

//! Custom animation operation that allows defining arbitrary transformations.
//! Unlike predefined operations like rotation or translation, custom operations
//! can represent any kind of transformation by directly providing transformation data
//! as arrays of values. This class can be used to implement specialized operations
//! that don't fit into standard transformation categories.
class XCAFAnimObjects_CustomOperation : public XCAFAnimObjects_Operation
{
public:
//! Constructor for a custom operation with a single keyframe.
//! @param thePresentation Array of values representing the transformation data
//! @param theCustomTypeName Name identifying the type of custom operation
Standard_EXPORT XCAFAnimObjects_CustomOperation(const NCollection_Array1<double>& thePresentation,
const TCollection_AsciiString& theCustomTypeName);

//! Constructor for a custom operation with multiple keyframes.
//! @param thePresentation 2D array of transformation values, where each row corresponds to a
//! keyframe
//! @param theTimeStamps Array of time values corresponding to each keyframe
//! @param theCustomTypeName Name identifying the type of custom operation
Standard_EXPORT XCAFAnimObjects_CustomOperation(const NCollection_Array2<double>& thePresentation,
const NCollection_Array1<double>& theTimeStamps,
const TCollection_AsciiString& theCustomTypeName);

//! Copy constructor.
//! @param theOperation Source operation to copy from
Standard_EXPORT XCAFAnimObjects_CustomOperation(
const Handle(XCAFAnimObjects_CustomOperation)& theOperation);

//! Returns the type identifier for this operation.
//! @return XCAFAnimObjects_OperationType_Custom
XCAFAnimObjects_OperationType GetType() const Standard_OVERRIDE
{
return XCAFAnimObjects_OperationType_Custom;
}

//! Returns a 2D array containing the general presentation of this operation.
//! Each row represents a keyframe, with columns containing the transformation values.
//! @return 2D array of transformation values
NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE
{
return myPresentation;
}

//! Returns the custom type name of this operation.
//! This name can be used to identify specific subtypes of custom operations.
//! @return String identifier for the custom operation type
TCollection_AsciiString GetTypeName() const Standard_OVERRIDE { return myTypeName; }

//! Returns the raw presentation data for the custom operation.
//! This allows direct access to the transformation values.
//! @return 2D array containing the transformation data
const NCollection_Array2<double>& CustomPresentation() const { return myPresentation; }

private:
TCollection_AsciiString myTypeName; //!< Custom operation type identifier
NCollection_Array2<double> myPresentation; //!< 2D array containing transformation data
};

#endif // _XCAFAnimObjects_CustomOperation_HeaderFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#ifndef _XCAFAnimObjects_InterpolationType_HeaderFile
#define _XCAFAnimObjects_InterpolationType_HeaderFile

//! Interpolation is a description of behavior between timestamps
enum XCAFAnimObjects_InterpolationType
{
XCAFAnimObjects_InterpolationType_Custom = 0, //!< User-defined interpolation
XCAFAnimObjects_InterpolationType_Step, //!< No interpolation, just apply timestamps step by step
XCAFAnimObjects_InterpolationType_Linear, //!< Linear dependency from t_(i) to t_(i+1)
XCAFAnimObjects_InterpolationType_CubicSpline, //!< Cubic dependency from t_(i) to t_(i+1)
XCAFAnimObjects_InterpolationType_Static //!< No animation in this time period, use the closest
//!< static value
};

#endif // _XCAFAnimObjects_InterpolationType_HeaderFile
31 changes: 31 additions & 0 deletions src/DataExchange/TKXCAF/XCAFAnimObjects/XCAFAnimObjects_Object.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#include <XCAFAnimObjects_Object.hxx>

IMPLEMENT_STANDARD_RTTIEXT(XCAFAnimObjects_Object, Standard_Transient)

//=================================================================================================

XCAFAnimObjects_Object::XCAFAnimObjects_Object()
: myInterpolationType(XCAFAnimObjects_InterpolationType_Step)
{
}

//=================================================================================================

XCAFAnimObjects_Object::XCAFAnimObjects_Object(const Handle(XCAFAnimObjects_Object)& theObject)
: myInterpolationType(XCAFAnimObjects_InterpolationType_Step),
myOrderedOperations(theObject->myOrderedOperations)
{
}
87 changes: 87 additions & 0 deletions src/DataExchange/TKXCAF/XCAFAnimObjects/XCAFAnimObjects_Object.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#ifndef _XCAFAnimObjects_Object_HeaderFile
#define _XCAFAnimObjects_Object_HeaderFile

#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
#include <NCollection_List.hxx>
#include <XCAFAnimObjects_InterpolationType.hxx>

class XCAFAnimObjects_Operation;

//! The main class representing an animation object in XCAF document.
//! An animation object contains an ordered list of operations that define
//! how a shape should transform over time, along with an interpolation type
//! that specifies how values between key frames should be calculated.
//! Operations can include translations, rotations, scales and other transformations.
class XCAFAnimObjects_Object : public Standard_Transient
{
public:
DEFINE_STANDARD_RTTIEXT(XCAFAnimObjects_Object, Standard_Transient)

public:
//! Default constructor.
//! Creates an empty animation object with the default interpolation type (Step).
Standard_EXPORT XCAFAnimObjects_Object();

//! Copy constructor.
//! Creates a new animation object by copying the operations from another object.
//! @param theObject Source animation object to copy from
Standard_EXPORT XCAFAnimObjects_Object(const Handle(XCAFAnimObjects_Object)& theObject);

//! Adds a new operation to the end of the operations list.
//! Operations are applied sequentially in the order they are added.
//! @param theOperation Operation to add to the animation
void AppendNewOperation(const Handle(XCAFAnimObjects_Operation)& theOperation)
{
myOrderedOperations.Append(theOperation);
}

//! Returns the current interpolation type for this animation.
//! The interpolation type determines how intermediate values between key frames are calculated.
//! @return Current interpolation type
XCAFAnimObjects_InterpolationType GetInterpolationType() const { return myInterpolationType; }

//! Sets the interpolation type for this animation.
//! @param theType Interpolation type to set (Linear, Step, CubicSpline, etc.)
void SetInterpolationType(const XCAFAnimObjects_InterpolationType theType)
{
myInterpolationType = theType;
}

//! Returns a reference to the ordered list of operations.
//! This is a const access that doesn't allow modification.
//! @return Const reference to the list of operations
const NCollection_List<Handle(XCAFAnimObjects_Operation)>& GetOrderedOperations() const
{
return myOrderedOperations;
}

//! Returns a modifiable reference to the ordered list of operations.
//! This allows adding, removing, or reordering operations.
//! @return Non-const reference to the list of operations
NCollection_List<Handle(XCAFAnimObjects_Operation)>& ChangeOrderedOperations()
{
return myOrderedOperations;
}

private:
//! Type of interpolation for this animation
XCAFAnimObjects_InterpolationType myInterpolationType;
//! List of operations in sequence order
NCollection_List<Handle(XCAFAnimObjects_Operation)> myOrderedOperations;
};

#endif // _XCAFAnimObjects_Object_HeaderFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#include <XCAFAnimObjects_Operation.hxx>

IMPLEMENT_STANDARD_RTTIEXT(XCAFAnimObjects_Operation, Standard_Transient)

//=================================================================================================

XCAFAnimObjects_Operation::XCAFAnimObjects_Operation(const bool theIsInverse)
: myIsInverse(theIsInverse)
{
}

//=================================================================================================

XCAFAnimObjects_Operation::XCAFAnimObjects_Operation(
const NCollection_Array1<double>& theTimeStamps,
const bool theIsInverse)
: myIsInverse(theIsInverse),
myTimeStamps(theTimeStamps)
{
}

//=================================================================================================

XCAFAnimObjects_Operation::XCAFAnimObjects_Operation(
const Handle(XCAFAnimObjects_Operation)& theOperation)
: myIsInverse(theOperation->myIsInverse),
myTimeStamps(theOperation->myTimeStamps)
{
}
Loading
Loading