diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 08a7364b1e..29840c5d9a 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -4957,9 +4957,40 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work Standard_Integer aNb = aModel->NbEntities(); STEPConstruct_Tool aTool(theWS); + TDF_LabelMap aGeneralLabelMap; + NCollection_DataMap, TDF_LabelMapHasher> anAttrMap; + NCollection_DataMap>, 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()) + { + TDF_Label aShapeLabel; + if (myMap.Find(aShape, aShapeLabel)) + { + aGeneralLabelMap.Add(aShapeLabel); + NCollection_Sequence> 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 +5010,13 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work if (aPropDefinitionList.IsEmpty()) continue; + NCollection_List 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 aGroupedProperties; Interface_EntityIterator aSharingsListOfPD = theWS->Graph().Sharings(aPropDefinition); for (aSharingsListOfPD.Start(); aSharingsListOfPD.More(); aSharingsListOfPD.Next()) { @@ -5127,40 +5158,70 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work continue; TDF_Label aShapeLabel; - if (myMap.IsBound(aShape)) - { - aShapeLabel = myMap.Find(aShape); - } - if (!aShapeLabel.IsNull()) + if (myMap.Find(aShape, aShapeLabel)) { aLabelSeq.Append(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)) + NCollection_Sequence* aPropSeqPtr = anAttrMap.ChangeSeek(aLabelIt.Value()); + if (aPropSeqPtr == NULL) { - anAttr = new TDataStd_NamedData; - aLabel.AddAttribute(anAttr); + NCollection_Sequence aPropSeq; + aPropSeqPtr = anAttrMap.Bound(aLabelIt.Value(), aPropSeq); } - fillAttributes(theWS, aPropDefinition, anAttr); + aPropSeqPtr->Append(aPropDefinition); if (!aGroupedProperties.IsEmpty()) { NCollection_List::Iterator aPropIt(aGroupedProperties); - for ( ; aPropIt.More(); aPropIt.Next()) + for (; aPropIt.More(); aPropIt.Next()) { - fillAttributes(theWS, aPropIt.Value(), anAttr); + aPropSeqPtr->Append(aPropIt.Value()); } } } } } + // 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); + } + NCollection_Sequence anAttrib; + if (anAttrMap.Find(aLabelIt.Value(), anAttrib)) + { + NCollection_Sequence::Iterator aPropIt(anAttrib); + for (; aPropIt.More(); aPropIt.Next()) + { + fillAttributes(theWS, aPropIt.Value(), anAttr); + } + } + NCollection_Sequence> aPairSeq; + if (anExtraAttrMap.Find(aLabelIt.Value(), aPairSeq)) + { + NCollection_Sequence>::Iterator aSeqIt(aPairSeq); + for (; aSeqIt.More(); aSeqIt.Next()) + { + const auto & aPair = aSeqIt.Value(); + if (aPair.second.IsNull() || aPair.second->String().IsEmpty()) + { + continue; + } + anAttr->SetString(aPair.first, aPair.second->String()); + } + } + } + return Standard_True; } diff --git a/tests/metadata/end b/tests/metadata/end index fc085fc911..fc54e89d6c 100644 --- a/tests/metadata/end +++ b/tests/metadata/end @@ -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 diff --git a/tests/metadata/step/A1 b/tests/metadata/step/A1 index fb28d05518..14555c4e4d 100644 --- a/tests/metadata/step/A1 +++ b/tests/metadata/step/A1 @@ -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 } diff --git a/tests/metadata/step/A2 b/tests/metadata/step/A2 index 9c8f9f9c64..b3871109e2 100644 --- a/tests/metadata/step/A2 +++ b/tests/metadata/step/A2 @@ -22,6 +22,7 @@ Iyx : 2.044e-07 Iyy : 3.6385e-06 Iyz : -1.2030000000000001e-07 zCenterOfGravity : -0.056064514900000001 +ProductID : SHEET METAL F3D JoggleFormula : } diff --git a/tests/metadata/step/A3 b/tests/metadata/step/A3 index 9a041d7ff0..1d2020db06 100644 --- a/tests/metadata/step/A3 +++ b/tests/metadata/step/A3 @@ -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 } diff --git a/tests/metadata/step/A4 b/tests/metadata/step/A4 index fe1470690b..acd99574e0 100644 --- a/tests/metadata/step/A4 +++ b/tests/metadata/step/A4 @@ -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 diff --git a/tests/metadata/step/A5 b/tests/metadata/step/A5 index c3833d11f3..4c9c2d3919 100644 --- a/tests/metadata/step/A5 +++ b/tests/metadata/step/A5 @@ -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 } diff --git a/tests/metadata/step/A6 b/tests/metadata/step/A6 index a34fcd93cc..dd8647b921 100644 --- a/tests/metadata/step/A6 +++ b/tests/metadata/step/A6 @@ -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 } diff --git a/tests/metadata/step/A7 b/tests/metadata/step/A7 index 0614869453..c24e619d9a 100644 --- a/tests/metadata/step/A7 +++ b/tests/metadata/step/A7 @@ -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 : - > diff --git a/tests/metadata/step/A8 b/tests/metadata/step/A8 index aeed101adf..1823854491 100644 --- a/tests/metadata/step/A8 +++ b/tests/metadata/step/A8 @@ -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 : diff --git a/tests/metadata/step/A9 b/tests/metadata/step/A9 index f4ec55d953..f7b15e3741 100644 --- a/tests/metadata/step/A9 +++ b/tests/metadata/step/A9 @@ -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 index 95e00a7c4d..0000000000 --- a/tests/metadata/step/begin +++ /dev/null @@ -1,2 +0,0 @@ -set conf "provider.STEP.OCC.read.metadata : 1" -