Salome HOME
0022338: EDF GEOM: Regression when partitoning a compound by a plane
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PartitionDriver.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 <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 <StdFail_NotDone.hxx>
62 #include <Precision.hxx>
63 #include <gp_Pnt.hxx>
64 #include <BOPAlgo_CheckerSI.hxx>
65 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
66 #include <BOPCol_ListOfShape.hxx>
67 #include <BOPDS_DS.hxx>
68
69 // Depth of self-intersection check (see BOPAlgo_CheckerSI::SetLevelOfCheck() for more details)
70 // Default value for BOPAlgo_CheckerSI gives very long computation when checking face-to-face intersections;
71 // here check level is decreased to more appropriate value to avoid problems with performance).
72 #define BOP_SELF_INTERSECTIONS_LEVEL 4
73
74 //=======================================================================
75 //function : GetID
76 //purpose  :
77 //=======================================================================
78 const Standard_GUID& GEOMImpl_PartitionDriver::GetID()
79 {
80   static Standard_GUID aPartitionDriver("FF1BBB22-5D14-4df2-980B-3A668264EA16");
81   return aPartitionDriver;
82 }
83
84
85 //=======================================================================
86 //function : GEOMImpl_PartitionDriver
87 //purpose  :
88 //=======================================================================
89 GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver()
90 {
91 }
92
93 //=======================================================================
94 //function : SimplifyCompound
95 //purpose  :
96 //=======================================================================
97 static void PrepareShapes (const TopoDS_Shape&   theShape,
98                            Standard_Integer      theType,
99                            TopTools_ListOfShape& theSimpleList)
100 {
101   if (theType == PARTITION_NO_SELF_INTERSECTIONS ||
102       theShape.ShapeType() != TopAbs_COMPOUND) {
103     theSimpleList.Append(theShape);
104     return;
105   }
106
107   // explode compound on simple shapes to allow their intersections
108   TopoDS_Iterator It (theShape, Standard_True, Standard_True);
109   TopTools_MapOfShape mapShape;
110   for (; It.More(); It.Next()) {
111     if (mapShape.Add(It.Value())) {
112       TopoDS_Shape curSh = It.Value();
113       PrepareShapes(curSh, theType, theSimpleList);
114     }
115   }
116 }
117
118 static void CheckSelfIntersection(const TopoDS_Shape &theShape)
119 {
120   BOPAlgo_CheckerSI aCSI;  // checker of self-interferences
121   BOPCol_ListOfShape aList;
122
123   aList.Append(theShape);
124   aCSI.SetLevelOfCheck(BOP_SELF_INTERSECTIONS_LEVEL);
125   aCSI.SetArguments(aList);
126   aCSI.Perform();
127
128   if (aCSI.ErrorStatus() || aCSI.DS().Interferences().Extent() > 0) {
129     StdFail_NotDone::Raise("Partition operation will not be performed, because argument shape is self-intersected");
130   }
131 }
132
133 //=======================================================================
134 //function : Execute
135 //purpose  :
136 //=======================================================================
137 Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
138 {
139   if (Label().IsNull()) return 0;
140   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
141
142   GEOMImpl_IPartition aCI (aFunction);
143   Standard_Integer aType = aFunction->GetType();
144   const Standard_Boolean isCheckSelfInte = aCI.GetCheckSelfIntersection();
145
146   TopoDS_Shape aShape;
147   GEOMAlgo_Splitter PS;
148
149   TopTools_DataMapOfShapeShape aCopyMap;
150   TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
151
152   if (aType == PARTITION_PARTITION || aType == PARTITION_NO_SELF_INTERSECTIONS)
153   {
154     Handle(TColStd_HSequenceOfTransient) aShapes  = aCI.GetShapes();
155     Handle(TColStd_HSequenceOfTransient) aTools   = aCI.GetTools();
156     Handle(TColStd_HSequenceOfTransient) aKeepIns = aCI.GetKeepIns();
157     Handle(TColStd_HSequenceOfTransient) aRemIns  = aCI.GetRemoveIns();
158     Handle(TColStd_HArray1OfInteger) aMaterials   = aCI.GetMaterials();
159     //skl Standard_Boolean DoRemoveWebs = !aMaterials.IsNull();
160
161     unsigned int ind;
162     //unsigned int ind, nbshapes = 0;
163     //nbshapes += aShapes->Length() + aTools->Length();
164     //nbshapes += aKeepIns->Length() + aRemIns->Length();
165     //TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes);
166     TopTools_MapOfShape ShapesMap, ToolsMap;
167
168     // add object shapes that are in ListShapes;
169     for (ind = 1; ind <= aShapes->Length(); ind++) {
170       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind));
171       TopoDS_Shape aShape_i = aRefShape->GetValue();
172       if (aShape_i.IsNull()) {
173         Standard_NullObject::Raise("In Partition a shape is null");
174       }
175
176       // Check self-intersection.
177       if (isCheckSelfInte) {
178         CheckSelfIntersection(aShape_i);
179       }
180
181       TopoDS_Shape aShape_i_copy;
182       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
183
184       // fill aCopyMap for history
185       TopTools_IndexedMapOfShape aShape_i_inds;
186       TopTools_IndexedMapOfShape aShape_i_copy_inds;
187       TopExp::MapShapes(aShape_i, aShape_i_inds);
188       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
189       Standard_Integer nbInds = aShape_i_inds.Extent();
190       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
191         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
192       }
193       //
194       TopTools_ListOfShape aSimpleShapes;
195       //PrepareShapes(aShape_i, aType, aSimpleShapes);
196       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
197       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
198       for (; aSimpleIter.More(); aSimpleIter.Next()) {
199         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
200         if (ShapesMap.Add(aSimpleSh)) {
201           PS.AddArgument(aSimpleSh);
202           //skl if (DoRemoveWebs) {
203           //skl if (aMaterials->Length() >= ind)
204           //skl PS.SetMaterial(aSimpleSh, aMaterials->Value(ind));
205           //skl }
206         }
207       }
208     }
209
210     // add tool shapes that are in ListTools and not in ListShapes;
211     for (ind = 1; ind <= aTools->Length(); ind++) {
212       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aTools->Value(ind));
213       TopoDS_Shape aShape_i = aRefShape->GetValue();
214       if (aShape_i.IsNull()) {
215         Standard_NullObject::Raise("In Partition a tool shape is null");
216       }
217
218       // Check self-intersection.
219       if (isCheckSelfInte) {
220         CheckSelfIntersection(aShape_i);
221       }
222
223       //
224       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
225       TopoDS_Shape aShape_i_copy;
226       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
227       //if (aCopyTool.IsDone())
228       //  aShape_i_copy = aCopyTool.Shape();
229       //else
230       //  Standard_NullObject::Raise("Bad shape detected");
231       //
232       // fill aCopyMap for history
233       TopTools_IndexedMapOfShape aShape_i_inds;
234       TopTools_IndexedMapOfShape aShape_i_copy_inds;
235       TopExp::MapShapes(aShape_i, aShape_i_inds);
236       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
237       Standard_Integer nbInds = aShape_i_inds.Extent();
238       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
239         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
240       }
241       //
242       TopTools_ListOfShape aSimpleShapes;
243       //PrepareShapes(aShape_i, aType, aSimpleShapes);
244       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
245       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
246       for (; aSimpleIter.More(); aSimpleIter.Next()) {
247         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
248         if (!ShapesMap.Contains(aSimpleSh) && ToolsMap.Add(aSimpleSh)) {
249           PS.AddTool(aSimpleSh);
250         }
251       }
252     }
253
254     // add shapes that are in ListKeepInside, as object shapes;
255     for (ind = 1; ind <= aKeepIns->Length(); ind++) {
256       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
257       TopoDS_Shape aShape_i = aRefShape->GetValue();
258       if (aShape_i.IsNull()) {
259         Standard_NullObject::Raise("In Partition a Keep Inside shape is null");
260       }
261       //
262       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
263       TopoDS_Shape aShape_i_copy;
264       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
265       //if (aCopyTool.IsDone())
266       //  aShape_i_copy = aCopyTool.Shape();
267       //else
268       //  Standard_NullObject::Raise("Bad shape detected");
269       //
270       // fill aCopyMap for history
271       TopTools_IndexedMapOfShape aShape_i_inds;
272       TopTools_IndexedMapOfShape aShape_i_copy_inds;
273       TopExp::MapShapes(aShape_i, aShape_i_inds);
274       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
275       Standard_Integer nbInds = aShape_i_inds.Extent();
276       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
277         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
278       }
279       //
280       TopTools_ListOfShape aSimpleShapes;
281       //PrepareShapes(aShape_i, aType, aSimpleShapes);
282       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
283       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
284       for (; aSimpleIter.More(); aSimpleIter.Next()) {
285         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
286         if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
287           PS.AddArgument(aSimpleSh);
288       }
289     }
290
291     // add shapes that are in ListRemoveInside, as object shapes;
292     for (ind = 1; ind <= aRemIns->Length(); ind++) {
293       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
294       TopoDS_Shape aShape_i = aRefShape->GetValue();
295       if (aShape_i.IsNull()) {
296         Standard_NullObject::Raise("In Partition a Remove Inside shape is null");
297       }
298       //
299       //BRepBuilderAPI_Copy aCopyTool (aShape_i);
300       TopoDS_Shape aShape_i_copy;
301       TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
302       //if (aCopyTool.IsDone())
303       //  aShape_i_copy = aCopyTool.Shape();
304       //else
305       //  Standard_NullObject::Raise("Bad shape detected");
306       //
307       // fill aCopyMap for history
308       TopTools_IndexedMapOfShape aShape_i_inds;
309       TopTools_IndexedMapOfShape aShape_i_copy_inds;
310       TopExp::MapShapes(aShape_i, aShape_i_inds);
311       TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
312       Standard_Integer nbInds = aShape_i_inds.Extent();
313       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
314         aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
315       }
316       //
317       TopTools_ListOfShape aSimpleShapes;
318       //PrepareShapes(aShape_i, aType, aSimpleShapes);
319       PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
320       TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
321       for (; aSimpleIter.More(); aSimpleIter.Next()) {
322         const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
323         if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
324           PS.AddArgument(aSimpleSh);
325       }
326     }
327
328     PS.SetLimitMode(aCI.GetKeepNonlimitShapes());
329     PS.SetLimit((TopAbs_ShapeEnum)aCI.GetLimit());
330     PS.Perform();
331
332     //skl PS.Compute();
333     //skl PS.SetRemoveWebs(!DoRemoveWebs);
334     //skl PS.Build((TopAbs_ShapeEnum) aCI.GetLimit());
335     /*skl
336     // suppress result outside of shapes in KInsideMap
337     for (ind = 1; ind <= aKeepIns->Length(); ind++) {
338       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
339       TopoDS_Shape aShape_i = aRefShape->GetValue();
340       PS.KeepShapesInside(aShape_i);
341     }
342
343     // suppress result inside of shapes in RInsideMap
344     for (ind = 1; ind <= aRemIns->Length(); ind++) {
345       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
346       TopoDS_Shape aShape_i = aRefShape->GetValue();
347       PS.RemoveShapesInside(aShape_i);
348     }
349     */
350   }
351   else if (aType == PARTITION_HALF)
352   {
353     Handle(GEOM_Function) aRefShape = aCI.GetShape();
354     Handle(GEOM_Function) aRefPlane = aCI.GetPlane();
355     TopoDS_Shape aShapeArg = aRefShape->GetValue();
356     TopoDS_Shape aPlaneArg = aRefPlane->GetValue();
357
358     if (aShapeArg.IsNull() || aPlaneArg.IsNull()) {
359       Standard_NullObject::Raise("In Half Partition a shape or a plane is null");
360     }
361
362     // Check self-intersection.
363     if (isCheckSelfInte) {
364       CheckSelfIntersection(aShapeArg);
365       CheckSelfIntersection(aPlaneArg);
366     }
367
368     TopoDS_Shape aShapeArg_copy;
369     TopoDS_Shape aPlaneArg_copy;
370     {
371       TNaming_CopyShape::CopyTool(aShapeArg, aMapTShapes, aShapeArg_copy);
372       //BRepBuilderAPI_Copy aCopyTool (aShapeArg);
373       //if (aCopyTool.IsDone())
374       //  aShapeArg_copy = aCopyTool.Shape();
375       //else
376       //  Standard_NullObject::Raise("Bad shape detected");
377       //
378       // fill aCopyMap for history
379       TopTools_IndexedMapOfShape aShapeArg_inds;
380       TopTools_IndexedMapOfShape aShapeArg_copy_inds;
381       TopExp::MapShapes(aShapeArg, aShapeArg_inds);
382       TopExp::MapShapes(aShapeArg_copy, aShapeArg_copy_inds);
383       Standard_Integer nbInds = aShapeArg_inds.Extent();
384       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
385         aCopyMap.Bind(aShapeArg_inds.FindKey(ie), aShapeArg_copy_inds.FindKey(ie));
386       }
387     }
388     {
389       TNaming_CopyShape::CopyTool(aPlaneArg, aMapTShapes, aPlaneArg_copy);
390       //BRepBuilderAPI_Copy aCopyTool (aPlaneArg);
391       //if (aCopyTool.IsDone())
392       //  aPlaneArg_copy = aCopyTool.Shape();
393       //else
394       //  Standard_NullObject::Raise("Bad shape detected");
395       //
396       // fill aCopyMap for history
397       TopTools_IndexedMapOfShape aPlaneArg_inds;
398       TopTools_IndexedMapOfShape aPlaneArg_copy_inds;
399       TopExp::MapShapes(aPlaneArg, aPlaneArg_inds);
400       TopExp::MapShapes(aPlaneArg_copy, aPlaneArg_copy_inds);
401       Standard_Integer nbInds = aPlaneArg_inds.Extent();
402       for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
403         aCopyMap.Bind(aPlaneArg_inds.FindKey(ie), aPlaneArg_copy_inds.FindKey(ie));
404       }
405     }
406
407     // add object shapes that are in ListShapes;
408     PS.AddArgument(aShapeArg_copy);
409     //PS.AddShape(aShapeArg);
410
411     // add tool shapes that are in ListTools and not in ListShapes;
412     PS.AddTool(aPlaneArg_copy);
413     //PS.AddTool(aPlaneArg);
414
415     //skl PS.Compute();
416     PS.Perform();
417     //PS.SetRemoveWebs(Standard_False);
418     //PS.Build(aShapeArg.ShapeType());
419
420   } else {
421   }
422
423   aShape = PS.Shape();
424   if (aShape.IsNull()) {
425     // Mantis issue 22009
426     if (PS.ErrorStatus() == 100 && PS.Tools().Extent() == 0 && PS.Arguments().Extent() == 1)
427       aShape = PS.Arguments().First();
428     else
429       return 0;
430   }
431
432   //Alternative case to check not valid partition IPAL21418
433   TopoDS_Iterator It (aShape, Standard_True, Standard_True);
434   int nbSubshapes = 0;
435   for (; It.More(); It.Next())
436     nbSubshapes++;
437   if (!nbSubshapes)
438     Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
439   //end of IPAL21418
440
441   if (!BRepAlgo::IsValid(aShape)) {
442     // 08.07.2008 added by skl during fixing bug 19761 from Mantis
443     ShapeFix_ShapeTolerance aSFT;
444     aSFT.LimitTolerance(aShape, Precision::Confusion(),
445                         Precision::Confusion(), TopAbs_SHAPE);
446     Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
447     aSfs->Perform();
448     aShape = aSfs->Shape();
449     if (!BRepAlgo::IsValid(aShape))
450       Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
451   }
452
453   aFunction->SetValue(aShape);
454
455   // Fill history to be used by GetInPlace functionality
456   TopTools_IndexedMapOfShape aResIndices;
457   TopExp::MapShapes(aShape, aResIndices);
458
459   // Map: source_shape/images of source_shape in Result
460   const BOPCol_IndexedDataMapOfShapeListOfShape& aMR = PS.ImagesResult();
461   //const TopTools_IndexedDataMapOfShapeListOfShape& aMR = PS.ImagesResult();
462
463   // history for all argument shapes
464   // be sure to use aCopyMap
465   TDF_LabelSequence aLabelSeq;
466   aFunction->GetDependency(aLabelSeq);
467   Standard_Integer nbArg = aLabelSeq.Length();
468
469   for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) {
470
471     TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);
472
473     Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
474     TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();
475
476     TopTools_IndexedMapOfShape anArgumentIndices;
477     TopExp::MapShapes(anArgumentShape, anArgumentIndices);
478     Standard_Integer nbArgumentEntities = anArgumentIndices.Extent();
479
480     // Find corresponding label in history
481     TDF_Label anArgumentHistoryLabel =
482       aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True);
483
484     for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) {
485       TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie);
486       // be sure to use aCopyMap here
487       if (aCopyMap.IsBound(anEntity))
488         anEntity = aCopyMap.Find(anEntity);
489       //
490       if (!aMR.Contains(anEntity)) continue;
491
492       const BOPCol_ListOfShape& aModified = aMR.FindFromKey(anEntity);
493       //const TopTools_ListOfShape& aModified = aMR.FindFromKey(anEntity);
494       Standard_Integer nbModified = aModified.Extent();
495
496       if (nbModified > 0) { // Mantis issue 0021182
497         int ih = 1;
498         BOPCol_ListIteratorOfListOfShape itM (aModified);
499         for (; itM.More() && nbModified > 0; itM.Next(), ++ih) {
500           if (!aResIndices.Contains(itM.Value())) {
501             nbModified = 0;
502           }
503         }
504       }
505       if (nbModified > 0) {
506         TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True);
507         Handle(TDataStd_IntegerArray) anAttr =
508           TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified);
509
510         int ih = 1;
511         BOPCol_ListIteratorOfListOfShape itM (aModified);
512         //TopTools_ListIteratorOfListOfShape itM (aModified);
513         for (; itM.More(); itM.Next(), ++ih) {
514           int id = aResIndices.FindIndex(itM.Value());
515           anAttr->SetValue(ih, id);
516         }
517       }
518     }
519   }
520
521   log.SetTouched(Label());
522
523   return 1;
524 }
525
526 //================================================================================
527 /*!
528  * \brief Returns a name of creation operation and names and values of creation parameters
529  */
530 //================================================================================
531
532 bool GEOMImpl_PartitionDriver::
533 GetCreationInformation(std::string&             theOperationName,
534                        std::vector<GEOM_Param>& theParams)
535 {
536   if (Label().IsNull()) return 0;
537   Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
538
539   GEOMImpl_IPartition aCI( function );
540   Standard_Integer aType = function->GetType();
541
542   theOperationName = "PARTITION";
543
544   switch ( aType ) {
545   case PARTITION_PARTITION:
546   case PARTITION_NO_SELF_INTERSECTIONS:
547     AddParam( theParams, "Objects", aCI.GetShapes() );
548     AddParam( theParams, "Tool objects", aCI.GetTools() );
549     {
550       Handle(TColStd_HSequenceOfTransient) objSeq = aCI.GetKeepIns();
551       if ( !objSeq.IsNull() && objSeq->Length() > 0 )
552         AddParam( theParams, "Objects to keep inside", objSeq );
553       objSeq = aCI.GetRemoveIns();
554       if ( !objSeq.IsNull() && objSeq->Length() > 0 )
555         AddParam( theParams, "Objects to remove inside", objSeq );
556       Handle(TColStd_HArray1OfInteger) intSeq = aCI.GetMaterials();
557       if ( !intSeq.IsNull() && intSeq->Length() > 0 )
558         AddParam( theParams, "Materials", aCI.GetMaterials() );
559     }
560     AddParam( theParams, "Resulting type", (TopAbs_ShapeEnum) aCI.GetLimit());
561     AddParam( theParams, "Keep shapes of lower type", aCI.GetKeepNonlimitShapes());
562     AddParam( theParams, "No object intersections", ( aType == PARTITION_NO_SELF_INTERSECTIONS ));
563     break;
564   case PARTITION_HALF:
565     AddParam( theParams, "Object", aCI.GetShape() );
566     AddParam( theParams, "Plane", aCI.GetPlane() );
567     break;
568   default:
569     return false;
570   }
571   
572   return true;
573 }
574
575 IMPLEMENT_STANDARD_HANDLE (GEOMImpl_PartitionDriver,GEOM_BaseDriver);
576 IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_PartitionDriver,GEOM_BaseDriver);