Salome HOME
62d69cb1b4a8a3ad98df3b17e051d79e01bf9320
[modules/geom.git] / src / GEOM / GEOM_Function.hxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _GEOM_Function_HeaderFile
24 #define _GEOM_Function_HeaderFile
25
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>
38
39 class GEOM_Function;
40 DEFINE_STANDARD_HANDLE (GEOM_Function, Standard_Transient)
41
42 class GEOM_Function : public Standard_Transient
43 {
44   GEOM_Function(const TDF_Label& theEntry) { _label = theEntry; }
45
46 public:
47
48   //Returns a GUID for a function tree
49   Standard_EXPORT static const Standard_GUID& GetFunctionTreeID();
50
51   //Returns the ID which is associated with a reference to another function
52   Standard_EXPORT static const Standard_GUID& GetDependencyID();
53
54   //Finds and returns a function located on a label theEntry
55   Standard_EXPORT static Handle(GEOM_Function) GetFunction(const TDF_Label& theEntry);
56
57
58   Standard_EXPORT GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType);
59   Standard_EXPORT ~GEOM_Function();
60
61   Standard_EXPORT TDF_Label GetOwnerEntry();
62
63   //Access to properties
64
65   //Returns a result of the function built by the function Driver
66   Standard_EXPORT TopoDS_Shape GetValue();
67
68   //Sets the function result
69   Standard_EXPORT void SetValue(TopoDS_Shape& theShape);
70
71   //Returns a function entry in the OCAF document
72   Standard_EXPORT TDF_Label& GetEntry() { return _label; }
73
74   //Returns the type of the function
75   Standard_EXPORT int GetType();
76
77   //Returns a function Driver GUID
78   Standard_EXPORT Standard_GUID GetDriverGUID();
79
80   //Returns aPython description of the function
81   Standard_EXPORT TCollection_AsciiString GetDescription();
82
83   //Sets aPython description of the function
84   Standard_EXPORT void SetDescription(const TCollection_AsciiString& theDescription);
85
86   //Access to arguments
87
88   //Sets a real argument at position thePosition
89   Standard_EXPORT void SetReal(int thePosition, double theValue);
90
91   //Returns a real argument at position thePosition
92   Standard_EXPORT double GetReal(int thePosition);
93
94   //Sets a real array argument at position thePosition
95   Standard_EXPORT void SetRealArray(int thePosition, const Handle(TColStd_HArray1OfReal)& theArray);
96
97   //Returns a real array argument at position thePosition
98   Standard_EXPORT Handle(TColStd_HArray1OfReal) GetRealArray(int thePosition);
99
100   //Sets an integer argument at position thePosition
101   Standard_EXPORT void SetInteger(int thePosition, int theValue);
102
103   //Returns an integer argument at position thePosition
104   Standard_EXPORT int GetInteger(int thePosition);
105
106   //Sets an integer array argument at position thePosition
107   Standard_EXPORT void SetIntegerArray(int thePosition, const Handle(TColStd_HArray1OfInteger)& theArray);
108
109   //Returns an integer array argument at position thePosition
110   Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntegerArray(int thePosition);
111
112   //Sets a byte array argument at position thePosition
113   Standard_EXPORT void SetByteArray(int thePosition, const Handle(TColStd_HArray1OfByte)& theArray);
114
115   //Returns a byte array argument at position thePosition
116   Standard_EXPORT Handle(TColStd_HArray1OfByte) GetByteArray(int thePosition);
117
118   //Sets a boolean array argument at position thePosition
119   Standard_EXPORT void SetBooleanArray(int thePosition, const Handle(TColStd_HArray1OfByte)& theArray);
120
121   //Returns a boolean array argument at position thePosition
122   Standard_EXPORT Handle(TColStd_HArray1OfByte) GetBooleanArray(int thePosition);
123
124   //Sets a reference to other function argument at position thePosition
125   Standard_EXPORT void SetReference(int thePosition, Handle(GEOM_Function) theReference);
126
127   //Sets a string argument at position thePosition
128   Standard_EXPORT void SetString(int thePosition, const TCollection_AsciiString& theValue);
129
130   //Returns a string argument at position thePosition
131   Standard_EXPORT TCollection_AsciiString GetString(int thePosition);
132
133   //Returns a reference to other function argument at position thePosition
134   Standard_EXPORT Handle(GEOM_Function) GetReference(int thePosition);
135
136   //Set an array of ExtendedString
137   Standard_EXPORT void SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray);
138
139   //Returns the array of ExtendedString
140   Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringArray(int thePosition);
141
142   //Returns true if data of given type already exists
143   Standard_EXPORT bool HasData(int thePosition, const Standard_GUID& dataID);
144
145   //Returns a GUID for a references tree
146   Standard_EXPORT static const Standard_GUID& GetReferencesTreeID();
147
148   //Sets a list of references to other function arguments at position thePosition
149   Standard_EXPORT void SetReferenceList (int thePosition,
150                          const Handle(TColStd_HSequenceOfTransient)& theRefList);
151
152   //Returns a list of references to other function arguments at position thePosition
153   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetReferenceList (int thePosition);
154
155   // Save a pointer to a data holder intended to pass data Driver -> Operation.
156   // This method should be called by Operation to set the data holder.
157   // An instance of GEOM_Function that sets the data holder will remove the
158   // corresponding OCAF attribute at it's destruction
159   Standard_EXPORT void SetCallBackData( void* data );
160
161   // Returns a pointer to a data holder intended to pass data Driver -> Operation.
162   // This method should be called by Driver to get the data holder to fill it in.
163   // Returns NULL if the Operation have not set the data holder.
164   Standard_EXPORT void* GetCallBackData();
165
166   //Sets a TopoDS_Shape argument at position thePosition
167   //void SetShape(int thePosition, const TopoDS_Shape& theShape);
168
169   //Returns a TopoDS_Shape argument at position thePosition
170   //TopoDS_Shape GetShape(int thePosition);
171
172   //Returns true if the last method succided
173   Standard_EXPORT bool IsDone() { return _isDone; }
174
175   //Returns true if this function is the last one in the study
176   Standard_EXPORT bool IsLastFuntion();
177
178   //Returns a sequence of the external dependencies of this function
179   Standard_EXPORT void GetDependency(TDF_LabelSequence& theSeq);
180
181   // Add/Remove/Check/Get subshape references
182   Standard_EXPORT void AddSubShapeReference   (Handle(GEOM_Function) theSubShape);
183   Standard_EXPORT void RemoveSubShapeReference(Handle(GEOM_Function) theSubShape);
184   Standard_EXPORT bool HasSubShapeReferences();
185   Standard_EXPORT const TDataStd_ListOfExtendedString& GetSubShapeReferences();
186
187   //Returns top label of this function's history tree
188   Standard_EXPORT TDF_Label GetHistoryEntry (const Standard_Boolean create = Standard_True);
189
190   //Returns history label, corresponding to the label,
191   //on which a reference on argument is stored
192   Standard_EXPORT TDF_Label GetArgumentHistoryEntry (const TDF_Label&       theArgumentRefEntry,
193                                                      const Standard_Boolean create = Standard_True);
194
195   //Returns top label of this function's naming tree
196   Standard_EXPORT TDF_Label GetNamingEntry (const Standard_Boolean create = Standard_True);
197
198   DEFINE_STANDARD_RTTIEXT(GEOM_Function,Standard_Transient)
199
200   private:
201
202   TDF_Label _label;
203   bool      _isDone;
204   bool      _isCallBackData;
205 };
206
207 #endif