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