mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0031382: Data Exchange - BinXCAF should preserve length unit information
Possibility for adding LengthUnit info to XCAF document using special class XCAFDoc_LenghtUnit and XCAFDoc_LenghtUnitTool is implemented. Package UnitsMethods is split: geom methods were placed to new file GeomConvert_Units which is in the toolkit TKXSBase, internal step scale factors was placed to StepData. Updated UnitMethods to convert scale factor to different unit types. Now, XSAlgo::XSAlgo_AlgoContainer is used to update unit info from static interface values. New Draw command "XSetLengthUnit" and "XGetLengthUnit" for set or get XDE attribute. Upgraded tests for STEP, IGES, OBJ, glTF, VRML formats to check area regressing with used unit. Upgraded tests\de test cases to use any units in the "loop back" algorithms.
This commit is contained in:
@@ -29,11 +29,13 @@
|
||||
#include <XCAFDoc_ClippingPlaneTool.hxx>
|
||||
#include <XCAFDoc_DimTolTool.hxx>
|
||||
#include <XCAFDoc_LayerTool.hxx>
|
||||
#include <XCAFDoc_LengthUnit.hxx>
|
||||
#include <XCAFDoc_MaterialTool.hxx>
|
||||
#include <XCAFDoc_NotesTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_ViewTool.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
#include <UnitsMethods.hxx>
|
||||
|
||||
IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(XCAFDoc_DocumentTool,TDataStd_GenericEmpty,"xcaf","DocumentTool")
|
||||
|
||||
@@ -329,6 +331,76 @@ Handle(XCAFDoc_NotesTool) XCAFDoc_DocumentTool::NotesTool(const TDF_Label& acces
|
||||
return XCAFDoc_NotesTool::Set(NotesLabel(acces));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLengthUnit
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_DocumentTool::GetLengthUnit(const Handle(TDocStd_Document)& theDoc,
|
||||
Standard_Real& theResult,
|
||||
const UnitsMethods_LengthUnit theBaseUnit)
|
||||
{
|
||||
if (theDoc.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
Handle(XCAFDoc_LengthUnit) aLengthAttr;
|
||||
if (theDoc->Main().Root().FindAttribute(XCAFDoc_LengthUnit::GetID(), aLengthAttr))
|
||||
{
|
||||
theResult = aLengthAttr->GetUnitValue() *
|
||||
UnitsMethods::GetLengthUnitScale(UnitsMethods_LengthUnit_Meter, theBaseUnit);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLengthUnit
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_DocumentTool::GetLengthUnit(const Handle(TDocStd_Document)& theDoc,
|
||||
Standard_Real& theResult)
|
||||
{
|
||||
if (theDoc.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
Handle(XCAFDoc_LengthUnit) aLengthAttr;
|
||||
if (theDoc->Main().Root().FindAttribute(XCAFDoc_LengthUnit::GetID(), aLengthAttr))
|
||||
{
|
||||
theResult = aLengthAttr->GetUnitValue();
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLengthUnit
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_DocumentTool::SetLengthUnit(const Handle(TDocStd_Document)& theDoc,
|
||||
const Standard_Real theUnitValue,
|
||||
const UnitsMethods_LengthUnit theBaseUnit)
|
||||
{
|
||||
// Sets length unit info
|
||||
TCollection_AsciiString aUnitName = UnitsMethods::DumpLengthUnit(theUnitValue, theBaseUnit);
|
||||
const Standard_Real aScaleFactor = theUnitValue *
|
||||
UnitsMethods::GetLengthUnitScale(theBaseUnit, UnitsMethods_LengthUnit_Meter);
|
||||
XCAFDoc_LengthUnit::Set(theDoc->Main().Root(), aUnitName, aScaleFactor);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLengthUnit
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_DocumentTool::SetLengthUnit(const Handle(TDocStd_Document)& theDoc,
|
||||
const Standard_Real theUnitValue)
|
||||
{
|
||||
// Sets length unit info
|
||||
TCollection_AsciiString aUnitName =
|
||||
UnitsMethods::DumpLengthUnit(theUnitValue, UnitsMethods_LengthUnit_Meter);
|
||||
XCAFDoc_LengthUnit::Set(theDoc->Main().Root(), aUnitName, theUnitValue);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
|
Reference in New Issue
Block a user