]> OCCT Git - occt.git/commitdiff
0033660: Data Exchange, Step Import - Adding product attributes to metadata CR33660
authorichesnok <ichesnok@opencascade.com>
Mon, 1 Apr 2024 11:13:15 +0000 (12:13 +0100)
committerichesnok <ichesnok@opencascade.com>
Mon, 1 Apr 2024 15:05:25 +0000 (16:05 +0100)
Attributes of product was added to metadata.

12 files changed:
src/STEPCAFControl/STEPCAFControl_Reader.cxx
tests/metadata/end
tests/metadata/step/A1
tests/metadata/step/A2
tests/metadata/step/A3
tests/metadata/step/A4
tests/metadata/step/A5
tests/metadata/step/A6
tests/metadata/step/A7
tests/metadata/step/A8
tests/metadata/step/A9
tests/metadata/step/begin [deleted file]

index 08a7364b1ec87eb6570e52db39fbbc7ab6219190..515848e93e0f8fdad0384703a868ce88e30c6895 100644 (file)
@@ -4957,9 +4957,47 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
   Standard_Integer aNb = aModel->NbEntities();
   STEPConstruct_Tool aTool(theWS);
 
+  TDF_LabelMap aGeneralLabelMap;
+  NCollection_DataMap<TDF_Label, NCollection_Sequence<Handle(StepRepr_PropertyDefinition)>, TDF_LabelMapHasher> anAttrMap;
+  NCollection_DataMap<TDF_Label, NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>>, TDF_LabelMapHasher> anExtraAttrMap;
   for (Standard_Integer anEntityInd = 1; anEntityInd <= aNb; ++anEntityInd)
   {
     Handle(Standard_Transient) anEntity = aModel->Value(anEntityInd);
+
+    // checking for Product attributes
+    Handle(StepBasic_ProductDefinition) aProdDefinition = Handle(StepBasic_ProductDefinition)::DownCast(anEntity);
+    if (!aProdDefinition.IsNull())
+    {
+      Handle(Transfer_Binder) aBinder = aTP->Find(aProdDefinition);
+      if (!aBinder.IsNull())
+      {
+        TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, aBinder);
+        if (aShape.IsNull())
+          continue;
+
+        TDF_Label aShapeLabel;
+        if (myMap.IsBound(aShape))
+        {
+          aShapeLabel = myMap.Find(aShape);
+        }
+        if (!aShapeLabel.IsNull())
+        {
+          if (!aGeneralLabelMap.Contains(aShapeLabel))
+          {
+            aGeneralLabelMap.Add(aShapeLabel);
+          }
+          NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>> anAttrSeq;
+          Handle(StepBasic_Product) aProduct = aProdDefinition->Formation()->OfProduct();
+          anAttrSeq.Append({ "ProductID", aProduct->Id() });
+          anAttrSeq.Append({ "ProductName", aProduct->Name() });
+          anAttrSeq.Append({ "Description", aProduct->Description() });
+          anAttrSeq.Append({ "ProductDefinition", aProdDefinition->Description() });
+          anExtraAttrMap.Bind(aShapeLabel, anAttrSeq);
+        }
+      }
+    }
+
+    // checking for User Defined Attributes
     Handle(StepBasic_GeneralProperty) aGeneralProp = Handle(StepBasic_GeneralProperty)::DownCast(anEntity);
     if (aGeneralProp.IsNull())
       continue;
@@ -4979,13 +5017,13 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
     if (aPropDefinitionList.IsEmpty())
       continue;
 
+    NCollection_List<Handle(StepRepr_PropertyDefinition)> aGroupedProperties;
     NCollection_List< Handle(StepRepr_PropertyDefinition)>::Iterator aPropDefIter(aPropDefinitionList);
     for ( ; aPropDefIter.More(); aPropDefIter.Next())
     {
       Handle(StepRepr_PropertyDefinition) aPropDefinition = aPropDefIter.Value();
 
       // check group of PropertyDefinition
-      NCollection_List<Handle(StepRepr_PropertyDefinition)> aGroupedProperties;
       Interface_EntityIterator aSharingsListOfPD = theWS->Graph().Sharings(aPropDefinition);
       for (aSharingsListOfPD.Start(); aSharingsListOfPD.More(); aSharingsListOfPD.Next())
       {
@@ -5134,28 +5172,78 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
         if (!aShapeLabel.IsNull())
         {
           aLabelSeq.Append(aShapeLabel);
+          if (!aGeneralLabelMap.Contains(aShapeLabel))
+          {
+            aGeneralLabelMap.Add(aShapeLabel);
+          }
         }
       }
 
-      //create metadata
+      // fill user defined attribute map
       for (TDF_LabelSequence::Iterator aLabelIt(aLabelSeq); aLabelIt.More(); aLabelIt.Next())
       {
-        TDF_Label aLabel = aLabelIt.Value();
-        Handle(TDataStd_NamedData) anAttr;
-        if (!aLabel.FindAttribute(TDataStd_NamedData::GetID(), anAttr))
+        if (anAttrMap.IsBound(aLabelIt.Value()))
+        {
+          anAttrMap.ChangeFind(aLabelIt.Value()).Append(aPropDefinition);
+          if (!aGroupedProperties.IsEmpty())
+          {
+            NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(aGroupedProperties);
+            for (; aPropIt.More(); aPropIt.Next())
+            {
+              anAttrMap.ChangeFind(aLabelIt.Value()).Append(aPropIt.Value());
+            }
+          }
+        }
+        else
         {
-          anAttr = new TDataStd_NamedData;
-          aLabel.AddAttribute(anAttr);
+          NCollection_Sequence<Handle(StepRepr_PropertyDefinition)> aPropSeq;
+          aPropSeq.Append(aPropDefinition);
+          if (!aGroupedProperties.IsEmpty())
+          {
+            NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(aGroupedProperties);
+            for (; aPropIt.More(); aPropIt.Next())
+            {
+              aPropSeq.Append(aPropIt.Value());
+            }
+          }
+          anAttrMap.Bind(aLabelIt.Value(), aPropSeq);
         }
+      }
+    }
+  }
 
-        fillAttributes(theWS, aPropDefinition, anAttr);
-        if (!aGroupedProperties.IsEmpty())
+  // create metadata
+  for (TDF_LabelMap::Iterator aLabelIt(aGeneralLabelMap); aLabelIt.More(); aLabelIt.Next())
+  {
+    Handle(TDataStd_NamedData) anAttr;
+    if (!aLabelIt.Value().FindAttribute(TDataStd_NamedData::GetID(), anAttr))
+    {
+      anAttr = new TDataStd_NamedData;
+      aLabelIt.Value().AddAttribute(anAttr);
+    }
+    if (anAttrMap.IsBound(aLabelIt.Value()))
+    {
+      NCollection_Sequence<Handle(StepRepr_PropertyDefinition)> anAttrib = anAttrMap.Find(aLabelIt.Value());
+      NCollection_Sequence<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(anAttrib);
+      for (; aPropIt.More(); aPropIt.Next())
+      {
+        fillAttributes(theWS, aPropIt.Value(), anAttr);
+      }
+    }
+    if (anExtraAttrMap.IsBound(aLabelIt.Value()))
+    {
+      NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>> aStrSeq = anExtraAttrMap.Find(aLabelIt.Value());
+      if (!aStrSeq.IsEmpty())
+      {
+        NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>>::Iterator anIt(aStrSeq);
+        for (; anIt.More(); anIt.Next())
         {
-          NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(aGroupedProperties);
-          for ( ; aPropIt.More(); aPropIt.Next())
+          auto aPair = anIt.Value();
+          if (aPair.second.IsNull())
           {
-            fillAttributes(theWS, aPropIt.Value(), anAttr);
+            continue;
           }
+          anAttr->SetString(aPair.first, aPair.second->String());
         }
       }
     }
index fc085fc91108cff2e00353f1ada755cd959abbab..b4a6b04b2b7bd772ea030169b9ba35b9713dfa27 100644 (file)
@@ -11,7 +11,7 @@ set end_line "\" \n"
 # Read original file
 if { [string length $filename] > 1} {
   set path_file [locate_data_file $filename]
-  if { [catch { ReadFile D $path_file -conf $conf} catch_result] } {
+  if { [catch { ReadFile D $path_file} catch_result] } {
     set err_msg "Error: file was not read - exception "
     puts $err_msg
     append todo_msg $todo_mask $err_msg $end_line
index fb28d05518ef2aad83310c5a220dd20039be373a..14555c4e4d5293701e21df0c2d3029ee31075f7c 100644 (file)
@@ -4,6 +4,9 @@ set filename bug28345_30338.stp
 set ref_data {
 Property for [0:1:1:1]:
 H_CIP : 55.545955351400004
+ProductID : MVE0300X02S030_ASM
+Description : NOT SPECIFIED
+ProductName : MVE0300X02S030_ASM
 Property for [0:1:1:2]:
 A : 3
 B : 16
@@ -13,8 +16,11 @@ E : 55
 F : 0.29999999999999999
 H : 45
 I : 15
+ProductID : CUT_MVE0300X02S030
 MODELED_BY : 
 DESCRIPTION : 
+Description : NOT SPECIFIED
+ProductName : CUT_MVE0300X02S030
 Property for [0:1:1:3]:
 A : 3
 B : 16
@@ -24,7 +30,10 @@ E : 55
 F : 0.29999999999999999
 H : 45
 I : 15
+ProductID : NOCUT_MVE0300X02S030
 MODELED_BY : 
 DESCRIPTION : 
+Description : NOT SPECIFIED
+ProductName : NOCUT_MVE0300X02S030
 
 }
index 9c8f9f9c6473786d03b8f7ec0134df8763cf930a..b3871109e2428d82fc94c9b274f9f8071d137c9b 100644 (file)
@@ -22,6 +22,7 @@ Iyx : 2.044e-07
 Iyy : 3.6385e-06
 Iyz : -1.2030000000000001e-07
 zCenterOfGravity : -0.056064514900000001
+ProductID : SHEET METAL F3D
 JoggleFormula : 
 
 }
index 9a041d7ff08b642ce30bcce4a2775b5d651b539b..1d2020db0648d50a06447730c6e3d3b502cb1ae7 100644 (file)
@@ -20,5 +20,7 @@ Iyy : 4.46342e-05
 Iyz : -1.3068999999999999e-06
 zCenterOfGravity : -0.10963042420000001
 Length : 0
+ProductID : NIST PMI FTC 06 ASME1
+Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
 
 }
index fe1470690b870668d32a9b7a016584734c32dc57..acd99574e044025150f7c164d608e361b7ff8906 100644 (file)
@@ -603,6 +603,7 @@ BOHR_TIEFE DESCRIPTION : NULL
 STEIGUNG SOURCE : Mass Properties
 D_LAST_MODIFIED SOURCE : User-Defined
 PRO_MP_ALT_IXX SOURCE : Alternate Mass Prop
+ProductID : REV_PART_NEU_01
 PRO_MP_TRF_21 SOURCE : Mass Properties
 PRO_MP_TRF_41 : ->
 PROI_RELEASE ACCESS : Limited
index c3833d11f3c784f67b315da3594630ad8f09324e..4c9c2d39195fb655e7f82d879438e5f082379f4a 100644 (file)
@@ -8,6 +8,7 @@ FILESIZE : 1495040
 MaterialMultipleAssigned : FALSE
 FILESAVETIME : Tue Dec 09 03:47:24 2014
 Revision : D
+ProductID : nist_ctc_05_asme1
 CAD_SOURCE : ug
 Description : NIST PMI test model downloaded from http://go.usa.gov/mGVm
 ATTR_VERSION : 18.3.001
@@ -15,5 +16,6 @@ FILENAME : nist_ctc_05_asme1.prt
 MTIME : 1418096844
 MaterialMissingAssignments : TRUE
 Part Number : NIST PMI CTC 05 ASME1
+ProductName : nist_ctc_05_asme1
 
 }
index a34fcd93cc87585539b15230d158ddd636517efb..dd8647b921ef95dd97adec73c8f59ee2821842b2 100644 (file)
@@ -27,9 +27,11 @@ FINISH : BLACK OXIDE
 NOTES : 
 LENGTH : STUB
 SHANK_IM : M
+ProductID : Tool1
 MODELED_BY : LSD
 STANDARD_BODY_DIA : Y
 DESCRIPTION : T-A HOLDER
+Description : NOT SPECIFIED
 SS_FLANGE : NO
 MATERIAL : STEEL
 DEEP_HOLE_NOTES : 
@@ -38,5 +40,6 @@ SHANK : ER
 FLUTE : STRAIGHT
 SERIES : Y
 DEEP_HOLE_WEBSITE : 
+ProductName : Tool1
 
 }
index 06148694538784324adfa4e47a55465152704904..c24e619d9a1329418d91652928db720744ddef76 100644 (file)
@@ -226,6 +226,7 @@ PRO_MP_TRF_32 : - >
 PRO_MP_TRF_33 : - >
 PRO_MP_VOLUME DESIGNATED : NO
 PRO_MP_ALT_IXX SOURCE : Alternate Mass Prop
+ProductID : NIST_CTC_04_ASME1_RD_CR4050_RA
 PRO_MP_TRF_21 SOURCE : Mass Properties
 PRO_MP_TRF_41 : - >
 PRO_MP_TRF_42 : - >
index aeed101adf5d9a5f59a1953725485281d017f547..1823854491d071f11f44fda57ffde6ec33d32398 100644 (file)
@@ -24,6 +24,7 @@ REFERENCE :
 PART_NUMBER : 
 REFERENCE_DESIGNATION== : 
 LANGUAGE : 
+ProductID : Block
 TECHNICAL_SPECIFICATION : 
 MODEL_3D_APPROVED_BY_DEPARTMENT : 
 PROJECT : 
@@ -43,12 +44,14 @@ PART_SOURCE :
 GENERAL_TOLERANCES : 
 MODEL_3D_CHECKED_BY : 
 SPARE_WEARING_PART : 
+Description : Block
 ARTICLE_NUMBER : 
 TOLERANCING_PRINCIPLE : 
 REFERENCE_DESIGNATION= : 
 MATERIAL : 
 EDGE_CONDITION_INNER_EDGE : 
 SURFACE_PROTECTION : 
+ProductDefinition :  
 SUPPLIER_NUMBER : 
 SEMI_FINISHED_PRODUCT : 
 SIMPLIFIED_DRAWING_REVISION : 
index f4ec55d95378943efc44ce3462ecd2e0dde358f0..f7b15e3741d3fc75480e1ed3c06442cf9883eb0e 100644 (file)
@@ -4,7 +4,10 @@ set filename nist_ftc_08_asme1_ap242-2.stp
 set ref_data {
 Property for [0:1:1:1]:
 Revision : C
+ProductID : NIST PMI FTC 08 ASME1
 DescriptionRef : NIST PMI test model downloaded from http://go.usa.gov/mGVm
 PartNumber : NIST PMI FTC 08 ASME1
+ProductDefinition :  
+ProductName : NIST PMI FTC 08 ASME1
 
 }
diff --git a/tests/metadata/step/begin b/tests/metadata/step/begin
deleted file mode 100644 (file)
index 95e00a7..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-set conf "provider.STEP.OCC.read.metadata : 1"
-