1

I'm working on reading a STEP file into my C++ application, translating it into OCCT shapes, and displaying them using VTK. Everything seems to be working fine EXCEPT the scale. The shape I'm importing is just under 20 mm in diameter according to a 3D viewer (which matches what it was when I exported it from my app), but when I import it, it displays as the expected shape but at just under 20 meters in diameter. The program uses meters internally; OCCT appears to be ignoring units during import.

My program runs the following on initialization:

STEPControl_Controller::Init();
Interface_Static::SetCVal("xstep.cascade.unit","M");

The import code is:

STEPControl_Reader rdr;
IFSelect_ReturnStatus ret = rdr.ReadFile(filname);
if (ret == IFSelect_RetDone)
{
    int navail = rdr.NbRootsForTransfer();
    debugPrint("Found ",std::to_string(navail)," roots available");
    int nroots = rdr.TransferRoots();
    debugPrint("Transferred ",std::to_string(nroots)," roots");
    TopoDS_Shape s = rdr.OneShape();
    
    // Process the returned shape for display after this...
}

I've tried changing the value of "xstep.cascade.unit", and it has no effect on the size of the imported shape. It works as expected when exporting OCCT shapes to a STEP file, but not importing. Is there some parameter or initialization step I'm missing? We're using OCCT version 7.6.0.

ADDENDUM: I did check inside the STEP file, and the units are recorded with lines like:

#68 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) );

So it shouldn't be a matter of not knowing what it's translating from.

mastick
  • 31
  • 3
  • 1
    Make sure to use bug-fixes from maintenance releases - e.g. OCCT 7.6.1 includes a bugfix for length units import: https://github.com/Open-Cascade-SAS/OCCT/releases/tag/V7_6_1 – gkv311 Mar 30 '22 at 18:52
  • Hadn't seen that one - the main site still listed 7.6.0 as the latest. Will give that a try. Fingers crossed... – mastick Mar 30 '22 at 19:16
  • Finally got it installed and that did indeed fix the issue. Thanks! – mastick Mar 31 '22 at 15:23

0 Answers0