1 // Copyright (C) 2007-2016 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 #ifndef _GEOM_Function_HeaderFile
24 #define _GEOM_Function_HeaderFile
26 #include <Standard_Transient.hxx>
27 #include <Standard_GUID.hxx>
28 #include <TColStd_HArray1OfExtendedString.hxx>
29 #include <TColStd_HArray1OfByte.hxx>
30 #include <TColStd_HArray1OfReal.hxx>
31 #include <TColStd_HArray1OfInteger.hxx>
32 #include <TColStd_HSequenceOfTransient.hxx>
33 #include <TCollection_AsciiString.hxx>
34 #include <TDF_Label.hxx>
35 #include <TDF_LabelSequence.hxx>
36 #include <TDataStd_ListOfExtendedString.hxx>
37 #include <TopoDS_Shape.hxx>
39 #include <Basics_OCCTVersion.hxx>
42 DEFINE_STANDARD_HANDLE (GEOM_Function, Standard_Transient);
44 class GEOM_Function : public Standard_Transient
46 GEOM_Function(const TDF_Label& theEntry) { _label = theEntry; }
50 //Returns a GUID for a function tree
51 Standard_EXPORT static const Standard_GUID& GetFunctionTreeID();
53 //Returns the ID which is associated with a reference to another function
54 Standard_EXPORT static const Standard_GUID& GetDependencyID();
56 //Finds and returns a function located on a label theEntry
57 Standard_EXPORT static Handle(GEOM_Function) GetFunction(const TDF_Label& theEntry);
60 Standard_EXPORT GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType);
61 Standard_EXPORT ~GEOM_Function();
63 Standard_EXPORT TDF_Label GetOwnerEntry();
65 //Access to properties
67 //Returns a result of the function built by the function Driver
68 Standard_EXPORT TopoDS_Shape GetValue();
70 //Sets the function result
71 Standard_EXPORT void SetValue(TopoDS_Shape& theShape);
73 //Returns a function entry in the OCAF document
74 Standard_EXPORT TDF_Label& GetEntry() { return _label; }
76 //Returns the type of the function
77 Standard_EXPORT int GetType();
79 //Returns a function Driver GUID
80 Standard_EXPORT Standard_GUID GetDriverGUID();
82 //Returns aPython description of the function
83 Standard_EXPORT TCollection_AsciiString GetDescription();
85 //Sets aPython description of the function
86 Standard_EXPORT void SetDescription(const TCollection_AsciiString& theDescription);
90 //Sets a real argument at position thePosition
91 Standard_EXPORT void SetReal(int thePosition, double theValue);
93 //Returns a real argument at position thePosition
94 Standard_EXPORT double GetReal(int thePosition);
96 //Sets a real array argument at position thePosition
97 Standard_EXPORT void SetRealArray(int thePosition, const Handle(TColStd_HArray1OfReal)& theArray);
99 //Returns a real array argument at position thePosition
100 Standard_EXPORT Handle(TColStd_HArray1OfReal) GetRealArray(int thePosition);
102 //Sets an integer argument at position thePosition
103 Standard_EXPORT void SetInteger(int thePosition, int theValue);
105 //Returns an integer argument at position thePosition
106 Standard_EXPORT int GetInteger(int thePosition);
108 //Sets an integer array argument at position thePosition
109 Standard_EXPORT void SetIntegerArray(int thePosition, const Handle(TColStd_HArray1OfInteger)& theArray);
111 //Returns an integer array argument at position thePosition
112 Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntegerArray(int thePosition);
114 //Sets a byte array argument at position thePosition
115 Standard_EXPORT void SetByteArray(int thePosition, const Handle(TColStd_HArray1OfByte)& theArray);
117 //Returns a byte array argument at position thePosition
118 Standard_EXPORT Handle(TColStd_HArray1OfByte) GetByteArray(int thePosition);
120 //Sets a boolean array argument at position thePosition
121 Standard_EXPORT void SetBooleanArray(int thePosition, const Handle(TColStd_HArray1OfByte)& theArray);
123 //Returns a boolean array argument at position thePosition
124 Standard_EXPORT Handle(TColStd_HArray1OfByte) GetBooleanArray(int thePosition);
126 //Sets a reference to other function argument at position thePosition
127 Standard_EXPORT void SetReference(int thePosition, Handle(GEOM_Function) theReference);
129 //Sets a string argument at position thePosition
130 Standard_EXPORT void SetString(int thePosition, const TCollection_AsciiString& theValue);
132 //Returns a string argument at position thePosition
133 Standard_EXPORT TCollection_AsciiString GetString(int thePosition);
135 //Returns a reference to other function argument at position thePosition
136 Standard_EXPORT Handle(GEOM_Function) GetReference(int thePosition);
138 //Set an array of ExtendedString
139 Standard_EXPORT void SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray);
141 //Returns the array of ExtendedString
142 Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringArray(int thePosition);
144 //Returns true if data of given type already exists
145 Standard_EXPORT bool HasData(int thePosition, const Standard_GUID& dataID);
147 //Returns a GUID for a references tree
148 Standard_EXPORT static const Standard_GUID& GetReferencesTreeID();
150 //Sets a list of references to other function arguments at position thePosition
151 Standard_EXPORT void SetReferenceList (int thePosition,
152 const Handle(TColStd_HSequenceOfTransient)& theRefList);
154 //Returns a list of references to other function arguments at position thePosition
155 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetReferenceList (int thePosition);
157 // Save a pointer to a data holder intended to pass data Driver -> Operation.
158 // This method should be called by Operation to set the data holder.
159 // An instance of GEOM_Function that sets the data holder will remove the
160 // corresponding OCAF attribute at it's destruction
161 Standard_EXPORT void SetCallBackData( void* data );
163 // Returns a pointer to a data holder intended to pass data Driver -> Operation.
164 // This method should be called by Driver to get the data holder to fill it in.
165 // Returns NULL if the Operation have not set the data holder.
166 Standard_EXPORT void* GetCallBackData();
168 //Sets a TopoDS_Shape argument at position thePosition
169 //void SetShape(int thePosition, const TopoDS_Shape& theShape);
171 //Returns a TopoDS_Shape argument at position thePosition
172 //TopoDS_Shape GetShape(int thePosition);
174 //Returns true if the last method succided
175 Standard_EXPORT bool IsDone() { return _isDone; }
177 //Retuns true if this function is the last one in the study
178 Standard_EXPORT bool IsLastFuntion();
180 //Returns a sequence of the external dependencies of this function
181 Standard_EXPORT void GetDependency(TDF_LabelSequence& theSeq);
183 // Add/Remove/Check/Get subshape references
184 Standard_EXPORT void AddSubShapeReference (Handle(GEOM_Function) theSubShape);
185 Standard_EXPORT void RemoveSubShapeReference(Handle(GEOM_Function) theSubShape);
186 Standard_EXPORT bool HasSubShapeReferences();
187 Standard_EXPORT const TDataStd_ListOfExtendedString& GetSubShapeReferences();
189 //Returns top label of this function's history tree
190 Standard_EXPORT TDF_Label GetHistoryEntry (const Standard_Boolean create = Standard_True);
192 //Returns history label, corresponding to the label,
193 //on which a reference on argument is stored
194 Standard_EXPORT TDF_Label GetArgumentHistoryEntry (const TDF_Label& theArgumentRefEntry,
195 const Standard_Boolean create = Standard_True);
197 //Returns top label of this function's naming tree
198 Standard_EXPORT TDF_Label GetNamingEntry (const Standard_Boolean create = Standard_True);
200 OCCT_DEFINE_STANDARD_RTTIEXT(GEOM_Function,Standard_Transient)
206 bool _isCallBackData;