1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include <GEOM_Function.hxx>
26 #include <GEOM_Object.hxx>
27 #include <GEOM_Solver.hxx>
28 #include <GEOM_ISubShape.hxx>
30 #include <Basics_OCCTVersion.hxx>
32 #include "utilities.h"
35 #include <TDF_Tool.hxx>
36 #include <TDF_Data.hxx>
37 #include <TDF_ChildIterator.hxx>
38 #include <TDF_Reference.hxx>
39 #include <TDataStd_BooleanArray.hxx>
40 #include <TDataStd_ByteArray.hxx>
41 #include <TDataStd_Integer.hxx>
42 #include <TDataStd_IntegerArray.hxx>
43 #include <TDataStd_Real.hxx>
44 #include <TDataStd_RealArray.hxx>
45 #include <TDataStd_Comment.hxx>
46 #include <TDataStd_TreeNode.hxx>
47 #include <TDataStd_UAttribute.hxx>
48 #include <TDataStd_ChildNodeIterator.hxx>
49 #include <TDataStd_ExtStringArray.hxx>
50 #include <TDataStd_ExtStringList.hxx>
51 #include <TDocStd_Owner.hxx>
52 #include <TDocStd_Document.hxx>
53 #include <TFunction_Function.hxx>
54 #include <TNaming_NamedShape.hxx>
55 #include <TNaming_Builder.hxx>
57 #include <TColStd_ListOfInteger.hxx>
58 #include <TColStd_ListIteratorOfListOfInteger.hxx>
59 #include <TColStd_HArray1OfReal.hxx>
60 #include <TColStd_HArray1OfInteger.hxx>
61 #include <TColStd_HSequenceOfTransient.hxx>
62 #include <TCollection_AsciiString.hxx>
63 #include <TCollection_ExtendedString.hxx>
65 #include <Standard_Failure.hxx>
66 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
68 // This modification was introduced in frame of Mantis issue 0021251.
69 // This line allows to keep shape orientation together with the shape itself.
70 // Otherwise orientation can be lost in some cases.
71 #define KEEP_ORIENTATION_0021251
73 #define ARGUMENT_LABEL 1
74 #define RESULT_LABEL 2
75 #define DESCRIPTION_LABEL 3
76 #define HISTORY_LABEL 4
77 #define SUBSHAPES_LABEL 5 // 0020756: GetGroups
78 #define NAMING_LABEL 6 // 0020750: Naming during STEP import
80 #ifdef KEEP_ORIENTATION_0021251
81 #define ORIENTATION_LABEL 7 // 0021251: TNaming_NamedShape doesn't store orientation
84 #define ARGUMENTS _label.FindChild((ARGUMENT_LABEL))
85 #define ARGUMENT(thePosition) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePosition))
86 #define SUB_ARGUMENT(thePos1, thePos2) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePos1)).FindChild((thePos2))
88 //=======================================================================
89 //function : GetFunctionTreeID
91 //=======================================================================
92 const Standard_GUID& GEOM_Function::GetFunctionTreeID()
94 static Standard_GUID aFunctionTreeID("FF1BBB00-5D14-4df2-980B-3A668264EA16");
95 return aFunctionTreeID;
99 //=======================================================================
100 //function : GetDependencyID
102 //=======================================================================
103 const Standard_GUID& GEOM_Function::GetDependencyID()
105 static Standard_GUID aDependencyID("E2620650-2354-41bd-8C2C-210CFCD00948");
106 return aDependencyID;
109 //=============================================================================
113 //=============================================================================
114 Handle(GEOM_Function) GEOM_Function::GetFunction(const TDF_Label& theEntry)
116 if(!theEntry.IsAttribute(TFunction_Function::GetID())) return NULL;
118 return new GEOM_Function(theEntry);
121 //=============================================================================
125 //=============================================================================
126 GEOM_Function::GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType)
129 TFunction_Function::Set(theEntry, theGUID);
130 TDataStd_Integer::Set(theEntry, theType);
132 //Add function to a function tree
133 Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(theEntry.Data());
134 Handle(TDataStd_TreeNode) aRoot, aNode;
135 if(!aDoc->Main().FindAttribute(GetFunctionTreeID(), aRoot))
136 aRoot = TDataStd_TreeNode::Set(aDoc->Main(), GetFunctionTreeID());
138 aNode = TDataStd_TreeNode::Set(theEntry, GetFunctionTreeID());
139 aRoot->Append(aNode);
142 //================================================================================
144 * \brief Retuns true if this function is the last one in the study
146 //================================================================================
148 bool GEOM_Function::IsLastFuntion()
152 Handle(TDataStd_TreeNode) aNode;
153 if (_label.FindAttribute(GetFunctionTreeID(), aNode))
154 isLast = !aNode->HasNext();
159 //=============================================================================
163 //=============================================================================
164 TDF_Label GEOM_Function::GetOwnerEntry()
166 TDF_Label aFather = _label.Father();
167 while(!aFather.IsRoot()) {
168 if(aFather.IsAttribute(GEOM_Object::GetObjectID())) return aFather;
169 aFather = aFather.Father();
175 //=============================================================================
179 //=============================================================================
180 int GEOM_Function::GetType()
183 Handle(TDataStd_Integer) aType;
184 if(!_label.FindAttribute(TDataStd_Integer::GetID(), aType)) return 0;
189 //=============================================================================
193 //=============================================================================
194 TopoDS_Shape GEOM_Function::GetValue()
199 TDF_Label aLabel = GetOwnerEntry();
200 if (aLabel.IsRoot()) return aShape;
201 Handle(GEOM_Object) anObject = GEOM_Object::GetObject(aLabel);
202 if (anObject.IsNull()) return aShape;
204 if (!anObject->IsMainShape()) {
205 bool isResult = false;
206 TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL);
207 if (!aResultLabel.IsNull()) {
208 Handle(TNaming_NamedShape) aNS;
209 if (aResultLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS))
216 Standard_Integer aTic = anObject->GetTic();
219 GEOM_ISubShape aCI (this);
220 TDF_Label aLabelObjMainSh = aCI.GetMainShape()->GetOwnerEntry();
221 if (aLabelObjMainSh.IsRoot()) return aShape;
222 Handle(GEOM_Object) anObjMainSh = GEOM_Object::GetObject(aLabelObjMainSh);
223 if (anObjMainSh.IsNull()) return aShape;
224 Standard_Integer aTicMainSh = anObjMainSh->GetTic();
227 isResult = ((aTic == aTicMainSh) ? true : false);
233 GEOM_Solver aSolver(GEOM_Engine::GetEngine());
234 if (!aSolver.ComputeFunction(this)) {
235 MESSAGE("GEOM_Object::GetValue Error : Can't build a sub-shape");
239 catch (Standard_Failure) {
240 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
241 MESSAGE("GEOM_Function::GetValue Error: " << aFail->GetMessageString());
247 TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL);
248 Handle(TNaming_NamedShape) aNS;
249 if (!aResultLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape;
253 #ifdef KEEP_ORIENTATION_0021251
254 // 0021251: TNaming_NamedShape doesn't store orientation
255 TDF_Label anOrientationLabel = _label.FindChild(ORIENTATION_LABEL);
256 Handle(TDataStd_Integer) anInteger;
257 if (anOrientationLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)) {
258 aShape.Orientation((TopAbs_Orientation)anInteger->Get());
266 //=============================================================================
270 //=============================================================================
271 void GEOM_Function::SetValue(TopoDS_Shape& theShape)
274 TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL);
275 TNaming_Builder aBuilder (aResultLabel);
277 aBuilder.Generated(theShape);
279 #ifdef KEEP_ORIENTATION_0021251
280 // 0021251: TNaming_NamedShape doesn't store orientation
281 TDF_Label anOrientationLabel = _label.FindChild(ORIENTATION_LABEL);
282 TDataStd_Integer::Set(anOrientationLabel, (int)theShape.Orientation());
285 // synchronisation between main shape and its sub-shapes
286 TDF_Label aLabel = GetOwnerEntry();
287 if (aLabel.IsRoot()) return;
288 Handle(GEOM_Object) anObject = GEOM_Object::GetObject(aLabel);
289 if (anObject.IsNull()) return;
290 if (anObject->IsMainShape()) {
291 // increase modifications counter of this (main) shape
292 anObject->IncrementTic();
295 // update modifications counter of this (sub-) shape to be the same as on main shape
296 GEOM_ISubShape aCI (this);
297 TDF_Label aLabelObjMainSh = aCI.GetMainShape()->GetOwnerEntry();
298 if (aLabelObjMainSh.IsRoot()) return;
299 Handle(GEOM_Object) anObjMainSh = GEOM_Object::GetObject(aLabelObjMainSh);
300 if (anObjMainSh.IsNull()) return;
302 anObject->SetTic(anObjMainSh->GetTic());
308 //=============================================================================
312 //=============================================================================
313 Standard_GUID GEOM_Function::GetDriverGUID()
315 Handle(TFunction_Function) aFunction;
316 if(!_label.FindAttribute(TFunction_Function::GetID(), aFunction)) {
317 return TDF::LowestID();
320 return aFunction->GetDriverGUID();
323 //=============================================================================
327 //=============================================================================
328 TCollection_AsciiString GEOM_Function::GetDescription()
330 Handle(TDataStd_Comment) aComment;
331 TDF_Label aChild = _label.FindChild(DESCRIPTION_LABEL);
332 if(!aChild.FindAttribute(TDataStd_Comment::GetID(), aComment)) return TCollection_AsciiString();
333 TCollection_AsciiString aDescr(aComment->Get());
337 //=============================================================================
341 //=============================================================================
342 void GEOM_Function::SetDescription(const TCollection_AsciiString& theDescription)
344 TDF_Label aChild = _label.FindChild(DESCRIPTION_LABEL);
345 Handle(TDataStd_Comment) aComment =
346 TDataStd_Comment::Set(aChild, TCollection_ExtendedString(theDescription));
349 //=============================================================================
353 //=============================================================================
354 void GEOM_Function::SetReal(int thePosition, double theValue)
357 if(thePosition <= 0) return;
358 TDF_Label anArgLabel = ARGUMENT(thePosition);
359 TDataStd_Real::Set(anArgLabel, theValue);
363 //=============================================================================
367 //=============================================================================
368 void GEOM_Function::SetRealArray (int thePosition,
369 const Handle(TColStd_HArray1OfReal)& theArray)
372 if(thePosition <= 0) return;
373 TDF_Label anArgLabel = ARGUMENT(thePosition);
374 Handle(TDataStd_RealArray) anAttr =
375 TDataStd_RealArray::Set(anArgLabel, theArray->Lower(), theArray->Upper());
376 anAttr->ChangeArray(theArray);
380 //=============================================================================
384 //=============================================================================
385 double GEOM_Function::GetReal(int thePosition)
388 if(thePosition <= 0) return 0.0;
389 Handle(TDataStd_Real) aReal;
390 TDF_Label anArgLabel = ARGUMENT(thePosition);
391 if(!anArgLabel.FindAttribute(TDataStd_Real::GetID(), aReal)) return 0.0;
397 //=============================================================================
401 //=============================================================================
402 Handle(TColStd_HArray1OfReal) GEOM_Function::GetRealArray(int thePosition)
405 if(thePosition <= 0) return NULL;
406 Handle(TDataStd_RealArray) aRealArray;
407 TDF_Label anArgLabel = ARGUMENT(thePosition);
408 if(!anArgLabel.FindAttribute(TDataStd_RealArray::GetID(), aRealArray)) return NULL;
411 return aRealArray->Array();
414 //=============================================================================
418 //=============================================================================
419 void GEOM_Function::SetInteger(int thePosition, int theValue)
422 if(thePosition <= 0) return;
423 TDF_Label anArgLabel = ARGUMENT(thePosition);
424 TDataStd_Integer::Set(anArgLabel, theValue);
428 //=============================================================================
432 //=============================================================================
433 void GEOM_Function::SetIntegerArray (int thePosition,
434 const Handle(TColStd_HArray1OfInteger)& theArray)
437 if(thePosition <= 0) return;
438 TDF_Label anArgLabel = ARGUMENT(thePosition);
439 Handle(TDataStd_IntegerArray) anAttr =
440 TDataStd_IntegerArray::Set(anArgLabel, theArray->Lower(), theArray->Upper());
441 anAttr->ChangeArray(theArray);
445 //=============================================================================
449 //=============================================================================
450 int GEOM_Function::GetInteger(int thePosition)
453 if(thePosition <= 0) return 0;
454 Handle(TDataStd_Integer) anInteger;
455 TDF_Label anArgLabel = ARGUMENT(thePosition);
456 if(!anArgLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)) return 0;
459 return anInteger->Get();
462 //=============================================================================
466 //=============================================================================
467 Handle(TColStd_HArray1OfInteger) GEOM_Function::GetIntegerArray(int thePosition)
470 if(thePosition <= 0) return 0;
471 Handle(TDataStd_IntegerArray) anIntegerArray;
472 TDF_Label anArgLabel = ARGUMENT(thePosition);
473 if(!anArgLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)) return 0;
476 return anIntegerArray->Array();
479 //=============================================================================
483 //=============================================================================
484 void GEOM_Function::SetByteArray (int thePosition,
485 const Handle(TColStd_HArray1OfByte)& theArray)
488 if(thePosition <= 0) return;
489 TDF_Label anArgLabel = ARGUMENT(thePosition);
490 Handle(TDataStd_ByteArray) anAttr =
491 TDataStd_ByteArray::Set(anArgLabel, theArray->Lower(), theArray->Upper());
492 anAttr->ChangeArray(theArray);
496 //=============================================================================
500 //=============================================================================
501 Handle(TColStd_HArray1OfByte) GEOM_Function::GetByteArray(int thePosition)
504 if(thePosition <= 0) return 0;
505 Handle(TDataStd_ByteArray) aByteArray;
506 TDF_Label anArgLabel = ARGUMENT(thePosition);
507 if(!anArgLabel.FindAttribute(TDataStd_ByteArray::GetID(), aByteArray)) return 0;
510 return aByteArray->InternalArray();
513 //=============================================================================
517 //=============================================================================
518 void GEOM_Function::SetBooleanArray (int thePosition,
519 const Handle(TColStd_HArray1OfByte)& theArray)
522 if(thePosition <= 0) return;
523 TDF_Label anArgLabel = ARGUMENT(thePosition);
524 Handle(TDataStd_BooleanArray) anAttr =
525 TDataStd_BooleanArray::Set(anArgLabel, theArray->Lower(), theArray->Upper());
526 anAttr->SetInternalArray(theArray);
530 //=============================================================================
534 //=============================================================================
535 Handle(TColStd_HArray1OfByte) GEOM_Function::GetBooleanArray(int thePosition)
538 if(thePosition <= 0) return 0;
539 Handle(TDataStd_BooleanArray) aBooleanArray;
540 TDF_Label anArgLabel = ARGUMENT(thePosition);
541 if(!anArgLabel.FindAttribute(TDataStd_BooleanArray::GetID(), aBooleanArray)) return 0;
544 return aBooleanArray->InternalArray();
547 //=============================================================================
551 //=============================================================================
552 void GEOM_Function::SetString(int thePosition, const TCollection_AsciiString& theValue)
555 if(thePosition <= 0) return;
556 TDF_Label anArgLabel = ARGUMENT(thePosition);
557 TDataStd_Comment::Set(anArgLabel, theValue);
561 //=============================================================================
565 //=============================================================================
566 TCollection_AsciiString GEOM_Function::GetString(int thePosition)
569 TCollection_AsciiString aRes;
570 if(thePosition <= 0) return aRes;
571 Handle(TDataStd_Comment) aString;
572 TDF_Label anArgLabel = ARGUMENT(thePosition);
573 if(!anArgLabel.FindAttribute(TDataStd_Comment::GetID(), aString)) return aRes;
576 aRes = TCollection_AsciiString(aString->Get());
580 //=============================================================================
584 //=============================================================================
585 void GEOM_Function::SetReference(int thePosition, Handle(GEOM_Function) theReference)
588 if (thePosition <= 0) return;
589 if (theReference.IsNull()) return;
590 TDF_Label anArgLabel = ARGUMENT(thePosition);
591 TDF_Reference::Set(anArgLabel, theReference->GetEntry());
592 TDataStd_UAttribute::Set(anArgLabel, GetDependencyID());
597 //=============================================================================
601 //=============================================================================
602 Handle(GEOM_Function) GEOM_Function::GetReference(int thePosition)
605 if(thePosition <= 0) return NULL;
606 TDF_Label anArgLabel = ARGUMENT(thePosition);
607 Handle(TDF_Reference) aRef;
608 if(!anArgLabel.FindAttribute(TDF_Reference::GetID(), aRef)) return NULL;
611 return GetFunction(aRef->Get());
615 //=============================================================================
619 //=============================================================================
620 void GEOM_Function::SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray)
623 if(thePosition <= 0 || theArray.IsNull()) return;
624 TDF_Label anArgLabel = ARGUMENT(thePosition);
626 Handle(TDataStd_ExtStringArray) anArray =
627 TDataStd_ExtStringArray::Set(anArgLabel, theArray->Lower(), theArray->Upper());
628 anArray->ChangeArray(theArray);
634 //=============================================================================
638 //=============================================================================
639 Handle(TColStd_HArray1OfExtendedString) GEOM_Function::GetStringArray(int thePosition)
642 if(thePosition <= 0) return NULL;
643 TDF_Label anArgLabel = ARGUMENT(thePosition);
644 Handle(TDataStd_ExtStringArray) anArray;
645 if(!anArgLabel.FindAttribute(TDataStd_ExtStringArray::GetID(), anArray)) return NULL;
648 return anArray->Array();
651 //=======================================================================
653 //purpose : Returns true if data of given type already exists
654 //=======================================================================
656 bool GEOM_Function::HasData(int thePosition, const Standard_GUID& dataID)
658 if(thePosition <= 0) return false;
659 TDF_Label anArgLabel = ARGUMENT(thePosition);
660 return anArgLabel.IsAttribute( dataID );
663 //=======================================================================
664 //function : GetReferencesTreeID
666 //=======================================================================
667 const Standard_GUID& GEOM_Function::GetReferencesTreeID()
669 static Standard_GUID aReferencesTreeID("FF1BBB10-5D14-4df2-980B-3A668264EA16");
670 return aReferencesTreeID;
673 //=============================================================================
677 //=============================================================================
678 void GEOM_Function::SetReferenceList (int thePosition,
679 const Handle(TColStd_HSequenceOfTransient)& theRefList)
682 if(thePosition <= 0) return;
684 // parent label for the list of references
685 TDF_Label anArgLabel = ARGUMENT(thePosition);
686 anArgLabel.ForgetAllAttributes();
688 // set TreeNode on the parent label
689 Handle(TDataStd_TreeNode) aRoot, aNode;
690 aRoot = TDataStd_TreeNode::Set(anArgLabel, GetReferencesTreeID());
692 // store references on sub-labels of the parent label
693 Handle(GEOM_Function) aFunc;
694 Standard_Integer ind, len = theRefList->Length();
695 for (ind = 1; ind <= len; ind++) {
696 aFunc = Handle(GEOM_Function)::DownCast(theRefList->Value(ind));
697 if (aFunc.IsNull()) continue;
698 TDF_Label anArgLabel_i = SUB_ARGUMENT(thePosition, ind);
699 TDF_Reference::Set(anArgLabel_i, aFunc->GetEntry());
700 TDataStd_UAttribute::Set(anArgLabel_i, GetDependencyID());
702 // set TreeNode on the child label
703 aNode = TDataStd_TreeNode::Set(anArgLabel_i, GetReferencesTreeID());
704 aRoot->Append(aNode);
711 //=============================================================================
715 //=============================================================================
716 Handle(TColStd_HSequenceOfTransient) GEOM_Function::GetReferenceList(int thePosition)
718 Handle(TColStd_HSequenceOfTransient) aResult = new TColStd_HSequenceOfTransient;
720 if(thePosition <= 0) return aResult;
722 // parent label for the list of references
723 TDF_Label anArgLabel = ARGUMENT(thePosition);
724 Handle(TDF_Reference) aRef;
726 // get TreeNode on the parent label
727 Handle(TDataStd_TreeNode) aRoot, aNode;
728 if(!anArgLabel.FindAttribute(GetReferencesTreeID(), aRoot))
731 // get references, stored on sub-labels of the parent label
733 TDataStd_ChildNodeIterator anIter (aRoot);
734 for (; anIter.More(); anIter.Next()) {
735 aNode = anIter.Value();
736 aLabel_i = aNode->Label();
737 if (!aLabel_i.FindAttribute(TDF_Reference::GetID(), aRef)) continue;
738 Handle(GEOM_Function) aFunc_i = GetFunction(aRef->Get());
739 if (aFunc_i.IsNull()) continue;
740 aResult->Append(aFunc_i);
747 //=============================================================================
751 //=============================================================================
752 //void GEOM_Function::SetShape(int thePosition, const TopoDS_Shape& theShape)
755 // if(thePosition <= 0 || theShape.IsNull()) return;
757 // TDF_Label anArgLabel = ARGUMENT(thePosition);
758 // TNaming_Builder aBuilder(anArgLabel);
759 // aBuilder.Generated(theShape);
765 //=============================================================================
769 //=============================================================================
770 //TopoDS_Shape GEOM_Function::GetShape(int thePosition)
773 // TopoDS_Shape aShape;
774 // if(thePosition <= 0) return aShape;
776 // TDF_Label anArgLabel = ARGUMENT(thePosition);
777 // Handle(TNaming_NamedShape) aNS;
778 // if(!anArgLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape;
780 // aShape = aNS->Get();
786 //=============================================================================
790 //=============================================================================
791 void GEOM_Function::GetDependency(TDF_LabelSequence& theSeq)
793 TDF_ChildIterator anIterator(ARGUMENTS, Standard_True);
794 for(; anIterator.More(); anIterator.Next()) {
795 if(anIterator.Value().IsAttribute(GetDependencyID())) theSeq.Append(anIterator.Value());
799 //=============================================================================
801 * AddSubShapeReference
803 //=============================================================================
804 void GEOM_Function::AddSubShapeReference(Handle(GEOM_Function) theSubShape)
808 TDF_Label aSubShapesLabel = _label.FindChild(SUBSHAPES_LABEL);
810 Handle(TDataStd_ExtStringList) aList;
811 if (!aSubShapesLabel.FindAttribute(TDataStd_ExtStringList::GetID(), aList)) {
812 aList = new TDataStd_ExtStringList;
813 aSubShapesLabel.AddAttribute(aList);
816 TCollection_AsciiString anEntry;
817 TDF_Tool::Entry(theSubShape->GetOwnerEntry(), anEntry);
818 aList->Append(anEntry);
823 //=============================================================================
825 * RemoveSubShapeReference
827 //=============================================================================
828 void GEOM_Function::RemoveSubShapeReference(Handle(GEOM_Function) theSubShape)
832 TDF_Label aSubShapesLabel = _label.FindChild(SUBSHAPES_LABEL);
834 Handle(TDataStd_ExtStringList) aList;
835 if (aSubShapesLabel.FindAttribute(TDataStd_ExtStringList::GetID(), aList)) {
836 TCollection_AsciiString anEntry;
837 TDF_Tool::Entry(theSubShape->GetOwnerEntry(), anEntry);
838 aList->Remove(anEntry);
844 //=============================================================================
846 * HasSubShapeReferences
848 //=============================================================================
849 bool GEOM_Function::HasSubShapeReferences()
853 TDF_Label aSubShapesLabel = _label.FindChild(SUBSHAPES_LABEL);
854 return aSubShapesLabel.IsAttribute(TDataStd_ExtStringList::GetID());
857 //=============================================================================
859 * GetSubShapeReferences
861 //=============================================================================
862 const TDataStd_ListOfExtendedString& GEOM_Function::GetSubShapeReferences()
866 TDF_Label aSubShapesLabel = _label.FindChild(SUBSHAPES_LABEL);
868 Handle(TDataStd_ExtStringList) aList;
869 if (!aSubShapesLabel.FindAttribute(TDataStd_ExtStringList::GetID(), aList)) {
870 aList = new TDataStd_ExtStringList;
871 aSubShapesLabel.AddAttribute(aList);
875 return aList->List();
878 //=============================================================================
882 //=============================================================================
883 TDF_Label GEOM_Function::GetHistoryEntry (const Standard_Boolean create)
885 return _label.FindChild(HISTORY_LABEL, create);
888 //=============================================================================
890 * GetArgumentHistoryEntry
892 //=============================================================================
893 TDF_Label GEOM_Function::GetArgumentHistoryEntry (const TDF_Label& theArgumentRefEntry,
894 const Standard_Boolean create)
896 TColStd_ListOfInteger anArgumentRefTags;
897 TDF_Tool::TagList(theArgumentRefEntry, anArgumentRefTags);
898 Standard_Integer anArgumentRefLabelPos = anArgumentRefTags.Extent();
900 TDF_Label aHistoryLabel = GetHistoryEntry(create);
901 if (aHistoryLabel.IsNull())
902 return aHistoryLabel;
903 Standard_Integer aHistoryLabelPos = aHistoryLabel.Depth() + 1;
905 Standard_Integer itag;
906 TDF_Label aHistoryCurLabel = aHistoryLabel;
907 TColStd_ListIteratorOfListOfInteger aListIter (anArgumentRefTags);
908 for (itag = 1; itag <= aHistoryLabelPos; itag++) {
911 for (; itag <= anArgumentRefLabelPos; itag++) {
912 aHistoryCurLabel = aHistoryCurLabel.FindChild(aListIter.Value(), create);
913 if (aHistoryCurLabel.IsNull())
914 return aHistoryCurLabel;
918 return aHistoryCurLabel;
921 //=============================================================================
925 //=============================================================================
926 TDF_Label GEOM_Function::GetNamingEntry (const Standard_Boolean create)
928 return _label.FindChild(NAMING_LABEL, create);
931 IMPLEMENT_STANDARD_HANDLE (GEOM_Function, Standard_Transient);
932 IMPLEMENT_STANDARD_RTTIEXT(GEOM_Function, Standard_Transient );