Salome HOME
Merge from V6_main_20120808 08Aug12
[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       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
152       TopoDS_Shape aShape_i_copy;
153       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
154       //if (aCopyTool.IsDone())
155       //  aShape_i_copy = aCopyTool.Shape();
156       //else
157       //  Standard_NullObject::Raise("Bad shape detected");
158       //
159       // fill aCopyMap for history
160       TopTools_IndexedMapOfShape aShape_i_inds;
161       TopTools_IndexedMapOfShape aShape_i_copy_inds;
162       TopExp::MapShapes(aShape_i, aShape_i_inds);
163       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
164       Standard_Integer nbInds = aShape_i_inds.Extent();
165       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
166         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
167       }
168       //
169       TopTools_ListOfShape aSimpleShapes;
170       //PrepareShapes(aShape_i, aType, aSimpleShapes);
171       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
172       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
173       for (; aSimpleIter.More(); aSimpleIter.Next()) {
174         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
175         if (ShapesMap.Add(aSimpleSh)) {
176           PS.AddShape(aSimpleSh);
177           //skl if (DoRemoveWebs) {
178           //skl if (aMaterials->Length() >= ind)
179           //skl PS.SetMaterial(aSimpleSh, aMaterials->Value(ind));
180           //skl }
181         }
182       }
183     }
184
185     // add tool shapes that are in ListTools and not in ListShapes;
186     for (ind = 1; ind <= aTools->Length(); ind++) {
187       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aTools->Value(ind));
188       TopoDS_Shape aShape_i = aRefShape->GetValue();
189       if (aShape_i.IsNull()) {
190         Standard_NullObject::Raise("In Partition a tool shape is null");
191       }
192       //
193       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
194       TopoDS_Shape aShape_i_copy;
195       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
196       //if (aCopyTool.IsDone())
197       //  aShape_i_copy = aCopyTool.Shape();
198       //else
199       //  Standard_NullObject::Raise("Bad shape detected");
200       //
201       // fill aCopyMap for history
202       TopTools_IndexedMapOfShape aShape_i_inds;
203       TopTools_IndexedMapOfShape aShape_i_copy_inds;
204       TopExp::MapShapes(aShape_i, aShape_i_inds);
205       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
206       Standard_Integer nbInds = aShape_i_inds.Extent();
207       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
208         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
209       }
210       //
211       TopTools_ListOfShape aSimpleShapes;
212       //PrepareShapes(aShape_i, aType, aSimpleShapes);
213       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
214       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
215       for (; aSimpleIter.More(); aSimpleIter.Next()) {
216         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
217         if (!ShapesMap.Contains(aSimpleSh) && ToolsMap.Add(aSimpleSh)) {
218           PS.AddTool(aSimpleSh);
219         }
220       }
221     }
222
223     // add shapes that are in ListKeepInside, as object shapes;
224     for (ind = 1; ind <= aKeepIns->Length(); ind++) {
225       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
226       TopoDS_Shape aShape_i = aRefShape->GetValue();
227       if (aShape_i.IsNull()) {
228         Standard_NullObject::Raise("In Partition a Keep Inside shape is null");
229       }
230       //
231       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
232       TopoDS_Shape aShape_i_copy;
233       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
234       //if (aCopyTool.IsDone())
235       //  aShape_i_copy = aCopyTool.Shape();
236       //else
237       //  Standard_NullObject::Raise("Bad shape detected");
238       //
239       // fill aCopyMap for history
240       TopTools_IndexedMapOfShape aShape_i_inds;
241       TopTools_IndexedMapOfShape aShape_i_copy_inds;
242       TopExp::MapShapes(aShape_i, aShape_i_inds);
243       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
244       Standard_Integer nbInds = aShape_i_inds.Extent();
245       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
246         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
247       }
248       //
249       TopTools_ListOfShape aSimpleShapes;
250       //PrepareShapes(aShape_i, aType, aSimpleShapes);
251       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
252       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
253       for (; aSimpleIter.More(); aSimpleIter.Next()) {
254         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
255         if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
256           PS.AddShape(aSimpleSh);
257       }
258     }
259
260     // add shapes that are in ListRemoveInside, as object shapes;
261     for (ind = 1; ind <= aRemIns->Length(); ind++) {
262       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
263       TopoDS_Shape aShape_i = aRefShape->GetValue();
264       if (aShape_i.IsNull()) {
265         Standard_NullObject::Raise("In Partition a Remove Inside shape is null");
266       }
267       //
268       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
269       TopoDS_Shape aShape_i_copy;
270       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
271       //if (aCopyTool.IsDone())
272       //  aShape_i_copy = aCopyTool.Shape();
273       //else
274       //  Standard_NullObject::Raise("Bad shape detected");
275       //
276       // fill aCopyMap for history
277       TopTools_IndexedMapOfShape aShape_i_inds;
278       TopTools_IndexedMapOfShape aShape_i_copy_inds;
279       TopExp::MapShapes(aShape_i, aShape_i_inds);
280       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
281       Standard_Integer nbInds = aShape_i_inds.Extent();
282       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
283         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
284       }
285       //
286       TopTools_ListOfShape aSimpleShapes;
287       //PrepareShapes(aShape_i, aType, aSimpleShapes);
288       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
289       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
290       for (; aSimpleIter.More(); aSimpleIter.Next()) {
291         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
292         if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
293           PS.AddShape(aSimpleSh);
294       }
295     }
296
297     PS.SetLimitMode(aCI.GetKeepNonlimitShapes());
298     PS.SetLimit((TopAbs_ShapeEnum)aCI.GetLimit());
299     PS.Perform();
300
301     //skl PS.Compute();
302     //skl PS.SetRemoveWebs(!DoRemoveWebs);
303     //skl PS.Build((TopAbs_ShapeEnum) aCI.GetLimit());
304     /*skl
305     // suppress result outside of shapes in KInsideMap
306     for (ind = 1; ind <= aKeepIns->Length(); ind++) {
307       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
308       TopoDS_Shape aShape_i = aRefShape->GetValue();
309       PS.KeepShapesInside(aShape_i);
310     }
311
312     // suppress result inside of shapes in RInsideMap
313     for (ind = 1; ind <= aRemIns->Length(); ind++) {
314       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
315       TopoDS_Shape aShape_i = aRefShape->GetValue();
316       PS.RemoveShapesInside(aShape_i);
317     }
318     */
319   }
320   else if (aType == PARTITION_HALF)
321   {
322     Handle(GEOM_Function) aRefShape = aCI.GetShape();
323     Handle(GEOM_Function) aRefPlane = aCI.GetPlane();
324     TopoDS_Shape aShapeArg = aRefShape->GetValue();
325     TopoDS_Shape aPlaneArg = aRefPlane->GetValue();
326
327     if (aShapeArg.IsNull() || aPlaneArg.IsNull()) {
328       Standard_NullObject::Raise("In Half Partition a shape or a plane is null");
329     }
330
331     TopoDS_Shape aShapeArg_copy;
332     TopoDS_Shape aPlaneArg_copy;
333     {
334       TNaming_CopyShape::CopyTool(aShapeArg, aMapTShapes, aShapeArg_copy);
335       //BRepBuilderAPI_Copy aCopyTool (aShapeArg);
336       //if (aCopyTool.IsDone())
337       //  aShapeArg_copy = aCopyTool.Shape();
338       //else
339       //  Standard_NullObject::Raise("Bad shape detected");
340       //
341       // fill aCopyMap for history
342       TopTools_IndexedMapOfShape aShapeArg_inds;
343       TopTools_IndexedMapOfShape aShapeArg_copy_inds;
344       TopExp::MapShapes(aShapeArg, aShapeArg_inds);
345       TopExp::MapShapes(aShapeArg_copy, aShapeArg_copy_inds);
346       Standard_Integer nbInds = aShapeArg_inds.Extent();
347       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
348         aCopyMap.Bind(aShapeArg_inds.FindKey(ie), aShapeArg_copy_inds.FindKey(ie));
349       }
350     }
351     {
352       TNaming_CopyShape::CopyTool(aPlaneArg, aMapTShapes, aPlaneArg_copy);
353       //BRepBuilderAPI_Copy aCopyTool (aPlaneArg);
354       //if (aCopyTool.IsDone())
355       //  aPlaneArg_copy = aCopyTool.Shape();
356       //else
357       //  Standard_NullObject::Raise("Bad shape detected");
358       //
359       // fill aCopyMap for history
360       TopTools_IndexedMapOfShape aPlaneArg_inds;
361       TopTools_IndexedMapOfShape aPlaneArg_copy_inds;
362       TopExp::MapShapes(aPlaneArg, aPlaneArg_inds);
363       TopExp::MapShapes(aPlaneArg_copy, aPlaneArg_copy_inds);
364       Standard_Integer nbInds = aPlaneArg_inds.Extent();
365       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
366         aCopyMap.Bind(aPlaneArg_inds.FindKey(ie), aPlaneArg_copy_inds.FindKey(ie));
367       }
368     }
369
370     // add object shapes that are in ListShapes;
371     PS.AddShape(aShapeArg_copy);
372     //PS.AddShape(aShapeArg);
373
374     // add tool shapes that are in ListTools and not in ListShapes;
375     PS.AddTool(aPlaneArg_copy);
376     //PS.AddTool(aPlaneArg);
377
378     //skl PS.Compute();
379     PS.Perform();
380     //PS.SetRemoveWebs(Standard_False);
381     //PS.Build(aShapeArg.ShapeType());
382
383   } else {
384   }
385
386   aShape = PS.Shape();
387   if (aShape.IsNull()) return 0;
388
389   //Alternative case to check not valid partition IPAL21418
390   TopoDS_Iterator It (aShape, Standard_True, Standard_True);
391   int nbSubshapes=0;
392   for (; It.More(); It.Next())
393     nbSubshapes++;
394   if (!nbSubshapes)
395     Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
396   //end of IPAL21418
397
398   if (!BRepAlgo::IsValid(aShape)) {
399     // 08.07.2008 added by skl during fixing bug 19761 from Mantis
400     ShapeFix_ShapeTolerance aSFT;
401     aSFT.LimitTolerance(aShape, Precision::Confusion(),
402                         Precision::Confusion(), TopAbs_SHAPE);
403     Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
404     aSfs->Perform();
405     aShape = aSfs->Shape();
406     if (!BRepAlgo::IsValid(aShape))
407       Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
408   }
409
410   aFunction->SetValue(aShape);
411
412   // Fill history to be used by GetInPlace functionality
413   TopTools_IndexedMapOfShape aResIndices;
414   TopExp::MapShapes(aShape, aResIndices);
415
416   // Map: source_shape/images of source_shape in Result
417   const TopTools_IndexedDataMapOfShapeListOfShape& aMR = PS.ImagesResult();
418
419   // history for all argument shapes
420   // be sure to use aCopyMap
421   TDF_LabelSequence aLabelSeq;
422   aFunction->GetDependency(aLabelSeq);
423   Standard_Integer nbArg = aLabelSeq.Length();
424
425   for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) {
426
427     TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);
428
429     Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
430     TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();
431
432     TopTools_IndexedMapOfShape anArgumentIndices;
433     TopExp::MapShapes(anArgumentShape, anArgumentIndices);
434     Standard_Integer nbArgumentEntities = anArgumentIndices.Extent();
435
436     // Find corresponding label in history
437     TDF_Label anArgumentHistoryLabel =
438       aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True);
439
440     for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) {
441       TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie);
442       // be sure to use aCopyMap here
443       if (aCopyMap.IsBound(anEntity))
444         anEntity = aCopyMap.Find(anEntity);
445       //
446       if (!aMR.Contains(anEntity)) continue;
447
448       const TopTools_ListOfShape& aModified = aMR.FindFromKey(anEntity);
449       Standard_Integer nbModified = aModified.Extent();
450
451       if (nbModified > 0) { // Mantis issue 0021182
452         int ih = 1;
453         TopTools_ListIteratorOfListOfShape itM (aModified);
454         for (; itM.More() && nbModified > 0; itM.Next(), ++ih) {
455           if (!aResIndices.Contains(itM.Value())) {
456             nbModified = 0;
457           }
458         }
459       }
460       if (nbModified > 0) {
461         TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True);
462         Handle(TDataStd_IntegerArray) anAttr =
463           TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified);
464
465         int ih = 1;
466         TopTools_ListIteratorOfListOfShape itM (aModified);
467         for (; itM.More(); itM.Next(), ++ih) {
468           int id = aResIndices.FindIndex(itM.Value());
469           anAttr->SetValue(ih, id);
470         }
471       }
472     }
473   }
474
475   log.SetTouched(Label());
476
477   return 1;
478 }
479
480
481 //=======================================================================
482 //function :  GEOMImpl_PartitionDriver_Type_
483 //purpose  :
484 //=======================================================================
485 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_()
486 {
487   static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
488   if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
489   static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
490   if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
491   static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
492   if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
493
494   static Handle_Standard_Transient _Ancestors[] = {aType1,aType2,aType3,NULL};
495   static Handle_Standard_Type _aType =
496     new Standard_Type ("GEOMImpl_PartitionDriver", sizeof(GEOMImpl_PartitionDriver),
497                        1, (Standard_Address)_Ancestors, (Standard_Address)NULL);
498
499   return _aType;
500 }
501
502 //=======================================================================
503 //function : DownCast
504 //purpose  :
505 //=======================================================================
506 const Handle(GEOMImpl_PartitionDriver) Handle(GEOMImpl_PartitionDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
507 {
508   Handle(GEOMImpl_PartitionDriver) _anOtherObject;
509
510   if (!AnObject.IsNull()) {
511      if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PartitionDriver))) {
512        _anOtherObject = Handle(GEOMImpl_PartitionDriver)((Handle(GEOMImpl_PartitionDriver)&)AnObject);
513      }
514   }
515
516   return _anOtherObject;
517 }