]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix for the "0020750: EDF 1296 GEOM: Naming during STEP import" issue.
authorana <ana@opencascade.com>
Thu, 15 Mar 2012 13:49:46 +0000 (13:49 +0000)
committerana <ana@opencascade.com>
Thu, 15 Mar 2012 13:49:46 +0000 (13:49 +0000)
src/STEPImport/STEPImport.cxx

index 28b54a339ff0971cbe075c65e8473f51c45a55f3..4bccba4600b47ac07b39aae5ea882edddac09d66 100644 (file)
@@ -53,6 +53,8 @@
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TDF_Label.hxx>
+#include <TDF_ChildIDIterator.hxx>
+#include <TNaming_NamedShape.hxx>
 #include <TDF_Tool.hxx>
 #include <Interface_Static.hxx>
 
@@ -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);
               }