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