custom properties from STEP to GLTF

Hi guys!
I use STEPCAFControl_Reader for reading step-files and STEPCAFControl_Reader for writing gltf.

Is it possible to get custom properties (like "density" from the attached file) from the intermidiate TDocStd_Document or in any other way?

I need to write it into extra fields of the resulting gltf.

#206=DERIVED_UNIT((#201,#202));
#207=DERIVED_UNIT((#203,#204));
#208=MEASURE_REPRESENTATION_ITEM('density measure',
POSITIVE_RATIO_MEASURE(19.3),#206);
#209=MEASURE_REPRESENTATION_ITEM('density measure',
POSITIVE_RATIO_MEASURE(0.76),#207);
#210=PROPERTY_DEFINITION_REPRESENTATION(#220,#214);
#211=PROPERTY_DEFINITION_REPRESENTATION(#221,#215);
#212=PROPERTY_DEFINITION_REPRESENTATION(#222,#216);
#213=PROPERTY_DEFINITION_REPRESENTATION(#223,#217);
#214=REPRESENTATION('material name',(#218),#2031);
#215=REPRESENTATION('density',(#208),#2031);
#216=REPRESENTATION('material name',(#219),#2032);
#217=REPRESENTATION('density',(#209),#2032);
#218=DESCRIPTIVE_REPRESENTATION_ITEM('\X2\0417043E043B043E0442043E\X0\',
'\X2\0417043E043B043E0442043E\X0\');
#219=DESCRIPTIVE_REPRESENTATION_ITEM('\X2\04140435044004350432043E\X0\
(\X2\043404430431\X0\)','\X2\04140435044004350432043E\X0\ (\X2\043404430431\X0\)');
#220=PROPERTY_DEFINITION('material property','material name',#2051);
#221=PROPERTY_DEFINITION('material property','density of part',#2051);
#222=PROPERTY_DEFINITION('material property','material name',#2052);
#223=PROPERTY_DEFINITION('material property','density of part',#2052);
#224=SURFACE_STYLE_RENDERING_WITH_PROPERTIES($,#253,(#226));
#225=SURFACE_STYLE_RENDERING_WITH_PROPERTIES($,#254,(#227));

Kirill Gavrilov's picture

This specific entity "density" is translated into XCAFDoc_Material within XCAF document, so that you may retrieve it with help of XCAFDoc_MaterialTool::GetDensityForShape() for an appropriate shape label.

Attachments: 
Prajwal Shelar's picture

Hello Kirill,
What is the unit of density returned from XCAFDoc_MaterialTool::GetDensityForShape() ?
Also is there any way to set the mass/density units before importing STEP ?
Thanks & Regards,
Prajwal

gkv311 n's picture

Prajwal Shelar, according to comments in source code, XCAFDoc_MaterialTool::GetDensityForShape() returns g/mm³, while XCAFDoc_Material::GetDensity() returns g/cm³:

Standard_Real XCAFDoc_MaterialTool::GetDensityForShape(const TDF_Label& ShapeL)
{
  Standard_Real Dens=0.0;
  Handle(TDataStd_TreeNode) Node;
  if ( ! ShapeL.FindAttribute ( XCAFDoc::MaterialRefGUID(), Node) ||
       ! Node->HasFather() ) return Dens;
  TDF_Label MatL = Node->Father()->Label();
  Handle(XCAFDoc_Material) MatAttr;
  if(!MatL.FindAttribute(XCAFDoc_Material::GetID(),MatAttr)) {
    return Dens;
  }
  // default dimension fo density - gram/sm^3
  // we transfer "sm" into "mm"
  Dens = MatAttr->GetDensity()*0.001; 
  return Dens;
}

Of course, proper unit information will be returned only in case of a valid STEP file and absence of particular bugs in OCCT translator.

OCCT documentation refers to the following STEP recommended practices, which XCAF translator is supposed to rely on:

Materials are implemented in accordance with Recommended practices for material identification and density section 4. OCCT translator processes materials attached to solids in shape representations. The name, description and density (name and value) are imported for each material.

Prajwal Shelar's picture

Hi,
I tried XCAFDoc_Material::GetDensity() for two STEP files with same material STEEL.
For file 'Difi_000001.stp', I get density value as 7.85 gm/cm3 (unit as you mentioned in previous comment) which is correct.
But for file 'Hinge.step', I get density value as 0.00785 gm/cm3 which is wrong. Is this a bug?
Similarly, XCAFDoc_MaterialTool::GetDensityForShape() also gives wrong results.
I have attached the two STEP files.
I get same result for CAD Assistant as well. https://dev.opencascade.org/content/cad-assistant-v161-wrong-density-mat...
Thanks.

Attachments: