mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0027764: Visualization - add functionality for animation of 3D camera and interactive objects
Added classes AIS_Animation, AIS_AnimationCamera, AIS_AnimationObjectLocatio. Draw Harness command vanimation has been modified to manage animation timeline. Command vfit has been extended with option -noupdate. Formatting of vviewparams command output has been improved. Functionality of commands vlocreset, vlocmove, vloctranslate, vlocrotate, vlocmirror, vlocscale has been merged into vlocation/vsetlocation. vlocation now can print the current local transformation of the object. v3d/ivtk test group does not call vfit anymore. Fixed misprint in test cases bugs/vis/bug24623_3 and bug25532.
This commit is contained in:
@@ -98,6 +98,7 @@ gp_Trsf2d.cxx
|
||||
gp_Trsf2d.hxx
|
||||
gp_Trsf2d.lxx
|
||||
gp_TrsfForm.hxx
|
||||
gp_TrsfNLerp.hxx
|
||||
gp_Vec.cxx
|
||||
gp_Vec.hxx
|
||||
gp_Vec.lxx
|
||||
|
@@ -16,27 +16,45 @@
|
||||
|
||||
#include <gp_Quaternion.hxx>
|
||||
|
||||
/**
|
||||
* Class perform linear interpolation (approximate rotation interpolation),
|
||||
* result quaternion nonunit, its length lay between. sqrt(2)/2 and 1.0
|
||||
*/
|
||||
//! Class perform linear interpolation (approximate rotation interpolation),
|
||||
//! result quaternion nonunit, its length lay between. sqrt(2)/2 and 1.0
|
||||
class gp_QuaternionNLerp
|
||||
{
|
||||
public:
|
||||
|
||||
//! Compute interpolated quaternion between two quaternions.
|
||||
//! @param theStart first quaternion
|
||||
//! @param theEnd second quaternion
|
||||
//! @param theT normalized interpolation coefficient within 0..1 range,
|
||||
//! with 0 pointing to theStart and 1 to theEnd.
|
||||
static gp_Quaternion Interpolate (const gp_Quaternion& theQStart,
|
||||
const gp_Quaternion& theQEnd,
|
||||
Standard_Real theT)
|
||||
{
|
||||
gp_Quaternion aResult;
|
||||
gp_QuaternionNLerp aLerp (theQStart, theQEnd);
|
||||
aLerp.Interpolate (theT, aResult);
|
||||
return aResult;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor,
|
||||
gp_QuaternionNLerp() {}
|
||||
|
||||
//! Constructor with initialization.
|
||||
gp_QuaternionNLerp (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
|
||||
{
|
||||
Init (theQStart, theQEnd);
|
||||
}
|
||||
|
||||
//! Initialize the tool with Start and End values.
|
||||
void Init (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
|
||||
{
|
||||
InitFromUnit (theQStart.Normalized(), theQEnd.Normalized());
|
||||
}
|
||||
|
||||
//! Initialize the tool with Start and End unit quaternions.
|
||||
void InitFromUnit (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
|
||||
{
|
||||
myQStart = theQStart;
|
||||
@@ -55,16 +73,6 @@ public:
|
||||
theResultQ = myQStart + myQEnd * theT;
|
||||
}
|
||||
|
||||
static gp_Quaternion Interpolate (const gp_Quaternion& theQStart,
|
||||
const gp_Quaternion& theQEnd,
|
||||
Standard_Real theT)
|
||||
{
|
||||
gp_Quaternion aResultQ;
|
||||
gp_QuaternionNLerp aNLerp (theQStart, theQEnd);
|
||||
aNLerp.Interpolate (theT, aResultQ);
|
||||
return aResultQ;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
gp_Quaternion myQStart;
|
||||
|
@@ -16,27 +16,45 @@
|
||||
|
||||
#include <gp_Quaternion.hxx>
|
||||
|
||||
/**
|
||||
* Perform Spherical Linear Interpolation of the quaternions,
|
||||
* return unit length quaternion.
|
||||
*/
|
||||
//! Perform Spherical Linear Interpolation of the quaternions,
|
||||
//! return unit length quaternion.
|
||||
class gp_QuaternionSLerp
|
||||
{
|
||||
public:
|
||||
|
||||
//! Compute interpolated quaternion between two quaternions.
|
||||
//! @param theStart first quaternion
|
||||
//! @param theEnd second quaternion
|
||||
//! @param theT normalized interpolation coefficient within 0..1 range,
|
||||
//! with 0 pointing to theStart and 1 to theEnd.
|
||||
static gp_Quaternion Interpolate (const gp_Quaternion& theQStart,
|
||||
const gp_Quaternion& theQEnd,
|
||||
Standard_Real theT)
|
||||
{
|
||||
gp_Quaternion aResult;
|
||||
gp_QuaternionSLerp aLerp (theQStart, theQEnd);
|
||||
aLerp.Interpolate (theT, aResult);
|
||||
return aResult;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor,
|
||||
gp_QuaternionSLerp() {}
|
||||
|
||||
//! Constructor with initialization.
|
||||
gp_QuaternionSLerp (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
|
||||
{
|
||||
Init (theQStart, theQEnd);
|
||||
}
|
||||
|
||||
//! Initialize the tool with Start and End values.
|
||||
void Init (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
|
||||
{
|
||||
InitFromUnit (theQStart.Normalized(), theQEnd.Normalized());
|
||||
}
|
||||
|
||||
//! Initialize the tool with Start and End unit quaternions.
|
||||
void InitFromUnit (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
|
||||
{
|
||||
myQStart = theQStart;
|
||||
|
93
src/gp/gp_TrsfNLerp.hxx
Normal file
93
src/gp/gp_TrsfNLerp.hxx
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2016 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 _gp_TrsfNLerp_HeaderFile
|
||||
#define _gp_TrsfNLerp_HeaderFile
|
||||
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <gp_QuaternionNLerp.hxx>
|
||||
#include <NCollection_Lerp.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
//! Linear interpolation tool for transformation defined by gp_Trsf.
|
||||
//!
|
||||
//! In general case, there is a no well-defined interpolation between arbitrary transformations,
|
||||
//! because desired transient values might vary depending on application needs.
|
||||
//!
|
||||
//! This tool performs independent interpolation of three logical
|
||||
//! transformation parts - rotation (using gp_QuaternionNLerp), translation and scale factor.
|
||||
//! Result of such interpolation might be not what application expects,
|
||||
//! thus this tool might be considered for simple cases or for interpolating between small intervals.
|
||||
template<> class NCollection_Lerp<gp_Trsf>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Empty constructor
|
||||
NCollection_Lerp() {}
|
||||
|
||||
//! Main constructor.
|
||||
NCollection_Lerp (const gp_Trsf& theStart, const gp_Trsf& theEnd)
|
||||
{
|
||||
Init (theStart, theEnd);
|
||||
}
|
||||
|
||||
//! Initialize values.
|
||||
void Init (const gp_Trsf& theStart, const gp_Trsf& theEnd)
|
||||
{
|
||||
myTrsfStart = theStart;
|
||||
myTrsfEnd = theEnd;
|
||||
myLocLerp .Init (theStart.TranslationPart(), theEnd.TranslationPart());
|
||||
myRotLerp .Init (theStart.GetRotation(), theEnd.GetRotation());
|
||||
myScaleLerp.Init (theStart.ScaleFactor(), theEnd.ScaleFactor());
|
||||
}
|
||||
|
||||
//! Compute interpolated value between two values.
|
||||
//! @param theT normalized interpolation coefficient within [0, 1] range,
|
||||
//! with 0 pointing to first value and 1 to the second value.
|
||||
//! @param theResult [out] interpolated value
|
||||
void Interpolate (double theT, gp_Trsf& theResult) const
|
||||
{
|
||||
if (Abs (theT - 0.0) < Precision::Confusion())
|
||||
{
|
||||
theResult = myTrsfStart;
|
||||
return;
|
||||
}
|
||||
else if (Abs (theT - 1.0) < Precision::Confusion())
|
||||
{
|
||||
theResult = myTrsfEnd;
|
||||
return;
|
||||
}
|
||||
|
||||
gp_XYZ aLoc;
|
||||
gp_Quaternion aRot;
|
||||
Standard_Real aScale = 1.0;
|
||||
myLocLerp .Interpolate (theT, aLoc);
|
||||
myRotLerp .Interpolate (theT, aRot);
|
||||
myScaleLerp.Interpolate (theT, aScale);
|
||||
theResult = gp_Trsf();
|
||||
theResult.SetRotation (aRot);
|
||||
theResult.SetTranslationPart (aLoc);
|
||||
theResult.SetScaleFactor (aScale);
|
||||
}
|
||||
|
||||
private:
|
||||
NCollection_Lerp<gp_XYZ> myLocLerp;
|
||||
NCollection_Lerp<Standard_Real> myScaleLerp;
|
||||
gp_QuaternionNLerp myRotLerp;
|
||||
gp_Trsf myTrsfStart;
|
||||
gp_Trsf myTrsfEnd;
|
||||
};
|
||||
|
||||
typedef NCollection_Lerp<gp_Trsf> gp_TrsfNLerp;
|
||||
|
||||
#endif // _gp_TrsfNLerp_HeaderFile
|
Reference in New Issue
Block a user