From 9b141497778b014d0dcdbd10739a5f8e68ecf4d7 Mon Sep 17 00:00:00 2001 From: ana Date: Thu, 15 Mar 2012 13:49:46 +0000 Subject: [PATCH] Fix for the "0020750: EDF 1296 GEOM: Naming during STEP import" issue. --- src/STEPImport/STEPImport.cxx | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/STEPImport/STEPImport.cxx b/src/STEPImport/STEPImport.cxx index 28b54a339..4bccba460 100644 --- a/src/STEPImport/STEPImport.cxx +++ b/src/STEPImport/STEPImport.cxx @@ -53,6 +53,8 @@ #include #include #include +#include +#include #include #include @@ -232,14 +234,29 @@ extern "C" { TopoDS_Shape aSub = anIndices.FindKey(isub); if (aSub.IsPartner(S)) { - // create label and set shape TDF_Label L; - TDF_TagSource aTag; - L = aTag.NewChild(theShapeLabel); - TNaming_Builder tnBuild (L); - //tnBuild.Generated(S); - tnBuild.Generated(aSub); - + if (enti->IsKind(tGeom)) { + // check all named shapes using iterator + TDF_ChildIDIterator anIt (theShapeLabel, TDataStd_Name::GetID(), Standard_True); + for (; anIt.More(); anIt.Next()) { + Handle(TDataStd_Name) nameAttr = + Handle(TDataStd_Name)::DownCast(anIt.Value()); + if (nameAttr.IsNull()) continue; + TDF_Label Lab = nameAttr->Label(); + Handle(TNaming_NamedShape) shAttr; + if (Lab.FindAttribute(TNaming_NamedShape::GetID(), shAttr) && shAttr->Get().IsEqual(aSub)) + L = Lab; + } + } + // create label and set shape + if (L.IsNull()) + { + TDF_TagSource aTag; + L = aTag.NewChild(theShapeLabel); + TNaming_Builder tnBuild (L); + //tnBuild.Generated(S); + tnBuild.Generated(aSub); + } // set a name TDataStd_Name::Set(L, aNameExt); } -- 2.39.2