]> OCCT Git - occt-copy.git/commitdiff
refs #314: Get notes attached to sub-shapes/attributes of an assembly item
authorsnn <snn@opencascade.com>
Tue, 18 Apr 2017 14:09:14 +0000 (17:09 +0300)
committersnn <snn@opencascade.com>
Tue, 18 Apr 2017 14:10:19 +0000 (17:10 +0300)
src/XCAFDoc/XCAFDoc_NotesTool.cxx
src/XCAFDoc/XCAFDoc_NotesTool.hxx

index a1b68b018304e5acae2461d4eece9c28112d63ae..ad51f49a07fbe9880a44d4eac33a5d1954d4aa74 100644 (file)
@@ -132,7 +132,7 @@ XCAFDoc_NotesTool::FindAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) co
 }
 
 TDF_Label 
-XCAFDoc_NotesTool::FindAnnotatedItemGUID(const XCAFDoc_AssemblyItemId& theItemId,
+XCAFDoc_NotesTool::FindAnnotatedItemAttr(const XCAFDoc_AssemblyItemId& theItemId,
                                          const Standard_GUID&          theGUID) const
 {
   for (TDF_ChildIDIterator anIter(GetAnnotatedItemsLabel(), XCAFDoc_AssemblyItemRef::GetID()); anIter.More(); anIter.Next())
@@ -218,6 +218,53 @@ XCAFDoc_NotesTool::GetNotes(const XCAFDoc_AssemblyItemId& theItemId,
   return theNoteLabels.Length();
 }
 
+
+Standard_Integer
+XCAFDoc_NotesTool::GetAttrNotes(const XCAFDoc_AssemblyItemId& theItemId,
+                                const Standard_GUID&          theGUID,
+                                TDF_LabelSequence&            theNoteLabels) const
+{
+  TDF_Label anAnnotatedItem = FindAnnotatedItemAttr(theItemId, theGUID);
+  if (anAnnotatedItem.IsNull())
+    return 0;
+
+  Handle(XCAFDoc_GraphNode) aChild;
+  if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
+    return 0;
+
+  Standard_Integer nbFathers = aChild->NbFathers();
+  for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
+  {
+    Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
+    theNoteLabels.Append(aFather->Label());
+  }
+
+  return theNoteLabels.Length();
+}
+
+Standard_Integer
+XCAFDoc_NotesTool::GetSubshapeNotes(const XCAFDoc_AssemblyItemId& theItemId,
+                                    Standard_Integer              theSubshapeIndex,
+                                    TDF_LabelSequence&            theNoteLabels) const
+{
+  TDF_Label anAnnotatedItem = FindAnnotatedItemSubshape(theItemId, theSubshapeIndex);
+  if (anAnnotatedItem.IsNull())
+    return 0;
+
+  Handle(XCAFDoc_GraphNode) aChild;
+  if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
+    return 0;
+
+  Standard_Integer nbFathers = aChild->NbFathers();
+  for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
+  {
+    Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
+    theNoteLabels.Append(aFather->Label());
+  }
+
+  return theNoteLabels.Length();
+}
+
 Handle(XCAFDoc_AssemblyItemRef)
 XCAFDoc_NotesTool::AddNote(const TDF_Label&              theNoteLabel,
                            const XCAFDoc_AssemblyItemId& theItemId)
@@ -276,7 +323,7 @@ XCAFDoc_NotesTool::AddNoteToAttr(const TDF_Label&              theNoteLabel,
     return anItemRef;
 
   Handle(XCAFDoc_GraphNode) aChild;
-  TDF_Label anAnnotatedItem = FindAnnotatedItemGUID(theItemId, theGUID);
+  TDF_Label anAnnotatedItem = FindAnnotatedItemAttr(theItemId, theGUID);
   if (anAnnotatedItem.IsNull())
   {
     TDF_TagSource aTag;
index 83d36551b9226996bc2689a67be206f79f8e14d9..e079fe065d6a603fc5e49db994da4d6dac44d3ad 100644 (file)
@@ -57,7 +57,7 @@ public:
 
   Standard_EXPORT Standard_Boolean IsAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) const;
   Standard_EXPORT TDF_Label FindAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) const;
-  Standard_EXPORT TDF_Label FindAnnotatedItemGUID(const XCAFDoc_AssemblyItemId& theItemId,
+  Standard_EXPORT TDF_Label FindAnnotatedItemAttr(const XCAFDoc_AssemblyItemId& theItemId,
                                                   const Standard_GUID&          theGUID) const;
   Standard_EXPORT TDF_Label FindAnnotatedItemSubshape(const XCAFDoc_AssemblyItemId& theItemId,
                                                       Standard_Integer              theSubshapeIndex) const;
@@ -80,6 +80,12 @@ public:
 
   Standard_EXPORT Standard_Integer GetNotes(const XCAFDoc_AssemblyItemId& theItemId,
                                             TDF_LabelSequence&            theNoteLabels) const;
+  Standard_EXPORT Standard_Integer GetAttrNotes(const XCAFDoc_AssemblyItemId& theItemId,
+                                                const Standard_GUID&          theGUID,
+                                                TDF_LabelSequence&            theNoteLabels) const;
+  Standard_EXPORT Standard_Integer GetSubshapeNotes(const XCAFDoc_AssemblyItemId& theItemId,
+                                                    Standard_Integer              theSubshapeIndex,
+                                                    TDF_LabelSequence&            theNoteLabels) const;
 
   Standard_EXPORT Handle(XCAFDoc_AssemblyItemRef) AddNote(const TDF_Label&              theNoteLabel,
                                                           const XCAFDoc_AssemblyItemId& theItemId);