xstep.cascade.unit doesnt work for STEPControl_Reader in 7.6 version

Hello Team,
Looks like in latest release this parameter doesnt matter for reading data.
I see there is new method SetSystemLengthUnit for this purposes ?

Thanks.
With respects, Eugene.

Kirill Gavrilov's picture

OCCT 7.6.0 now stores length unit information in XCAF document, which required redesigning logic working with units in XDE translations. So that while reading STEP or other model into XCAF document it is now preferred to setup desired system units at document creation time.

Handle(TDocStd_Document) theDoc;
XCAFDoc_LengthUnit::Set (theDoc->Main().Root(), "m", 1.0);

But at the same time, an attempt to preserve compatibility with old API "xstep.cascade.unit" has been done - so that the old code is expected to keep working, with some minor exceptions.

Therefore, a reproducible code sample demonstrating the problem would be helpful. An issue on Bugtracker could be also registered to either fix the bug or to put missing information into Upgrade Guide.

Eugene Zaliznyak's picture

Hello Kirill,
Thank you for your answer.
I believe the problem is in function:
Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepBasic_NamedUnit)& aUnit);

In version 7.5 it was calculation:
lengthFactor = parameter * 1000. / UnitsMethods::GetCasCadeLengthUnit();

But in version 7.6 there is:
const Standard_Real aCascadeUnit = StepData_GlobalFactors::Intance().CascadeUnit();
...
lengthFactor = parameter * 1000. / aCascadeUnit;

Eugene Zaliznyak's picture

I think it is forgotten to add:
if (!model->IsInitializedUnit())
{
XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
model->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
}

also for STEPControl_ActorRead::Transfer as it was done for TEPControl_ActorWrite::Transfer ?

If I am not wrong.

Dmitry Pasukhin's picture

Hello Eugene,

STEPControl_ActorRead or STEPControl_ActorWrite :: Transfer () is a recursive function and will be called many times.

As for a STEPControl_ActorWrite, unit initialization is not the best solution, but it protects against an uninitializable Writers.

As for a STEPControl_ActorRead, thanks for your research. Yes, I agree with you, adding initialization to the current solution is necessary.

I recommend to directly initialize Reader and Writer. This will remove the dependency on internal initialization:

STEPControl_Reader aReader();

aReader.ReadFile (aPath);

XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
aReader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit());

Eugene Zaliznyak's picture

Thank you, Dmitry, we will do it in this way.
With respects, Eugene.