Back to index

salome-geom  6.5.0
GEOM_Function.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef _GEOM_Function_HeaderFile
00024 #define _GEOM_Function_HeaderFile
00025 
00026 #ifndef _Standard_TypeMismatch_HeaderFile
00027 #include <Standard_TypeMismatch.hxx>
00028 #endif
00029 #ifndef _Standard_HeaderFile
00030 #include <Standard.hxx>
00031 #endif
00032 #ifndef _Standard_Macro_HeaderFile
00033 #include <Standard_Macro.hxx>
00034 #endif
00035 #ifndef _Handle_MMgt_TShared_HeaderFile
00036 #include <Handle_MMgt_TShared.hxx>
00037 #endif
00038 #ifndef _MMgt_TShared_HeaderFile
00039 #include <MMgt_TShared.hxx>
00040 #endif
00041 #ifndef _Standard_GUID_HeaderFile
00042 #include <Standard_GUID.hxx>
00043 #endif
00044 #ifndef _TopoDS_Shape_HeaderFile
00045 #include <TopoDS_Shape.hxx>
00046 #endif
00047 #ifndef _TDF_Label_HeaderFile
00048 #include <TDF_Label.hxx>
00049 #endif
00050 #ifndef _TDF_LabelSequence_HeaderFile
00051 #include <TDF_LabelSequence.hxx>
00052 #endif
00053 #ifndef _TColStd_HArray1OfExtendedString_HeaderFile
00054 #include <TColStd_HArray1OfExtendedString.hxx>
00055 #endif
00056 
00057 class Handle_TColStd_HArray1OfReal;
00058 class Handle_TColStd_HArray1OfInteger;
00059 class Handle_TColStd_HSequenceOfTransient;
00060 class Handle_TColStd_HArray1OfExtendedString;
00061 
00062 class Standard_Transient;
00063 class Handle_Standard_Type;
00064 class Handle(MMgt_TShared);
00065 class GEOM_Function;
00066 
00067 #include <TCollection_AsciiString.hxx>
00068 #include <TDataStd_ListOfExtendedString.hxx>
00069 
00070 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Function);
00071 
00072 class Handle(GEOM_Function) : public Handle(MMgt_TShared) {
00073   public:
00074     inline void* operator new(size_t,void* anAddress)
00075       {
00076         return anAddress;
00077       }
00078     inline void* operator new(size_t size)
00079       {
00080         return Standard::Allocate(size);
00081       }
00082     inline void  operator delete(void *anAddress)
00083       {
00084         if (anAddress) Standard::Free((Standard_Address&)anAddress);
00085       }
00086 
00087     Handle(GEOM_Function)():Handle(MMgt_TShared)() {}
00088     Handle(GEOM_Function)(const Handle(GEOM_Function)& aHandle) : Handle(MMgt_TShared)(aHandle)
00089      {
00090      }
00091 
00092     Handle(GEOM_Function)(const GEOM_Function* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem)
00093      {
00094      }
00095 
00096     Handle(GEOM_Function)& operator=(const Handle(GEOM_Function)& aHandle)
00097      {
00098       Assign(aHandle.Access());
00099       return *this;
00100      }
00101 
00102     Handle(GEOM_Function)& operator=(const GEOM_Function* anItem)
00103      {
00104       Assign((Standard_Transient *)anItem);
00105       return *this;
00106      }
00107 
00108     GEOM_Function* operator->()
00109      {
00110       return (GEOM_Function *)ControlAccess();
00111      }
00112 
00113     GEOM_Function* operator->() const
00114      {
00115       return (GEOM_Function *)ControlAccess();
00116      }
00117 
00118    Standard_EXPORT ~Handle(GEOM_Function)() {};
00119 
00120    Standard_EXPORT static const Handle(GEOM_Function) DownCast(const Handle(Standard_Transient)& AnObject);
00121 };
00122 
00123 class GEOM_Function : public MMgt_TShared
00124 {
00125 
00126 public:
00127 
00128     inline void* operator new(size_t,void* anAddress)
00129       {
00130         return anAddress;
00131       }
00132     inline void* operator new(size_t size)
00133       {
00134         return Standard::Allocate(size);
00135       }
00136     inline void  operator delete(void *anAddress)
00137       {
00138         if (anAddress) Standard::Free((Standard_Address&)anAddress);
00139       }
00140 
00141     // Type management
00142     //
00143     Standard_EXPORT friend Handle_Standard_Type& GEOM_Function_Type_();
00144     Standard_EXPORT const Handle(Standard_Type)& DynamicType() const
00145       { return STANDARD_TYPE(GEOM_Function) ; }
00146     Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
00147       { return (STANDARD_TYPE(GEOM_Function) == AType || MMgt_TShared::IsKind(AType)); }
00148 
00149 
00150 private:
00151   GEOM_Function(const TDF_Label& theEntry) { _label = theEntry; }
00152 
00153 public:
00154 
00155   //Returns a GUID for a function tree
00156   Standard_EXPORT static const Standard_GUID& GetFunctionTreeID();
00157 
00158   //Returns the ID which is associated with a reference to another function
00159   Standard_EXPORT static const Standard_GUID& GetDependencyID();
00160 
00161   //Finds and returns a function located on a label theEntry
00162   Standard_EXPORT static Handle(GEOM_Function) GetFunction(const TDF_Label& theEntry);
00163 
00164 
00165   Standard_EXPORT GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType);
00166   Standard_EXPORT ~GEOM_Function() {;}
00167 
00168   Standard_EXPORT TDF_Label GetOwnerEntry();
00169 
00170   //Access to properties
00171 
00172   //Returns a result of the function built by the function Driver
00173   Standard_EXPORT TopoDS_Shape GetValue();
00174 
00175   //Sets the function result
00176   Standard_EXPORT void SetValue(TopoDS_Shape& theShape);
00177 
00178   //Returns a function entry in the OCAF document
00179   Standard_EXPORT TDF_Label& GetEntry() { return _label; }
00180 
00181   //Returns the type of the function
00182   Standard_EXPORT int GetType();
00183 
00184   //Returns a function Driver GUID
00185   Standard_EXPORT Standard_GUID GetDriverGUID();
00186 
00187   //Returns aPython description of the function
00188   Standard_EXPORT TCollection_AsciiString GetDescription();
00189 
00190   //Sets aPython description of the function
00191   Standard_EXPORT void SetDescription(const TCollection_AsciiString& theDescription);
00192 
00193   //Access to arguments
00194 
00195   //Sets a real argument at position thePosition
00196   Standard_EXPORT void SetReal(int thePosition, double theValue);
00197 
00198   //Returns a real argument at position thePosition
00199   Standard_EXPORT double GetReal(int thePosition);
00200 
00201   //Sets a real array argument at position thePosition
00202   Standard_EXPORT void SetRealArray(int thePosition, const Handle(TColStd_HArray1OfReal)& theArray);
00203 
00204   //Returns a real array argument at position thePosition
00205   Standard_EXPORT Handle(TColStd_HArray1OfReal) GetRealArray(int thePosition);
00206 
00207   //Sets an integer argument at position thePosition
00208   Standard_EXPORT void SetInteger(int thePosition, int theValue);
00209 
00210   //Returns an integer argument at position thePosition
00211   Standard_EXPORT int GetInteger(int thePosition);
00212 
00213   //Sets an integer array argument at position thePosition
00214   Standard_EXPORT void SetIntegerArray(int thePosition, const Handle(TColStd_HArray1OfInteger)& theArray);
00215 
00216   //Returns an integer array argument at position thePosition
00217   Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntegerArray(int thePosition);
00218 
00219   //Sets a reference to other function argument at position thePosition
00220   Standard_EXPORT void SetReference(int thePosition, Handle(GEOM_Function) theReference);
00221 
00222   //Sets a string argument at position thePosition
00223   Standard_EXPORT void SetString(int thePosition, const TCollection_AsciiString& theValue);
00224 
00225   //Returns a string argument at position thePosition
00226   Standard_EXPORT TCollection_AsciiString GetString(int thePosition);
00227 
00228   //Returns a reference to other function argument at position thePosition
00229   Standard_EXPORT Handle(GEOM_Function) GetReference(int thePosition);
00230 
00231   //Set an array of ExtendedString
00232   Standard_EXPORT void SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray);
00233 
00234   //Returns the array of ExtendedString
00235   Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringArray(int thePosition);
00236 
00237   //Returns a GUID for a references tree
00238   Standard_EXPORT static const Standard_GUID& GetReferencesTreeID();
00239 
00240   //Sets a list of references to other function arguments at position thePosition
00241   Standard_EXPORT void SetReferenceList (int thePosition,
00242                          const Handle(TColStd_HSequenceOfTransient)& theRefList);
00243 
00244   //Returns a list of references to other function arguments at position thePosition
00245   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetReferenceList (int thePosition);
00246 
00247   //Sets a TopoDS_Shape argument at position thePosition
00248   //void SetShape(int thePosition, const TopoDS_Shape& theShape);
00249 
00250   //Returns a TopoDS_Shape argument at position thePosition
00251   //TopoDS_Shape GetShape(int thePosition);
00252 
00253   //Returns true if the last method succided
00254   Standard_EXPORT bool IsDone() { return _isDone; }
00255 
00256   //Returns a sequence of the external dependencies of this function
00257   Standard_EXPORT void GetDependency(TDF_LabelSequence& theSeq);
00258 
00259   // Add/Remove/Check/Get subshape references
00260   Standard_EXPORT void AddSubShapeReference   (Handle(GEOM_Function) theSubShape);
00261   Standard_EXPORT void RemoveSubShapeReference(Handle(GEOM_Function) theSubShape);
00262   Standard_EXPORT bool HasSubShapeReferences();
00263   Standard_EXPORT const TDataStd_ListOfExtendedString& GetSubShapeReferences();
00264 
00265   //Returns top label of this function's history tree
00266   Standard_EXPORT TDF_Label GetHistoryEntry (const Standard_Boolean create = Standard_True);
00267 
00268   //Returns history label, corresponding to the label,
00269   //on which a reference on argument is stored
00270   Standard_EXPORT TDF_Label GetArgumentHistoryEntry (const TDF_Label&       theArgumentRefEntry,
00271                                                      const Standard_Boolean create = Standard_True);
00272 
00273   //Returns top label of this function's naming tree
00274   Standard_EXPORT TDF_Label GetNamingEntry (const Standard_Boolean create = Standard_True);
00275 
00276 private:
00277 
00278   TDF_Label _label;
00279   bool      _isDone;
00280 };
00281 
00282 #endif