1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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:
dpasukhi
2020-11-10 07:52:30 +03:00
committed by bugmaster
parent 9592ae247b
commit da80ff68f1
106 changed files with 2258 additions and 662 deletions

View File

@@ -228,6 +228,7 @@
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_GeomTolerance.hxx>
#include <XCAFDoc_GraphNode.hxx>
#include <XCAFDoc_LengthUnit.hxx>
#include <XCAFDoc_LayerTool.hxx>
#include <XCAFDoc_Material.hxx>
#include <XCAFDoc_MaterialTool.hxx>
@@ -240,8 +241,11 @@
#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
#include <XCAFPrs_DataMapOfStyleShape.hxx>
#include <XCAFPrs_Style.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSControl_TransferWriter.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
// added by skl 15.01.2004 for D&GT writing
//#include <StepRepr_CompoundItemDefinition.hxx>
@@ -359,6 +363,25 @@ IFSelect_ReturnStatus STEPCAFControl_Writer::Write (const Standard_CString filen
return status;
}
//=======================================================================
//function : prepareUnit
//purpose :
//=======================================================================
void STEPCAFControl_Writer::prepareUnit(const TDF_Label& theLabel,
const Handle(StepData_StepModel)& theModel)
{
Handle(XCAFDoc_LengthUnit) aLengthAttr;
if (!theLabel.IsNull() &&
theLabel.Root().FindAttribute(XCAFDoc_LengthUnit::GetID(), aLengthAttr))
{
theModel->SetLocalLengthUnit(aLengthAttr->GetUnitValue() * 1000); // convert to mm
}
else
{
XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
theModel->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
}
}
//=======================================================================
//function : Transfer
@@ -516,6 +539,8 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer,
Handle(STEPCAFControl_ActorWrite) Actor =
Handle(STEPCAFControl_ActorWrite)::DownCast ( writer.WS()->NormAdaptor()->ActorWrite() );
const Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(writer.WS()->Model());
prepareUnit(labels.First(), aModel); // set local length unit to the model
// translate free top-level shapes of the DECAF document
Standard_Integer ap = Interface_Static::IVal ("write.step.schema");
TDF_LabelSequence sublabels;
@@ -659,10 +684,9 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer,
WriteMaterials(writer.WS(),sublabels);
// register all MDGPRs in model
const Handle(Interface_InterfaceModel) &Model = writer.WS()->Model();
MoniTool_DataMapIteratorOfDataMapOfShapeTransient anItr(myMapCompMDGPR);
for (; anItr.More(); anItr.Next())
Model->AddWithRefs( anItr.Value() );
aModel->AddWithRefs( anItr.Value() );
}
if ( multi ) { // external refs