Salome HOME
NPAL18111: Bad shape build by partition.
[modules/geom.git] / src / GEOM / GEOM_Object.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
8 //
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 #ifndef _GEOM_Object_HeaderFile
21 #define _GEOM_Object_HeaderFile
22
23 #ifndef _Standard_TypeMismatch_HeaderFile
24 #include <Standard_TypeMismatch.hxx>
25 #endif
26 #ifndef _Standard_HeaderFile
27 #include <Standard.hxx>
28 #endif
29 #ifndef _Standard_Macro_HeaderFile
30 #include <Standard_Macro.hxx>
31 #endif
32 #ifndef _Standard_HeaderFile
33 #include <Standard.hxx>
34 #endif
35 #ifndef _Handle_MMgt_TShared_HeaderFile
36 #include <Handle_MMgt_TShared.hxx>
37 #endif
38 #ifndef _MMgt_TShared_HeaderFile
39 #include <MMgt_TShared.hxx>
40 #endif
41 #ifndef _Standard_GUID_HeaderFile
42 #include <Standard_GUID.hxx>
43 #endif
44 #ifndef _TopoDS_Shape_HeaderFile
45 #include <TopoDS_Shape.hxx>
46 #endif
47 #ifndef _TDF_Label_HeaderFile
48 #include <TDF_Label.hxx>
49 #endif
50 #ifndef _TColStd_HSequenceOfTransient_HeaderFile
51 #include <TColStd_HSequenceOfTransient.hxx>
52 #endif
53 #ifndef _TCollection_AsciiString_HeaderFile
54 #include <TCollection_AsciiString.hxx>
55 #endif
56
57 class Handle_TColStd_HSequenceOfTransient;
58 class Standard_Transient;
59 class Handle_Standard_Type;
60 class Handle(MMgt_TShared);
61 class GEOM_Object;
62
63
64 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object);
65
66 class Handle(GEOM_Object) : public Handle(MMgt_TShared) {
67   public:
68     inline void* operator new(size_t,void* anAddress)
69       {
70         return anAddress;
71       }
72     inline void* operator new(size_t size)
73       {
74         return Standard::Allocate(size);
75       }
76     inline void  operator delete(void *anAddress)
77       {
78         if (anAddress) Standard::Free((Standard_Address&)anAddress);
79       }
80
81     Handle(GEOM_Object)():Handle(MMgt_TShared)() {}
82     Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle)
83      {
84      }
85
86     Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem)
87      {
88      }
89
90     Handle(GEOM_Object)& operator=(const Handle(GEOM_Object)& aHandle)
91      {
92       Assign(aHandle.Access());
93       return *this;
94      }
95
96     Handle(GEOM_Object)& operator=(const GEOM_Object* anItem)
97      {
98       Assign((Standard_Transient *)anItem);
99       return *this;
100      }
101
102     GEOM_Object* operator->()
103      {
104       return (GEOM_Object *)ControlAccess();
105      }
106
107     GEOM_Object* operator->() const
108      {
109       return (GEOM_Object *)ControlAccess();
110      }
111
112    Standard_EXPORT ~Handle(GEOM_Object)() {};
113
114    Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject);
115 };
116
117
118 #include <Standard_GUID.hxx>
119 #include <TDataStd_TreeNode.hxx>
120 #include "GEOM_Function.hxx"
121 #include "GEOM_Engine.hxx"
122
123 class GEOM_Object : public MMgt_TShared
124 {
125  friend class GEOM_Engine;
126
127  public:
128   inline void* operator new(size_t,void* anAddress)
129     {
130       return anAddress;
131     }
132   inline void* operator new(size_t size)
133     {
134       return Standard::Allocate(size);
135     }
136   inline void  operator delete(void *anAddress)
137     {
138       if (anAddress) Standard::Free((Standard_Address&)anAddress);
139     }
140
141   // Type management
142   //
143   Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_();
144   Standard_EXPORT const Handle(Standard_Type)& DynamicType() const  { return STANDARD_TYPE(GEOM_Object) ; }
145   Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
146            { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); }
147
148  private:
149   GEOM_Object(TDF_Label& theLabel);
150
151  public:
152   Standard_EXPORT GEOM_Object(TDF_Label& theEntry, int theType);
153   Standard_EXPORT ~GEOM_Object() {;}
154
155   //Finds a GEOM_Object on the label theLabel
156   Standard_EXPORT static Handle(GEOM_Object) GetObject(TDF_Label& theLabel);
157
158   //Finds a GEOM_Object by a reference, stored on the label theLabel
159   Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel);
160
161   //Returns a GEOM_Object common GUID
162   Standard_EXPORT static const Standard_GUID& GetObjectID();
163
164   //Returns a GUID associated with a sub shape object
165   Standard_EXPORT static const Standard_GUID& GetSubShapeID();
166
167   //###########################################################
168   //Access to properties
169   //###########################################################
170
171   //Returns a TreeNode that presents a root of a function tree for this GEOM_Object
172   Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; }
173
174   //Returns a label of this GEOM_Object
175   Standard_EXPORT TDF_Label GetEntry() { return _label; }
176
177   //Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...)
178   Standard_EXPORT int GetType();
179
180   //Sets the type of this GEOM_Object
181   Standard_EXPORT void SetType(int theType);
182
183   //Modifications counter management
184   Standard_EXPORT int  GetTic();
185   Standard_EXPORT void SetTic(int theTic);
186   Standard_EXPORT void IncrementTic();
187
188   //Returns an ID of the OCAF document where this GEOM_Object is stored
189   Standard_EXPORT int GetDocID();
190
191   //Returns a value (as TopoDS_Shape) of this GEOM_Object
192   Standard_EXPORT TopoDS_Shape GetValue();
193
194   //Sets a name of this GEOM_Object
195   Standard_EXPORT void SetName(const char* theName);
196
197   //Returns a name of this GEOM_Object
198   Standard_EXPORT char* GetName();
199
200   //Sets an auxiliary data
201   Standard_EXPORT void SetAuxData(const char* theData);
202
203   //Returns an auxiliary data
204   Standard_EXPORT TCollection_AsciiString GetAuxData();
205
206   //###########################################################
207   // Sub shape methods
208   //###########################################################
209
210   //Returns false if the object is a sub shape of another object
211   Standard_EXPORT bool IsMainShape();
212
213   //###########################################################
214   // CORBA related methods
215   //###########################################################
216
217   //Sets an IOR of CORBA GEOM_Object_i which refers to this object
218   Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
219
220   //Returns an IOR of CORBA GEOM_Object_i which refers to this object
221   Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
222
223   //###########################################################
224   //Functions methods
225   //###########################################################
226
227   //Adds a function with a driver GUID = theGUID and a type theFunctionType
228   //to the function tree of this GEOM_Object
229   Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID, int theFunctionType);
230
231   //Returns a number of functions of this GEOM_Object
232   Standard_EXPORT int GetNbFunctions();
233
234   //Returns a function with given number theFunctionNumber
235   Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
236
237   //Return the last function of this GEOM_Object
238   Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
239
240   //Returns all dependencies of the object
241   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
242
243   //Returns the dependencies of the last function
244   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
245
246   //###########################################################
247   // Internal methods
248   //###########################################################
249
250   //Returns a label which could be used to store some additional data
251   Standard_EXPORT TDF_Label GetFreeLabel();
252
253  private:
254   Handle(TDataStd_TreeNode) _root;
255   TDF_Label                 _label;
256   TCollection_AsciiString   _ior;
257 };
258
259 #endif