Salome HOME
0021018: EDF 1592 GEOM: Problems with the radius input field in the Fillet 1D dialog box
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PartitionDriver.cxx
1 //  Copyright (C) 2007-2010  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 #include <Standard_Stream.hxx>
23
24 #include <GEOMImpl_PartitionDriver.hxx>
25 #include <GEOMImpl_IPartition.hxx>
26 #include <GEOMImpl_Types.hxx>
27
28 #include <GEOM_Object.hxx>
29 #include <GEOM_Function.hxx>
30
31 #include <GEOMAlgo_Splitter.hxx>
32
33 #include <TDataStd_IntegerArray.hxx>
34 #include <TNaming_CopyShape.hxx>
35
36 //#include <BRepBuilderAPI_Copy.hxx>
37 #include <BRep_Tool.hxx>
38 #include <BRepAlgo.hxx>
39
40 #include <TopAbs.hxx>
41 #include <TopExp.hxx>
42 #include <TopoDS.hxx>
43 #include <TopoDS_Shape.hxx>
44 #include <TopoDS_Vertex.hxx>
45 #include <TopoDS_Wire.hxx>
46 #include <TopoDS_Iterator.hxx>
47 #include <TopTools_MapOfShape.hxx>
48 #include <TopTools_IndexedMapOfShape.hxx>
49 #include <TopTools_ListIteratorOfListOfShape.hxx>
50 #include <TopTools_DataMapOfShapeShape.hxx>
51
52 #include <ShapeFix_ShapeTolerance.hxx>
53 #include <ShapeFix_Shape.hxx>
54
55 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
56 #include <TColStd_ListIteratorOfListOfInteger.hxx>
57 #include <TColStd_ListOfInteger.hxx>
58 #include <Standard_NullObject.hxx>
59 #include <Precision.hxx>
60 #include <gp_Pnt.hxx>
61
62 //=======================================================================
63 //function : GetID
64 //purpose  :
65 //=======================================================================
66 const Standard_GUID& GEOMImpl_PartitionDriver::GetID()
67 {
68   static Standard_GUID aPartitionDriver("FF1BBB22-5D14-4df2-980B-3A668264EA16");
69   return aPartitionDriver;
70 }
71
72
73 //=======================================================================
74 //function : GEOMImpl_PartitionDriver
75 //purpose  :
76 //=======================================================================
77 GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver()
78 {
79 }
80
81 //=======================================================================
82 //function : SimplifyCompound
83 //purpose  :
84 //=======================================================================
85 static void PrepareShapes (const TopoDS_Shape&   theShape,
86                            Standard_Integer      theType,
87                            TopTools_ListOfShape& theSimpleList)
88 {
89   if (theType == PARTITION_NO_SELF_INTERSECTIONS ||
90       theShape.ShapeType() != TopAbs_COMPOUND) {
91     theSimpleList.Append(theShape);
92     return;
93   }
94
95   // explode compound on simple shapes to allow their intersections
96   TopoDS_Iterator It (theShape, Standard_True, Standard_True);
97   TopTools_MapOfShape mapShape;
98   for (; It.More(); It.Next()) {
99     if (mapShape.Add(It.Value())) {
100       TopoDS_Shape curSh = It.Value();
101       PrepareShapes(curSh, theType, theSimpleList);
102     }
103   }
104 }
105
106 //=======================================================================
107 //function : Execute
108 //purpose  :
109 //=======================================================================
110 Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
111 {
112   if (Label().IsNull()) return 0;
113   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
114
115   GEOMImpl_IPartition aCI (aFunction);
116   Standard_Integer aType = aFunction->GetType();
117
118   TopoDS_Shape aShape;
119   //sklNMTAlgo_Splitter1 PS;
120   GEOMAlgo_Splitter PS;
121
122   TopTools_DataMapOfShapeShape aCopyMap;
123   TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
124
125   if (aType == PARTITION_PARTITION || aType == PARTITION_NO_SELF_INTERSECTIONS)
126   {
127     Handle(TColStd_HSequenceOfTransient) aShapes  = aCI.GetShapes();
128     Handle(TColStd_HSequenceOfTransient) aTools   = aCI.GetTools();
129     Handle(TColStd_HSequenceOfTransient) aKeepIns = aCI.GetKeepIns();
130     Handle(TColStd_HSequenceOfTransient) aRemIns  = aCI.GetRemoveIns();
131     Handle(TColStd_HArray1OfInteger) aMaterials   = aCI.GetMaterials();
132     //skl Standard_Boolean DoRemoveWebs = !aMaterials.IsNull();
133
134     unsigned int ind;
135     //unsigned int ind, nbshapes = 0;
136     //nbshapes += aShapes->Length() + aTools->Length();
137     //nbshapes += aKeepIns->Length() + aRemIns->Length();
138     //TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes);
139     TopTools_MapOfShape ShapesMap, ToolsMap;
140
141     // add object shapes that are in ListShapes;
142     for (ind = 1; ind <= aShapes->Length(); ind++) {
143       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind));
144       TopoDS_Shape aShape_i = aRefShape->GetValue();
145       if (aShape_i.IsNull()) {
146         Standard_NullObject::Raise("In Partition a shape is null");
147       }
148       //
149       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
150       TopoDS_Shape aShape_i_copy;
151       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
152       //if (aCopyTool.IsDone())
153       //  aShape_i_copy = aCopyTool.Shape();
154       //else
155       //  Standard_NullObject::Raise("Bad shape detected");
156       //
157       // fill aCopyMap for history
158       TopTools_IndexedMapOfShape aShape_i_inds;
159       TopTools_IndexedMapOfShape aShape_i_copy_inds;
160       TopExp::MapShapes(aShape_i, aShape_i_inds);
161       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
162       Standard_Integer nbInds = aShape_i_inds.Extent();
163       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
164         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
165       }
166       //
167       TopTools_ListOfShape aSimpleShapes;
168       //PrepareShapes(aShape_i, aType, aSimpleShapes);
169       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
170       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
171       for (; aSimpleIter.More(); aSimpleIter.Next()) {
172         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
173         if (ShapesMap.Add(aSimpleSh)) {
174           PS.AddShape(aSimpleSh);
175           //skl if (DoRemoveWebs) {
176           //skl if (aMaterials->Length() >= ind)
177           //skl PS.SetMaterial(aSimpleSh, aMaterials->Value(ind));
178           //skl }
179         }
180       }
181     }
182
183     // add tool shapes that are in ListTools and not in ListShapes;
184     for (ind = 1; ind <= aTools->Length(); ind++) {
185       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aTools->Value(ind));
186       TopoDS_Shape aShape_i = aRefShape->GetValue();
187       if (aShape_i.IsNull()) {
188         Standard_NullObject::Raise("In Partition a tool shape is null");
189       }
190       //
191       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
192       TopoDS_Shape aShape_i_copy;
193       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
194       //if (aCopyTool.IsDone())
195       //  aShape_i_copy = aCopyTool.Shape();
196       //else
197       //  Standard_NullObject::Raise("Bad shape detected");
198       //
199       // fill aCopyMap for history
200       TopTools_IndexedMapOfShape aShape_i_inds;
201       TopTools_IndexedMapOfShape aShape_i_copy_inds;
202       TopExp::MapShapes(aShape_i, aShape_i_inds);
203       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
204       Standard_Integer nbInds = aShape_i_inds.Extent();
205       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
206         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
207       }
208       //
209       TopTools_ListOfShape aSimpleShapes;
210       //PrepareShapes(aShape_i, aType, aSimpleShapes);
211       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
212       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
213       for (; aSimpleIter.More(); aSimpleIter.Next()) {
214         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
215         if (!ShapesMap.Contains(aSimpleSh) && ToolsMap.Add(aSimpleSh)) {
216           PS.AddTool(aSimpleSh);
217         }
218       }
219     }
220
221     // add shapes that are in ListKeepInside, as object shapes;
222     for (ind = 1; ind <= aKeepIns->Length(); ind++) {
223       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
224       TopoDS_Shape aShape_i = aRefShape->GetValue();
225       if (aShape_i.IsNull()) {
226         Standard_NullObject::Raise("In Partition a Keep Inside shape is null");
227       }
228       //
229       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
230       TopoDS_Shape aShape_i_copy;
231       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
232       //if (aCopyTool.IsDone())
233       //  aShape_i_copy = aCopyTool.Shape();
234       //else
235       //  Standard_NullObject::Raise("Bad shape detected");
236       //
237       // fill aCopyMap for history
238       TopTools_IndexedMapOfShape aShape_i_inds;
239       TopTools_IndexedMapOfShape aShape_i_copy_inds;
240       TopExp::MapShapes(aShape_i, aShape_i_inds);
241       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
242       Standard_Integer nbInds = aShape_i_inds.Extent();
243       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
244         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
245       }
246       //
247       TopTools_ListOfShape aSimpleShapes;
248       //PrepareShapes(aShape_i, aType, aSimpleShapes);
249       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
250       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
251       for (; aSimpleIter.More(); aSimpleIter.Next()) {
252         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
253         if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
254           PS.AddShape(aSimpleSh);
255       }
256     }
257
258     // add shapes that are in ListRemoveInside, as object shapes;
259     for (ind = 1; ind <= aRemIns->Length(); ind++) {
260       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
261       TopoDS_Shape aShape_i = aRefShape->GetValue();
262       if (aShape_i.IsNull()) {
263         Standard_NullObject::Raise("In Partition a Remove Inside shape is null");
264       }
265       //
266       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
267       TopoDS_Shape aShape_i_copy;
268       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
269       //if (aCopyTool.IsDone())
270       //  aShape_i_copy = aCopyTool.Shape();
271       //else
272       //  Standard_NullObject::Raise("Bad shape detected");
273       //
274       // fill aCopyMap for history
275       TopTools_IndexedMapOfShape aShape_i_inds;
276       TopTools_IndexedMapOfShape aShape_i_copy_inds;
277       TopExp::MapShapes(aShape_i, aShape_i_inds);
278       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
279       Standard_Integer nbInds = aShape_i_inds.Extent();
280       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
281         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
282       }
283       //
284       TopTools_ListOfShape aSimpleShapes;
285       //PrepareShapes(aShape_i, aType, aSimpleShapes);
286       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
287       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
288       for (; aSimpleIter.More(); aSimpleIter.Next()) {
289         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
290         if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
291           PS.AddShape(aSimpleSh);
292       }
293     }
294
295     PS.SetLimitMode(aCI.GetKeepNonlimitShapes());
296     PS.SetLimit((TopAbs_ShapeEnum)aCI.GetLimit());
297     PS.Perform();
298
299     //skl PS.Compute();
300     //skl PS.SetRemoveWebs(!DoRemoveWebs);
301     //skl PS.Build((TopAbs_ShapeEnum) aCI.GetLimit());
302     /*skl
303     // suppress result outside of shapes in KInsideMap
304     for (ind = 1; ind <= aKeepIns->Length(); ind++) {
305       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
306       TopoDS_Shape aShape_i = aRefShape->GetValue();
307       PS.KeepShapesInside(aShape_i);
308     }
309
310     // suppress result inside of shapes in RInsideMap
311     for (ind = 1; ind <= aRemIns->Length(); ind++) {
312       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
313       TopoDS_Shape aShape_i = aRefShape->GetValue();
314       PS.RemoveShapesInside(aShape_i);
315     }
316     */
317   }
318   else if (aType == PARTITION_HALF)
319   {
320     Handle(GEOM_Function) aRefShape = aCI.GetShape();
321     Handle(GEOM_Function) aRefPlane = aCI.GetPlane();
322     TopoDS_Shape aShapeArg = aRefShape->GetValue();
323     TopoDS_Shape aPlaneArg = aRefPlane->GetValue();
324
325     if (aShapeArg.IsNull() || aPlaneArg.IsNull()) {
326       Standard_NullObject::Raise("In Half Partition a shape or a plane is null");
327     }
328
329     TopoDS_Shape aShapeArg_copy;
330     TopoDS_Shape aPlaneArg_copy;
331     {
332       TNaming_CopyShape::CopyTool(aShapeArg, aMapTShapes, aShapeArg_copy);
333       //BRepBuilderAPI_Copy aCopyTool (aShapeArg);
334       //if (aCopyTool.IsDone())
335       //  aShapeArg_copy = aCopyTool.Shape();
336       //else
337       //  Standard_NullObject::Raise("Bad shape detected");
338       //
339       // fill aCopyMap for history
340       TopTools_IndexedMapOfShape aShapeArg_inds;
341       TopTools_IndexedMapOfShape aShapeArg_copy_inds;
342       TopExp::MapShapes(aShapeArg, aShapeArg_inds);
343       TopExp::MapShapes(aShapeArg_copy, aShapeArg_copy_inds);
344       Standard_Integer nbInds = aShapeArg_inds.Extent();
345       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
346         aCopyMap.Bind(aShapeArg_inds.FindKey(ie), aShapeArg_copy_inds.FindKey(ie));
347       }
348     }
349     {
350       TNaming_CopyShape::CopyTool(aPlaneArg, aMapTShapes, aPlaneArg_copy);
351       //BRepBuilderAPI_Copy aCopyTool (aPlaneArg);
352       //if (aCopyTool.IsDone())
353       //  aPlaneArg_copy = aCopyTool.Shape();
354       //else
355       //  Standard_NullObject::Raise("Bad shape detected");
356       //
357       // fill aCopyMap for history
358       TopTools_IndexedMapOfShape aPlaneArg_inds;
359       TopTools_IndexedMapOfShape aPlaneArg_copy_inds;
360       TopExp::MapShapes(aPlaneArg, aPlaneArg_inds);
361       TopExp::MapShapes(aPlaneArg_copy, aPlaneArg_copy_inds);
362       Standard_Integer nbInds = aPlaneArg_inds.Extent();
363       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
364         aCopyMap.Bind(aPlaneArg_inds.FindKey(ie), aPlaneArg_copy_inds.FindKey(ie));
365       }
366     }
367
368     // add object shapes that are in ListShapes;
369     PS.AddShape(aShapeArg_copy);
370     //PS.AddShape(aShapeArg);
371
372     // add tool shapes that are in ListTools and not in ListShapes;
373     PS.AddTool(aPlaneArg_copy);
374     //PS.AddTool(aPlaneArg);
375
376     //skl PS.Compute();
377     PS.Perform();
378     //PS.SetRemoveWebs(Standard_False);
379     //PS.Build(aShapeArg.ShapeType());
380
381   } else {
382   }
383
384   aShape = PS.Shape();
385   if (aShape.IsNull()) return 0;
386
387   //Alternative case to check not valid partition IPAL21418
388   TopoDS_Iterator It (aShape, Standard_True, Standard_True);
389   int nbSubshapes=0;
390   for (; It.More(); It.Next())
391     nbSubshapes++;
392   if (!nbSubshapes)
393     Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
394   //end of IPAL21418
395
396   if (!BRepAlgo::IsValid(aShape)) {
397     // 08.07.2008 added by skl during fixing bug 19761 from Mantis
398     ShapeFix_ShapeTolerance aSFT;
399     aSFT.LimitTolerance(aShape, Precision::Confusion(),
400                         Precision::Confusion(), TopAbs_SHAPE);
401     Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
402     aSfs->Perform();
403     aShape = aSfs->Shape();
404     if (!BRepAlgo::IsValid(aShape))
405       Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
406   }
407
408   aFunction->SetValue(aShape);
409
410   // Fill history to be used by GetInPlace functionality
411   TopTools_IndexedMapOfShape aResIndices;
412   TopExp::MapShapes(aShape, aResIndices);
413
414   // Map: source_shape/images of source_shape in Result
415   const TopTools_IndexedDataMapOfShapeListOfShape& aMR = PS.ImagesResult();
416
417   // history for all argument shapes
418   // be sure to use aCopyMap
419   TDF_LabelSequence aLabelSeq;
420   aFunction->GetDependency(aLabelSeq);
421   Standard_Integer nbArg = aLabelSeq.Length();
422
423   for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) {
424
425     TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);
426
427     Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
428     TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();
429
430     TopTools_IndexedMapOfShape anArgumentIndices;
431     TopExp::MapShapes(anArgumentShape, anArgumentIndices);
432     Standard_Integer nbArgumentEntities = anArgumentIndices.Extent();
433
434     // Find corresponding label in history
435     TDF_Label anArgumentHistoryLabel =
436       aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True);
437
438     for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) {
439       TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie);
440       // be sure to use aCopyMap here
441       if (aCopyMap.IsBound(anEntity))
442         anEntity = aCopyMap.Find(anEntity);
443       //
444       if (!aMR.Contains(anEntity)) continue;
445
446       const TopTools_ListOfShape& aModified = aMR.FindFromKey(anEntity);
447       Standard_Integer nbModified = aModified.Extent();
448
449       if (nbModified > 0) {
450         TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True);
451         Handle(TDataStd_IntegerArray) anAttr =
452           TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified);
453
454         int ih = 1;
455         TopTools_ListIteratorOfListOfShape itM (aModified);
456         for (; itM.More(); itM.Next(), ++ih) {
457           int id = aResIndices.FindIndex(itM.Value());
458           anAttr->SetValue(ih, id);
459         }
460       }
461     }
462   }
463
464   log.SetTouched(Label());
465
466   return 1;
467 }
468
469
470 //=======================================================================
471 //function :  GEOMImpl_PartitionDriver_Type_
472 //purpose  :
473 //=======================================================================
474 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_()
475 {
476   static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
477   if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
478   static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
479   if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
480   static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
481   if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
482
483   static Handle_Standard_Transient _Ancestors[] = {aType1,aType2,aType3,NULL};
484   static Handle_Standard_Type _aType =
485     new Standard_Type ("GEOMImpl_PartitionDriver", sizeof(GEOMImpl_PartitionDriver),
486                        1, (Standard_Address)_Ancestors, (Standard_Address)NULL);
487
488   return _aType;
489 }
490
491 //=======================================================================
492 //function : DownCast
493 //purpose  :
494 //=======================================================================
495 const Handle(GEOMImpl_PartitionDriver) Handle(GEOMImpl_PartitionDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
496 {
497   Handle(GEOMImpl_PartitionDriver) _anOtherObject;
498
499   if (!AnObject.IsNull()) {
500      if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PartitionDriver))) {
501        _anOtherObject = Handle(GEOMImpl_PartitionDriver)((Handle(GEOMImpl_PartitionDriver)&)AnObject);
502      }
503   }
504
505   return _anOtherObject;
506 }