Large step file size

Hello,

Im working on an application where i read a step file, but i have issues with large file sizes. I have a large step file of 50MB, and when i export a small sub assembly of this file, the size is more than 40MB.

//reading
STEPCAFControl_Reader Reader;
Handle(TDocStd_Application) app = new TDocStd_Application;
BinXCAFDrivers::DefineFormat(app);
app->NewDocument("BinXCAF", doc);
Reader.ReadFile(filename);
Reader.Transfer(doc);

//writing
Handle(TDocStd_Application) newApp = new TDocStd_Application();
Handle(TDocStd_Document) newDoc;
newApp->NewDocument("NewDocumentFormat", newDoc);
Handle(XCAFDoc_ShapeTool) newShapeTool = XCAFDoc_DocumentTool::ShapeTool(newDoc->Main());
TDF_Label emptyShape = newShapeTool->NewShape();
newShapeTool->AddComponent(emptyShape, reflabel, mytrsf); //reflabel is my small subassembly
STEPCAFControl_Writer writer;
writer.Write(Path.c_str());

I'm affraid i can not share the step file with you. If it is really neccesary, I could find a different step file online and try to replicate this scenario. Maybe there is something wrong about the way i am reading or exporting the file? Or maybe this is a known issue in Open Cascade?

Dmitrii Pasukhin's picture

There can be a lot of  reason of growing up of the file size: different ISO version(214, 242 ...), writing PCurve, dummy entities.

If you be able to share a file, which helps us to reproduce - I will be able to help you.

Best regards, Dmitrii.

martijn db's picture

Hey Pasukhin, thanks for the fast response! I found a step file online. It's not as big as my private step file, but the same thing happens. The exported sub-assembly is even larger than the original file in this case. See the attachments. I also included my exported sub assembly.

Attachments: 
Dmitrii Pasukhin's picture

I was right. There a lot of new PCurve and more.

You need to modify static parameters to disable writing PCurves.

#include <UnitsMethods_LengthUnit.hxx>
 
 enum WriteMode_PrecisionMode
  {
    WriteMode_PrecisionMode_Least = -1,
    WriteMode_PrecisionMode_Average = 0,
    WriteMode_PrecisionMode_Greatest = 1,
    WriteMode_PrecisionMode_Session = 2
  };
  enum WriteMode_Assembly
  {
    WriteMode_Assembly_Off = 0,
    WriteMode_Assembly_On,
    WriteMode_Assembly_Auto
  };
  enum WriteMode_StepSchema
  {
    WriteMode_StepSchema_AP214CD = 1,
    WriteMode_StepSchema_AP214DIS,
    WriteMode_StepSchema_AP203,
    WriteMode_StepSchema_AP214IS,
    WriteMode_StepSchema_AP242DIS
  };
  enum WriteMode_VertexMode
  {
    WriteMode_VertexMode_OneCompound = 0,
    WriteMode_VertexMode_SingleVertex
  };
  STEPCAFControl_Controller::Init();
  Interface_Static::SetIVal("write.precision.mode", WriteMode_PrecisionMode_Average);
  Interface_Static::SetRVal("write.precision.val", 0.001);
  Interface_Static::SetIVal("write.step.assembly", WriteMode_Assembly_Off);
  Interface_Static::SetIVal("write.step.schema", WriteMode_StepSchema_AP242DIS);
  Interface_Static::SetIVal("write.surfacecurve.mode", false);
  Interface_Static::SetIVal("write.step.unit", UnitsMethods_LengthUnit_Millimeter);
  Interface_Static::SetIVal("write.step.vertex.mode", WriteMode_VertexMode_OneCompound);
  Interface_Static::SetIVal("write.stepcaf.subshapes.name", false);

Best regards, Dmitrii.

martijn db's picture

Works like a charm, you are amazing. Thanks!