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