From 1bebdb9c92b14ff79a7c378c958fb712e8e1700e Mon Sep 17 00:00:00 2001 From: snn Date: Tue, 18 Apr 2017 17:09:14 +0300 Subject: [PATCH] refs #314: Get notes attached to sub-shapes/attributes of an assembly item --- src/XCAFDoc/XCAFDoc_NotesTool.cxx | 51 +++++++++++++++++++++++++++++-- src/XCAFDoc/XCAFDoc_NotesTool.hxx | 8 ++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/XCAFDoc/XCAFDoc_NotesTool.cxx b/src/XCAFDoc/XCAFDoc_NotesTool.cxx index a1b68b0183..ad51f49a07 100644 --- a/src/XCAFDoc/XCAFDoc_NotesTool.cxx +++ b/src/XCAFDoc/XCAFDoc_NotesTool.cxx @@ -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; diff --git a/src/XCAFDoc/XCAFDoc_NotesTool.hxx b/src/XCAFDoc/XCAFDoc_NotesTool.hxx index 83d36551b9..e079fe065d 100644 --- a/src/XCAFDoc/XCAFDoc_NotesTool.hxx +++ b/src/XCAFDoc/XCAFDoc_NotesTool.hxx @@ -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);