#include <TCollection_HAsciiString.hxx>
#include <TColStd_SequenceOfHAsciiString.hxx>
#include <TDataStd_Name.hxx>
+#include <TDataStd_RealArray.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDataStd_UAttribute.hxx>
#include <TDF_Attribute.hxx>
IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(XCAFDoc_ShapeTool,TDataStd_GenericEmpty,"xcaf","ShapeTool")
-static Standard_Boolean theAutoNaming = Standard_True;
+namespace
+{
+ static Standard_Boolean THE_AUTO_NAMING_FLAG = Standard_True;
+ static Standard_Boolean THE_UNIFORM_SCALING_SUPPORT_FLAG = Standard_False;
+
+ //=======================================================================
+ //function : GetUniformScaleGUID
+ //purpose :
+ //=======================================================================
+ const Standard_GUID& GetUniformScaleGUID()
+ {
+ static Standard_GUID anUniformScaleID("D4DA66EA-EBAD-4775-ACEC-1A018C6A4501");
+ return anUniformScaleID;
+ }
+}
// attribute methods //////////////////////////////////////////////////
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
mainNode->Append(refNode);
- if (theAutoNaming)
+ if (THE_AUTO_NAMING_FLAG)
SetLabelNameByLink(L);
}
// }
A->SetShape(S);
- if (theAutoNaming)
+ if (THE_AUTO_NAMING_FLAG)
SetLabelNameByShape(ShapeLabel);
// if shape is Compound and flag is set, create assembly
// mark assembly by assigning UAttribute
Handle(TDataStd_UAttribute) Uattr;
Uattr = TDataStd_UAttribute::Set ( ShapeLabel, XCAFDoc::AssemblyGUID() );
- if (theAutoNaming)
+ if (THE_AUTO_NAMING_FLAG)
TDataStd_Name::Set(ShapeLabel, TCollection_ExtendedString("ASSEMBLY"));
// iterate on components
//=======================================================================
//function : SetAutoNaming
-//purpose :
+//purpose :
//=======================================================================
-
void XCAFDoc_ShapeTool::SetAutoNaming (const Standard_Boolean V)
{
- theAutoNaming = V;
+ THE_AUTO_NAMING_FLAG = V;
}
-
//=======================================================================
//function : AutoNaming
-//purpose :
+//purpose :
//=======================================================================
-
Standard_Boolean XCAFDoc_ShapeTool::AutoNaming()
{
- return theAutoNaming;
+ return THE_AUTO_NAMING_FLAG;
}
+//=======================================================================
+//function : SetUniformScalingSupport
+//purpose :
+//=======================================================================
+void XCAFDoc_ShapeTool::SetUniformScalingSupport(const Standard_Boolean theSupportFlag)
+{
+ THE_UNIFORM_SCALING_SUPPORT_FLAG = theSupportFlag;
+}
//=======================================================================
-//function : ComputeShapes
-//purpose :
+//function : UniformScalingSupport
+//purpose :
//=======================================================================
+Standard_Boolean XCAFDoc_ShapeTool::UniformScalingSupport()
+{
+ return THE_UNIFORM_SCALING_SUPPORT_FLAG;
+}
+//=======================================================================
+//function : GetShapeUniformScale
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFDoc_ShapeTool::GetShapeUniformScale(const TDF_Label& theShLabel,
+ double& theDX,
+ double& theDY,
+ double& theDZ)
+{
+ if (theShLabel.IsNull())
+ {
+ return Standard_False;
+ }
+ Handle(TDataStd_RealArray) anArrAttr;
+ if (!theShLabel.FindAttribute(GetUniformScaleGUID(), anArrAttr) ||
+ anArrAttr->Length() != 3)
+ {
+ return Standard_False;
+ }
+ theDX = anArrAttr->Value(1);
+ theDY = anArrAttr->Value(2);
+ theDZ = anArrAttr->Value(3);
+}
+
+//=======================================================================
+//function : SetShapeUniformScale
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFDoc_ShapeTool::SetShapeUniformScale(const TDF_Label& theShLabel,
+ const double theDX,
+ const double theDY,
+ const double theDZ)
+{
+ if (!IsShape(theShLabel))
+ {
+ return Standard_False;
+ }
+ Handle(TDataStd_RealArray) anArray = TDataStd_RealArray::Set(theShLabel, GetUniformScaleGUID(), 1, 3);
+ anArray->SetValue(1, theDX);
+ anArray->SetValue(2, theDY);
+ anArray->SetValue(3, theDZ);
+}
+
+//=======================================================================
+//function : ComputeShapes
+//purpose :
+//=======================================================================
void XCAFDoc_ShapeTool::ComputeShapes(const TDF_Label& L)
{
TDF_ChildIterator it(L);
TDF_TagSource aTag;
TDF_Label UpperSubL = aTag.NewChild( labels( 1 ) );
- if (theAutoNaming) {
+ if (THE_AUTO_NAMING_FLAG) {
TCollection_ExtendedString Entry("SHUO");
TDataStd_Name::Set(UpperSubL, TCollection_ExtendedString( Entry ));
}
// add other next_usage occurrences.
for (i = 2; i <= labels.Length(); i++) {
TDF_Label NextSubL = aTag.NewChild( labels( i ) );
- if (theAutoNaming) {
+ if (THE_AUTO_NAMING_FLAG) {
TCollection_ExtendedString EntrySub("SHUO-");
EntrySub += i;
TDataStd_Name::Set(NextSubL, TCollection_ExtendedString( EntrySub ));
//! Returns current auto-naming mode. See SetAutoNaming() for
//! description.
Standard_EXPORT static Standard_Boolean AutoNaming();
+
+ //! Sets uniform scaling support mode to <theSupportFlag>.
+ //! If True then some DataExchange components be able to keep
+ //! uniform scale information into special XCAF attribute.
+ //!
+ //! This setting is global; it cannot be made a member function
+ //! as it is used by static methods as well.
+ //! By default, uniform scaling support is disable.
+ //! See also UniformScalingSupport().
+ Standard_EXPORT static void SetUniformScalingSupport (const Standard_Boolean theSupportFlag);
+
+ //! Returns current niform scaling support mode.
+ //! See SetUniformScalingSupport() for description.
+ Standard_EXPORT static Standard_Boolean UniformScalingSupport();
+
+ //! Gets uniform scale values from the label.
+ //! @return true if scaling is support and attribute is exist
+ Standard_EXPORT static Standard_Boolean GetShapeUniformScale(const TDF_Label& theShLabel,
+ double& theDX,
+ double& theDY,
+ double& theDZ);
+
+ //! Sets uniform scale values on the label.
+ //! @return true if scaling is support and label contains shape
+ Standard_EXPORT static Standard_Boolean SetShapeUniformScale(const TDF_Label& theShLabel,
+ const double theDX,
+ const double theDY,
+ const double theDZ);
//! recursive
Standard_EXPORT void ComputeShapes (const TDF_Label& L);