Salome HOME
0c488e56b713123fc6bc567988d0935f8609c30b
[modules/geom.git] / src / GEOM / GEOM_Object.cxx
1 // Copyright (C) 2007-2013  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.
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 #include "GEOM_Object.hxx"
24 #include "GEOM_Engine.hxx"
25 #include "GEOM_Solver.hxx"
26
27 #include <Standard_Stream.hxx>
28 #include <TColStd_HArray1OfReal.hxx>
29 #include <TCollection_AsciiString.hxx>
30 #include <TCollection_ExtendedString.hxx>
31 #include <TDF_Data.hxx>
32 #include <TDF_LabelSequence.hxx>
33 #include <TDF_Reference.hxx>
34 #include <TDF_Tool.hxx>
35 #include <TDataStd_ByteArray.hxx>
36 #include <TDataStd_ChildNodeIterator.hxx>
37 #include <TDataStd_Comment.hxx>
38 #include <TDataStd_Integer.hxx>
39 #include <TDataStd_Name.hxx>
40 #include <TDataStd_Real.hxx>
41 #include <TDataStd_RealArray.hxx>
42 #include <TDataStd_UAttribute.hxx>
43 #include <TDocStd_Document.hxx>
44 #include <TDocStd_Owner.hxx>
45 #include <TFunction_Driver.hxx>
46 #include <TFunction_DriverTable.hxx>
47 #include <TopExp.hxx>
48 #include <TopTools_IndexedMapOfShape.hxx>
49
50 #include "utilities.h"
51
52
53 #define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb)))
54 #define TYPE_LABEL       2
55 #define FREE_LABEL       3
56 #define TIC_LABEL        4
57 #define COLOR_LABEL      5
58 #define AUTO_COLOR_LABEL 6
59 #define MARKER_LABEL     7
60
61 #define MARKER_LABEL_TYPE 1
62 #define MARKER_LABEL_SIZE 2
63 #define MARKER_LABEL_ID   3
64
65 //=======================================================================
66 //function : GetObjectID
67 //purpose  :
68 //=======================================================================
69 const Standard_GUID& GEOM_Object::GetObjectID()
70 {
71   static Standard_GUID anObjectID("FF1BBB01-5D14-4df2-980B-3A668264EA16");
72   return anObjectID;
73 }
74
75 //=======================================================================
76 //function : GetSubShapeID
77 //purpose  :
78 //=======================================================================
79 const Standard_GUID& GEOM_Object::GetSubShapeID()
80 {
81   static Standard_GUID anObjectID("FF1BBB68-5D14-4df2-980B-3A668264EA16");
82   return anObjectID;
83 }
84
85 //=============================================================================
86 /*!
87  *  GetObject
88  */
89 //=============================================================================
90 Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel)
91 {
92   if (!theLabel.IsAttribute(GetObjectID())) return NULL;
93
94   TCollection_AsciiString anEntry;
95   TDF_Tool::Entry(theLabel, anEntry);
96
97   Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(theLabel.Data());
98   if(aDoc.IsNull()) return NULL;
99
100   Handle(TDataStd_Integer) anID;
101   if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return NULL;
102
103
104   GEOM_Engine* anEngine=  GEOM_Engine::GetEngine();
105   if(anEngine == NULL) return NULL;
106   return anEngine->GetObject(anID->Get(), (char*) anEntry.ToCString());
107
108
109 }
110
111 //=============================================================================
112 /*!
113  *  GetReferencedObject
114  */
115 //=============================================================================
116 Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel)
117 {
118   Handle(TDF_Reference) aRef;
119   if (!theLabel.FindAttribute(TDF_Reference::GetID(), aRef)) {
120     return NULL;
121   }
122   
123   if(aRef.IsNull() || aRef->Get().IsNull()) {
124     return NULL;
125   }
126
127
128   // Get TreeNode of a referenced function
129   Handle(TDataStd_TreeNode) aT, aFather;
130   if (!TDataStd_TreeNode::Find(aRef->Get(), aT)) {
131     return NULL;
132   }
133
134
135   // Get TreeNode of Object of the referenced function
136   aFather = aT->Father();
137   if (aFather.IsNull()) {
138     return NULL;
139   }
140
141   // Get label of the referenced object
142   TDF_Label aLabel = aFather->Label();
143   
144
145   return GEOM_Object::GetObject(aLabel);
146 }
147
148 //=============================================================================
149 /*!
150  *  Constructor: private
151  */
152 //=============================================================================
153 GEOM_Object::GEOM_Object(TDF_Label& theEntry)
154   : _label(theEntry), _ior(""), _docID(-1)
155 {
156   Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
157   if(!aDoc.IsNull()) {
158     Handle(TDataStd_Integer) anID;
159     if(aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) _docID = anID->Get();
160   }
161
162   if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
163     _root = TDataStd_TreeNode::Set(theEntry);
164 }
165
166 //=============================================================================
167 /*!
168  *  Constructor: public
169  */
170 //=============================================================================
171 GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType)
172 : _label(theEntry), _ior(""), _docID(-1)
173 {
174   Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
175   if(!aDoc.IsNull()) {
176     Handle(TDataStd_Integer) anID;
177     if(aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) _docID = anID->Get();
178   }
179
180   theEntry.ForgetAllAttributes(Standard_True);
181
182   if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
183     _root = TDataStd_TreeNode::Set(theEntry);
184
185   TDataStd_Integer::Set(theEntry.FindChild(TYPE_LABEL), theType);
186
187   TDataStd_UAttribute::Set(theEntry, GetObjectID());
188 }
189
190 //=============================================================================
191 /*!
192  *  Destructor
193  */
194 //=============================================================================
195 GEOM_Object::~GEOM_Object()
196 {
197   MESSAGE("GEOM_Object::~GEOM_Object()");
198 }
199
200 //=============================================================================
201 /*!
202  *  GetType
203  */
204 //=============================================================================
205 int GEOM_Object::GetType()
206 {
207   Handle(TDataStd_Integer) aType;
208   if(!_label.FindChild(TYPE_LABEL).FindAttribute(TDataStd_Integer::GetID(), aType)) return -1;
209
210   return aType->Get();
211 }
212
213 //=============================================================================
214 /*!
215  *  SetType
216  */
217 //=============================================================================
218 void GEOM_Object::SetType(int theType)
219 {
220   TDataStd_Integer::Set(_label.FindChild(TYPE_LABEL), theType);
221 }
222
223
224 //=============================================================================
225 /*!
226  *  Returns modifications counter of this object.
227  *  Comparing this value with modifications counters of argument objects
228  *  (on which this object depends) we decide whether this object needs to be updated.
229  */
230 //=============================================================================
231 int GEOM_Object::GetTic()
232 {
233   Handle(TDataStd_Integer) aTicAttr;
234   if (!_label.FindChild(TIC_LABEL).FindAttribute(TDataStd_Integer::GetID(), aTicAttr))
235     return 0;
236
237   return aTicAttr->Get();
238 }
239
240 //=============================================================================
241 /*!
242  *  Set another value of modifications counter.
243  *
244  *  Use this method to update modifications counter of dependent object
245  *  to be equal to modifications counter of its argument.
246  *  This is commonly done in GEOM_Function::GetValue()
247  */
248 //=============================================================================
249 void GEOM_Object::SetTic(int theTic)
250 {
251   TDataStd_Integer::Set(_label.FindChild(TIC_LABEL), theTic);
252 }
253
254 //=============================================================================
255 /*!
256  *  Increment modifications counter to mark this object as modified.
257  *
258  *  Commonly called from GEOM_Function::SetValue()
259  */
260 //=============================================================================
261 void GEOM_Object::IncrementTic()
262 {
263   TDF_Label aTicLabel = _label.FindChild(TIC_LABEL);
264
265   Standard_Integer aTic = 0;
266   Handle(TDataStd_Integer) aTicAttr;
267   if (aTicLabel.FindAttribute(TDataStd_Integer::GetID(), aTicAttr))
268     aTic = aTicAttr->Get();
269
270   TDataStd_Integer::Set(aTicLabel, aTic + 1);
271 }
272
273
274 //=============================================================================
275 /*!
276  *  GetDocID
277  */
278 //=============================================================================
279 int GEOM_Object::GetDocID()
280 {
281   return _docID;
282 }
283
284
285 //=============================================================================
286 /*!
287  *  GetValue
288  */
289 //=============================================================================
290 TopoDS_Shape GEOM_Object::GetValue()
291 {
292   TopoDS_Shape aShape;
293
294   Handle(GEOM_Function) aFunction = GetLastFunction();
295
296   if (!aFunction.IsNull())
297     aShape = aFunction->GetValue();
298
299   return aShape;
300 }
301
302 //=============================================================================
303 /*!
304  *  SetName
305  */
306 //=============================================================================
307 void GEOM_Object::SetName(const char* theName)
308 {
309   TDataStd_Name::Set(_label, (char*)theName);
310 }
311
312 //=============================================================================
313 /*!
314  *  GetName
315  */
316 //=============================================================================
317 TCollection_AsciiString GEOM_Object::GetName()
318 {
319   TCollection_AsciiString aName;
320   Handle(TDataStd_Name) aNameAttr;
321   if(_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr))
322     aName = aNameAttr->Get();
323   // do not return pointer of local variable
324   // return aName.ToCString();
325   // the following code could lead to memory leak, so take care about recieved pointer
326   return aName;
327 }
328
329 //=============================================================================
330 /*!
331  *  SetColor
332  */
333 //=============================================================================
334 void GEOM_Object::SetColor(const GEOM_Object::Color& theColor)
335 {
336   Handle(TDataStd_RealArray) anArray = new TDataStd_RealArray();
337   anArray->Init( 1, 3 );
338   anArray->SetValue( 1, theColor.R );
339   anArray->SetValue( 2, theColor.G );
340   anArray->SetValue( 3, theColor.B );
341
342   Handle(TDataStd_RealArray) anAttr =
343     TDataStd_RealArray::Set(_label.FindChild(COLOR_LABEL), anArray->Lower(), anArray->Upper());
344   anAttr->ChangeArray(anArray->Array());
345 }
346
347 //=============================================================================
348 /*!
349  *  GetColor
350  */
351 //=============================================================================
352 GEOM_Object::Color GEOM_Object::GetColor()
353 {
354   Handle(TDataStd_RealArray) anArray;
355   bool isFound = _label.FindChild(COLOR_LABEL).FindAttribute(TDataStd_RealArray::GetID(), anArray);
356
357   GEOM_Object::Color aColor;
358   aColor.R = isFound ? anArray->Value( 1 ) : -1;
359   aColor.G = isFound ? anArray->Value( 2 ) : -1;
360   aColor.B = isFound ? anArray->Value( 3 ) : -1;
361
362   return aColor;
363 }
364
365 //=============================================================================
366 /*!
367  *  SetAutoColor
368  */
369 //=============================================================================
370 void GEOM_Object::SetAutoColor(bool theAutoColor)
371 {
372   TDataStd_Integer::Set(_label.FindChild(AUTO_COLOR_LABEL), (int)theAutoColor);
373 }
374
375 //=============================================================================
376 /*!
377  *  GetAutoColor
378  */
379 //=============================================================================
380 bool GEOM_Object::GetAutoColor()
381 {
382   Handle(TDataStd_Integer) anAutoColor;
383   if(!_label.FindChild(AUTO_COLOR_LABEL).FindAttribute(TDataStd_Integer::GetID(), anAutoColor)) return false;
384
385   return bool(anAutoColor->Get());
386 }
387
388 //=============================================================================
389 /*!
390  *  SetMarkerStd
391  */
392 //=============================================================================
393 void GEOM_Object::SetMarkerStd(const Aspect_TypeOfMarker theType, double theSize)
394 {
395   TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL);
396   TDataStd_Integer::Set(aMarkerLabel.FindChild(MARKER_LABEL_TYPE), (int)theType);
397   TDataStd_Real::Set(aMarkerLabel.FindChild(MARKER_LABEL_SIZE), theSize);
398 }
399   
400 //=============================================================================
401 /*!
402  *  SetMarkerTexture
403  */
404 //=============================================================================
405 void GEOM_Object::SetMarkerTexture(int theTextureId)
406 {
407   TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL);
408   TDataStd_Integer::Set(aMarkerLabel.FindChild(MARKER_LABEL_TYPE), (int)Aspect_TOM_USERDEFINED);
409   TDataStd_Integer::Set(aMarkerLabel.FindChild(MARKER_LABEL_ID),   theTextureId);
410 }
411
412 //=============================================================================
413 /*!
414  *  GetMarkerType
415  */
416 //=============================================================================
417 Aspect_TypeOfMarker GEOM_Object::GetMarkerType()
418 {
419   Standard_Integer aType = -1;
420   TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL, Standard_False);
421   if(!aMarkerLabel.IsNull()) {
422     TDF_Label aTypeLabel = aMarkerLabel.FindChild(MARKER_LABEL_TYPE, Standard_False);
423     Handle(TDataStd_Integer) aTypeAttr;
424     if (!aTypeLabel.IsNull() && aTypeLabel.FindAttribute(TDataStd_Integer::GetID(), aTypeAttr))
425       aType = aTypeAttr->Get();
426   }
427   return (Aspect_TypeOfMarker)aType;
428 }
429
430 //=============================================================================
431 /*!
432  *  GetMarkerSize
433  */
434 //=============================================================================
435 double GEOM_Object::GetMarkerSize()
436 {
437   Standard_Real aSize = 0.;
438   TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL, Standard_False);
439   if(!aMarkerLabel.IsNull()) {
440     TDF_Label aSizeLabel = aMarkerLabel.FindChild(MARKER_LABEL_SIZE, Standard_False);
441     Handle(TDataStd_Real) aSizeAttr;
442     if (!aSizeLabel.IsNull() && aSizeLabel.FindAttribute(TDataStd_Real::GetID(), aSizeAttr))
443       aSize = aSizeAttr->Get();
444   }
445   return aSize;
446 }
447
448 //=============================================================================
449 /*!
450  *  GetMarkerTexture
451  */
452 //=============================================================================
453 int GEOM_Object::GetMarkerTexture()
454 {
455   Standard_Integer anId = 0;
456   if ( GetMarkerType() == Aspect_TOM_USERDEFINED) {
457     TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL, Standard_False);
458     if(!aMarkerLabel.IsNull()) {
459       TDF_Label aTypeLabel = aMarkerLabel.FindChild(MARKER_LABEL_ID, Standard_False);
460       Handle(TDataStd_Integer) anIdAttr;
461       if (!aTypeLabel.IsNull() && aTypeLabel.FindAttribute(TDataStd_Integer::GetID(), anIdAttr))
462         anId = anIdAttr->Get();
463     }
464   }
465   return anId;
466 }
467
468 //=============================================================================
469 /*!
470  *  SetAuxData
471  */
472 //=============================================================================
473 void GEOM_Object::UnsetMarker()
474 {
475   SetMarkerStd((Aspect_TypeOfMarker)-1, 0.);
476 }
477
478 //=============================================================================
479 /*!
480  *  SetAuxData
481  */
482 //=============================================================================
483 void GEOM_Object::SetAuxData(const char* theData)
484 {
485   TDataStd_Comment::Set(_label, (char*)theData);
486 }
487
488 //=============================================================================
489 /*!
490  *  GetAuxData
491  */
492 //=============================================================================
493 TCollection_AsciiString GEOM_Object::GetAuxData()
494 {
495   TCollection_AsciiString aData;
496
497   Handle(TDataStd_Comment) aCommentAttr;
498   if (_label.FindAttribute(TDataStd_Comment::GetID(), aCommentAttr))
499     aData = aCommentAttr->Get();
500
501   return aData;
502 }
503
504 //=============================================================================
505 /*!
506  *  SetParameters
507  */
508 //=============================================================================
509 void GEOM_Object::SetParameters(const TCollection_AsciiString& theParameters)
510 {
511   if( _parameters.IsEmpty() )
512     _parameters = theParameters;
513   else {
514     _parameters += "|";
515     _parameters += theParameters;
516   }
517 }
518
519 //=============================================================================
520 /*!
521  *  GetParameters
522  */
523 //=============================================================================
524 TCollection_AsciiString GEOM_Object::GetParameters() const
525 {
526   return _parameters;
527 }
528
529
530 //=============================================================================
531 /*!
532  *  IsSubShape
533  */
534 //=============================================================================
535 bool GEOM_Object::IsMainShape()
536 {
537   Handle(GEOM_Function) aFunction = GetFunction(1);
538   if(aFunction.IsNull() || aFunction->GetDriverGUID() != GetSubShapeID()) return true; // mkr : IPAL9921
539   return false;
540 }
541
542
543 //=============================================================================
544 /*!
545  *  AddFunction
546  */
547 //=============================================================================
548 Handle(GEOM_Function) GEOM_Object::AddFunction(const Standard_GUID& theGUID,
549                                                int                  theFunctionType,
550                                                bool                 allowSubShape)
551 {
552   Standard_Integer nb = GetNbFunctions();
553   if(!allowSubShape && nb == 1 && theGUID == GetSubShapeID()) return NULL; //It's impossible to add a function to sub-shape
554   nb++;
555   TDF_Label aChild = FUNCTION_LABEL(nb);
556
557   Handle(TDataStd_TreeNode) aNode = TDataStd_TreeNode::Set(aChild);
558   _root->Append(aNode);
559
560   Handle(GEOM_Function) aFunction = new GEOM_Function(aChild, theGUID, theFunctionType);
561
562   return aFunction;
563
564 }
565
566 //=============================================================================
567 /*!
568  *  GetNbFunctions
569  */
570 //=============================================================================
571 int GEOM_Object::GetNbFunctions()
572 {
573   Standard_Integer nb = 0;
574   for(TDataStd_ChildNodeIterator CI(_root); CI.More(); CI.Next()) nb++;
575   return nb;
576 }
577
578 //=============================================================================
579 /*!
580  *  GetFunction
581  */
582 //=============================================================================
583 Handle(GEOM_Function) GEOM_Object::GetFunction(int theFunctionNumber)
584 {
585   TDF_Label aChild = FUNCTION_LABEL(theFunctionNumber);
586   return GEOM_Function::GetFunction(aChild);
587 }
588
589 //=============================================================================
590 /*!
591  *  GetlastFunction
592  */
593 //=============================================================================
594 Handle(GEOM_Function) GEOM_Object::GetLastFunction()
595 {
596   Standard_Integer nb = GetNbFunctions();
597   if(nb) return GetFunction(nb);
598
599   return NULL;
600 }
601
602
603 //=============================================================================
604 /*!
605  *  GetAllDependency
606  */
607 //=============================================================================
608 Handle(TColStd_HSequenceOfTransient) GEOM_Object::GetAllDependency()
609 {
610   Handle(TColStd_HSequenceOfTransient) anArray;
611   TDF_LabelSequence aSeq;
612   Standard_Integer nb = GetNbFunctions();
613   if(nb == 0) return anArray;
614   for(Standard_Integer i=1; i<=nb; i++) {
615     Handle(GEOM_Function) aFunction = GetFunction(i);
616     if(aFunction.IsNull()) continue;
617     aFunction->GetDependency(aSeq);
618   }
619
620   Standard_Integer aLength = aSeq.Length();
621   if(aLength > 0) {
622     anArray = new TColStd_HSequenceOfTransient;
623     for(Standard_Integer j =1; j<=aLength; j++) {
624       Handle(GEOM_Object) aRefObj = GetReferencedObject(aSeq(j));
625       if(!aRefObj.IsNull()) anArray->Append(aRefObj);
626     }
627   }
628
629   return anArray;
630 }
631
632 //=============================================================================
633 /*!
634  *  GetLastDependency
635  */
636 //=============================================================================
637 Handle(TColStd_HSequenceOfTransient) GEOM_Object::GetLastDependency()
638 {
639   Handle(TColStd_HSequenceOfTransient) anArray;
640   Handle(GEOM_Function) aFunction = GetLastFunction();
641   if (aFunction.IsNull()) return anArray;
642
643   TDF_LabelSequence aSeq;
644   aFunction->GetDependency(aSeq);
645   Standard_Integer aLength = aSeq.Length();
646   if (aLength > 0) {
647     anArray = new TColStd_HSequenceOfTransient;
648     for (Standard_Integer i = 1; i <= aLength; i++)
649       anArray->Append(GetReferencedObject(aSeq(i)));
650   }
651
652   return anArray;
653 }
654
655 //================================================================================
656 /*!
657  * \brief Returns a driver creator of this object
658  */
659 //================================================================================
660
661 Handle(TFunction_Driver) GEOM_Object::GetCreationDriver()
662 {
663   Handle(TFunction_Driver) aDriver;
664
665   Handle(GEOM_Function) function = GetFunction(1);
666   if ( !function.IsNull() )
667   {
668     Standard_GUID aGUID = function->GetDriverGUID();
669     if ( TFunction_DriverTable::Get()->FindDriver(aGUID, aDriver))
670       aDriver->Init( function->GetEntry() );
671   }
672   return aDriver;
673 }
674
675 //=============================================================================
676 /*!
677  *  GetFreeLabel
678  */
679 //=============================================================================
680 TDF_Label GEOM_Object::GetFreeLabel()
681 {
682   return _label.FindChild(FREE_LABEL);
683 }
684
685 //=======================================================================
686 //function :  GEOM_Object_Type_
687 //purpose  :
688 //=======================================================================
689 Standard_EXPORT Handle_Standard_Type& GEOM_Object_Type_()
690 {
691
692   static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared);
693   if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared);
694   static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient);
695   if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient);
696
697
698   static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL};
699   static Handle_Standard_Type _aType = new Standard_Type("GEOM_Object",
700                                                          sizeof(GEOM_Object),
701                                                          1,
702                                                          (Standard_Address)_Ancestors,
703                                                          (Standard_Address)NULL);
704   return _aType;
705 }
706
707 //=======================================================================
708 //function : DownCast
709 //purpose  :
710 //=======================================================================
711
712 const Handle(GEOM_Object) Handle(GEOM_Object)::DownCast(const Handle(Standard_Transient)& AnObject)
713 {
714   Handle(GEOM_Object) _anOtherObject;
715
716   if (!AnObject.IsNull()) {
717      if (AnObject->IsKind(STANDARD_TYPE(GEOM_Object))) {
718        _anOtherObject = Handle(GEOM_Object)((Handle(GEOM_Object)&)AnObject);
719      }
720   }
721
722   return _anOtherObject ;
723 }
724
725