1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Compare commits

..

1 Commits

Author SHA1 Message Date
ichesnok
b936aa6ed1 0033660: Data Exchange, Step Import - Adding product attributes to metadata
Attributes of product was added to metadata.
2024-04-01 16:05:25 +01:00

View File

@@ -4972,20 +4972,27 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
if (!aBinder.IsNull())
{
TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, aBinder);
if (!aShape.IsNull())
if (aShape.IsNull())
continue;
TDF_Label aShapeLabel;
if (myMap.IsBound(aShape))
{
TDF_Label aShapeLabel;
if (myMap.Find(aShape, aShapeLabel))
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);
}
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);
}
}
}
@@ -5158,30 +5165,48 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
continue;
TDF_Label aShapeLabel;
if (myMap.Find(aShape, aShapeLabel))
if (myMap.IsBound(aShape))
{
aShapeLabel = myMap.Find(aShape);
}
if (!aShapeLabel.IsNull())
{
aLabelSeq.Append(aShapeLabel);
aGeneralLabelMap.Add(aShapeLabel);
if (!aGeneralLabelMap.Contains(aShapeLabel))
{
aGeneralLabelMap.Add(aShapeLabel);
}
}
}
// fill user defined attribute map
for (TDF_LabelSequence::Iterator aLabelIt(aLabelSeq); aLabelIt.More(); aLabelIt.Next())
{
NCollection_Sequence<Handle(StepRepr_PropertyDefinition)>* aPropSeqPtr = anAttrMap.ChangeSeek(aLabelIt.Value());
if (aPropSeqPtr == NULL)
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
{
NCollection_Sequence<Handle(StepRepr_PropertyDefinition)> aPropSeq;
aPropSeqPtr = anAttrMap.Bound(aLabelIt.Value(), aPropSeq);
}
aPropSeqPtr->Append(aPropDefinition);
if (!aGroupedProperties.IsEmpty())
{
NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(aGroupedProperties);
for (; aPropIt.More(); aPropIt.Next())
aPropSeq.Append(aPropDefinition);
if (!aGroupedProperties.IsEmpty())
{
aPropSeqPtr->Append(aPropIt.Value());
NCollection_List<Handle(StepRepr_PropertyDefinition)>::Iterator aPropIt(aGroupedProperties);
for (; aPropIt.More(); aPropIt.Next())
{
aPropSeq.Append(aPropIt.Value());
}
}
anAttrMap.Bind(aLabelIt.Value(), aPropSeq);
}
}
}
@@ -5196,27 +5221,30 @@ Standard_Boolean STEPCAFControl_Reader::ReadMetadata(const Handle(XSControl_Work
anAttr = new TDataStd_NamedData;
aLabelIt.Value().AddAttribute(anAttr);
}
NCollection_Sequence<Handle(StepRepr_PropertyDefinition)> anAttrib;
if (anAttrMap.Find(aLabelIt.Value(), anAttrib))
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);
}
}
NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>> aPairSeq;
if (anExtraAttrMap.Find(aLabelIt.Value(), aPairSeq))
if (anExtraAttrMap.IsBound(aLabelIt.Value()))
{
NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>>::Iterator aSeqIt(aPairSeq);
for (; aSeqIt.More(); aSeqIt.Next())
NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>> aStrSeq = anExtraAttrMap.Find(aLabelIt.Value());
if (!aStrSeq.IsEmpty())
{
const auto& aPair = aSeqIt.Value();
if (aPair.second.IsNull() || aPair.second->String().IsEmpty())
NCollection_Sequence<std::pair<TCollection_AsciiString, Handle(TCollection_HAsciiString)>>::Iterator anIt(aStrSeq);
for (; anIt.More(); anIt.Next())
{
continue;
auto aPair = anIt.Value();
if (aPair.second.IsNull())
{
continue;
}
anAttr->SetString(aPair.first, aPair.second->String());
}
anAttr->SetString(aPair.first, aPair.second->String());
}
}
}