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

// fixed logic problems

This commit is contained in:
dpasukhi 2023-05-28 20:11:07 +01:00 committed by oan
parent 514c451b3a
commit ccb708b8d3
11 changed files with 102 additions and 72 deletions

View File

@ -40,7 +40,7 @@ public:
const NCollection_Array1<double>& TimeStamps() const { return myTimeStamps; }
//!
bool HasTimeStamps() const { return myTimeStamps.IsEmpty(); }
bool HasTimeStamps() const { return !myTimeStamps.IsEmpty(); }
//!
Standard_EXPORT virtual XCAFAnimObjects_OperationType GetType() const = 0;

View File

@ -44,14 +44,14 @@ XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const NCollection_Array1<gp_Quate
XCAFAnimObjects_Orient::XCAFAnimObjects_Orient(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(theTimeStamps),
myOrientPresentation(1, theGeneralPresentation.RowLength())
myOrientPresentation(1, theGeneralPresentation.NbRows())
{
if (theGeneralPresentation.ColLength() != 4)
if (theGeneralPresentation.NbColumns() != 4)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Orient: Incorrect Quaternion general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++)
{
gp_Quaternion aQuat(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),

View File

@ -69,7 +69,7 @@ XCAFAnimObjects_Rotate::XCAFAnimObjects_Rotate(const NCollection_Array2<double>&
{
aNbDouble = 1;
}
if (theGeneralPresentation.ColLength() != aNbDouble)
if (theGeneralPresentation.NbColumns() != aNbDouble)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Rotate: Incorrect Rotate presentation";
}

View File

@ -43,14 +43,14 @@ XCAFAnimObjects_Scale::XCAFAnimObjects_Scale(const NCollection_Array1<gp_XYZ>& t
XCAFAnimObjects_Scale::XCAFAnimObjects_Scale(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(theTimeStamps),
myScalePresentation(1, theGeneralPresentation.RowLength())
myScalePresentation(1, theGeneralPresentation.NbRows())
{
if (theGeneralPresentation.ColLength() != 3)
if (theGeneralPresentation.NbColumns() != 3)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Scale: Incorrect XYZ general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++)
{
gp_XYZ aXYZ(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),

View File

@ -19,7 +19,7 @@
//function : XCAFAnimObjects_Skew
//purpose :
//=======================================================================
XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const Skew& theSkew) :
XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const gp_XYZ& theSkew) :
XCAFAnimObjects_Operation(false),
mySkewPresentation(1, 1)
{
@ -30,7 +30,7 @@ XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const Skew& theSkew) :
//function : XCAFAnimObjects_Skew
//purpose :
//=======================================================================
XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array1<Skew>& theSkew,
XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array1<gp_XYZ>& theSkew,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(theTimeStamps),
mySkewPresentation(theSkew)
@ -43,22 +43,18 @@ XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array1<Skew>& theSk
XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(theTimeStamps),
mySkewPresentation(1, theGeneralPresentation.RowLength())
mySkewPresentation(1, theGeneralPresentation.NbRows())
{
if (theGeneralPresentation.ColLength() != 7)
if (theGeneralPresentation.NbColumns() != 3)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Skew: Incorrect Skew general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++)
{
Skew aSkew{ theGeneralPresentation.Value(aRowInd, 1),
{theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3),
theGeneralPresentation.Value(aRowInd, 4) },
{theGeneralPresentation.Value(aRowInd, 5),
theGeneralPresentation.Value(aRowInd, 6),
theGeneralPresentation.Value(aRowInd, 7)} };
gp_XYZ aSkew(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3));
mySkewPresentation.SetValue(aRowInd, aSkew);
}
}
@ -78,18 +74,14 @@ XCAFAnimObjects_Skew::XCAFAnimObjects_Skew(const Handle(XCAFAnimObjects_Skew)& t
//=======================================================================
NCollection_Array2<double> XCAFAnimObjects_Skew::GeneralPresentation() const
{
NCollection_Array2<double> aRes(1, mySkewPresentation.Length(), 1, 7);
NCollection_Array2<double> aRes(1, mySkewPresentation.Length(), 1, 3);
for (int aRowInd = 1; aRowInd <= mySkewPresentation.Length(); aRowInd++)
{
const Skew& aSkew = mySkewPresentation.Value(aRowInd);
const gp_XYZ& aSkew = mySkewPresentation.Value(aRowInd);
aRes.SetValue(aRowInd, 1, aSkew.Angle);
aRes.SetValue(aRowInd, 2, aSkew.Axis1.X());
aRes.SetValue(aRowInd, 3, aSkew.Axis1.Y());
aRes.SetValue(aRowInd, 4, aSkew.Axis1.Z());
aRes.SetValue(aRowInd, 5, aSkew.Axis2.X());
aRes.SetValue(aRowInd, 6, aSkew.Axis2.Y());
aRes.SetValue(aRowInd, 7, aSkew.Axis2.Z());
aRes.SetValue(aRowInd, 1, aSkew.X());
aRes.SetValue(aRowInd, 2, aSkew.Y());
aRes.SetValue(aRowInd, 3, aSkew.Z());
}
return aRes;
}

View File

@ -15,8 +15,8 @@
#define _XCAFAnimObjects_Skew_HeaderFile
#include <XCAFAnimObjects_Operation.hxx>
#include <gp_Quaternion.hxx>
#include <gp_Ax3.hxx>
#include <gp_XYZ.hxx>
//!
class XCAFAnimObjects_Skew : public XCAFAnimObjects_Operation
@ -24,18 +24,10 @@ class XCAFAnimObjects_Skew : public XCAFAnimObjects_Operation
public:
//!
struct Skew
{
double Angle = 0.; //!<
gp_Dir Axis1; //!<
gp_Dir Axis2; //!<
};
Standard_EXPORT XCAFAnimObjects_Skew(const gp_XYZ& theSkew);
//!
Standard_EXPORT XCAFAnimObjects_Skew(const Skew& theSkew);
//!
Standard_EXPORT XCAFAnimObjects_Skew(const NCollection_Array1<Skew>& theSkew,
Standard_EXPORT XCAFAnimObjects_Skew(const NCollection_Array1<gp_XYZ>& theSkew,
const NCollection_Array1<double>& theTimeStamps);
//!
@ -55,11 +47,11 @@ public:
Standard_EXPORT NCollection_Array2<double> GeneralPresentation() const Standard_OVERRIDE;
//!
const NCollection_Array1<Skew>& SkewPresentation() const { return mySkewPresentation; }
const NCollection_Array1<gp_XYZ>& SkewPresentation() const { return mySkewPresentation; }
private:
NCollection_Array1<Skew> mySkewPresentation; //!<
NCollection_Array1<gp_XYZ> mySkewPresentation; //!<
};
#endif // _XCAFAnimObjects_Skew_HeaderFile

View File

@ -43,33 +43,32 @@ XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const NCollection_Array1<NC
XCAFAnimObjects_Transform::XCAFAnimObjects_Transform(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(theTimeStamps),
myTransformPresentation(1, theGeneralPresentation.RowLength())
myTransformPresentation(1, theGeneralPresentation.NbRows())
{
if (theGeneralPresentation.ColLength() != 16)
if (theGeneralPresentation.NbColumns() != 16)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Transform: Incorrect Mat4x4 general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++)
{
NCollection_Mat4<double> aTransform;
aTransform.SetRow(1, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 1),
aTransform.SetRow(0, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),
theGeneralPresentation.Value(aRowInd, 3),
theGeneralPresentation.Value(aRowInd, 4)));
aTransform.SetRow(2, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 5),
aTransform.SetRow(1, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 5),
theGeneralPresentation.Value(aRowInd, 6),
theGeneralPresentation.Value(aRowInd, 7),
theGeneralPresentation.Value(aRowInd, 8)));
aTransform.SetRow(3, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 9),
aTransform.SetRow(2, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 9),
theGeneralPresentation.Value(aRowInd, 10),
theGeneralPresentation.Value(aRowInd, 11),
theGeneralPresentation.Value(aRowInd, 12)));
aTransform.SetRow(4, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 13),
aTransform.SetRow(3, NCollection_Vec4<double>(theGeneralPresentation.Value(aRowInd, 13),
theGeneralPresentation.Value(aRowInd, 14),
theGeneralPresentation.Value(aRowInd, 15),
theGeneralPresentation.Value(aRowInd, 16)));
myTransformPresentation.SetValue(aRowInd, aTransform);
}
}
@ -94,22 +93,22 @@ NCollection_Array2<double> XCAFAnimObjects_Transform::GeneralPresentation() cons
{
const NCollection_Mat4<double>& aTransform = myTransformPresentation.Value(aRowInd);
aRes.SetValue(aRowInd, 1, aTransform.GetValue(1, 1));
aRes.SetValue(aRowInd, 2, aTransform.GetValue(1, 2));
aRes.SetValue(aRowInd, 3, aTransform.GetValue(1, 3));
aRes.SetValue(aRowInd, 4, aTransform.GetValue(1, 4));
aRes.SetValue(aRowInd, 5, aTransform.GetValue(2, 1));
aRes.SetValue(aRowInd, 6, aTransform.GetValue(2, 2));
aRes.SetValue(aRowInd, 7, aTransform.GetValue(2, 3));
aRes.SetValue(aRowInd, 8, aTransform.GetValue(2, 4));
aRes.SetValue(aRowInd, 9, aTransform.GetValue(3, 1));
aRes.SetValue(aRowInd, 10, aTransform.GetValue(3, 2));
aRes.SetValue(aRowInd, 11, aTransform.GetValue(3, 3));
aRes.SetValue(aRowInd, 12, aTransform.GetValue(3, 4));
aRes.SetValue(aRowInd, 13, aTransform.GetValue(4, 1));
aRes.SetValue(aRowInd, 14, aTransform.GetValue(4, 2));
aRes.SetValue(aRowInd, 15, aTransform.GetValue(4, 3));
aRes.SetValue(aRowInd, 16, aTransform.GetValue(4, 4));
aRes.SetValue(aRowInd, 1, aTransform.GetValue(0, 0));
aRes.SetValue(aRowInd, 2, aTransform.GetValue(0, 1));
aRes.SetValue(aRowInd, 3, aTransform.GetValue(0, 2));
aRes.SetValue(aRowInd, 4, aTransform.GetValue(0, 3));
aRes.SetValue(aRowInd, 5, aTransform.GetValue(1, 0));
aRes.SetValue(aRowInd, 6, aTransform.GetValue(1, 1));
aRes.SetValue(aRowInd, 7, aTransform.GetValue(1, 2));
aRes.SetValue(aRowInd, 8, aTransform.GetValue(1, 3));
aRes.SetValue(aRowInd, 9, aTransform.GetValue(2, 0));
aRes.SetValue(aRowInd, 10, aTransform.GetValue(2, 1));
aRes.SetValue(aRowInd, 11, aTransform.GetValue(2, 2));
aRes.SetValue(aRowInd, 12, aTransform.GetValue(2, 3));
aRes.SetValue(aRowInd, 13, aTransform.GetValue(3, 0));
aRes.SetValue(aRowInd, 14, aTransform.GetValue(3, 1));
aRes.SetValue(aRowInd, 15, aTransform.GetValue(3, 2));
aRes.SetValue(aRowInd, 16, aTransform.GetValue(3, 3));
}
return aRes;
}

View File

@ -44,14 +44,14 @@ XCAFAnimObjects_Translate::XCAFAnimObjects_Translate(const NCollection_Array1<gp
XCAFAnimObjects_Translate::XCAFAnimObjects_Translate(const NCollection_Array2<double>& theGeneralPresentation,
const NCollection_Array1<double>& theTimeStamps) :
XCAFAnimObjects_Operation(theTimeStamps),
myTranslatePresentation(1, theGeneralPresentation.RowLength())
myTranslatePresentation(1, theGeneralPresentation.NbRows())
{
if (theGeneralPresentation.ColLength() != 3)
if (theGeneralPresentation.NbColumns() != 3)
{
Message::SendWarning() << "Warning: XCAFAnimObjects_Translate: Incorrect XYZ general presentation";
return;
}
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.RowLength(); aRowInd++)
for (int aRowInd = 1; aRowInd <= theGeneralPresentation.NbRows(); aRowInd++)
{
gp_XYZ aXYZ(theGeneralPresentation.Value(aRowInd, 1),
theGeneralPresentation.Value(aRowInd, 2),

View File

@ -377,7 +377,7 @@ Handle(XCAFAnimObjects_AnimObject) XCAFDoc_Animation::GetObject() const
{
continue;
}
TCollection_AsciiString aOperName = aOperNameAttr->Get();
const TCollection_AsciiString aOperName = aOperNameAttr->Get();
aNewOperObj = new XCAFAnimObjects_CustomOperation(aValuesArr, aTimeStampsArr, aOperName);
break;
}

View File

@ -23,6 +23,7 @@
#include <TDF_Label.hxx>
#include <TDF_Tool.hxx>
#include <TDocStd_Document.hxx>
#include <XCAFDoc_AnimationTool.hxx>
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_ClippingPlaneTool.hxx>
#include <XCAFDoc_DimTolTool.hxx>
@ -88,6 +89,7 @@ Handle(XCAFDoc_DocumentTool) XCAFDoc_DocumentTool::Set(const TDF_Label& L,
XCAFDoc_NotesTool::Set(NotesLabel(L));
XCAFDoc_ViewTool::Set(ViewsLabel(L));
XCAFDoc_ClippingPlaneTool::Set(ClippingPlanesLabel(L));
XCAFDoc_AnimationTool::Set(AnimationlLabel(L));
}
return A;
}
@ -237,6 +239,17 @@ TDF_Label XCAFDoc_DocumentTool::VisMaterialLabel (const TDF_Label& theLabel)
return aLabel;
}
//=======================================================================
//function : AnimationlLabel
//purpose :
//=======================================================================
TDF_Label XCAFDoc_DocumentTool::AnimationlLabel(const TDF_Label& theLabel)
{
TDF_Label aLabel = DocLabel(theLabel).FindChild(18, Standard_True);
TDataStd_Name::Set(aLabel, "Animation");
return aLabel;
}
//=======================================================================
//function : ShapeTool
//purpose :
@ -294,6 +307,15 @@ Handle(XCAFDoc_VisMaterialTool) XCAFDoc_DocumentTool::VisMaterialTool (const TDF
return XCAFDoc_VisMaterialTool::Set (VisMaterialLabel (theLabel));
}
//=======================================================================
//function : AnimationTool
//purpose :
//=======================================================================
Handle(XCAFDoc_AnimationTool) XCAFDoc_DocumentTool::AnimationTool(const TDF_Label& theLabel)
{
return XCAFDoc_AnimationTool::Set(AnimationlLabel(theLabel));
}
//=======================================================================
//function : CheckVisMaterialTool
//purpose :
@ -308,12 +330,26 @@ Standard_Boolean XCAFDoc_DocumentTool::CheckVisMaterialTool(const TDF_Label& the
return aLabel.IsAttribute(XCAFDoc_VisMaterialTool::GetID());
}
//=======================================================================
//function : CheckAnimationTool
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_DocumentTool::CheckAnimationTool(const TDF_Label& theAcces)
{
TDF_Label aLabel = DocLabel(theAcces).FindChild(18, Standard_False);
if (aLabel.IsNull())
{
return Standard_False;
}
return aLabel.IsAttribute(XCAFDoc_AnimationTool::GetID());
}
//=======================================================================
//function : LayerTool
//purpose :
//=======================================================================
Handle(XCAFDoc_LayerTool) XCAFDoc_DocumentTool::LayerTool (const TDF_Label& acces)
Handle(XCAFDoc_LayerTool) XCAFDoc_DocumentTool::LayerTool (const TDF_Label& acces)
{
return XCAFDoc_LayerTool::Set(LayersLabel(acces));
}

View File

@ -26,6 +26,7 @@
class Standard_GUID;
class TDF_Label;
class TDocStd_Document;
class XCAFDoc_AnimationTool;
class XCAFDoc_ShapeTool;
class XCAFDoc_ColorTool;
class XCAFDoc_ClippingPlaneTool;
@ -92,6 +93,9 @@ public:
//! Returns sub-label of DocLabel() with tag 10.
Standard_EXPORT static TDF_Label VisMaterialLabel (const TDF_Label& theLabel);
//! Returns sub-label of DocLabel() with tag 18.
Standard_EXPORT static TDF_Label AnimationlLabel(const TDF_Label& theLabel);
//! Creates (if it does not exist) ShapeTool attribute on ShapesLabel().
Standard_EXPORT static Handle(XCAFDoc_ShapeTool) ShapeTool (const TDF_Label& acces);
@ -110,10 +114,17 @@ public:
//! Should not be confused with MaterialTool() defining physical/manufacturing materials.
Standard_EXPORT static Handle(XCAFDoc_VisMaterialTool) VisMaterialTool (const TDF_Label& theLabel);
//! Creates (if it does not exist) XCAFDoc_AnimationTool attribute on AnimationLabell().
Standard_EXPORT static Handle(XCAFDoc_AnimationTool) AnimationTool(const TDF_Label& theLabel);
//! Checks for the VisMaterialTool attribute on the label's document
//! Returns TRUE if Tool exists, ELSE if it has not been created
Standard_EXPORT static Standard_Boolean CheckVisMaterialTool(const TDF_Label& theAcces);
//! Checks for the AnimationTool attribute on the label's document
//! Returns TRUE if Tool exists, ELSE if it has not been created
Standard_EXPORT static Standard_Boolean CheckAnimationTool(const TDF_Label& theAcces);
//! Creates (if it does not exist) LayerTool attribute on LayersLabel().
Standard_EXPORT static Handle(XCAFDoc_LayerTool) LayerTool (const TDF_Label& acces);